How do I upload a sketch over the USART without access reset pin?

Hi,

I need to put a microcontroller at the end of a long optical fibre run. I'd like to make it Arduino-compatible (because it's awesome). I'm thinking about an ATxmega (need 12-bit ADC. I know that's not the standard arduino, but the Xmega project (GitHub - Xmegaduino/Xmegaduino: Xmegaduino fork of Arduino) seems to be good).

I can only run a single fibre pair to the TX/RX pair of the USART and wont have a separate fibre run for the reset pin.

My question is: Can I upload sketches over the USART without the asserting the reset pin? I was thinking a process would look like:

Write a program on the PC that programs the arduino:

  • Open serial port

  • Write "RESET"

  • Close serial port

  • Run 'avrdude' with correct settings.

  • Is that the right sort of approach?

  • Can anyone recommend any better solutions or links (I've done lots of Googling but had no luck so far).

  • Is there some documentation on what the avrdude protocol does? (e.g. does it need to assert RST multiple times? When?)

In theory yes - but if you ever fail to upload a "reset aware" sketch by bug or accident
you'll be stuck again. A little bit of hardware at the receiving end might be more
reliable, perhaps pulling the signal line low for long enough could signal this (I
think that's known in serial comms as a 'break'). A low pass filter and threshold
circuit might then be enough (normal characters have stop bits so can't be low
100% of the time).

I bet someone has done something similar already, perhaps they'll pipe-up here.

I haven't done it but have thought about it many times.

A little bit of hardware at the receiving end might be more reliable,

A chip like the MAX6816 (a pushbutton debouncer) has a debounce period of 40mS (nominal), if that was connected to your Rx signal on one side and RST on the other it would reset the CPU if you send a break of that duration. So as long as the normal comms bit rate is faster (and it will be) that should work pretty well.


Rob

A chip like the MAX6816 (a pushbutton debouncer) has a debounce period of 40ms (nominal), if that was connected to your Rx signal on one side and RST on the other it would reset the CPU if you send a break of that duration. So as long as the normal comms bit rate is faster (and it will be) that should work pretty well.

That's a great idea Rob! I'll see if I can use that.

Cheers all,

K

And of course you need the hardware on the sending side, to convert the assertion of RTS into a "break" function with a monostable.

I've not tried it, so please report how it goes if you do.

EDIT: We're suggesting this is done on the data line so a break has to be transmitted on that. If it's sourced by a PC that might be a problem, but sending 0x00 at a slower baud rate should work. But there will be some dicking around required I suspect.


Rob