Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Admin on February 28, 2007, 07:36:36 PM

Title: PonyProg programming AVR STK serial
Post by: Admin on February 28, 2007, 07:36:36 PM
Probably the dumbest question I've ever asked, but Im struggling to figure this out . . .

I am trying to program an ATmega8 using PonyProg2000 (http://www.lancos.com/prog.html) and the AVR STK Serial Port Dongle Programmer (http://www.sparkfun.com/commerce/product_info.php?products_id=14).

Cant seem to find any help files anywhere . . .

So the question is, HOW!? I have AVR Studio and code that compiles with no errors, but not sure what to do after that . . . PonyProg is asking for a .e2p file, but I have no idea what that is . . .

In other news, I was extra dumb today and accidently swapped ground and power to my board . . . Im praying to the robot gods that the voltage regulator prevented me from frying my ATmega8 . . .
Title: Re: PonyProg programming AVR STK serial
Post by: trigger on February 28, 2007, 11:44:42 PM
In other news, I was extra dumb today and accidently swapped ground and power to my board . . . Im praying to the robot gods that the voltage regulator prevented me from frying my ATmega8 . . .

Hmm...did you have a diode between your power supply and the regulator? I would think that would prevent negative voltages from frying your device.
Title: Re: PonyProg programming AVR STK serial
Post by: JesseWelling on March 01, 2007, 12:44:28 AM
Sorry, I've only used avr-gcc and uisp wich only needs the hex files. maybe it's looking for .eep files though? I'm not quite sure what they do but ...... :-\
Title: Re: PonyProg programming AVR STK serial
Post by: dunk on March 01, 2007, 03:44:42 AM
have you tried the "Newbie's Guide To AVR Development" on http://www.avrfreaks.net/index.php?module=FreaksArticles&func=viewArticles (http://www.avrfreaks.net/index.php?module=FreaksArticles&func=viewArticles) ?
it talks you through getting started with AVR Studio.
i've never used AVR Studio though as i'm in the same boat as Jesse having only used avr-gcc and uisp so can't realy be much more help.

dunk.
Title: Re: PonyProg programming AVR STK serial
Post by: JonHylands on March 01, 2007, 06:20:00 AM
Admin,

In my tutorial for connecting a PC to the Bioloid bus, I include a small section on how to do exactly that...

http://www.bioloid.info/tiki/tiki-index.php?page=pc+serial

In a nutshell:

You need to produce a .hex file, and load that into Ponyrog using "Open Device File". Plug it in, turn your AVR board on, and execute "Write All" from the Command menu.

You should always power down the AVR board when you are plugging in/unplugging the programmer.

- Jon
Title: Re: PonyProg programming AVR STK serial
Post by: Admin on March 01, 2007, 03:46:31 PM
Im having issues producing that darn .hex file . . . (the AVRfreaks article wasnt helpful as it doesnt talk about make files :()

Using AVR studio, I keep getting this red dot error:
make: *** No Rule to make target 'F:/Documents', needed by 'a2dtest.elf'. Stop.

Im using the test file a2dtest.c that came with AVRlib so its not any code of mine causing the problem . . . For the makefile I am using MFile (the yellow genie lamp thing) that comes with WinAVR to generate it.

I set the MCU to ATmega644, the Main file to a2dtest, and source C file to a2dtest.c in the makefile.

Thinking that AVR Studio has a bug that causes failure if a filename has a space in it (i.e. F:/Documents and Settings/FileName), I changed the folder to H:/Code/FileName and now just get a new error:

Makefile:531: *** multiple target patterns. Stop.

Im so confused ??? Any thoughts on what Im doing wrong?

attached is my make file
Title: Re: PonyProg programming AVR STK serial
Post by: JonHylands on March 01, 2007, 04:10:01 PM
Admin,

Sorry, you've gone way past my level on that stuff. My brother (who is a big-time embedded C programmer) set up all the make stuff for me, and I just use what he gave me, and it works.

Try this link, it may help:

http://www.instructables.com/id/E5H5UDWB5UEUKIKV8V

- Jon
Title: Re: PonyProg programming AVR STK serial
Post by: JesseWelling on March 01, 2007, 06:33:09 PM
If I could only count how many times Dave has saved me. :P
Title: Re: PonyProg programming AVR STK serial
Post by: Admin on March 02, 2007, 03:01:43 PM
I should report on my progress for solving this problem . . .

First, there is a problem with AVR Studio itself. There are three rules you must follow when linking to a make file:
1. Target name must equal project name.
2. Clean/rebuild support requires  "clean" target.
3. Makefile and target must exist in the same folder[/li][/list]

These were annoying pointless rules that I just didnt notice before . . .  :-\
For example, I always call my first file main.c, not the name of the project, '$50 Robot' . . . apparently they must be the same name. The make file must also exist in the same folder, meaning I cant have a master make file in a separate folder . . . blaaaahhhh. This is especially confusing cause AVR Studio allows you to locate the make file in other folders (why?!) . . .

The next problem I found was the makefile itself not getting along with AVRlib, and Im still trying to figure out why. I think its cause AVR Studio isnt allowing me to link to files in other folders . . .

Anyway, I found my really old AVR code from like 2 years ago and after working around these bugs I got it to compile. Finally! This gives me something to work with and to know Im not completely incompetent in making a darn .hex file :P

Lastly, within the last day or two ago, AVR Studio came out with a new version, AVR Studio v4.13:
http://www.atmel.com/dyn/resources/prod_documents/aStudio4b528.exe

It comes with a few new features, but doesnt fix the bugs Ive been having :-\
Starting to remember why I stopped using AVR the first time I tried them out . . . Oh well too late now!
Title: Re: PonyProg programming AVR STK serial
Post by: JesseWelling on March 03, 2007, 08:38:52 PM
I think the issue is that you are doing AVR through Windows.

Gnu make files require no such nonsense...and linking the AVRlib files in is as simple as makeing a $AVRLIB path name and adjusting your make files. did you do this:
Code: [Select]
#include someAVRLibfile.hin the files where you used AVRLib? Then you need to do something like this in your make file:
Code: [Select]
SRC += avrlib/a2d.c
SRC += servo/servoT3.c
SRC += avrlib/rprintf.c
SRC += avrlib/uart2.c
SRC += avrlib/buffer.c
SRC += sonar/sonar.c
SRC += TWI-Slave/TWI_slave.c

ahem....<soapbox> try linux, you'll like it</soapbox>  :P


Title: Re: PonyProg programming AVR STK serial
Post by: JonHylands on March 04, 2007, 06:02:49 AM
I actually use make files for my AVR stuff, but (a) my brother set them up for me, and (b) I'm using Cygwin.

- Jon
Title: Re: PonyProg programming AVR STK serial
Post by: Admin on March 10, 2007, 02:33:49 PM
hmmmm still having problems with PonyProg . . .

I use the 'Write All' command but it just sits saying 'Writing...' without the progress bar going up. Im using the correct port because it gives me the Device missing or unknown device error if I use any other port or turn the power off.

I can successfully program the AVR using the AVR ISP programmer with no problems. But after when I try to use PonyProg, the robot stops doing anything, so I know its accessing the AVR.

Im using a USB to serial adaptor . . . any clue to how I can fix this problem?

This is the very very last step for my tutorial and Ill be done if I can solve this!

correction: Strangely, after I finished writing this post (like after 15 minutes), the progress bar went to 5% then 10%. Will it take 2 hours?!? Is this normal!? This is aweful painful!
Title: Re: PonyProg programming AVR STK serial
Post by: Admin on March 10, 2007, 03:30:27 PM
Ok it works!

However, it took an entire hour to upload the program!!!!!!!! pain!!!!!!!!!!!

Is there any way to speed up the PonyProg? Any way I can turn off the verification wait (which added like 30 more minutes)?
Title: Re: PonyProg programming AVR STK serial
Post by: JonHylands on March 10, 2007, 05:46:40 PM
Admin,

According to this page:

http://www.lancos.com/e2p/ponyprog2000.html

...

After the Calibration you can choose the speed for every serial bus modifying the following parameters in the ponyprog.ini (.PonyProgrc under Linux) file:

    * I2CBusSpeed=NORMAL    affect 24Cxx eeprom and other I�CBus devices
    * SPIBusSpeed=NORMAL    affect AVR micro, AT89Sxx micro and 25xxx eeprom
    * MicroWireBusSpeed=NORMAL    affect 93Cxx eeprom
    * PICBusSpeed=NORMAL    affect PIC16x84 micro
    * SDEBusSpeed=NORMAL    affect SDE2506 eeprom

Every parameter can be assigned the value SLOW, NORMAL, FAST or TURBO.
Avoid to use the TURBO value because it means "no delay", and probably it doesn't work on your PC, especially with the I/O driver.
Just for example my PC (Pentium MMX 200MHz) run I�CBus at about 80Khz with NORMAL, and 110 Khz with FAST. Note that a lot of I�CBus devices don't work at speed above the 100KHz.

...

Seems to me you should look in your PonyProg.ini file, and see what SPIBusSpeed is set to...

- Jon
Title: Re: PonyProg programming AVR STK serial
Post by: Admin on March 10, 2007, 06:51:02 PM
:'(

So I change the .INI file so that it says:
SPIBusSpeed=FAST

I also change:
VerifyAfterWrite=NO
(because it took 45 minutes to do this last time)

So it programs after like 20 minutes (I think the same as with SPIBusSpeed=NORMAL). Still crazy slow!!! After it programs, my robot doesnt do anything. Just sits there. I try to reprogram it using PonyProg, it sits for like 5 minutes, then tells me its unable to connect to it.

So Im like ok . . . lets reprogram it using my AVR ISP programmer with AVR Studio (this way normally works and only takes like 30 seconds). Well it connects to the AVR, but refuses to program or read calibration bits or anything. I cant seem to program it, read from it, or even erase it anymore  :'(

It just says 'ISP Mode Error' but doesnt give me any useful information.

Did PonyProg (or I?) fry my ATmega8!? Any way to fix this?
Title: Re: PonyProg programming AVR STK serial
Post by: JonHylands on March 10, 2007, 07:03:10 PM
Wow, that's really weird.

If your AVR ISP won't program it, then chances are something got toasted. Either that or you need to reboot your machine...

I'm sorry, I used PonyProg once to program my ATmega128, and after that I ended up getting an AVRISPmk2, which I have used pretty much exclusively since.

At this point, I have no idea what the problem could be...

- Jon
Title: Re: PonyProg programming AVR STK serial
Post by: Admin on February 11, 2009, 11:31:06 PM
I know I'm reviving a really dead topic, but I just wanted to let people know it was because you can't use a USB to serial adapter with PonyProg . . .