Go Down

Topic: Autoreset Circuit on Uno (Read 2 times) previous topic - next topic

Riva



Hi There,

I'm mildly confused as to how the autoreset circuit works on the arduino uno.  I assume DTR goes low when the serial transmission from the PC begins.  That discharges the 100 nF cap which pulls the reset line low.  With a time constant determined by the 10k pullup to 5V and the 100 nF cap the cap will recharge and the reset line will be high.  I assume that the bootloader takes over right after the reset line goes high at which point it slurps up whatever it gets over the serial line as program code and then resets the processors instruction pointer.  Is that correct?  Is there any indication when programming is complete?  How long is DTR pulled low for (I don't have a scope :().  Thanks!

D


Yes that is basically how it works. The IDE (via AVRDUDE) just pulses the DTR signal on then off to cause the AVR to reset (it also pulses the RTS signal which older boards used instead of DTR) which starts the bootloader code that then communicates to the IDE via AVRDUDE to actually then start the upload data transactions, which when completed the bootloader jumps to the sketches start in flash memory. If the bootloader gets no proper response from AVRDUDE after a specific time out period and if there is already an existing sketch loaded some prior time then the bootload jumps to the program.


Can you program other pre-upload conditions into AVRDUDE? I'm wondering if it could send a specific text sequence that a bluetooth serial connected arduino could interpret to self reset prior to being programmed over BT connection?

bperrybap


Can you program other pre-upload conditions into AVRDUDE? I'm wondering if it could send a specific text sequence that a bluetooth serial connected arduino could interpret to self reset prior to being programmed over BT connection?


Yes, but avrdude is a pretty complex program.
A much easier way is to write a wrapper that gets run instead of avrdude.
The wrapper can do it's magic thing then run avrdude.

--- bill

Riva



Can you program other pre-upload conditions into AVRDUDE? I'm wondering if it could send a specific text sequence that a bluetooth serial connected arduino could interpret to self reset prior to being programmed over BT connection?


Yes, but avrdude is a pretty complex program.
A much easier way is to write a wrapper that gets run instead of avrdude.
The wrapper can do it's magic thing then run avrdude.

The downside of this is I either have to hack Arduino IDE to use wrapper instead of AVRDUDE or rename AVRDUDE and call my wrapper by the same name. Both then have the problem of reverting to normal AVRDUDE for standard USB connected devices.
Could one just add a new programmer definition to AVRDUDE that's basically a duplicate of maybe the stk500v1 protocol but with the prefix string needed to reboot BT attached arduino and then add another programmer definition to the Arduino programmers.txt file.

bperrybap


The downside of this is I either have to hack Arduino IDE to use wrapper instead of AVRDUDE or rename AVRDUDE and call my wrapper by the same name. Both then have the problem of reverting to normal AVRDUDE for standard USB connected devices.
Could one just add a new programmer definition to AVRDUDE that's basically a duplicate of maybe the stk500v1 protocol but with the prefix string needed to reboot BT attached arduino and then add another programmer definition to the Arduino programmers.txt file.


I have done this very thing to get the chipkit uno32 auto-reset working on the Arduino 1.5 IDE
when I moved the pic32 core over to the latest Arduino IDE.

In Arduino 1.5 you can specify the name of the uploader
program so you really don't have to rename it.

I simply renamed the original avrdude command, then I created a simple bash shell script.
It runs a few extra commands then passes the same arguments it received
on to the original/real avrdude command.
Easy Peasy...

The wrapper can be as smart as is needed.
It can look at any of the avrdude arguments and make decisions
on what to do based on those arguments before it passes
them on to avrdude.
Depending on the arguments,  it could choose to do nothing before running avrdude.

The reason I went with a wrapper is that it is minimizes the changes necessary
to the IDE tree. No changes to boards.txt, no changes to platform.txt
just rename the original avrdude and insert a shell script.




As far as adding a new programmer/protocol to avrdude. Yes it can be done
but have you looked at the avrdude code? It isn't as simple as you might think.
Plus you have to have the tools to rebuild it.
While not hard in a unix/linux environment its not so easy for Windows environments.
And then you may have to create special boards.txt entries to use the new protocol/programmer
I see this route as more work vs creating a wrapper.

--- bill

Go Up