Reducing ROM size for the nRF52833

I think I've followed practically every "minimal configuration" example I could find, and implemented as many Kconfig options as possible, but our firmware image is still too large for DFU. I also created a static partition scheme and reduced MCU boot partition to 32 kilobytes and NVS partition to 8 kilobytes.

Despite this, our ROM size comes out to be around 13 kilobytes too large for MCU boot.

Here's my full project configuration file, with the Kconfig options I've found that actually reduce ROM size at the top. Please let me know if there's any Kconfig options I'm missing or anything else I can do to reduce the ROM size.

# not yet sure if this is helpful, harmful, or just unnecessary... but it actually decreases the project size!
CONFIG_NCS_SAMPLES_DEFAULTS=y

# to reduce image size
CONFIG_CBPRINTF_NANO=y
CONFIG_CBPRINTF_LIBC_SUBSTS=n
CONFIG_MINIMAL_LIBC=y
CONFIG_SIZE_OPTIMIZATIONS=y
CONFIG_BT_ASSERT=n
CONFIG_BT_DATA_LEN_UPDATE=n
#CONFIG_BT_GATT_SERVICE_CHANGED=n # unfortunately this is required by DFU
CONFIG_BT_GATT_READ_MULTIPLE=n
CONFIG_BT_GATT_READ_MULT_VAR_LEN=n
CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n
CONFIG_BT_PHY_UPDATE=n
CONFIG_BT_CTLR_LE_PING=n
CONFIG_BT_CTLR_PRIVACY=n
CONFIG_BT_CTLR_PHY_2M=n
CONFIG_TIMEOUT_64BIT=n
CONFIG_TIMESLICING=n
CONFIG_LOG=n
CONFIG_FPU=y # despite guidance from "Minimal" examples, enabling this actually decreases ROM size
CONFIG_SPI=n
CONFIG_ASSERT=n # should be enabled while developing, disabled for production
CONFIG_CONSOLE=n # should be enabled while developing, disabled for production
CONFIG_SERIAL=n # should be enabled while developing, disabled for production
CONFIG_USE_SEGGER_RTT=n # is this required for development? what does this really do?

# for DFU (remote firmware upgrades)
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

# for reading / writing to flash
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# software resets
CONFIG_REBOOT=y

# for button, LED, accelerometer
CONFIG_GPIO=y
CONFIG_I2C=y

# for printing heap usage stats
CONFIG_SYS_HEAP_RUNTIME_STATS=y

# for bluetooth (general)
CONFIG_BT=y

# for bluetooth (advertising)
CONFIG_BT_PERIPHERAL=y # technically our application only requires "broadcaster" but "peripheral" is required for DFU
CONFIG_BT_DEVICE_APPEARANCE=512
CONFIG_BT_DEVICE_NAME="AirA7v100"
CONFIG_BT_EXT_ADV=y
CONFIG_BT_EXT_ADV_MAX_ADV_SET=3

# for bluetooth (tx power control)
CONFIG_BT_HCI_VS_EXT=y
CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y

# for bluetooth (scanning)
CONFIG_BT_CENTRAL=y
CONFIG_BT_SCAN=y
CONFIG_BT_ID_MAX=1
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_NAME_CNT=2

# for bluetooth (connecting)
CONFIG_BT_SMP=y
CONFIG_BT_SMP_SC_ONLY=n
CONFIG_BT_SMP_APP_PAIRING_ACCEPT=n
CONFIG_BT_SMP_ENFORCE_MITM=y
CONFIG_BT_BONDABLE=n

# for blueooth (GATT)
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_DM=y
CONFIG_BT_GATT_DM_DATA_PRINT=y

# for reading voltage
CONFIG_NRFX_SAADC=y
CONFIG_NRFX_TIMER2=y
CONFIG_NRFX_PPI=y

# for power management
CONFIG_PM_DEVICE=y

# for power-off state
CONFIG_POWEROFF=y

Related