0

A question about programing
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

A question about programing

by lospheris on Thu Apr 02, 2009 10:59 am

I have found a file that i want to upload to my arduino that wasn't specifically designed for an arduino, it was however designed for the atmega168 but since he used avr-gcc he seems to have a hex file instead of a .pde. Well i did me a little research and im pretty sure that my arduino can be programmed with this file just by using avrdude which i am pretty sure the arduino IDE uses (since when things go wrong sometimes you get errors from avrdude) but my big question is what do i use for my -c option. i read Ladyada's tutorial (here) on avrdude but i didn't see anything about programming it with the arduino; I did see the info on the STK500 is the arduino similar enough to use that as the programmer??? I have looked around to find what i can about this but there doesn't seem to be much and i have scoured the avrdude .conf files in arduino-012 to try to see if they have any programmers that the version i downloaded doesn't but i don't see anything different. I'm kind of stuck at this point so i was hoping someone here might have a good direction for me to go in, my biggest fear is that if i do something wrong i will mess up my chip and have to get a new one so i am really trying to check and double check my work here.
Any help anyone could give would be greatly appriciated.



the project i am trying to do can be found at http://www.uchobby.com/index.php/2008/0 ... -analyzer/

lospheris
 
Posts: 17
Joined: Wed Nov 26, 2008 6:18 pm

Re: A question about programing

by jarv on Thu Apr 02, 2009 4:50 pm

the pde file is a collection of stuff which when compiled results in a hex file that is sent to your arduino board via avrdude.
If you want to see the details of what is going on try setting
build.verbose=true
in your .arduino/preferences.txt file

This will give you an avrdude command you can just copy and paste for your hex file.
Should be something like :

avrdude -C<config file> -pm168 -c<programmer> -P/dev/ttyUSB0 -b19200 -D -Uflash:w:<hexfile>

A couple things to keep in mind when dealing with a hex file that you didn't build yourself:

a) If you are trying to download a hex file that you didn't build yourself keep in mind that you may be dealing with something that was originally built with a lower clock setting (if it was an atmega using the internal oscillator instead of an external crystal)

b) you will need to either reset the board right before you flash it (this can be done by holding down the reset button, issuing the command and releasing) OR setting DTR over the serial line right before you flash it.
projects (avr/electronics/programming) - http://jarv.org
jarv
 
Posts: 49
Joined: Tue Jan 02, 2007 5:48 pm

Re: A question about programing

by lospheris on Fri Apr 03, 2009 10:52 am

hey thanks for the help man, watching the verbose output didn't help as much as i hoped it would but what did really help though was peering into the makefiles of a couple of my sketches to find that stk500 was what i needed then going over ladyada's stuff again to see i had to use a -F to force it to ignore the bad device signature.


all together i modified the string you posted and after reading it twice and some trial and error with the reset button it was a complete success.
C:\avrdude>avrdude -F -pm168 -c stk500 -P com8 -b19200 -D -Uflash:w:logicanalyzer.hex

a picture of what the output of the device looks like after some simulated data and clock (a tact switch,some pull down resistors, and one line tied to 5v)

http://squishyshouse.com/Media/Pics/la.jpg

thanks again for the help jarv!

lospheris
 
Posts: 17
Joined: Wed Nov 26, 2008 6:18 pm

Please be positive and constructive with your questions and comments.