# AVR Development Tools¶

Read time: 7 minutes (1946 words)

The AVR processors can be programmed using a version of the Gnu C/C++ tools we have been using for projects on the PC. We need a version of those tools that generates code for the AVR chips, not the Pentium!

Note

It is possible to just install the Arduino IDE and get the needed tools. However, the compiler and other needed files live deep inside that code, and finding the right directory to add to your system PATH variable is a bit difficult. We will skip that idea here.

You can add these tools easily, on any system by doing the following steps:

## Windows¶

Install the Win-AVR tools from this link:

Warning

When I ran this installer on a new PC, I let it modify the system PATH. After doing that, all the old PATH settings were gone, and only the new WinAVR settings were present. For now, make sure you unckeck this option during the install, and add the new PATH setting yourself. I installed this in C:\tools\WinAVR and the executable files are in C:\tools\WinAVR\bin.

C:\> set path
Path=C:\tools\WinAVR\bin;...


Note

This entry may not be the first in the list you see.

Test the installation by doing this:

C:\> avr-gcc --version


Of course, make should also be installed!

## Mac¶

The tools we need here (and just about anything else you might need as a developer) can be installed using Homebrew:

$brew tap osx-cross/avr$ brew install avr-gcc
$brew install avrdude  ## Linux¶ On Linux systems (like Ubuntu) you install the tools as follows: $ sudo apt-get install binutils-avr
$sudo apt-get install - gcc-avr$ sudo apt-get install - avr-libc
$sudo apt-get install - avrdude  Once you have the tools needed to build projects for the AVR chips, we need a Makefile. Clone the demo project from my GitHub account (outside of your project folder!): All the Make components needed to build projects is in this repo, including some sample code using C and Assembly. Here is one I set up that will handle just about any program we will build for this course: Warning Make sure Python3 is installed on your system and can be run using just python from the command line. Makefile   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 # Makefile for AVR projects TARGET :=$(shell basename $(PWD)) MCU := atmega328p FREQ := 16000000L PGMR := arduino include mk/os_detect.mk include mk/avr-tools.mk include mk/avr-files.mk # check these settings after plugging in board ifeq ($(PLATFORM), Mac) PORT := /dev/cu.usbmodem1411 else ifeq ($(PLATFORM), Linux) PORT := /dev/ttyACM0 else PORT := COM6 endif endif # do not modify anything below this line .SUFFIXES: -include mk/avr-build.mk -include mk/avr-utils.mk -include mk/help.mk -include mk/debug.mk -include mk/version.mk  The mk directory has several component files used for AVR project: mk/avr-files.mk   1 2 3 4 5 6 7 8 9 10 11 # source files CSRCS :=$(wildcard src/*.c) CXXSRCS := $(wildcard src/*.cpp) SSRCS :=$(wildcard src/*.S) # required object files COBJS := $(CSRCS:.c=.o) CXXOBJS :=$(CXXSRCS:.cpp=.o) SOBJS := $(SSRCS:.S=.o) OBJS :=$(COBJS) $(CXXOBJS)$(SOBJS) LST := \$(TARGET).lst