Reducing Flash Occupancy

Hi,

We came close to occupying all available flash memory in the nRF52833 board:

Memory region Used Size Region Size %age Used
FLASH: 185620 B 187904 B 98.78%
SRAM: 37832 B 128 KB 28.86%
IDT_LIST: 0 GB 2 KB 0.00%

After a lot of optimizations we were able to reduce it to 83%:

Memory region Used Size Region Size %age Used
FLASH: 159652 B 192000 B 83.15%
SRAM: 37512 B 128 KB 28.62%
IDT_LIST: 0 GB 2 KB 0.00%

However, we are very concerned that it might not be enough for our future needs.

Partition Manager Report shows us the following picture of flash occupancy:

We see that MCUboot occupies most of the flash - 188 x 2 KB

and that bo (nRF Secure Immutable Bootloader) another 32 KB

This leaves our app only 187KB out of 512KB flash size!

I understand that we must use MCUboot for FOTA / DFU, as we're working with nRF Connect SDK.

1. Can we drop bo?

2. Is there a way to drop the secondary slot of MCUboot?

3. Are there any additional optimizations we can make?

Many Thanks!

Vitaliy

Parents
  • Hi Vitaliy,

    1. Can we drop bo?

    Yes, you can drop B0 (nRF Secure Immutable Bootloader). In that case the MCUBoot will have to be the immutable bootloder, so you will not have a upgradable MCUBoot (see Secure bootloader chain).

    2. Is there a way to drop the secondary slot of MCUboot?

    Yes, when you drop the nRF Secure Immutable Bootloader and use only MCUBoot as immutable bootloader there is no need for a secondary slot for MCUBoot (so you save another 48 kB).

    3. Are there any additional optimizations we can make?

    The above are the main flash usage optimizations you can do with regards to DFU architecture. For other memory optimizations you can refer to Memory Optimization with the nRF Connect SDK.

    Einar

  • Thanks Einar for the detailed response!
    How can the MCUboot be configured as the immutable, single slot bootloader?
    I did not find any documentation about it.

    Thanks!
    Vitaliy

  • You cans see details about that under Adding MCUboot as an immutable bootloader. (As you are starting off with a configuration with both B0 (nRF Secure Immutable Bootloader) and MCUboot as upgradable bootloader it is mostly a matter of removing configurations in practice).

  • Hi Einar,

    It is already configured that way in our project, with

    CONFIG_BOOTLOADER_MCUBOOT,

    and still we get both both b0 and MCUboot.

    Here's the full prj.conf:

    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    CONFIG_HEAP_MEM_POOL_SIZE=256
    
    # BT configuration
    CONFIG_BT=y
    #CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_SMP=y
    CONFIG_BT_SIGNING=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DIS=n
    CONFIG_BT_ATT_PREPARE_COUNT=5
    CONFIG_BT_BAS=n
    CONFIG_BT_HRS=n
    CONFIG_BT_PRIVACY=y
    CONFIG_BT_DEVICE_NAME="Dride-4K"
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_DEVICE_NAME_MAX=128
    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
    CONFIG_BT_SETTINGS=y
    # FOR FOTA
    CONFIG_BT_L2CAP_TX_MTU=252
    CONFIG_BT_BUF_ACL_RX_SIZE=256
    
    CONFIG_FLASH=y
    CONFIG_SETTINGS=y
    
    # FOTA settings
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_SECURE_BOOT=y
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n
    
    CONFIG_IMG_MANAGER=y
    
    CONFIG_NRFX_TEMP=y
    
    CONFIG_SERIAL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_USE_RUNTIME_CONFIGURE=y
    CONFIG_ADC=y
    What am I missing?
Reply
  • Hi Einar,

    It is already configured that way in our project, with

    CONFIG_BOOTLOADER_MCUBOOT,

    and still we get both both b0 and MCUboot.

    Here's the full prj.conf:

    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    CONFIG_HEAP_MEM_POOL_SIZE=256
    
    # BT configuration
    CONFIG_BT=y
    #CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_SMP=y
    CONFIG_BT_SIGNING=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DIS=n
    CONFIG_BT_ATT_PREPARE_COUNT=5
    CONFIG_BT_BAS=n
    CONFIG_BT_HRS=n
    CONFIG_BT_PRIVACY=y
    CONFIG_BT_DEVICE_NAME="Dride-4K"
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_DEVICE_NAME_MAX=128
    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
    CONFIG_BT_SETTINGS=y
    # FOR FOTA
    CONFIG_BT_L2CAP_TX_MTU=252
    CONFIG_BT_BUF_ACL_RX_SIZE=256
    
    CONFIG_FLASH=y
    CONFIG_SETTINGS=y
    
    # FOTA settings
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_SECURE_BOOT=y
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n
    
    CONFIG_IMG_MANAGER=y
    
    CONFIG_NRFX_TEMP=y
    
    CONFIG_SERIAL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_USE_RUNTIME_CONFIGURE=y
    CONFIG_ADC=y
    What am I missing?
Children
Related