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

Clear config after succesful DFU?

Hi,

We have a little issue that we at the moment need to cycle power on v3 nRF51822 after DFU.

We have determined the the reason has something to do with the whole complicated system configs - we use a customised bootloader that uses button, leds etc - and the app itself uses PWM (app_pwm patched my Mr Koppel). Issue now is that after DFU, the app freezes to nrf_drv_gpiote_out_init while initializing PWM.

I'm looking for a robust way to clear config after DFU to comparable to power cycle - how can we do that? Is there any suitable API? We do still want to utilise RAM retention for bonding info.

Br, //HS

  • So, in summary, before our timers_init function:

    static void timers_init(void)
    {
        // Initialize timer module.
        APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); //scheduler not used
       
        button_timer_init();
        battery_timer_init(); 
    //etc etc...
    }
    
  • Now, the timers_init function:

    static void timers_init(void)
    {
        //PWM disable timers, to avoid device bricking, after ATO DFU
        // See: devzone.nordicsemi.com/.../
        NRF_TIMER1->TASKS_STOP = 1;
        NRF_TIMER1->TASKS_SHUTDOWN=1;
        NRF_TIMER1->EVENTS_COMPARE[0]=0;
        NRF_TIMER1->EVENTS_COMPARE[1]=0;
        NRF_TIMER1->EVENTS_COMPARE[2]=0;
        NRF_TIMER1->EVENTS_COMPARE[3]=0;
        NVIC_DisableIRQ(TIMER1_IRQn);
    
        // Initialize timer module.
        APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); //scheduler not used
    
        button_timer_init();
        battery_timer_init();
      //etc etc...
    }
    
  • Hi,

    The softreset is done on the new Secure DFU from SDK v12, not the legacy DFU (SDKv6 til SDKv11).

    Note that we do clear all interrupts before we switch to application or bootloader with the interrupts_disable() function. What is leftover is the setting of the timer and the EVENTs. Clearing the Events before use is a good use.

    Note that APP_TIMER doesn't use NRF_TIMER, it uses RTC.

    You can implement your own soft reset with "NVIC_SystemReset()" when you switch from application to bootloader. You should call it after you set the GPREGRET, also if you forwarding bond information, you need to retain the RAM memory area for the peer_data.

    If you have further question, please create a new case describe your issue with more detail.

Related