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

Trouble with buttonless DFU - bootloader settings crc fails

Hi guys. I am struggling to get buttonless DFU to work in my owm application. I am using SDK12.2 with gcc on a pca10040 board with S132.

I have successfully followed this tutorial to get the buttonless DFU example working.

However, when I try to implement the same DFU service into my own existing project, the DFU service setup fails at the CRC in nrf_dfu_settings_init(). The code then tries to erase from flash in nrf_dfu_settings_write(...), but fails and returns NRF_ERROR_INTERNAL on line 210.

The following is what I have tried.

  1. Compile the /examples/dfu/bootloader_secure project using my own private/public key pair (hex file is called dfu_bootloader.hex)
  2. Comment out lines 44 through 94 in nrf_dfu_settings.c as suggested here
  3. Erase the chip: nrfjprog --eraseall -f nrf52
  4. Flash the bootloader: nrfjprog --program ../dfu/dfu_bootloader.hex -f nrf52
  5. Flash the softdevice: nrfjprog --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_3.0.0_softdevice.hex -f nrf52 --sectorerase nrfjprog --reset -f nrf52
  6. Add the DFU service setup code to services_init() (as in the experimental_ble_app_buttonless_dfu example). Also add all dependencies and update sdk_config.
  7. Compile project and create the firmware package: nrfutil pkg generate --debug-mode --application _build\nrf52832_xxaa.hex --key-file ..\dfu\priv.pem ../dfu/pkg.zip
  8. Connect to the nRF52 using nRF Connect and transfer the firmware package
  9. Watch the application boot and crash at the CRC check in nrf_dfu_settings_init().

If I follow the exact same procedure, only flashing the experimental_ble_app_buttonless_dfu example instead, everything seems to work fine. Is there a problem with the bootloader settings in my application, since the CRC fails?

Any help is greatly appreciated.

Parents
  • Have you updated the Public Key in your bootloader?

    You need to sign your application package with a Private/Public key pair (as you are doing). You need to update the dfu_public_key.c file of the bootloader source code with the corresponding public key. You can check this out to get the public key for a given key file: github.com/.../pc-nrfutil

    This was something I struggled with for a long time before finding this solution.

  • Hi Dingari, thanks for your answer. I did update the public key in the bootloader as well.

    See the RTT output below:

    0> :INFO:!!!!!!!!!!!!!!! Resetting bootloader settings !!!!!!!!!!!

    0> :INFO:Erasing old settings at: 0x20002a18

    0> :INFO:Erasing: 0x20002a18, num: 1

    0> :INFO:Erase failed: 6

    0> :ERROR:Erasing from flash memory failed.

    0> APP_ERROR:ERROR:Fatal

    Error code 6 indicates FS_ERR_UNALIGNED_ADDR.

Reply
  • Hi Dingari, thanks for your answer. I did update the public key in the bootloader as well.

    See the RTT output below:

    0> :INFO:!!!!!!!!!!!!!!! Resetting bootloader settings !!!!!!!!!!!

    0> :INFO:Erasing old settings at: 0x20002a18

    0> :INFO:Erasing: 0x20002a18, num: 1

    0> :INFO:Erase failed: 6

    0> :ERROR:Erasing from flash memory failed.

    0> APP_ERROR:ERROR:Fatal

    Error code 6 indicates FS_ERR_UNALIGNED_ADDR.

Children
No Data
Related