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

bootloader&wdt

FormerMember
FormerMember

hello everyone:

do you have try to add wdt into bootloader project?

i add it as follow: in the static void wait_for_events(void) function, i add two

if(NRF_WDT->RUNSTATUS&0x01){ NRF_WDT->RR[0]=WDT_RR_RR_Reload;}

static void wait_for_events(void)
{
    for (;;)
    {
        // Wait in low power state for any events.
        uint32_t err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
				
				if(NRF_WDT->RUNSTATUS&0x01)
				{
						NRF_WDT->RR[0]=WDT_RR_RR_Reload;
				}
        // Event received. Process it from the scheduler.
        app_sched_execute();

        if ((m_update_status == BOOTLOADER_COMPLETE) ||
            (m_update_status == BOOTLOADER_TIMEOUT)  ||
            (m_update_status == BOOTLOADER_RESET))
        {
						if(NRF_WDT->RUNSTATUS&0x01)
						{
								NRF_WDT->RR[0]=WDT_RR_RR_Reload;
						}
            // When update has completed or a timeout/reset occured we will return.
            return;
        }
    }
}

and then,i try to DFU,when i send dfu command.it's time to wdt,it reset.

and before i add wdt to application.there i can dfu it nornal

is there anybody know the reason? can you tell me ? thank you

Parents Reply Children
  • i know in the SDK9.0,i can let it DFU by set the NRF_POWER->GPREGRET =BOOTLOADER_DFU_START(0xb1).and i want to use the same way in sdk12.3,but when i let NRF_POWER->GPREGRET =0xb1,it reset,and start application again,not in dfu mode ..and i test i really write the NRF_POWER->GPREGRET =0xb1,i printf it.(i use sdk12.3,nrf51822-QFAA),the reson is wdt.void

    wdt_timeout_handler(void * p_context)
    {
    	nrf_gpio_pin_toggle(18);
    	NRF_WDT->RR[0]=WDT_RR_RR_Reload;
    }
    #define WDT_INTERVAL			           APP_TIMER_TICKS(1000,APP_TIMER_PRESCALER)
    
    APP_TIMER_DEF(wdt_timer_id);
    

    i test when i not open the wdt, it can dfu ok.the led can togle, means that the timer is work,and then, i open the wdt(#define WDT_CONFIG_RELOAD_VALUE 7000).and then ,wnen i set NRF_POWER->GPREGRET =BOOTLOADER_DFU_START,and then it retart after 7 seconds.do you know the reson ?can you tell me? thank you

  • Hi Yichen,

    If you reset the chip (in the application) by the watchdog reset, the GPREGRET register will be erased.

    You have two options:

    1 - Keep the WDT running, reset using soft reset. Then inside the bootloader you need to feed the dog.

    2 - Let the WDT trigger the reset , but then you need to write the flag to enter bootloader mode in flash instead of GPREGRET. This way you don't need to handle the WDT in the bootloader.

Related