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 made a number of changes and it appears to be working now:

    1) Changed NRF_BL_DFU_ENTER_METHOD_BUTTON from 1 to 0 in sdk_config.h

    2) Changed NRF_BL_DFU_ENTER_METHOD_BUTTONLESS from 0 to 1 in sdk_config.h

    3) Changed the way I was requesting DFU in my app from

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

        to:

        uint32_t value;
        sd_power_gpregret_get(0, &value);
        value |= BOOTLOADER_DFU_START;
        sd_power_gpregret_set(0, value);
        sd_nvic_SystemReset();
    

        using the macro definition for BOOTLOADER_DFU_START taken from a bootloader header file.

    The combination of the above seems to have fixed the problem.

    I will close this ticket after I have performed more extensive testing.

    Regards to all.

    Dave

Reply
  • I have made a number of changes and it appears to be working now:

    1) Changed NRF_BL_DFU_ENTER_METHOD_BUTTON from 1 to 0 in sdk_config.h

    2) Changed NRF_BL_DFU_ENTER_METHOD_BUTTONLESS from 0 to 1 in sdk_config.h

    3) Changed the way I was requesting DFU in my app from

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

        to:

        uint32_t value;
        sd_power_gpregret_get(0, &value);
        value |= BOOTLOADER_DFU_START;
        sd_power_gpregret_set(0, value);
        sd_nvic_SystemReset();
    

        using the macro definition for BOOTLOADER_DFU_START taken from a bootloader header file.

    The combination of the above seems to have fixed the problem.

    I will close this ticket after I have performed more extensive testing.

    Regards to all.

    Dave

Children
Related