AVR Development
The Atmel AVR micros are well supported in the FOSS world with complete development tool chains such as a C compiler, simulator, debugger, downloader etc.
We prefer to develop in C and use standard Unix command-line tools.
An alternative is to use the Arduino Integrated Development Environment (IDE), which runs on a Java Virtual Machine (JVM) and the coding style is C++ based.
Contents |
Support in Debian GNU/Linux and variants
The Atmel AVR "toolchains" have been available for Debian/Ubuntu Linux for some years. Specifically:
- binutils-avr - Binary utilities supporting Atmel's AVR targets
- gcc-avr - The GNU C compiler (cross compiler for avr)
- gdb-avr - The GNU Debugger for avr
- simulavr - Atmel AVR simulator
- avrdude - software for programming Atmel AVR microcontrollers
All the other usual tools such as make, editors, version control etc. can be used as per any other development project.
Makefile template
A template Makefile:
PROJNAME = ... DEVICE = atmega328p CC = avr-gcc INCS = -Iusbdrv -I. CFLAGS = -Wall -Os $(INCS) -mmcu=$(DEVICE) -DDEBUG_LEVEL=0 AVRDUDE = avrdude -p $(DEVICE) -c arduino -P /dev/ftdi_cable1 -b 57600 -v USBDRV_OBJS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o # symbolic targets: all: $(PROJNAME).hex .c.o: $(CC) -c $(CFLAGS) $< -o $@ .S.o: $(CC) -x assembler-with-cpp -c $(CFLAGS) $< -o $@ .c.s: $(CC) -S $(CFLAGS) $< -o $@ %.bin: %.o $(USBDRV_OBJS) $(CC) $(CFLAGS) -o $@ $< $(USBDRV_OBJS) %.hex: %.bin rm -f $@ avr-objcopy -j .text -j .data -O ihex $< $@ flash: all $(AVRDUDE) -U flash:w:$(PROJNAME).hex
Downloading to target
We use AVRDude with either the Arduino-compatible serial loader already in FLASH and some form of serial interface, such as the FT232R based USB-serial cables, or a Bus Pirate connected to the Atmel AVR 6-pin programming header.
In the case of the AVR Stick, we use an 8-pin Small Outline Integrated Circuit (SOIC) testclip connected to the Bus Pirate.
External links
- Atmel AVR on Wikipedia