Enter bootloader after reset in app

Yet another question on Optiboot. If in my app I reset the MCU with:

void(* Reset)(void) = 0;
Reset();

I noticed that after reset the bootloader skips the timeout and runs the app immediately.
I also tried to use wdt to reset the MCU:

void Reset()
{
  wdt_enable(WDTO_15MS);
  while (1);
}

But the behavior is the same.

Is there a way to configure Optiboot to stay inside the bootloader also in this case?

I guess I can jump directly to the address of the bootloader, but I would avoid this since it strictly depends on the actual MCU I'm using.

All I know about it is that Optiboot determines the cause of the reset and acts accordingly. Software resets don't count as a reason to invoke the actual bootloading part.

Not forever. Older optiboots always had a delay. Maybe try one of those.
But westfw might have better ideas.

1 Like

If you have a spare pin you could connect it to the Reset pin and set it to OUTPUT+LOW to force a hardware reset. When the reset happens the pin will revert to INPUT and the existing 10k pull-up will cancel the reset.

The "Jump to start of bootload" will work, but:

  1. You need to jump to the start of the bootloader, not 0x0.
  2. You need to make sure that interrupts and timers are turned off before doing this.
  3. You need to make sure that MCUSR is zeroed before the jump.

there's an example here: https://github.com/Optiboot/optiboot/blob/master/optiboot/examples/demo_reset/demo_reset.ino#L129
(probably needs some adjustments for a 32u4 with BIGBOOT)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.