Getting started using linux – Pololu Orangutan USB User Manual

Page 18

Advertising
background image

6. Getting Started Using Linux

Recent versions of the linux kernel include support for the Pololu Orangutan USB Programmer as part of the usb-
serial driver. We have tested the following instructions under Ubuntu Linux 7.04; if you experience any problems,
we recommend you upgrade to the most recent version of your distribution.

To begin working with AVRs under linux, you will need to install four software packages, which can be
downloaded from their respective websites. Under Ubuntu Linux, these packages are provided in the “Universe”
repository.

1. gcc-avr: the GNU C compiler, ported to the AVR architecture

2. avr-libc: a library giving access to special functions of the AVR

3. binutils-avr: tools for converting object code into hex files

4. avrdude: the software to drive the programmer

Once these packages are installed, you will be able to compile C programs for the AVR with gcc to produce hex
files. We will not go into the details of writing C programs for the AVR here, but, as an example, we will show
you how to use your linux computer and Orangutan USB programmer to make the user LED on your Orangutan
or Baby Orangutan blink.

Download the archive that is appropriate for your device’s microcontroller:

• mega48:

BlinkLED.zip

[http://www.pololu.com/file/download/BlinkLED_m48.zip?file_id=0J188]

(9k zip)

• mega168:

BlinkLED.zip

[http://www.pololu.com/file/download/BlinkLED_m168.zip?file_id=0J189]

(9k zip)

• mega328:

BlinkLED.zip

[http://www.pololu.com/file/download/BlinkLED_m328.zip?file_id=0J190]

(9k zip)

and unpack it on your linux computer. Copy the file

BlinkLED/linux/Makefile

into the

BlinkLED/

directory. It

may be necessary for you to edit this file, changing the settings at the beginning to reflect the locations where
the AVR utilities were installed. Additionally, if you are using an original Orangutan mega168 (instead of a
Baby Orangutan, Orangutan SV-xx8, Orangutan LV-168, or 3pi robot), you might want to edit

BlinkLED.c

by

uncommenting line 2 and commenting out line 3 to account for the Orangutan’s lower 8 MHz clock frequency.

At this point, you should be ready to compile the example program and load it onto the Orangutan. Plug in the
programmer and type make.

You should see output like this:

/usr/bin/avr-gcc -g -Os -Wall -mcall-prologues -mmcu=atmega168 -c -o BlinkLED.o BlinkLED.c

/usr/bin/avr-gcc -g -Os -Wall -mcall-prologues -mmcu=atmega168 BlinkLED.o -o BlinkLED.obj

/usr/bin/avr-objcopy -R .eeprom -O ihex BlinkLED.obj BlinkLED.hex

/usr/bin/avrdude -c avrispv2 -p m168 -P /dev/ttyUSB0 -e

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9406

avrdude: erasing chip

avrdude: safemode: Fuses OK

avrdude done. Thank you.

/usr/bin/avrdude -c avrispv2 -p m168 -P /dev/ttyUSB0 -U flash:w:BlinkLED.hex

avrdude: AVR device initialized and ready to accept instructions

Pololu Orangutan USB Programmer User's Guide

© 2001–2011 Pololu Corporation

6. Getting Started Using Linux

Page 18 of 32

Advertising