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

Basic Bootloader nRF52832

Dear All,

I know similar questions have been asked before but I have read around quite a bit and I couldn't find an answer to my specific problem.

I have a ble application with softdevice which normally runs just fine. Now I would like to have some simple bootloader so that I can check at boot if a new firmware is available in an external flash. This is how my client wants it so there is no way out. Therefore I started testing with something simple.

I started with the iot_secure_dfu_bootloader and I stripped everything away until my main looked like this:

#include <stdint.h>
#include "boards.h"
#include "nrf_bootloader_info.h"
#include "nrf_bootloader_app_start.h"


void app_error_handler_bare(uint32_t error_code)
{
    (void)error_code;
    //NRF_LOG_ERROR("received an error: 0x%08x!\r\n", error_code);
    NVIC_SystemReset();
}

int main(void)
{
	while(1);
    nrf_bootloader_app_start();
}

where the while(1); can be commented or uncommented and serves as the simplest possible test of whether the bootloader is executing correctly or not. When I flash the bootloader directly from SEGGER Embedded Studio everything seems to work as expected (at least apparently), when the while(1); is there everything gets stuck, when I comment it out I can see my application start so that suggests that the control is going MBR->bootloader->softdevice->app.

However, if I then power-cycle the device the application always executes, even when I put an infinite loop in the bootloader, which makes me think that, after the power cycle, the bootloader is in fact not being executed and the control jumps straight to the application. What could the reason be?

Can anyone help me in setting up such simple bootloader? I have seen a lot of people on these forums struggling to get something simple like this to work, so I think it would be helpful for the community if we could document a clear and correct way to have a fully custom bootloader without DFU, encryption or anything of that sort.

Thank you very much.

Parents
  • Hi,

    The MBR checks if UICR.NRFFW[0] @ 0x10001014 contain a bootloader start address on startup, then if the address is valid the MBR will branch execution to this address. Can you verify that  UICR.NRFFW[0] holds the address to your bootloader? You can use the memory window in SES or the following nrfjprog command to check: nrfjprog --memrd 0x10001014. 

    where the while(1); can be commented or uncommented and serves as the simplest possible test of whether the bootloader is executing correctly or not. When I flash the bootloader directly from SEGGER Embedded Studio everything seems to work as expected (at least apparently), when the while(1); is there everything gets stuck, when I comment it out I can see my application start so that suggests that the control is going MBR->bootloader->softdevice->app.

    Maybe it's something with the debugger configuration. SES does for instance set the VTOR  register to the start address of the project you're building unless you build with  "NO_VTOR_CONFIG"

  • I figured it out, The UICR.NRFFW[0] was correctly set. The project is also builf with NO_VTOR_CONFIG.

    The problem was that I excluded bootloader_info.c from build. I got no warnings for that but for some reason it was breaking the functionality. I re-included it and everything works now. Not sure what the fundamental problem was but I am happy it works now.

    Thanks for your support

Reply Children
No Data
Related