Enter bootloader from main program

Hi Folks,

I was wondering, does a bootloader exist (or could an existing one be modified) which will allow me to enter the bootloader from within the main program?

The reason is this: I am creating a device which does not have a reset pin or button available (please don't just tell me to add one, I will if I can't find another way but I would rather not as I want it to be as simple for the end user as possible). The device has a serial connection which is used to connect it to either a PC for downloading data or a secondary device for streaming telemetry. What I want to be able to do is to use the PC terminal to send a command to the device which enters the bootloader so I can flash new firmware.

Just wondering about this; do you not think it is simple as possible for the end user to have the device just reset upon serial connection and automatically accept new firmware?

Isnt that what you always do when you upload a new sketch to arduino? IDE establishes a new connection, resets your microcontroller automatically and uploads new firmware. I dont know why are you so complicated about this wnen it is what you always do.

A jump or call to the first address in the bootloader section should do it.

[quote author=Coding Badly link=msg=2333409 date=1438055960] A jump or call to the first address in the bootloader section should do it.


The catch is that the bootloader doesn't wait very long before deciding nothing's being uploaded - you'd need to immediately follow that command with the programming. You might need to modify the bootloader so it waits longer.

Or, listen for the hello from avrdude then make the jump. I have a monitor that works that way. It works very well.

Just hope the code has not locked up so serial never receives the reset command.

I can't use the auto-reset as I only have power, RX and TX lines into the device.

CodingBadly, could you elaborate on the technique you mentioned involving a jump to the first address for the bootloader?


Let's see ... here we go ... a zero ('0') is sent first by avrdude to get things started... https://github.com/Coding-Badly/TinyISP/blob/master/TinyISP_Monitor.cpp#L244

That's your queue to make the leap.

Unfortunately, I cannot get the bootlooader to run. The attempt...

typedef void (* vvf_t)();

static const vvf_t bootloader = (vvf_t) (0x3F00 * 2);

void setup() 
  TCCR0A = 0;
  TCCR0B = 0;

void loop()