Hi,
We started out developing an application using the SoftDevice 1.0.0-3 (from SDK 0.9.2). We now need to upgrade to SoftDevice 4.0.2 (included in SDK 13.0.0).
We already have products with SoftDevice 1.0.0-3 that have been released to customers and we are trying to figure out how we can perform the DFU OTA which includes SoftDevice 4.0.2.
Note - we have our own implementation of DFU and OTA, hence we do not use the SDK for this. We only use the SoftDevice from the SDK. We have been using our own implementation successfully for a long time, but this is the first we actually have to upgrade the SoftDevice as part of a new release.
This is what we do:
When upgrading the SoftDevice, we extract the non-MBR parts of it, transfers it to the device OTA. The bootloader will then write it flash address 0x1000. We use the following command to extract the non-MBR parts from the SoftDevice:
$ arm-none-eabi-objcopy -Iihex -Obinary --remove-section .sec1 --gap-fill=0xff ~/nRF5_SDK_13.0.0/components/softdevice/s132/hex/s132_nrf52_4.0.2_softdevice.hex sd.bin
Of course, the application code is also updated to reflect the API changes in the SoftDevice.
This is what happens, and a short analysis of why it fails:
After performing the upgrade, the application will no longer start. If we compare the flash memory contents of a board that has been programmed via JTAG (4.0.2) and a board that has been upgraded 1.0.0-3 to 4.0.2 (using OTA), the ONLY difference when comparing the binary dumps of the complete 512 Kb flash memory is @ address 0x0 to 0x1000 which is the MBR. This is expected since we did not upgrade the MBR. But we expected that the board would still start up, using the old MBR (1.0.0-3).
If we extract the MBR (using arm-none-eabi-objcopy) from the 4.0.2 SoftDevice and write it using JTAG to the bricked board, it starts up again as expected. See the command sequence below.
$ arm-none-eabi-objcopy -Iihex -Oihex -R .sec2 -R .sec3 ~/nRF5_SDK_13.0.0/components/softdevice/s132/hex/s132_nrf52_4.0.2_softdevice.hex mbr.hex
$ nrfjprog --erasepage 0x0-0x1000 -f NRF52
$ nrfjprog --program mbr.hex -f NRF52
-> Board is now running SoftDevice 4.0.2 and the new application.
Questions:
Do we HAVE to switch to the MBR included in SoftDevice 4.0.2?
If not, then how do we get a board running with the combination of MBR 1.0.0-3 and SoftDevice 4.0.2?
If we have to change the MBR, then how can we do this without using JTAG? We tried, but ended up in a signal handler (0xfffffffe according to gdb backtrace) when trying to erase the first block, which contains the MBR. We disabled all the interrupts before the erase started.