Atmel Avr For Mac



  1. The Atmel Avr Microcontroller Pdf
  2. Atmel Avr For Mac Download

This document contains instructions to build AVR and ARM cross compilers on Mac OS X from source packages. Note, that precompiled binaries are available in our download area.

So far, only the ARM toolchain had been tested on Leopard, running on a PPC. Be warned, that building on other OS X releases or building the AVR toolchain may not work as described.

  1. I've been programming on Arduino for sometime, and now I am starting to learn how to program the ATmega328 using AVR-C and an AVR programmer. Unfortunately it seems the process is a bit more complicated on mac (I am currently using OS X El capitan version 10.11.6) since there's no Atmel studio on mac.
  2. The one that I chose was the Atmel ATtiny2313, because it has 20 pins, with up to eighteen outputs, can run without an external oscillator, and is fairly inexpensive at around $2.00 per piece. Since I’ve got a Mac laptop and no real serial or parallel port, I opted to go with a USB-based programming solution.

There's finally a good/fast way of installing all these tools under Mac OS X PPC or i386! First, download the OSX-AVR packge for PPC (older macs) or i386 (Intel macs, latest ones) from sourceforge. Run the OSX-AVR.mpkg. USB programmer for Atmel AVR microcontrollers including ATmega series. This is USBasp in circuit Programmer for programming Atmel AVR Series using USB interface. It is a complete DIY guide to build this programmer project. Core IC used in development of this programmer is ATmega8 or you can also use ATmega48.

Installing Xcode

Apple's Xcode package contains all the tools we need to build the cross toolchain. Open Terminal and enter

If the response is similar to

then GCC is already available and probably there is no need to install it again. However, if the response is

then you need to download Xcode from
developer.apple.com/tools/xcode/

A registration is required, but this is free of charge.

Leave the Terminal window open. We'll need it later on.

Download Toolchain Sources

In the Terminal window create a new directory and change to it. Feel free to use any name and create it at any place.

Now use the following commands to download the sources.

Additionally we need the C libraries, avr-libc for the AVR or newlib for the ARM platform. Get the newlib sources with

The avr-libc sources can be downloaded with

Next we unpack the sources, using

and

Atmel Avr For Mac

for the AVR library or

for the ARM library. Note the different option -xzf for the gzipped newlib. Each command takes at least several seconds to execute.

We will finally end up with 3 new subdirectories in our toolcahin folder. You may remove the downloaded archives or keep them in case you want to start all over again later on.

Build Environment Setup

The toolchain will be built in 5 steps:

  1. Building the binary utilities
  2. Building the compiler
  3. Building the libraries
  4. Rebuilding the compiler (ARM)
  5. Building the debugger

In the second step we get different results while building for AVR or ARM. For ARM targets we are building an intermediate compiler first, which is rebuilt in step 4.

The last step, building GDB, is optional and needed for in-circuit debugging only. This requires some additional tools, which are not discussed in this document.

In all steps we are going to use the same environment. Thus, once set in the Terminal window, you need to keep the window open to preserve these settings.

First we specify the target platform:

for the AVR or

for the ARM toolchain. For both targets we set

which defines the directory where the final binaries will be installed. If you prefer any different location, go ahead. Within this folder we need to create a bin directory in advance and add that to our PATH variable.

Note, that we need root authorization to access the path /usr/local, which had been stored in the variable $prefix. Thus the prepended sudo command, which will prompt you for your user password. If you chose a different location, this may not be required.

Building the Binary Utilities

GNU binutils is a collection of binary tools, which needs to be build first. As with all parts of the toolchain, we create a specific build directory inside the package's directory.

The next command, which configures the build, differs slightly among targets. For the AVR we simply use

while the ARM requires

When this went through without errors, we can start building and installing the binaries.

This will take several minutes. When done, try

to check the AVR build or

to check the ARM variant.

This should display the GNU assembler version information. If the command can't be found, check your PATH and prefix settings.

Building the Compiler

Building the ARM compiler requires a readily built library. Building the newlib library, however, requires a compiler. To solve this chicken and egg problem, we build an intermediate bootstrap compiler first, which requires the library's header files only. For the AVR, however, the final compiler is built in this step.

For both targets, create a build directory and change to it.

As expected, the configure options differ among our targets. For the AVR use

The intermediate ARM compiler is configured as follows.

Note, that we may need the sudo command to gain access to the installation directory, where the newlib header files will be copied to.

Building and installing the AVR compiler is done using the standard commands.

The Atmel Avr Microcontroller Pdf

To build and install the intermediate ARM compiler use

Again, this will take several minutes. When done, we can use

to test the AVR compiler or

for the ARM compiler. This should display the compiler version information.

If the build fails, you may try to exclude the C++ compiler by simply removing ,c++ from the --enable-languages option.

Building the Libraries

As stated earlier, we use avr-libc for the AVR and newlib for the ARM.

To configure the AVR build, use

Note the grave accents, acute accents will not work.

The following commands are used to configure the ARM library.

Both libraries are built with

Rebuilding the Compiler

As explained above, this step is only required when building for the ARM target.

Building the Debugger

Even if we do not have all tools available for in-circuit debugging, it is a good idea to build the GNU debugger now, so it will be available later. Here are the related commands, valid for both targets:

Stripping the Binaries

In an additional step we may strip the installed binaries to save disk space and decrease load times.

What's Next?

Now we have all tools available on our OS X machine to create firmware binaries for AVR and/or ARM target boards, either from C, C++ or assembler source code.

If you want to compile applications running on Nut/OS, you may now download the Ethernut package from the local download page.

Selecting a tool for uploading firmware binaries to your target board highly depends on the specific CPU and the programming adapter being used. For AVR targets, AVRDUDE is a good choice, while we recommend OpenOCD for ARM targets.

The document OpenOCD and Ethernut 3 contains additional information about installing and running OpenOCD on a Mac.

Finally you may want to set up an integrated development environment, which includes a source code editor, compiler, linker, debugger and more. If you are already familiar with Xcode, this might be the right way to go. If you are, like me, working on several different platforms, then Eclipse is probably a good choice.

External Links

dirkraffel.wordpress.com/2008/02/22/building-a-gnu-arm-cross-compiler-toolchain-on-mac-os-x/
Building a GNU ARM cross-compiler toolchain on Mac OS X.

www.nslu2-linux.org/wiki/HowTo/SetUpAToolChainOnAMac
Describes another way to set up an ARM toolchain on Mac OS X.

www.cocoamachine.com/blog/
Blog about setting up a cross development for the iPhone, which is based on an ARM CPU.

developer.apple.com/tools/xcode/
Xcode is Apple's premiere development environment for Mac OS X.

gcc.gnu.org/
Homepage of the GNU Compiler Collection.

www.gnu.org/software/binutils/
GNU Binutils' homepage.

sourceware.org/gdb/
GDB, the GNU Project Debugger.

www.eclipse.org/
An open development platform based on Java.

Atmel Avr For Mac Download

savannah.nongnu.org/projects/avrdude/
AVRDUDE is software for programming Atmel AVR Microcontrollers.

openocd.sourceforge.net
The Open On-Chip Debugger aims to provide debugging, in-system programming and boundary-scan testing for ARM based target devices.

I finally received the AVR USBASP programmer that I ordered on aliexpress.com today. I’ve been waiting for this so that I could start tinker with reflashing of ESCs and the Turnigy 9x that I had recently bought. I choose this one cause it had some built in protection (diodes) added.

It was also voltage selectable (3.3V and 5V) via adding or removing a 0ohm resistor. I plan on replacing the resistor with headers and a jumper later. It comes default as 5V which works for me, so I’ll leave it for now.

I run OS X, and most guides for things related to R/C are written for windows. I basically looked for the equivalent Mac based tools as described by the Windows based guides. I knew that I could do this cause there is nothing platform specific when it comes to working with the Atmel microcontrollers (the atmega8a that controls our ESC).

I chose to use CrossPack, by Objective Development Software, to provide me with the toolchain for working with the Atmel microcontrollers. And while I’m pretty comfortable with the OS X command line (many years of Linux), I figured that I wanted to be lazy and have a GUI interface. Thus I also chose to install AVRFuses, by Jason von Nieda, as the GUI that would hook into avrdude (comes with CrossPack and is the actual program that will flash the firmware to the ESC).

At the time of writing this, the versions that I used are (on OS X 10.7.4):

  • CrossPack-AVR-20120217.dmg
  • AVRFuses_1.4.4.zip

Installation is a piece of cake so I won’t go into that. I will however talk a bit about configuring AVRFuses so that it can talk to the AVR Programmer through avrdude.

After installing both pieces of software, open up AVRFuses and go to it’s preference pane. Here we will need to define “Path to avrdude” and if you read the readme file that came with CrossPack, you would know that it installs by default to “/usr/local/CrossPack-AVR-20120217/” and the full path to avrdude is “/usr/local/CrossPack-AVR-20120217/bin/avrdude”.

The programmer that I bought was USBASP so I selected “usbasp” (obviously), You may need to select a different option depending on your programmer. The port should again be selected based on the hardware programmer that you are using, and it is pretty safe to leave the baud rate at “[Default]“.

There has not been an update to AVRFuses since 2008, but I wanted to leave the option checked in case Jason decides to do something someday. I also left “Show avrdude Command Lines” so that I could monitor what was going on Click on “Close” and if everything is good you will see a nice green “SUCCESS” in the output console.

Now we can get ready to reflash the TX and some ESCs. I’ll write about those later on.