Difference between revisions of "AVR Development"

From Bobs Projects
Jump to: navigation, search
(External links)
 
(2 intermediate revisions by one user not shown)
Line 12: Line 12:
 
* [http://www.nongnu.org/avr-libc/ avr-libc] - libc for AVR
 
* [http://www.nongnu.org/avr-libc/ avr-libc] - libc for AVR
 
* gdb-avr - The GNU Debugger for avr
 
* gdb-avr - The GNU Debugger for avr
* simulavr - Atmel AVR simulator
+
* simulavr - [[Atmel AVR]] simulator
* [[AVRDUDE]] - software for programming Atmel AVR microcontrollers
+
* [[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.
 
All the other usual tools such as make, editors, version control etc. can be used as per any other development project.
Line 52: Line 52:
  
 
== Downloading to target ==
 
== 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.
+
The standard downloader for [[Linux]] is [[AVRDUDE]]. It supports a variety of downloading techniques:
 +
* the [[Arduino]]-compatible serial loader already programmed into FLASH memory and some form of serial interface, such as the [[FT232R]] based USB-serial cables
 +
* a [[Bus Pirate]] connected to the [[Atmel AVR]] 6-pin [[ICSP]] 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]].
+
In the case of the [[AVR Stick]], we use an 8-pin Small Outline Integrated Circuit (SOIC) testclip connected to an ICSP programmer (such as [[Bus Pirate]]).
 +
 
 +
== See also ==
 +
* [[ICSP]]
  
 
== External links ==
 
== External links ==
 
* [https://ccrma.stanford.edu/workshops/pid2004/lectures/programming/programming/ How to Program the AVR with avr-gcc and AVRLib]
 
* [https://ccrma.stanford.edu/workshops/pid2004/lectures/programming/programming/ How to Program the AVR with avr-gcc and AVRLib]
 
* [http://www.ladyada.net/learn/avr/index.html AVR Tutorial] at [http://www.ladyada.net/ LadaAda]
 
* [http://www.ladyada.net/learn/avr/index.html AVR Tutorial] at [http://www.ladyada.net/ LadaAda]
 +
* [http://www.atmel.com/webdoc/AVRLibcReferenceManual/index.html AVR Libc Reference Manual] at atmel.com
 
* [http://www.makehackvoid.com/project/MHVLib MHVLib] - An Efficiency Oriented Runtime Library for AVR Microcontrollers
 
* [http://www.makehackvoid.com/project/MHVLib MHVLib] - An Efficiency Oriented Runtime Library for AVR Microcontrollers

Latest revision as of 21:03, 28 November 2016

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)
  • avr-libc - libc 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

The standard downloader for Linux is AVRDUDE. It supports a variety of downloading techniques:

  • the Arduino-compatible serial loader already programmed into FLASH memory and some form of serial interface, such as the FT232R based USB-serial cables
  • a Bus Pirate connected to the Atmel AVR 6-pin ICSP programming header

In the case of the AVR Stick, we use an 8-pin Small Outline Integrated Circuit (SOIC) testclip connected to an ICSP programmer (such as Bus Pirate).

See also

External links