Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Boot Loader

Hi,

I'm trying to write custom boot loader, that receiving hex file via uart and write it to location 0x40000 and then jumps to the location. I changed FLASH_ADDRESS and FLASH_PH_ADDRESS to 0x40000 and built two applications from examples: blinky_pca10056 and led_softblink_pca10056. To jump to application I uses command nrf_bootloader_app_start_impl(0x40000). The problem is: blinky_pca10056  is started and running, but  softblink_pca10056 is started  (I can see that all 4 leds are on), but it is not running. I'm using in SEGGER. Should I do so operations before I call nrf_bootloader_app_start_impl? Any ideas?

Thank you.

  • Hi,

    You can debug an application even if it was added to the device though DFU. You should probably try to debug the softblink application to verify that it's running and when it stops running.

    If you have a look at when nrf_bootloader_app_start_impl is called in SDK14.2.0 (and older versions as far as I can recall) nrf_bootloader_app_start does a few important things before performing the switch. Interrupts are disabled and the vector table used by the SoftDevice to determine where to send events is set. Additionally, you may need to disable timers or clocks you have started like you can see on line 229 in nrf_dfu.c.

    Generally, what you need to do is removing any sort of conditions where an interrupt can cause code to run which the application wasn't ready for. If you are getting unexpected interrupts from hardware or the SoftDevice events are still being sent to the now uninitialized bootloader your system will crash quickly.

    Best regards,
    Rune Holmgren

  • Thank you for your answer.

    I do not use in SoftDevice, that is why I do not use nrf_bootloader_app_start, but directly call to nrf_bootloader_app_start_impl. This is a code


    NVIC->ICER[0]=0xFFFFFFFF;
    NVIC->ICPR[0]=0xFFFFFFFF;
    NVIC->ICER[1]=0xFFFFFFFF;
    NVIC->ICPR[1]=0xFFFFFFFF;
    app_uart_close();
    nrf_drv_clock_lfclk_release();
    while (nrf_clock_lf_is_running()) {;}
    nrf_drv_clock_uninit();
    nrf_bootloader_app_start_impl(0x40000);

    after this command it is entering to main of led_softblink_pca10056, I see all leds are on, but then it enters in loop with  _WFE(), but this application is not using events, so I do not know  why leds are not blinking, I would like to debug it, but I do not know how debug application that I jumping to. Can you give me a direction?

  • Hi,

    Most if not all debuggers will have an option to "Attach to running program". It is mostly like running a regular debugging session, the only difference being that you need to let the DFU process perform the flashing. Attaching to a running program this will not interfere with the flash and DFU operations, so you can start the debugger and have it running already when the bootloader is running with some breakpoints in the application to verify that a switch takes place as expected.

    Based on the description of the LED being updated and the _WFE call, it sounds like your application initializes without an error being returned, but no interrupts are received after initialization. You need to debug it to get any useful details helping you resolve the issue.

    Best regards,
    Rune Holmgren

     

  • Thank you, I will check initialization of interrupt vectors before I jump to program.

Related