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

Secure DFU bootloader: application not starting

Hello,

I have a problem with secure bootloader. what I did:

  1. Flash SoftDevice 130 using nRFgo Studio.
  2. Compiling \examples\dfu\bootloader_secure\ (i removed the error regarding the key).
  3. Flashing the bootloader with Keil (using nrfjprog.exe for flashing).

Unfortunately, the bootloader seems not to run. There is no advertisement "DfuTarg". When I compile the buttonless dfu example and flash it with Keil, there is still no response. So the bootloader does not start the application. There are no debug messages over UART either.

However, when I flash the precompiled debug version (secure_dfu_secure_dfu_ble_s130_pca10028_debug.hex), the bootloader is advertising as "DfuTarg". When I load an application (using Keil or DFU with nrfConnect´), it does not leave the bootloader mode.

Can you tell me whats wrong?

Thank you!

Edit: I use SD130 on nRF51

  • Hi,

    Please provide more information how you "removed the error regarding the key".

    Which SDK version are you testing with ?

    You can try to set the optimization level to 0 and step into the code and check why it doesn't advertise.

  • Hello and thanks for your response. Since I do not know the exact differences between the debug version and the normal one of the secure bootloader, I used the non-debug-version. To get a successful compilation, I changed the dfu_public_key.c to:

    //#ifdef NRF_DFU_DEBUG_VERSION 
    
    /** @brief Public key used to verify DFU images */
    __ALIGN(4) const uint8_t pk[64] =
    {
        0x6e, 0x76, 0x24, 0x50, 0x38, 0xb6, 0xed, 0x60, 0xc3, 0x60, 0x12, 0x50, 0x00, 0xd2, 0x25, 0x0f, 0xee, 0x37, 0xbf, 0x00, 0x02, 0x6b, 0x50, 0x92, 0x80, 0x32, 0x42, 0x2e, 0xd6, 0x68, 0xde, 0xdf, 
        0x3b, 0xcf, 0xa4, 0x6a, 0x3e, 0x45, 0x9b, 0xb3, 0xb1, 0x3c, 0xa3, 0x39, 0xcc, 0x95, 0x58, 0x36, 0xcd, 0x6d, 0x7e, 0x1f, 0xa1, 0xab, 0x79, 0x05, 0x35, 0x2d, 0x2a, 0xda, 0x19, 0xdb, 0x88, 0xce
    };
    
    //#else
    //#error "Debug public key not valid for production. Please see github.com/.../README.md to generate it"
    //#endif
    

    Could this be the reason for the bootloader not to start? I use SDK v12.1.0 on nRF51. I find it hard to debug software which interacts with a SoftDevice since it generates a Hard Fault after hitting the breakpoint.

    Thank you very much for your support!

    Edit: It's not possible to compile the bootloader with -O0 since the image gets too big. Unfortunately it's also not possible to enable the debug messages (NRF_LOG_INFO).

    Edit2: I am not sure if it's of any help since optimization is still active, but in nrf_dfu_transports_init() there is a call

    ret_val = trans->init_func();
    

    Regarding to the debugger, this is a zero-pointer (NULL).

    Edit3: Tried it with SDK V12.2.0 and it seems to work. Is there a precompiled version of nrfutil available for Windows which supports the pkg command?

  • I don't think there was any major modification between SDK v12.2 and SDK v12.0 on the DFU bootloader. Maybe if you test again with a fresh install of SDK v12.0 it may work.

    The difference between the debug version and the normal version is that the debug version won't check for version check (application version, bootloader version, hardware version etc). So if use the normal version, please make sure you set the version correctly (update version should not be lower than original version).

    To get nRFutil on Windows, you need to install python, install pip and then do "pip install nrfutil" please follow the instruction here.

  • Thank you. If i flash the application with Keil (using Segger J-Link) after flashing the bootloader, should the bootloader start this application? Atm it does not leave the bootloader mode (assuming no valid application is found at app start address). Do I have to adapt addresses in the application to get it recognized correctly by the bootloader? Or is it necessary to use the BLE DFU update to get the application running? Thank you.

  • Hi,

    The bootloader was made so that you would need to program the application via DFU bootloader to make it start.

    If you don't want to use the DFU bootloader to upload your first application, and prefer to use the programmer instead, you need to alter the bootloader setting in flash to tell the bootloader to start the application. You can generate a bootloader setting hex file then write it to flash to do that. Please have a look here.

Related