Problem with flash overflow when adding BLE DFU on nRF52833

I'm having trouble enabling BLE DFU on my firmware for the nRF52833. I'm following the steps from the Dev Academy course - FOTA over Bluetooth Low Energy. After adding the following to my prj.conf file:

# Enable FOTA over Bluetooth LE
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

And in the sysbuild.conf file:

# Enable MCUboot
SB_CONFIG_BOOTLOADER_MCUBOOT=y

I get the following overflow error:

/opt/nordic/ncs/toolchains/f8037e9b83/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/zephyr_pre0.elf section `rodata' will not fit in region `FLASH'
/opt/nordic/ncs/toolchains/f8037e9b83/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: region `FLASH' overflowed by 32788 bytes
collect2: error: ld returned 1 exit status

However, without the BLE OTA features, my used size region is well under what's available. I understand that MCUBoot will double the flash sized used, but even still, I should be under what's available.

Memory region         Used Size  Region Size  %age Used
           FLASH:      241768 B       488 KB     48.38%
             RAM:       52864 B       128 KB     40.33%
        IDT_LIST:          0 GB        32 KB      0.00%

I have tried removing some features in my prj.conf file, and following some recommendations in the memory footprint optimizations documentation, but the value reported in my overflow does not seem to change. Why is that? What can I try next?

Parents
  • Hello,

    The size of the application region is significantly reduced when MCUBoot is enabled in the build. To get the size that will be available to the app, you must first subtract the size of the bootloader (48kB by default)) from the 488 kB currently available to your app. Then, divide the remaining space by 2. This gives you the size of the MCUBoot primary and secondary slot. So, the new application region (mcuboot primary) size = (488k - 48k ) / 2 = 220 kB, and your current app size is 241768 bytes = 236.1 kB.

    Example of a typical memory layout on the nRF52833

    But we can halve the bootloader footprint by overwriting the default MCUBoot build configuration and disable logging and other things we don't need. To overwrite the default configuration we can create a folder named 'sysbuild' in the project root with the following folder structure:

    <project directory>/
    ├── sysbuild/
    │ └── mcuboot/
    │        └── prj.conf

    Below is an example configuration you can try with. The bootloader region is set to 24kB in this configuration. After adding the sysbuild folder to the project, remember to do a 'pristine' build to alllow the build system to detect that the new configuration files have been added.

    1638.sysbuild.zip

    Best regards,

    Vidar

Reply
  • Hello,

    The size of the application region is significantly reduced when MCUBoot is enabled in the build. To get the size that will be available to the app, you must first subtract the size of the bootloader (48kB by default)) from the 488 kB currently available to your app. Then, divide the remaining space by 2. This gives you the size of the MCUBoot primary and secondary slot. So, the new application region (mcuboot primary) size = (488k - 48k ) / 2 = 220 kB, and your current app size is 241768 bytes = 236.1 kB.

    Example of a typical memory layout on the nRF52833

    But we can halve the bootloader footprint by overwriting the default MCUBoot build configuration and disable logging and other things we don't need. To overwrite the default configuration we can create a folder named 'sysbuild' in the project root with the following folder structure:

    <project directory>/
    ├── sysbuild/
    │ └── mcuboot/
    │        └── prj.conf

    Below is an example configuration you can try with. The bootloader region is set to 24kB in this configuration. After adding the sysbuild folder to the project, remember to do a 'pristine' build to alllow the build system to detect that the new configuration files have been added.

    1638.sysbuild.zip

    Best regards,

    Vidar

Children
No Data
Related