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

  • Hi Henris,

    It's true that we don't reset the register configuration before we jump from bootloader to application. The application should not give assumption that all register is in reset state when it starts. It should configure all registers when start using the peripheral. Do you have the issue when you test with your bootloader + our example application ?

    If possible please provide us a simple example(bootloader + application) that show the issue that we can reproduce the issue here (prefer if it can be tested on nRF51 DK board).

  • 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.

  • Hi - we have found if this is not done then the device bricks after OTA DFU! Observed with SDK10 PWM library code, not in SDK8. This should be documented somewhere.

  • Hi NG,

    I agree that user should be made aware of this requirement. In our newer SDK, the switching between application and bootloader is done by a soft reset, so it's not needed.

  • Hi Hung Bui, Thanks for your response. Can you please clarify the soft reset done between application and bootloader? At the end our bootloader main function, we have "NVIC_SystemReset()" however this problem still occurs.

    The way I have worked around it is to include the timer1/2 stop code (as you wrote above) in the timer_init() function, just before APP_TIMER_INIT(). The reason I do it here is because adding the timer stop code only into reset_prepare() won't guarantee that the timers are stopped if you're doing a OTA DFU between SDK8 and SDK10 code, you'll brick your device.

Related