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

DFU on custom board, memory problem

Hello,

Currently, I'm trying to flash my custom board that has nRF52832 with an uart application that I integrated buttonless DFU. I'm running into a problem where when I try to flash my hex file that has the following combination :

  • Softdevice
  • Bootloader
  • Application
  • Bootloader setting

I got the following error :

"ERROR: The file specified is not a valid hex file, has data outside valid areas"

"ERROR: or does not have data in valid areas."

From what I understand, it is an error on the memory side where my program might have passed its limit. But I don't know how to fix it. I'm not sure the type of model of my nRF52832, but on nRF Connect, it says that it is NRF52832_xxAB_REV1, Core RAM: 32KiB and Core ROM: 256KiB in pages of 4KiB. I'm using SES with SDK 16.0.0


  • pca10040_s132_ble_debug_256k.zip

    Try this one. I did not change anything but the three things I mentioned in the previous reply. flash_placement.xml, build->memory segments, and linker->Section placement macros.

    In SES it is possible to attach the debugger if the .hex file is already flashed. Try to do this. To do so, try to use (toolbar->) Target -> Attach Debugger. If you do this, SES will not program anything.

    However, I suspect that you will run into some issues. Looking at the placement of the files, it looks like there is not enough RAM to run your application:

    The application uses 42.4kB RAM, and your nRF52 only has 32kB. This is the case for the previous (non _debug) project I sent as well. It uses 33.8kB (close, but still more than 32kB.

    It looks like the bootloader from SDK16 is too large for the 256/32 variant of the nRF52832.

    Perhaps you should consider moving to the 512/64 version?

    Alternatively, see if you can port the pca10040e bootloader project. It only uses 20kB of RAM, but you need to change it to using the S132 if that is what you are using.

    BR,

    Edvin

  • However, I suspect that you will run into some issues. Looking at the placement of the files, it looks like there is not enough RAM to run your application:

    Yes, you are correct. I got these errors :

    ..
    <warning> app: Aborting. Cannot fit new firmware on device
    <error> nrf_dfu_validation: Can't find room for update
    ..

    Alternatively, see if you can port the pca10040e bootloader project. It only uses 20kB of RAM, but you need to change it to using the S132 if that is what you are using.

    I'm not sure if my porting was correct, but here is what I did. I changed s112 to s132 in Code->Preprocessor->Preprocessor Definitions. Then I changed the header files in User Include Directories :

    • ../../../../../components/softdevice/s132/headers
    • ../../../../../components/softdevice/s132/headers/nrf52

    I flashed and did a debug session on the bootloader, tried to update it with the main application got the following problem :

    <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.
    <warning> nrf_dfu_settings: Resetting bootloader settings since neither the settings page nor the backup are valid (CRC error).
    <debug> nrf_dfu_settings: Writing settings...
    <debug> nrf_dfu_settings: Erasing old settings at: 0x0002F000
    <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0002F000, len=1 pages), queue usage: 0
    <debug> nrf_dfu_flash: Flash erase success: addr=0x0002F000, pending 0
    <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002F000, src=0x200040AC, len=896 bytes), queue usage: 1
    <debug> nrf_dfu_flash: Flash write success: addr=0x0002F000, pending 0
    <info> nrf_dfu_settings: Backing up settings page to address 0x2E000.
    <debug> nrf_dfu_settings: Writing settings...
    <debug> nrf_dfu_settings: Erasing old settings at: 0x0002E000
    <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0002E000, len=1 pages), queue usage: 1
    <debug> nrf_dfu_flash: Flash erase success: addr=0x0002E000, pending 0
    <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002E000, src=0x2000442C, len=896 bytes), queue usage: 1
    <debug> nrf_dfu_flash: Flash write success: addr=0x0002E000, pending 0
    <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 (0x200022E4)
    <debug> app: timer_activate (0x200022E4)
    <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
    <debug> nrf_dfu_ble: Connected
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 12
    <debug> nrf_dfu_ble: min_conn_interval: 12
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 600
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 6
    <debug> nrf_dfu_ble: min_conn_interval: 6
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 500
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 12
    <debug> nrf_dfu_ble: min_conn_interval: 12
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 600
    <debug> nrf_dfu_ble: Received BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST (request: 517, reply: 247).
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_SELECT (command)
    <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> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)
    <debug> app: timer_stop (0x200022E4)
    <debug> app: timer_activate (0x200022E4)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_ble: Buffer 0x20003010 acquired, len 141 (244)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    <debug> nrf_dfu_ble: Freeing buffer 0x20003010
    <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
    <warning> nrf_dfu_ver_validation: SD req not met.
    <warning> nrf_dfu_validation: Prevalidation failed.
    <debug> nrf_dfu_validation: Init command:
    <debug> nrf_dfu_validation:  08 00 10 34 1A 02 CB 01|...4....
    <debug> nrf_dfu_validation:  20 00 28 00 30 00 38 E8| .(.0.8.
    <debug> nrf_dfu_validation:  A4 02 42 24 08 03 12 20|..B$... 
    <debug> nrf_dfu_validation:  A1 A0 1E 6C 6E 4B 18 64|...lnK.d
    <debug> nrf_dfu_validation:  19 B2 A3 53 3F C0 4C 84|...S?.L.
    <debug> nrf_dfu_validation:  0F 04 F1 15 A0 DD 21 2B|......!+
    <debug> nrf_dfu_validation:  15 92 BB 11 6B AB DF DB|....k...
    <debug> nrf_dfu_validation:  48 00 52 04 08 01 12 00|H.R.....
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0xB
    <warning> nrf_dfu_ble: DFU request 4 failed with error: 0xB
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 6
    <debug> nrf_dfu_ble: min_conn_interval: 6
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 500
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 12
    <debug> nrf_dfu_ble: min_conn_interval: 12
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 600

  • Looks like the softdevice version check failed. Do you use the S132 as a requirement? What --sd-req did you use when you generated the packet, and what softdevice did you flash on your device? I assume it is the S132, but what version?

    Have you tried to debug to see where in sd_req_check() it fails?

    BR,

    Edvin

  • I'm using s132 v7.0.1. I did some modifications to the PCA10040e bootloader's configuration : 

    • I changed the Memory Segments : 

    FLASH RX 0x0 0x40000;RAM RWX 0x20000000 0x8000;uicr_bootloader_start_address RX 0x10001014 0x4;bootloader_settings_page RX 0x0003F000 0x1000;uicr_mbr_params_page RX 0x10001018 0x4;mbr_params_page RX 0x0003E000 0x1000

    • I changed the Section Placement Macros : 

    FLASH_PH_START=0x0 
    FLASH_PH_SIZE=0x40000
    RAM_PH_START=0x20000000
    RAM_PH_SIZE=0x6000
    FLASH_START=0x28000
    FLASH_SIZE=0x6000
    RAM_START=0x20002ad8
    RAM_SIZE=0xa698

    • I changed the softdevice in the loader to s132 v7.0.1
    • I changed the Target Device to nRF52832_xxAA
    • Register Definition File to ../../../../../modules/nrfx/mdk/nrf52832.svd

    I was able to compile and build the project. I also managed to flash it on my custom board. But the placement of the bootloader will cause some trouble. Here what the memory layout looks like : 

    I don't know I tried to change the FLASH_START to 0x3DF90 but end up getting some errors.

  • Edvin said:

    Looks like the softdevice version check failed. Do you use the S132 as a requirement? What --sd-req did you use when you generated the packet, and what softdevice did you flash on your device? I assume it is the S132, but what version?

    Have you tried to debug to see where in sd_req_check() it fails?

Related