Size Reduction to Implement OTA

Hello Nordic Team,

I am working on a project based on the following requirements, where I have added multiple configurations and peripherals in my firmware, and I need to use all these features together.

  1. Device should work as both Central + Peripheral.

  2. Device should be able to store information for 6 paired devices.

  3. Runtime authentication callbacks are used:

    • Display I/O

    • Auth passkey entry

  4. Other peripherals used are:

    • ADC (3 channels)

    • I2C polling + interrupt [Fuel Gauge IC]

    • PWM

    • GPIOs for LEDs & Buttons

    • LPCOMP

Currently, I am using the nRF52833, which has 512 KB flash memory.
To store 6 paired device records, I created a separate 8 KB partition area, so the available application size becomes around 504 KB.

After developing the application, the total flash usage reached around 57% of 504 KB. After disabling logs and enabling size optimization in the build configuration, I reduced it to around 45%.

Now, to implement OTA/DFU support, I need to further reduce the code and configuration size to around 40% of the total flash.

When I checked the memory report, I found that my actual application code size is only around 30 KB approximately, so further reduction from the application side is becoming difficult because I have already optimized most of the code.

I think most of the flash is being used by BLE-related features and configurations. I would like to know if there are any unused BLE components, configurations, or modules that can be disabled or removed to further reduce flash usage.

Based on the configurations and features mentioned above, could you please provide some suggestions or best practices to further reduce flash usage?

 

#CONFIG_PWM=y
CONFIG_PWM=y	
CONFIG_PWM_NRFX=y	

########################
# CORE SYSTEM
########################

CONFIG_REBOOT=y
CONFIG_POWEROFF=y
CONFIG_PM_DEVICE=y
CONFIG_NRFX_POWER=y

# STACK SIZES — not touched per your request.
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_MPSL_WORK_STACK_SIZE=2048
CONFIG_BT_RX_STACK_SIZE=2048
CONFIG_IDLE_STACK_SIZE=1024
CONFIG_ISR_STACK_SIZE=2048


CONFIG_HEAP_MEM_POOL_SIZE=2048

########################
# BLUETOOTH – ROLES
########################

CONFIG_BT=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_SMP_APP_PAIRING_ACCEPT=y
CONFIG_BT_FIXED_PASSKEY=y

CONFIG_BT_DEVICE_NAME="HANDHELD_v4.0"

CONFIG_BT_BUF_ACL_TX_COUNT=4
CONFIG_BT_BUF_ACL_RX_COUNT=4


CONFIG_BT_BUF_ACL_TX_SIZE=69
CONFIG_BT_BUF_ACL_RX_SIZE=69


CONFIG_BT_L2CAP_TX_MTU=65


CONFIG_BT_L2CAP_TX_BUF_COUNT=3

CONFIG_BT_CTLR_DATA_LENGTH_MAX=69


CONFIG_BT_CTLR_TX_PWR_PLUS_4=y

########################
# GATT & CLIENTS
########################

CONFIG_BT_GATT_CLIENT=y



########################
# SCANNING & CONNECTION MGMT
########################

CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1
CONFIG_BT_SCAN_NAME_CNT=1
CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL=n

CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=12
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=12
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400

CONFIG_BT_GATT_AUTO_SEC_REQ=y

########################
# FLASH & NVS
########################

CONFIG_FLASH=y
CONFIG_SOC_FLASH_NRF=y
CONFIG_NRFX_NVMC=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS=y

########################
# BLUETOOTH SECURITY / BONDING
########################

CONFIG_BT_BONDABLE=y
CONFIG_BT_SETTINGS=y

# BT_PRIVACY disabled — confirmed no bt_id_* or RPA calls in your code.
CONFIG_BT_PRIVACY=n


CONFIG_BT_MAX_CONN=2
CONFIG_BT_MAX_PAIRED=6

########################
# GPIO / WDT / CLOCK
########################

CONFIG_GPIO=y
CONFIG_WATCHDOG=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

########################
# LOGGING — already disabled, keeping as-is
########################

CONFIG_LOG=n
CONFIG_LOG_MODE_IMMEDIATE=n
CONFIG_USE_SEGGER_RTT=n
CONFIG_LOG_BACKEND_RTT=n
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=n
CONFIG_BT_LOG_LEVEL_WRN=n
CONFIG_BT_CONN_LOG_LEVEL_WRN=n
CONFIG_BT_ISO_LOG_LEVEL_WRN=n
CONFIG_BT_HCI_DRIVER_LOG_LEVEL_WRN=n



########################
# BLUETOOTH SECURITY
########################

CONFIG_BT_SMP=y



########################
# FILTER ACCEPT LIST
########################

CONFIG_BT_FILTER_ACCEPT_LIST=y

########################
# BT CONTROLLER FLAGS
########################

CONFIG_BT_DATA_LEN_UPDATE=n
CONFIG_BT_PHY_UPDATE=n

CONFIG_BT_GATT_CACHING=n


CONFIG_BT_GATT_SERVICE_CHANGED=n

CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n

CONFIG_BT_ASSERT=n


CONFIG_BT_CTLR_PRIVACY=y

CONFIG_BT_CTLR_PHY_2M=n

########################
# SIZE OPTIMIZATIONS — already set, keeping
########################

CONFIG_SIZE_OPTIMIZATIONS=y
CONFIG_MINIMAL_LIBC=y
CONFIG_LTO=y
CONFIG_ISR_TABLES_LOCAL_DECLARATION=y

########################
# I2C / ADC
########################

CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_ADC=y
CONFIG_ADC_NRFX_SAADC=y

########################
# FLASH PARTITION
########################

CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x2000

Related