Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cromulent

macrumors 604
Original poster
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
My Dad has recently given me his old AVR Butterfly and I thought I'd do a little bit of playing around with it. Does anyone know of a decent tool chain that is easy to setup and configure for AVR's on OS X?

I've found a few tutorials for building my own cross compiler and associated tool chain but it is really quite difficult to spare the time at the moment faffing about with compiling cross compilers. Is there an alternative to AVR Studio on the Mac or some such?

Any help appreciated. I'm completely new to the world of embedded programming so I'm hoping it will provide a little fun and something a bit different.

Edit : Hmm just found something that looks promising. Let's hope it actually works.
 

Cromulent

macrumors 604
Original poster
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
Okay AVRMacPack which I linked above seems to compile AVR code properly. I've also found a serial terminal called goSerial to communicate with the device which I can't get to work unfortunately.

I have absolutely no idea how I am supposed to upload the code to the AVR device. I know how to do it on Windows but under Mac OS X it seems somewhat more complex involving avrdude and usbasp or some such.

I might see if I can get stuff going under Windows just to make sure things are working then I can see what is going wrong on the Mac side.

If anyone has any experience with this I would appreciated some help :).
 

autorelease

macrumors regular
Oct 13, 2008
144
0
Achewood, CA
Okay AVRMacPack which I linked above seems to compile AVR code properly. I've also found a serial terminal called goSerial to communicate with the device which I can't get to work unfortunately.

I have absolutely no idea how I am supposed to upload the code to the AVR device. I know how to do it on Windows but under Mac OS X it seems somewhat more complex involving avrdude and usbasp or some such.

I might see if I can get stuff going under Windows just to make sure things are working then I can see what is going wrong on the Mac side.

If anyone has any experience with this I would appreciated some help :).

Use avrdude. The exact command depends on the device and programmer you're using. Here is what I use: (example for an AVRISP mkII programmer, an ATmega168, and object code in a file called main.hex):
Code:
avrdude -c avrispmkII -P usb -p atmega168 -U flash:w:main.hex:i

The AVRMacPack main page (http://www.obdev.at/products/avrmacpack/index.html) has a good example at the bottom. I'd recommend working that into a Makefile.
 

Cromulent

macrumors 604
Original poster
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
Use avrdude. The exact command depends on the device and programmer you're using. Here is what I use: (example for an AVRISP mkII programmer, an ATmega168, and object code in a file called main.hex):
Code:
avrdude -c avrispmkII -P usb -p atmega168 -U flash:w:main.hex:i
The AVRMacPack main page (http://www.obdev.at/products/avrmacpack/index.html) has a good example at the bottom. I'd recommend working that into a Makefile.

Thanks for the information. But I've been doing that for hours, here is what my avrdude command looks like but I just don't know what I am doing wrong.

Code:
avrdude -c butterfly -P /dev/tty.usbserial -p atmega169 -U flash:w:main.hex:i
and here is the relevant area in the Makefile:

Code:
DEVICE     = atmega169
CLOCK      = 8000000
PROGRAMMER = -c butterfly -P /dev/tty.usbserial
OBJECTS    = main.o
FUSES      = -U hfuse:w:0xd9:m -U lfuse:w:0x24:m

I have no idea if it is the fuse bits that are causing the issue but I get the following error:

Code:
Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

which is the best of the bunch really. At least it appears to be doing something when I get that error message rather than just immediately terminating.
 

trule

macrumors 6502
Mar 16, 2007
310
0
Sounds like it can't communicate with the Butterfly.

First check that it is turned on, and if it has a programming mode enable that (I don't recall exactly how the Butterfly works).

Then look at your USB connection, try option -b 57600 or √ to set the baud rate and make sure your tty device is correct.

Try this also http://bluebat.dnsalias.org/howto/butterfly/:
The following steps are necessary to use the bootloader to program the AVR Butterfly via the serial port:

Start the bootloader by using the demo application (Options/Bootloader/Jump to Bootloader), by power-cycling or by resetting the AVR Butterfly (short-circuit pin 5 and 6 of the ISP/J403 connector).
Press the joystick center button (enter) and keep it pressed.
Run the following command (assuming your program is named main.hex and your AVR Butterfly is connected to ttyS0):
avrdude -p m169 -c butterfly -P /dev/ttyS0 -U flash:w:main.hex
As soon as avrdude connected to the bootloader, you may release the joystick.
Reset the AVR Butterfly to run your application. After the reset the bootloader is started again. You may leave it by pressing the joystick upwards.



The little butterfly is a great introduction to embedded programming, I had lots of fun with one about 5 years back...don't remember the specifics anymore.

Great web site is avrfreaks.net
 

Cromulent

macrumors 604
Original poster
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
Sounds like it can't communicate with the Butterfly.

First check that it is turned on, and if it has a programming mode enable that (I don't recall exactly how the Butterfly works).

Then look at your USB connection, try option -b 57600 or √ to set the baud rate and make sure your tty device is correct.

Try this also http://bluebat.dnsalias.org/howto/butterfly/:




The little butterfly is a great introduction to embedded programming, I had lots of fun with one about 5 years back...don't remember the specifics anymore.

Great web site is avrfreaks.net

Thanks this post helped me find the problem.

I think the issue is not being able to start the bootloader on the butterfly. God knows how I am going to fix that. I found a link to download the bootloader program but as you need the bootloader running to flash the AVR it seems like a catch 22 situation. You need the bootloader running to install the bootloader.

Back to the drawing board.
 

trule

macrumors 6502
Mar 16, 2007
310
0
Thanks this post helped me find the problem.

I think the issue is not being able to start the bootloader on the butterfly. God knows how I am going to fix that. I found a link to download the bootloader program but as you need the bootloader running to flash the AVR it seems like a catch 22 situation. You need the bootloader running to install the bootloader.

Back to the drawing board.

You can probably download it using the JTAG interface, if you have a programmer, or perhaps check the AVR documentation to see if there is a way to reset the device. The bootloader is supposed to be protected but if your father has a JTAG programmer then he may have overwritten it...but then you can restore it since you would have a JTAG programmer.

Take a long hard look at the manual, perhaps the answer is there.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.