Bootloader and application memory placement (nrf52811)

Hi,

Having problems setting up a bootloader and application in the flash memory sectors. The program dies at sd_softdevice_vector_table_base_set(bootloader_addr); It looks like I have the bootloader in address 0x00019000;

which makes sense because the bootloader memory placement is as follows;

FLASH_PH_START=0x0
FLASH_PH_SIZE=0x30000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x6000
FLASH_START=0x19000
FLASH_SIZE=0xE000
RAM_START=0x20000000
RAM_SIZE=0x6000

I think I have the app memory placement being placed at the same area;

FLASH_PH_START=0x0
FLASH_PH_SIZE=0x30000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x6000
FLASH_START=0x19000
FLASH_SIZE=0x17000
RAM_START=0x20002EA0
RAM_SIZE=0x3160

How do I remedy this?

My suspicion is I should change the bootloader memory placement to;

FLASH_PH_START=0x0
FLASH_PH_SIZE=0x30000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x6000
FLASH_START=0x19000
FLASH_SIZE=0xE000
RAM_START=0x20002EA0
RAM_SIZE=0x3160

And I should also change the app memory placement to;

FLASH_PH_START=0x0
FLASH_PH_SIZE=0x30000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x6000
FLASH_START=0x27000    (0x19000 + 0xE000)
FLASH_SIZE=0x17000
RAM_START=0x20002EA0
RAM_SIZE=0x3160

but to be honest, reviewing the memory for the nrf52811;

all these memory placements seem out of whack.

This is related to my other post.

  • Here's what I think I understand now;

    1) The soft device is placed first within the flash

    2) The app is placed after that

    3) The bootloader is placed towards the end

    With this understanding I setup the memory placement with the app after the soft device;

    App;
    FLASH_PH_START=0x0
    FLASH_PH_SIZE=0x30000
    RAM_PH_START=0x20000000
    RAM_PH_SIZE=0x6000
    FLASH_START=0x19000
    FLASH_SIZE=0x8000
    RAM_START=0x20002EA0
    RAM_SIZE=0x3160

    and the bootloader after the app;

    Bootloader;
    FLASH_PH_START=0x0
    FLASH_PH_SIZE=0x30000
    RAM_PH_START=0x20000000
    RAM_PH_SIZE=0x6000
    FLASH_START=0x22000
    FLASH_SIZE=0xE000
    RAM_START=0x20002EA0
    RAM_SIZE=0x3160

    I assumed the app and bootloader could use the same ram.

    Therefore I loaded the bootloader. Then I loaded the application. This resulted in the program downloading and just started running at some random location without me pressing "go" and is just stuck there;

  • Hi,

    I assumed the app and bootloader could use the same ram.

    They can use the same RAM area since they will never run concurrently. I recommend starting with the default bootloader linker settings used by the /examples/dfu/secure_bootloader/pca10056_s112_ble_debug example.

    1) The soft device is placed first within the flash

    2) The app is placed after that

    3) The bootloader is placed towards the end

    Yes, this is correct. It is also the same as is shown here: Memory layout.

    Best regards,

    Vidar

  • Okay so I started from scratch some. Was able to get a blinky to load via the /examples/dfu/secure_bootloader/pca10056_s112_ble_debug example.

    Now I generated a package of our application. This is what the secure bootloader wrote in the terminal after attempting to load the dfu package;

    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_SELECT (command)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)
    <debug> app: timer_stop (0x200022E0)
    <debug> app: timer_activate (0x200022E0)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_ble: Set receipt notif
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_RECEIPT_NOTIF_SET
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_ble: Buffer 0x20002788 acquired, len 141 (244)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    <debug> nrf_dfu_ble: Freeing buffer 0x20002788
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (command)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (command)
    <debug> nrf_dfu_validation: PB: Init packet data len: 64
    <info> nrf_dfu_validation: Signature required. Checking signature.
    <info> nrf_dfu_validation: Calculating hash (len: 64)
    <info> nrf_dfu_validation: Verify signature
    <info> nrf_dfu_validation: Image verified
    <debug> app: Enter nrf_dfu_cache_prepare()
    <debug> app: required_size: 0x83DC.
    <debug> app: single_bank: false.
    <debug> app: keep_app: false.
    <debug> app: keep_softdevice: true.
    <debug> app: SD_PRESENT: true.
    <debug> app: Bank contents:
    <debug> app: Bank 0 code: 0x00: Size: 0x0
    <debug> app: Bank 1 code: 0x00: Size: 0x0
    <debug> app: pass: 0.
    <debug> app: cache_address: 0x19000.
    <debug> app: cache_too_small: true.
    <debug> app: keep_firmware: false.
    <debug> app: delete_more: true.
    <debug> app: pass: 1.
    <debug> app: cache_address: 0x19000.
    <debug> app: cache_too_small: true.
    <debug> app: keep_firmware: true.
    <debug> app: delete_more: true.
    <warning> app: Aborting. Cannot fit new firmware on device
    <error> nrf_dfu_validation: Can't find room for update
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x4
    <warning> nrf_dfu_ble: DFU request 4 failed with error: 0x4
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_ABORT
    <debug> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_ble: Shutting down BLE transport.
    <debug> nrf_dfu_ble: Disconnecting.
    <debug> nrf_dfu_settings: Using settings page.
    <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    <debug> nrf_dfu_ble: BLE transport shut down.
    <debug> app: Resetting bootloader.
    <info> nrf_dfu_settings: Backing up settings page to address 0x2E000.
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    <info> app: Inside main
    <debug> app: In nrf_bootloader_init
    <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    <debug> nrf_dfu_settings: Using settings page.
    <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    <info> nrf_dfu_settings: Backing up settings page to address 0x2E000.
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    <debug> app: Enter nrf_bootloader_fw_activate
    <info> app: No firmware to activate.
    <info> app: Boot validation failed. No valid app to boot.
    <debug> app: DFU mode because app is not valid.
    <info> nrf_bootloader_wdt: WDT is not enabled
    <debug> app: in weak nrf_dfu_init_user
    <debug> app: timer_stop (0x200022E0)
    <debug> app: timer_activate (0x200022E0)
    <info> app: Entering DFU mode.
    <debug> app: Initializing transports (found: 1)
    <debug> nrf_dfu_ble: Initializing BLE DFU transport
    <debug> nrf_dfu_ble: Setting up vector table: 0x00022000
    <debug> nrf_dfu_ble: Enabling SoftDevice.
    <debug> nrf_dfu_ble: Configuring BLE stack.
    <debug> nrf_dfu_ble: Enabling the BLE stack.
    <debug> nrf_dfu_ble: No advertising name found
    <debug> nrf_dfu_ble: Using default advertising name
    <debug> nrf_dfu_ble: Advertising...
    <debug> nrf_dfu_ble: BLE DFU transport initialized.
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    <debug> app: Enter main loop

    <warning> app: Aborting. Cannot fit new firmware on device
    <error> nrf_dfu_validation: Can't find room for update
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x4
    <warning> nrf_dfu_ble: DFU request 4 failed with error: 0x4

  • The error indicates that the new application does not fit into the free space here:

    What is the size of your application? Disabling logging in your application could help reduce the flash footprint (i.e. set NRF_LOG_ENABLED to '0' in sdk_config.h)

  • when i build in ses (132.9KB);

    the resulting hex file is 93KB.

    192 kB for nrf58211-QFAA-R, correct?

    Good call on removing logging, forgot about that.

    120.7KB in ses without logging.

    the resulting hex file is 59KB.

    oh *#&$ it works. thank you.

Related