Difference between revisions of "AVR Development"

From Bobs Projects
Jump to: navigation, search
(Created page with "Category:Computing Atmel AVR is a range of 8-bit RISC microcontrollers with several sub-families such as tinyAVR (also known as ATtiny) and megaAVR (also known as ATmega)...")
 
(External links)
 
(10 intermediate revisions by one user not shown)
Line 1: Line 1:
 
[[Category:Computing]]
 
[[Category:Computing]]
[[Atmel AVR]] is a range of 8-bit RISC microcontrollers with several sub-families such as tinyAVR (also known as ATtiny) and megaAVR (also known as ATmega), amongst others. 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.
+
The [[Atmel AVR]] micros are well supported in the [[FOSS Advocacy| 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.
  
 
== Support in Debian GNU/Linux and variants ==
 
== Support in Debian GNU/Linux and variants ==
Line 6: Line 10:
 
* binutils-avr - Binary utilities supporting Atmel's AVR targets
 
* binutils-avr - Binary utilities supporting Atmel's AVR targets
 
* gcc-avr - The GNU C compiler (cross compiler for avr)
 
* gcc-avr - The GNU C compiler (cross compiler 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.
 +
 +
== Makefile template ==
 +
A template Makefile:
 +
<pre>
 +
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
 +
</pre>
 +
 +
== 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 ==
 +
* [[ICSP]]
  
 
== External links ==
 
== External links ==
* [[wikipedia:Atmel_AVR|Atmel AVR]] on Wikipedia
+
* [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.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

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