Optiboot / optiboot

Small and Fast Bootloader for Arduino and other Atmel AVR chips
Other
1.08k stars 396 forks source link

Add option for updating firmware after every reboot #345

Open vladtcvs opened 2 years ago

vladtcvs commented 2 years ago

When you connect device to rs485 network, or connect it by 4-pin uart, or may be smth else, you can not send reset signal to go into bootloader mode. Check if (ch != 0) just skips to application.

But with option ALWAYS_USE_BOOTLOADER you can jump to 0x3F00 from your application and start to update firmware.

WestfW commented 2 years ago

You should be able to "jump from the application" and have the bootloader run "always", if you've set MCUSR to zero (before the jump.) that's what the current check for ch!=0 does.

Isn't your "always_use_bootloader" flag backward? if set, you are running the code that decides NOT to run the bootloader.

Jumping to the bootloader start address and having it work is subject to a bunch of requirements like disabling interrupts and making sure certain other peripherals are in their "post-reset" status...

hecko commented 1 year ago

I think you can mimic this behavior already by combining

-DWDTTIME=8 -DNO_START_APP_ON_POR=1

So you get 8 seconds of bootloader on every start of the uC. That should be plenty to update the application over the bootloader. Or am I missunderstanding either this PR or the NO_START_APP_ON_POR flag? Do you need more than 8 seconds to start a loading process?