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

DFU update failking on nrf51822 with sdk12.3

I have developed an app for the nrf51822, using the nrf51-dk with SDK12.3, together with DFU functionality.

After having solved many issues to get to this point with the precious help provided in this forum, I get yet another road block.

The problem I am having now is that updating my app over the air works with the nrf51-dk, but not with the nrf51822 on my custom board.

This is the log from the boot loader:

:INFO:------- nrf_dfu_flash_init-------
:INFO:Waiting for events
:ERROR:received a fault! id: 0x000:INFO:Return false in CRC
:INFO:In nrf_dfu_transports_init
:INFO:num transports: 1
:INFO:vector table: 0x00035c00
SDH:DEBUG:sd_ble_enable: RAM start at 0x200025e0
:INFO:After nrf_dfu_transports_init
:INFO:------- nrf_dfu_flash_init-------
:INFO:Waiting for events
:INFO:Received select object
:INFO:Valid Command: NRF_DFU_OBJECT_OP_SELECT
:INFO:Sending Object Info: [0x60, 0x06, 0x01 max: 0:x00000100 0:x00000000, CRC:0x00000000]
:INFO:Set receipt notif
:INFO:Sending Response: [0x2, 0x1]
:INFO:Received create object
:INFO:Before OP create command
:INFO:Valid Command Create
:INFO:Sending Response: [0x1, 0x1]
:INFO:Before OP write command
:INFO:Before OP write command
:INFO:Before OP write command
:INFO:Before OP write command
:INFO:Before OP write command
:INFO:Before OP write command
:INFO:Before OP write command
:INFO:Before OP write command
:INFO:Received calculate CRC
:INFO:Valid Command CRC
:INFO:Sending CRC: [0x60, 0x03, 0x01, 0:x0000008d, CRC:0xdb6bef54]
:INFO:Received execute object
:INFO:Before OP execute command
:INFO:Valid command execute
:INFO:
12 8A 01 0A 44 08 01 12 40 08 02 10 33 1A 02 87  [email protected]...
01 20 00 28 00 30 00 38 DC 98 09 42 24 08 03 12  . .(.0.8..	B$...
20 3A 23 12 CC A6 30 93 56 D6 5F 21 3F E6 40 59   :#...0.V._!?.@Y
FA BB 75 3B 77 98 8B 22 77 26 9E F7 30 9B 2E CF  ..u;w.."w&..0...
6D 48 00 52 04 08 01 12 00 10 00 1A 40 AC 0A 3B  mH.R........@..;
2E D3 3F CF 04 E7 AA A9 DB 94 B5 DC AF 8D 10 EB  ..?.............
:INFO:
8D 10 EB F0 43 D4 7A 71 81 87 A4 6D 76 70 54 70  ....C.zq...mvpTp
79 95 6D 4B 86 93 DF A0 48 C0 79 CE 4E EF EA F9  y.mK....H.y.N...
D9 71 2A DA AE DD B3 91 DE BE C6 D0 C2 45 6A A1  .q*..........Ej.
:INFO:
:INFO:signature len: 64
:INFO:Image verified
:INFO:Enter nrf_dfu_find_cache
:INFO:No way to fit the new firmware on device
:INFO:Prevalidate FAILED!
:INFO:Sending Response: [0x4, 0x4]

In nrf_dfu_utils.c:

   // Simple check if size requirement can me met
    if(free_size < size_req)
    {
        NRF_LOG_INFO("No way to fit the new firmware on device\r\n");
        return NRF_ERROR_NO_MEM;
    }

Where free_size = 106496 and size_req = 150620

free size is calculates with DFU_REGION_TOTAL_SIZE = 109568 and DFU_APP_DATA_RESERVE = 3072, so 109568-3072=106496

DFU_REGION_TOTAL_SIZE is calculated from ((* (uint32_t *)NRF_UICR_BOOTLOADER_START_ADDRESS) - CODE_REGION_1_START)

where uirc_bootloader at address 0x10001014, contains =220160 (0x35C00, which matches the boot loader start address)

and CODE_REGION_1_START=110592 (0x1b000, which matches the start of my app), then total size is 220160-110592=109568, matching the values above.

This is the current usage of the flash:

1. mbr+soft device, 0x0 to 0x1b000

2. my app, 0x1b000 to 0x220c4 (22868 bytes)

3. boot loader, from 0x35c00

All start addresses match and calculations seem to be correct and the required size is actually the size of the .bin file inside the app_dfu_package.zip, but why is it so much bigger than the .hex file for the application (22868 bytes vs 150620 bytes)?

Is it a coincidence that the .bin file is almost the same size as the space between the soft device and the end of the flash (0x40000 - 0x1b000 = 151552)?

Is there a way to fix this? The bin file is actually bigger than the area between the soft device and the boot loader. This way it will never be possible to update the app.

Best regards,

Ricardo

Related