How to upload Arduino sketches manually (using avrdude)?

Hi everyone,

I made a posting in the troubleshooting forum about some strange things happening when trying to upload sketches to a breadboard Arduino. The thread didn't get any replies and after a search, it seems nobody actually has any idea how to fix the error, so I've decided to go about troubleshooting myself.

You can check out everything I've done so far in my old thread if you're so inclined:
http://arduino.cc/forum/index.php/topic,102600.0.html

For now, I am looking for alternatives to using the Arduino IDE to load sketches to the chip. Maybe using avrdude or something similar? The only catch is, I'd like to be able to do this without having to rewrite my code in C. Ideally I need a way to upload the sketch as it is written in the Arduino language.

Google search did not really turn up much, which is why I'm posing the question here. Help would be appreciated.

THanks!
boredat20

Find out the name of the .hex file by doing a verbose compile. Upload that.

eg.

avrdude -c usbtiny -p m328p -U flash:w:firmware.hex

However I just edit the preferences.txt file (in version 0022) and change:

upload.using=bootloader

to:

upload.using=usbtinyisp

Do this with the IDE closed. Open it and you are good to go, just upload the usual way. I do that quite frequently to get stuff onto a "bare bones" board.

Adjust the name of the loader to suit whatever you have.

EDIT: Did a little bit more research, it seems that neither of these methods will work since I'm using an FTDI board to upload sketches and not an external programmer. Sorry about that, I really should have mentioned that in my original post. So I take it I can't use avrdude at all with the FTDI board?

Hi Nick,

Wow! Thanks so much for your quick response. It seems like you've provided me with some great information. I have some questions though.

To be clear, I'm using a homemade FTDI board to do all my uploading. In this case I obviously wouldn't use "usbtiny" as my loader (or would I?). What would I put in place of "usbtiny" in the avrdude command to upload?

Is your second suggestion (changing the preferences file) independent of the first one, i.e. should I try using just avrdude and if that doesn't work, go on to changing "preferences.txt" as you suggested and using the Arduino IDE? In this case, what would I change upload.using to if I'm using an FTDI board?

Thanks again Nick!

Faaiz

OK, well I use the FTDI method as well. Whatever works, I say. :slight_smile:

In that case, since the FTDI device appears as a COM port (like the Arduino itself) you just upload totally the usual way using the bootloader. That's assuming you put the bootloader on the chip at some stage (or it was already there).

If that isn't working you may just want to check your "reset pulse".

Here's an example of when I did exactly that:

Full story:

If you follow the wiring for the FTDI header (including pull-up resistor and capacitor) then it should work.

Hey Nick,

Thanks again for replying so quickly. I'd like to make a request if you don't mind. Since you're currently helping me out here, and you obviously know a great deal more about this stuff than I do, could you perhaps check out the most recent update (in bold, part of post #1) in the previous thread I linked to?

My FTDI is set up EXACTLY like yours, and the reset pulse appears to be working. In fact, you'll see that while it fails to program a breadboard arduino (atmega328 on a breadboard), the FTDI board functions fine when the same atmega chip is dropped into an Arduino UNO as I showed in the diagram there!!!

So that is why I was looking for alternative methods to program the chip, which already has the Uno bootloader.

I guess I might just have to go out and build a programmer and abandon the FTDI chip altogether! It's a pity because the FTDI board I built is the first thing I've madeout of entirely SMD components and I really wanted it to work!

Thanks again,
boredat20

EDIT: I should mention, the only difference between my FTDI setup and yours is that I included the 0.1uf capacitor for the RTS pin on my FTDI board, but I don't think that makes a significant difference, as even manual reset is ineffective.

To save me (and others) jumping around here, can you post your exact wiring? I saw on the other thread four wires to your FTDI chip, when I expect five.

ive use the arduino as an isp a few times and it works well , the only thing i had issues with was the port speed in avrdude -P changes it i think i used 19200 or 38400 ,oh and you can change your programer setting to arduino as isp and just upload via the arduino ide for a atmega48 i used this in my boards.txt

##############################################################

atmega48.name=Rotceh-hack QM7298 w/ ATmega48V xD

attiny48.upload.using=arduino
atmega48.upload.maximum_size=4094
atmega48.upload.speed=19200

atmega48.bootloader.low_fuses=0xE2
atmega48.bootloader.high_fuses=0xDF
atmega48.bootloader.extended_fuses=0xFF
atmega48.bootloader.path=atmega
atmega48.bootloader.file=atmega48.hex
atmega48.bootloader.unlock_bits=0x3F
atmega48.bootloader.lock_bits=0x0F

atmega48.build.mcu=atmega48
atmega48.build.f_cpu=8000000L
atmega48.build.core=arduino
atmega48.build.variant=standard

then pick my board in the menu and compile / upload or find the temp .hex file via verbose compile like nick said

To save me (and others) jumping around here, can you post your exact wiring? I saw on the other thread four wires to your FTDI chip, when I expect five.

Nick, sorry about that. I have tried so many things, it's getting hard to keep track. I'm making a concerted effort to provide all information precisely to avoid inconveniencing the people that try to help me, but I guess I'm not doing a great job ;).

The reason you only see 4 wires is because originally I decided that the autoreset feature was what was getting me into trouble, so I tried uploading using manual reset just as the "XXXXX bytes...." message comes up on the arduino IDE. So far, that's the only configuration tha has worked, and that is what I've shown in my diagram. I'll attach that in this thread.

rotceh_dnih,

I had also considered using the Arduino as an ISP, but since I'm using an Uno, I was not sure that would work. Can you confirm that this works with an Uno?

Thanks a lot!

hmm yea i havent tried with a uno yet i'll grab one out and see :slight_smile:

edit my "uno board " is a freetronics usbdroid

so not sure it would , ill have a go when i find it .

Vin to the FTDI chip? Why not 5V?

Nick,

Either or works, I'm actually powering the Arduino through the FTDI in this case which is why I used Vin. The Arduino board in this case is literally just acting as a chip holder.

rotceh_dnih,

Thanks for the suggestion. I'll look into it, but tbh using the Arduino as an ISP was something I was trying to avoid, hence the FTDI chip! :slight_smile:

OFF TOPIC:

Nick, I can't believe I JUST found your website. Wow! That is a LOT of useful information! Guess I know what I'm doing for the next two weeks! Thanks for doing what you can to help out us amateurs, much appreciated.

boredat20