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

nrf52840 Bootloader issue - BL_size always over limit

Dear Sir,

I am working on Bootloader of nRF52840 which I need large space to display some LCD when bootloader startup. 

I use Keil compiler, SDK 1702.

In Keil, iROM set start address from 0xE0000.  So from 0xE0000 to 0xFE000, it should have 122.88k.

From Keil compiled result, I got

Build target 'nrf52840_xxaa_s140'
linking...
Program Size: Code=32732 RO-data=53448 RW-data=300 ZI-data=32584
FromELF: creating hex file...
".\_build\RemoteBootloader840.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:03

After program Softdevice, Main App and Bootlaoder to development board, start DFU will get the following debug print from RTT Viewer.

00> <info> app: Inside main
00> <info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
00> <info> app: No firmware to activate.
00> <info> app: check if key press
00> <info> app: DFU mode requested via button.
00> <info> nrf_bootloader_wdt: WDT is not enabled
00> <info> app: Entering DFU mode.
00> <info> nrf_dfu_validation: Signature required. Checking signature.
00> <info> nrf_dfu_validation: Calculating hash (len: 64)
00> <info> nrf_dfu_validation: Verify signature
00> <info> nrf_dfu_validation: Image verified
00> <error> nrf_dfu_validation: BL size (118876) over limit (114688)
00> <error> nrf_dfu_validation: Init packet does not contain valid firmware size
00> <warning> nrf_dfu_ble: DFU request 4 failed with error: 0x4
00> <info> app: display LCD image
00> <info> app: Inside main
00> <info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
00> <info> app: No firmware to activate.

Why the BL size is118876?  

How this size calculated? 

and why the limit is only 114688? 

Then if I change the Starting address from 0xDE000,

Keil result is

Program Size: Code=32732 RO-data=53448 RW-data=300 ZI-data=32584  

And debug printing become 

00> <error> nrf_dfu_validation: BL size (135260) over limit (131072)

Thanks so much!

Martin

Parents
  • Dear Martin,

    Your Keil build result says the total flash usage (Code + RO Data + RW Data) is only 86480 bytes ( or 84.45kB), so you should have had enough free space.

    The bitmap table you mentioned in your other post here, are you placing it at a specific section/address in flash, or is placed along with the other bootloader data?

    You may also want to go through the *.map file in your project's build directory to check if the linker has placed any data above 0xFE000.

    Best regards,

    Vidar

  • Dear Vidar,

    For every new test, I use NRFGo Studio to do the "Erase All", then program SoftDevice   s140_nrf52_7.2.0_softdevice.hex

    So there should not be any extra old Bootloader data 

    in folder nrf52_SDK_1702\components\softdevice\s140\hex

    Then program  Application. 

    Then use this command to upload Bootloader 

    nrfjprog -f nRF52 --program BootloaderV1.hex 

    This is the settings.hex file

    nrfutil settings display settings.hex
    Bad access at 0x7F000: not enough data to read 4 contiguous bytes

    Bootloader DFU Settings:
    * File: settings.hex
    * Family: NRF52840
    * Start Address: 0x000FE000
    * CRC: 0xFDB12A8D
    * Settings Version: 0x00000001 (1)
    * App Version: 0x00000003 (3)
    * Bootloader Version: 0x00000003 (3)
    * Bank Layout: 0x00000000
    * Current Bank: 0x00000000
    * Application Size: 0x0001C194 (115092 bytes)
    * Application CRC: 0x19A1E410
    * Bank0 Bank Code: 0x00000001
    * Softdevice Size: 0x00000000 (0 bytes)
    * Boot Validation CRC: 0x00000000
    * SD Boot Validation Type: 0x00000000 (0)
    * App Boot Validation Type: 0x00000000 (0)

    And this is how I generated the Zip file for DFU

    nrfutil pkg generate --hw-version 52 --bootloader-version 3 --bootloader BootloaderV1.hex --sd-req 0x100 --sd-id 0x100 --key-file private.key newBootDFU_33.zip

    For Keil , map file showing

    Code (inc. data) RO Data RW Data ZI Data Debug

    32768 6450 5616 300 32536 0 Grand Totals
    32768 6450 5616 300 32536 0 ELF Image Totals
    32768 6450 5616 300 0 0 ROM Totals

    ==============================================================================

    Total RO Size (Code + RO Data) 38384 ( 37.48kB)
    Total RW Size (RW Data + ZI Data) 32836 ( 32.07kB)
    Total ROM Size (Code + RO Data + RW Data) 38684 ( 37.78kB)

    Therefore, I don't able to see what was wrong.   

    Is that because when merging with settings file, then bootloader oversize?   

    It is always over size around 5k whatever I increase bootloader allocation size. 

    Thanks so much!

    Regards,

    Martin

Reply
  • Dear Vidar,

    For every new test, I use NRFGo Studio to do the "Erase All", then program SoftDevice   s140_nrf52_7.2.0_softdevice.hex

    So there should not be any extra old Bootloader data 

    in folder nrf52_SDK_1702\components\softdevice\s140\hex

    Then program  Application. 

    Then use this command to upload Bootloader 

    nrfjprog -f nRF52 --program BootloaderV1.hex 

    This is the settings.hex file

    nrfutil settings display settings.hex
    Bad access at 0x7F000: not enough data to read 4 contiguous bytes

    Bootloader DFU Settings:
    * File: settings.hex
    * Family: NRF52840
    * Start Address: 0x000FE000
    * CRC: 0xFDB12A8D
    * Settings Version: 0x00000001 (1)
    * App Version: 0x00000003 (3)
    * Bootloader Version: 0x00000003 (3)
    * Bank Layout: 0x00000000
    * Current Bank: 0x00000000
    * Application Size: 0x0001C194 (115092 bytes)
    * Application CRC: 0x19A1E410
    * Bank0 Bank Code: 0x00000001
    * Softdevice Size: 0x00000000 (0 bytes)
    * Boot Validation CRC: 0x00000000
    * SD Boot Validation Type: 0x00000000 (0)
    * App Boot Validation Type: 0x00000000 (0)

    And this is how I generated the Zip file for DFU

    nrfutil pkg generate --hw-version 52 --bootloader-version 3 --bootloader BootloaderV1.hex --sd-req 0x100 --sd-id 0x100 --key-file private.key newBootDFU_33.zip

    For Keil , map file showing

    Code (inc. data) RO Data RW Data ZI Data Debug

    32768 6450 5616 300 32536 0 Grand Totals
    32768 6450 5616 300 32536 0 ELF Image Totals
    32768 6450 5616 300 0 0 ROM Totals

    ==============================================================================

    Total RO Size (Code + RO Data) 38384 ( 37.48kB)
    Total RW Size (RW Data + ZI Data) 32836 ( 32.07kB)
    Total ROM Size (Code + RO Data + RW Data) 38684 ( 37.78kB)

    Therefore, I don't able to see what was wrong.   

    Is that because when merging with settings file, then bootloader oversize?   

    It is always over size around 5k whatever I increase bootloader allocation size. 

    Thanks so much!

    Regards,

    Martin

Children
  • Dear Martin,

    DYNAMICTOYS said:
    nrfutil pkg generate --hw-version 52 --bootloader-version 3 --bootloader BootloaderV1.hex --sd-req 0x100 --sd-id 0x100 --key-file private.key newBootDFU_33.zip

    Has the 'BootloaderV1.hex' file above been merged with settings.hex? That would explain why the bootloader update  always becomes rejected due to size. You are only supposed to include the bootloader in the DFU image.

    DYNAMICTOYS said:
    * Settings Version: 0x00000001 (1)

    Shouldn't it be version 2 here?

    Regards,

    Vidar

Related