This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK 12.3.0 nrf_dfu_settings calls to memset and memcpy on settings buffer causing compiled binary file to be 100 kb larger.

Hi,

I'm trying to implement the buttonless DFU service example for SDK 12.3.0 into my own project, but when I call ble_dfu_init my compiled .hex file becomes 10 kb larger and my compiled binary file becomes 100 kb larger (from 50 kb to 150+ kb) putting it over 150 kb and too large to OTA DFU. 

I've narrowed down the problem coming from nrf_dfu_settings_init and nrf_dfu_settings_write (in nrf_dfu_settings.c). In nrf_dfu_settings_init, a call to memcpy the DFU settings to a buffer causes the 100 kb jump in the compiled binary file. The m_dfu_settings_buffer points to the bootloaderSettings section.

bootloaderSettings in my flash_placement.xml file looks like this:

<MemorySegment name="$(FLASH_NAME:FLASH)">
<ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" />
<ProgramSection alignment="4" keep="Yes" load="Yes" name=".fs_data" address_symbol="__start_fs_data" end_symbol="__stop_fs_data" />
<ProgramSection alignment="4" load="Yes" name=".init" />
<ProgramSection alignment="4" load="Yes" name=".init_rodata" />
<ProgramSection alignment="4" load="Yes" name=".text" />
<ProgramSection alignment="4" load="Yes" name=".dtors" />
<ProgramSection alignment="4" load="Yes" name=".ctors" />
<ProgramSection alignment="4" load="Yes" name=".rodata" />
<ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
<ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
<ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
<ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
<ProgramSection alignment="4" load="Yes" name=".bootloaderSettings" start="$(BOOTLOADER_SETTINGS_START:0x0003FC00)" size="$(BOOTLOADER_SETTINGS_SIZE:0x400)" />
</MemorySegment>

I'm using nRF51822, SDK 12.3.0, S130, and the bootloader I'm using is the bootloader_secure example from SDK 12.3.0. Compiling in SES.

Any ideas of what could be happening? I can't figure out why memcpy on m_dfu_settings_buffer would result in a very very large increase of 100 kb to my compiled binary file.

Thanks.

Edit

I believe I know what is happening, but I'm unsure of how I can fix it. Below SES is telling me FLASH memory used after compiling:

The sliver of green at the end is the memory for bootloaderSettings set in flash_placement.xml. The space between that and the application (green on the left) looks to be about 100 kb. My theory is that the compiled file is including this space. When we delete the call to nrf_dfu_settings_init and the memcpy that references bootloaderSettings, the compiler must throw bootloaderSettings out and compiles to ~48 kb. 

Parents
  • Hi,

    Please note that buttonless DFU was still experimental in SDK 12.3.0.

    You are correct that the bootloader settings page, i.e. the sliver of green at the end, should not be part of the application. Unfortunately we do not have an example for SES in SDK 12.3.0, but as far as I can tell you should be able to fix this by changing load="Yes" to load="No" in the line

    <ProgramSection alignment="4" load="Yes" name=".bootloaderSettings" start="$(BOOTLOADER_SETTINGS_START:0x0003FC00)" size="$(BOOTLOADER_SETTINGS_SIZE:0x400)" />

    so that the full line reads

    <ProgramSection alignment="4" load="No" name=".bootloaderSettings" start="$(BOOTLOADER_SETTINGS_START:0x0003FC00)" size="$(BOOTLOADER_SETTINGS_SIZE:0x400)" />

    in order not to include the bootloader settings page flash region in the build output.

    Regards,
    Terje

Reply
  • Hi,

    Please note that buttonless DFU was still experimental in SDK 12.3.0.

    You are correct that the bootloader settings page, i.e. the sliver of green at the end, should not be part of the application. Unfortunately we do not have an example for SES in SDK 12.3.0, but as far as I can tell you should be able to fix this by changing load="Yes" to load="No" in the line

    <ProgramSection alignment="4" load="Yes" name=".bootloaderSettings" start="$(BOOTLOADER_SETTINGS_START:0x0003FC00)" size="$(BOOTLOADER_SETTINGS_SIZE:0x400)" />

    so that the full line reads

    <ProgramSection alignment="4" load="No" name=".bootloaderSettings" start="$(BOOTLOADER_SETTINGS_START:0x0003FC00)" size="$(BOOTLOADER_SETTINGS_SIZE:0x400)" />

    in order not to include the bootloader settings page flash region in the build output.

    Regards,
    Terje

Children
No Data
Related