Actions

Installing AVR Toolchain

From HacDC Wiki

Introduction

There are a few pieces of software you'll definitely want for AVR programming:

  • A compiler and/or assembler (avr-gcc) to convert human-readable code to binary
  • Manipulation of binaries (binutils-avr). You'll need to convert from the ELF file to something your chip will like.
  • Something to talk to your AVR programmer (AVRDUDE), that is the piece of hardware you plug into both your computer and the chip you want to program.
  • Not required, but something to make your life easier: (GNU make)

Note that both avr-gcc and binutils-avr come from the avr-libc project. avr-libc itself isn't software per-se; it's a library that implements standard C functions for AVRs.

Installation

Windows

WinAVR has everything you need.

OS X

CrossPack Will take care of you. It doesn't require you to have Xcode installed, but if you do, you can do your development in Xcode and run your makefile from that IDE. If you have an open terminal.app session open when you install it, you'll need to reload your .profile to use crosspack.

When you install crosspack, you'll be presented with documentation in your web browser. These docs are also located at /Applications/Crosspack-AVR-Manual.html. This is important, as the Crosspack docs are not on the www.obdev.at site :\

Making Crosspack projects work with Elliot's boards

Follow the crosspack 'getting started' section to create your first hello world project.

First, make a demo project.

 bash$ cd ~/Documents
bash$ mkdir AVR
bash$ cd AVR
bash$ avr-project Demo
bash$ open Demo 
bash$ cd Demo
bash$ ls -l
drwxr-xr-x   5 cs  cs  170 Nov 19 13:58 Demo.xcodeproj
drwxr-xr-x   4 cs  cs  136 Nov 19 13:58 firmware
bash$ cd firmware
bash$ ls -l
-rw-r--r--   1 cs  cs  4139 Nov 19 13:58 Makefile
-rw-r--r--   1 cs  cs   348 Nov 19 13:58 main.c

You can see, your code lives in the projects' firmware folder. You can replace the code (*.c) as you please with whatever blinkenlights project you see fit. You'll want to open up the Makefile and edit two lines - the DEVICE and PROGARMMER line. The device we are using is the "atmega88". The programmer needs to be set to avr109, the baud rate to 9600, and the port to whatever your /tty.usbserial device (read: FTDI cable) is called. Mine shows up as /dev/tty.usbserial-FTEA4CYY, yours may very well show up with a different name.

DEVICE     = atmega88
CLOCK      = 8000000
PROGRAMMER = -c avr109 -P /dev/tty.usbserial-FTEA4CYY -b 9600
OBJECTS    = main.o
FUSES      = -U hfuse:w:0xd9:m -U lfuse:w:0x24:m\

One you've edited your make file, you can run the following commands

make
make flash

Make will compile the c code into object code and then to the correct HEX code for the device. Make flash will try to program the code. Make sure you've held down reset and button A in order to let the device reset into programming mode! Grab Elliots blinking led code and try it out!

-Will

Linux

Ubuntu

Install the following packages:

  • avrdude
  • avrdude-doc
  • binutils-avr
  • avr-libc
  • gcc-avr

You can get them in one shot using:

sudo aptitude install avrdude avrdude-doc binutils-avr avr-libc gcc-avr

Atmel Dragon with avrdude on Ubuntu (This may be outdated? Feel free to ignore.)

Apparently there are two bugs that get in the way when trying to use avrdude with the dragon.

  • avrdude 5.8 (via apt-get) segfaults after writing 1 byte: http://savannah.nongnu.org/bugs/?27507 - there is a patch for 5.8 posted there
  • avrdude 5.9 (via the official site) source apparently has some other bug that prevents the build from completing

First, get the dependencies for building the code.

sudo apt-get build-dep avrdude

The solution (aside from applying patches to the above versions) is to use the patched 5.10 SVN code. The instructions are from this link: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=87972&start=20

That seems to have worked for me! I'm on 9.04 32bit and I also installed bison/flex/autoconf --obscurite