Go Down

Topic: bootloader callable from sketch? (Read 3 times) previous topic - next topic

Claghorn

I don't suppose the standard bootloader can be directly entered from code in a sketch without resetting can it? Some magic address I could jump to perhaps? I'd like to (eventually) be able to update the sketch via bluetooth simply by sending a special command to the sketch, then invoking avrdude to do the actual upload. The timing is such on my Uno R3 with a bluetooth shield that by the time the bluetooth is talking again after a reset, the bootloader has already jumped back to my sketch, so there is never a timing window where it is possible to do an upload.

magagna

Sort of.

You can do this

Code: [Select]
void software_Reset() // Restarts program from beginning but does not reset the peripherals and registers
{
asm volatile ("  jmp 0"); 
}


but you'll have to manually take care of resetting your hardware.

Google "arduino software reset" for more details than you probably want to know.....

Good luck!
http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

westfw

Except the bootloader is NOT at location 0.  It's off at 0x7e00 (chip dependent), and it has built-in assumptions that will not be true if it is called from a sketch (all interrupts off, all IO devices in their reset configuration, etc...)

The preferred way to cause a reset from software is to turn on the watchdog timer and let THAT reset the chip, except that this will normally skip the bootloader when optiboot is used, because it is part of the sequence used to start the sketch...

magagna

My mistake -- I misread the post. Apologies.

Chris
http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

westfw

It would probably be easier to create a custom bootloader with a longer timeout.  Up to 8s is an easy change.

Go Up