8
\$\begingroup\$

If I have a sketch compiled to hex, is it be possible to upload this sketch to an Arduino board using avrdude directly from command line?

Pekkaa figured out that arduino ide executes the following command when uploading the sketch:

./hardware/tools/avrdude -Chardware/tools/avrdude.conf -pm328p -cstk500v1 -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/home/pekka/sketchbook/Blink2/applet/Blink2.hex 
Trygve Laugstøl
1,4102 gold badges19 silver badges28 bronze badges
asked Oct 31, 2009 at 11:02
\$\endgroup\$

1 Answer 1

5
\$\begingroup\$

The arduino IDE resets the attached arduino before running avrdude. It does this by telling the FTDI device to pulse the DTR line which is attached to the arduino's reset pin. Pekkaa found the example perl code which does this and updated the thread on the Arduino forums.

For completeness here is the command they used to upload the .hex file:

perl -MDevice::SerialPort -e 'Device::SerialPort->new("/dev/ttyUSB0")->pulse_dtr_on(1000)'; \
./hardware/tools/avrdude -Chardware/tools/avrdude.conf -q -q -pm328p -cstk500v1 -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/home/pekka/sketchbook/Blink2/applet/Blink2.hex;

There is also a python script for reseting arduinos which can be used in place of the perl one if you have trouble getting it to work on your system.

boardbite
4,99212 gold badges51 silver badges75 bronze badges
answered Oct 31, 2009 at 11:53
\$\endgroup\$
3
  • \$\begingroup\$ Correct URL for the python code from University of Kent: projects.cs.kent.ac.uk/projects/kroc/trac/browser/kroc/trunk/… \$\endgroup\$ Commented Sep 10, 2012 at 18:58
  • \$\begingroup\$ Intergated your suggestion into the @Adam's answer; it will be updated soon. Thanks! \$\endgroup\$ Commented Sep 10, 2012 at 19:04
  • \$\begingroup\$ IIRC you can do accomplish the reset using stty without needing python or perl. \$\endgroup\$ Commented Oct 8, 2012 at 15:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.