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

Parents
  • Just an update to my comment, if you are using the app_pwm, there is a chance that the timer is not stopped when you jump from application to bootloader.

    Therefore if there are event pending, the event handler will be called again when we jump back ti application and we will be in trouble because it will be triggered even before we finish initialize the timer again.

    So you should stop any timer, clear any pending event before jumping to the bootloader. For example if you are using PWM0 and TIMER1 you should add: 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);

    to bootloader_util_app_start() in bootloader_util.c , and call these before bootloader_util_reset(start_addr);

    Another solution, maybe easier one is to do a soft reset after finish DFU and before jumpping back to application.

Reply
  • Just an update to my comment, if you are using the app_pwm, there is a chance that the timer is not stopped when you jump from application to bootloader.

    Therefore if there are event pending, the event handler will be called again when we jump back ti application and we will be in trouble because it will be triggered even before we finish initialize the timer again.

    So you should stop any timer, clear any pending event before jumping to the bootloader. For example if you are using PWM0 and TIMER1 you should add: 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);

    to bootloader_util_app_start() in bootloader_util.c , and call these before bootloader_util_reset(start_addr);

    Another solution, maybe easier one is to do a soft reset after finish DFU and before jumpping back to application.

Children
Related