This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

bootloader_app_start vs NVIC_SystemReset();

Hi, i want to jump from my app to the bootloader, i used the function

void bootloader_app_start(void)

{

    vMBt_eStopAdv_Exe() ;// Stoping the BLE ADV 
    sd_power_gpregret_clr(POWER_GPREGRET_GPREGRET_Msk); 
sd_power_gpregret_set(BOOTLOADER_DFU_START); 
sd_softdevice_disable(); 
interrupts_disable(); 
sd_softdevice_vector_table_base_set(NRF_UICR->BOOTLOADERADDR); 
bootloader_util_app_start(NRF_UICR->BOOTLOADERADDR);

}

and it's OK , but when i use NVIC_SystemReset(); instead of bootloader_util_app_start it dosen't work and the bootloader dosen't start. although i added in the script of the bootloader to enter the bootloader program if GPREGRET=BOOTLOADERADDR or GPREGRET=0x00 ( case of a reset is handled )

this the modfication in the bootloader code :

if (dfu_start || (!bootloader_app_is_valid(DFU_BANK_0_REGION_START)) ||NRF_POWER->GPREGRET == 0x00)... this the condition part to enter dfu_mode , i just added the case where GPREGRET=0x00

Remarks:

1- the initialisation of the softdevice is always done in the case of a reset because we have :

-static bool dfu_start = false;

  • bool app_reset = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_START);

  • ble_stack_init(!app_reset );

2- no button check is included , i commented that part as follow

//dfu_start |= ((nrf_gpio_pin_read(BOOTLOADER_BUTTON_PIN) == 0) ? true: false);

Questions :

  1. Why it dosen't work with the nvic reset ?
  2. can you explain to me the process of jump ..i have a small idea about assembly code but i don't know what are the registers used there when jumping...(thread mode .. )
  3. If i want to use Nvic_Reset() what should i do ? ( i don't care about the bonding service !! )
  4. This function ( __asm static void bootloader_util_reset(uint32_t start_addr) , used for the jump) is really confusing me !! in fact it's invoking a parameter that it never uses ..any explanation please
Parents
  • Hi Hung Bui,

    Ok, i find the problem, and thanks for your help. It was my misunderstanding of the impact of a soft reset. In fact i thought it changes the GPREGRET register to 0x00 as the hard reset do. Now, i commented the code before the soft reset ,as follow :

    // sd_power_gpregret_clr(POWER_GPREGRET_GPREGRET_Msk); // clear GPREGRET flag

    // sd_power_gpregret_set(BOOTLOADER_DFU_START); // set GPREGRET flag

    and it's working well.

    One more information for the reader, it works because in the bootloader code there is some where

    sd_power_gpregret_clr(POWER_GPREGRET_GPREGRET_Msk); just when the dfu starts, thats why app_reset will be false and the !app =true and then the softdevice re*-init.

  • Hello Toto, i was reading your post and just before I was reading this link text I have used only this code in my application: uint32_t err_code; err_code = sd_power_gpregret_set(10); APP_ERROR_CHECK(err_code);

    NVIC_SystemReset();
    

    I hope it helps...

Reply Children
No Data
Related