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

Secure bootloader - SDK12.2.0

While using the secure bootloader image and test application works consistently using the development kit I have not been able to port the solution reliably for our custom PCB. I suspect the image generation is done incorrectly on my behalf.

Tools used

  1. NRF52832
  2. Softdevice S310 v3.0
  3. SDK v12.2.0
  4. nrfutil version 2.0.0
  5. mergehex version: 8.0.0
  6. nRF Toolbox 4.2.0

I created a hex file containing SD132 v3 and the secure bootloader. The secure bootloader is slightly modified to look at GPREGRET to see if my main application has flagged the bootloader.

During first start the bootloader is alive and I can successfully upload my main application using nRFToolbox app. The application starts correctly.

I restart the device into bootloader mode but using the same hex file the CRC fails after the download/copy process.

 0> :INFO:CRC computation: Main app start: 0x0001f000, img size: 104884
 0> :INFO:CRC computation failed for copied app: src crc: 0x6ae723ad, res crc: 0xb3b939d

During the third attempt the same hex file is accepted and the device is live again.

 0> :INFO:Setting app as valid
 0> :INFO:CRC computation succesful: src crc: 0x6ae723ad, res crc: 0x6ae723ad

When I compare the log for run 2 and 3 I see there is a restart in the middle of the erase/write process after the download, this happens always in the same spot.

 0> :INFO:2 Target address: target_addr: 0x00041000, src_addr: 0x464e493a
 0> :INFO:Erasing: 0x00027000, num: 1
 0> :INFO:Erasing: 0x00041000, num: 1
 0> :INFO:Erasing old settings at: 0x0007f000
 0> :INFO:Erasing: 0x0007f000, num: 1
 0> :INFO:Writing 0x00000057 words
 0> :INFO:Writing settings...
 0> :INFO:Erasing: 0x00028000, num: 
 0> :INFO:Inside main
 0> :INFO:In nrf_bootloader_init

I have a feeling that this might be due to bootloader settings but I have not been able to generate the correct settings. I tested builing a settings file for the application but when I try to install that with DFU I get a error message stating the application is too big and will not fit.

 0> :INFO:Image verified
 0> :INFO:DFU REGION TOTAL SIZE: 344064
 0> :INFO:DFU APP DATA RESERVED: 12288
 0> :INFO:FREE SIZE: 331776
 0> :INFO:Enter nrf_dfu_find_cache
 0> :INFO:No way to fit the new firmware on device
 0> :INFO:Prevalidate FAILED!

These are the app settings that I merged with the same firmware.hex file that works every other time:

Bootloader DFU Settings:
* File:                 app-settings.hex
* Family:               nRF52
* CRC:                  0x4DE475AF
* Settings Version:     0x00000001 (1)
* App Version:          0x00000001 (1)
* Bootloader Version:   0x00000001 (1)
* Bank Layout:          0x00000000
* Current Bank:         0x00000000
* Application Size:     0x000199B4 (104884 bytes)
* Application CRC:      0x7B0FA160
* Bank0 Bank Code:      0x00000001

Any suggestions?

Thanks.

Related