[solved] Uploading hex file to a Duemilanove using Arduino's patched avrdude

I'm running Arduino 0.22 on Linux. I'd like to be able to upload hex files directly to my Arduino, so I can program it in C. I figured the easiest way to do this would be to use Arduino's patched version of avrdude.

So, for example, if I am uploading the blink sketch, I can see that the Arduino IDE is emitting a command like this:

/home/maxtothemax/arduino-0022/hardware/tools/avrdude -C/home/maxtothemax/arduino-0022/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P/dev/ttyUSB1 -b57600 -D -Uflash:w:/tmp/build866101964235295074.tmp/Blink.cpp.hex:i

And it works fine. But if I copy that exact same command into another terminal and run it:

/home/maxtothemax/arduino-0022/hardware/tools/avrdude -C/home/maxtothemax/arduino-0022/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P/dev/ttyUSB1 -b57600 -D -Uflash:w:/tmp/build866101964235295074.tmp/Blink.cpp.hex:i 

avrdude: Version 5.4-arduino, compiled on Oct 22 2007 at 13:15:12
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "/home/maxtothemax/arduino-0022/hardware/tools/avrdude.conf"
         User configuration file is "/home/maxtothemax/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port            : /dev/ttyUSB1
         Using Programmer      : stk500v1
         Overriding Baud Rate  : 57600
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: Send: Q [51]   [20] 
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

I've checked and /tmp/build866101964235295074.tmp/Blink.cpp.hex is still there... What am I missing?

Thanks,
-Max E.

if your using linux i can suggest to install eclipse + avr development plugin that will allow you to program your arduino in C and upload the code the same way you did with your arduino board you won’t be able to write arduino specific code on eclipse but since you want to use C youll be fine
ive attacked a screen - the only thing i dont like about it is that you can’t change the color scheme

also my arduino didn’t came with avrdude - i installed it from repositories (youll have to do that too in order to use eclipse )

hope this helps

Actually, if you look in your arduino-022 folder, under hardware/tools, you'll find a copy of avrdude. I was wondering why it works when the Arduino IDE calls it but not when I do.

I'll look into Eclipse and report if that works, so thanks for that, but my original question remains unanswered. :slight_smile:

I've modified the final line of the Arduino IDE's shell script launcher like this:

strace -fq -s 64 -e trace=execve java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base 2>&1 | grep -v ENOENT

This gives me a listing of all the subprocesses launched by the Arduino IDE, which I've put on Pastebin due to size restrictions:

I was looking for some command I might need to run before calling avrdude, but nothing jumps out at me.

I've found I can make it work by holding the reset button, then letting go right before running the command.

ah right i was looking in the first tool folder ive found
the thing with the reset the software changes the state of the DTR line which is used as an autoreset
now in the avrdude im using they introduce arduino as a programmer so if ill do something like

avrdude -v -v -v -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/build8110520817435269435.tmp/Blink.cpp.hex:i

instead of

/home/putyn/arduino/hardware/tools/avrdude -C/home/putyn/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/build8110520817435269435.tmp/Blink.cpp.hex:i

i could upload without pressing the reset button
also i did try to edit the avrdude.conf located in the same folder as avrdude but for some reason it gave me an error