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

Unable to get app to run when flashing BL, SD and App via nrfjprog

I am trying to flash a secure DFU bootloader (compiled using my own key), a soft device, and my application using nrfjprog with the intention being to have the application boot when the board is reset. However, it always goes back to the bootloader after the reset.

I'm using SDK 15.3.0 and soft device s140_nrf52_6.1.1_softdevice.hex.

If I use nRF Connect on my phone to download my app it will launch no problem.

I found some articles that said I have to write specific values to 0x3FC00 and 0x3FC04 to fool the bootloader into launching the app but I believe these addresses are not applicable to my setup as I believe the bootloader settings are located at FF000. Is that right?

Here are the commands I'm using to write to the flash, patched together from a bunch of things I have read

nrfjprog --eraseall
nrfutil settings generate --family NRF52840 --application emf_firmware_pca10056_s140.hex  --application-version 1 --bootloader-version 0 --bl-settings-version 2 bootloader_setting.hex
nrfjprog --program s140_nrf52_6.1.1_softdevice.hex -f NRF52
nrfjprog --program bootloader_setting.hex -f NRF52
nrfjprog --program secure_bootloader_ble_s140_pca10056.hex -f NRF52
nrfjprog --program emf_firmware_pca10056_s140.hex -f NRF52
nrfjprog --reset

Can someone please let me know what I'm missing to make this work? I've been trying various things for the last two days.

Thanks.

Parents
  • I have some updated information.

    Within my firmware app I have code that allows the user to switch to DFU mode so that they can upload a new firmware app via BLE DFU. If I go into DFU mode using that method and then run my script to erase all and flash everything it will not launch the app unless I power cycle the board after running my script. Once the board has been powered down and back up I can reflash everything over and over again and it always works.

    So to be clear, here is the sequence:

    1) f/w app running, go into DFU mode (see code below), flash SD/BL/APP (using nrfjprog) => bootloader still running and advertising for DFU

    2) power cycle board => firmware app launches ok

    3) flash SD/BL/APP (using nrfjprog) => firmware app is running

    Can repeat step 3 and always works

    This is what I'm doing within my firmware app to go into DFU mode:

        sd_power_gpregret_clr(0, 0xFF);
        sd_power_gpregret_set(0, 1);
        sd_nvic_SystemReset();
    

    Perhaps there is a better (proper?) way of getting into DFU mode?

Reply
  • I have some updated information.

    Within my firmware app I have code that allows the user to switch to DFU mode so that they can upload a new firmware app via BLE DFU. If I go into DFU mode using that method and then run my script to erase all and flash everything it will not launch the app unless I power cycle the board after running my script. Once the board has been powered down and back up I can reflash everything over and over again and it always works.

    So to be clear, here is the sequence:

    1) f/w app running, go into DFU mode (see code below), flash SD/BL/APP (using nrfjprog) => bootloader still running and advertising for DFU

    2) power cycle board => firmware app launches ok

    3) flash SD/BL/APP (using nrfjprog) => firmware app is running

    Can repeat step 3 and always works

    This is what I'm doing within my firmware app to go into DFU mode:

        sd_power_gpregret_clr(0, 0xFF);
        sd_power_gpregret_set(0, 1);
        sd_nvic_SystemReset();
    

    Perhaps there is a better (proper?) way of getting into DFU mode?

Children
No Data
Related