In this post I will show how to install the avr-gcc toolchain and avrdude on Mac OS X and Linux. If you are using a Mac and want to save the trouble of going through these steps, simply install CrossPack for AVR Development and follow the instructions in the manual. I might go over it sometime in future though.
Versions of macOS from 10.15 (a.k.a. "Catalina") and later have made it necessary to use an AVR development toolchain that consists of 64-bit executable programs. The previous toolchain used in EE109 consisted of 32-bit programs and can no longer be used. This web page describes a way to install a working AVR 64-bit toolchain based on using the Arduino IDE software. The Arduino IDE application actually contains a nearly complete copy of most of the AVR toolchain programs and with a little work these can be run from a Terminal window. Since Arduino appears to be periodically releasing new versions of their IDE, and this includes updated versions of the AVR toolchain, you can take advantage of this and use the toolchain software from within the Arduino IDE from a Terminal window.
Build An Avr Toolchain For Mac
If you had previously installed the AVR toolchain from the "CrossPack" distribution, you should remove that toolchain so it doesn't get in the way of the programs you are installing below. If you aren't sure if that software is installed, check for it with the command line interface operation
Download and install version 1.8.19 of the Arduino IDE. On the Arduino software web page, you will have to scroll down to find this listed as "Legacy IDE" but this is the one you want to get. Do not download any version that starts with "2" or says it's a "release candidate" or "hourly build" since these are configured differently and will not work with our setup. Installing the Arduino app is just a matter of downloading the ".zip" file, unzipping it to get the Arduino software with the green, round icon, and then putting it someplace like the system Applications folder or in the Applications folder inside your home folder. It doesn't make any difference where it goes as long as you can find it using the Terminal program as described in the next step.
Using a Terminal window, you'll need to find the AVR toolchain that is inside the Arduino IDE. First use the "cd" command to find the Arduino.app file and then do another "cd" to get inside the Arduino.app package. What looks like a single file on the Mac, like the Arduino.app package, is actually a directory full of subdirectories containing various things and the Terminal program can be used to get inside this directory structure. Assuming you installed it in the top level Applications folder do something like this.
Now that you have found the AVR toolchain files, you need to get the full path to the AVR toolchain. This can be done by typing the command "pwd -P" which will then print out your current location in the file system. Make a copy of this output string (just the output that was printed by the command, not the "pwd -P" part) for pasting later.
Put a link to the above AVR toolchain directory someplace where you can add it to the executable search path. A recommended place is in the "/usr/local" directory. Move to the /usr/local directory and make a symbolic link using the path to the AVR toolchain that you copied above. Make sure to put the path in quotes if it contain any spaces in the directory names. In the example below we also create a "/usr/local/bin" directory since we'll need that later.
To make the Arduino avr-gcc toolchain work properly it's very important the PATH variable be set correctly so it includes the directories where the avr-gcc programs have been installed. The easiest way to do this is to edit one of the files in your home directory that the shell program refers to when starting to include a command that adds the correct directories to the list. Unfortunately there are several shell programs available for use with macOS, with names like "bash", "zsh", "tcsh", etc., and the choice of which file to edit depends on the shell your Mac is using. You need to determine which shell program you are using in order to proceed with the the installation. This can be done by displaying the value of the "SHELL" environment variable by typing the command "printenv SHELL". For example,
If you decide to compile it yourself from Gnu sources, be advised that the normal way to build the "make" program from sources uses a working copy of "make" already on the system. Since you probably don't have that follow the instructions in the "README" file to use the provided "build.sh" script to build the "make" program. After the program is compiled, decide where to put the executable "make", perhaps /usr/local/bin, and move it there. Make sure whatever directory you put it in is also included in your executable search path. If not, edit the shell startup file as shown above to include it.
Here is a 'generic' step-by-step to getting an AVR development platform going on your computer using the free AVR toolchain (avr-gcc, avr-libc and avrdude) Pretty much every project uses this toolset so its a good way to get going
Within the context of the AVR Eclipse plugin the word AVR-GCC toolchain is used quite liberally for all tools and files required to develop and deploy applications for AVR processors with this Plugin. Actually these tools come from seperate sources, of which the real avr-gcc is only one.
At the core of the avr-gcc toolchain and absolutely required to build AVR applications, are the compiler, the binutils collection and the libc library. While the last one is a dedicated project, the first two (and gdb) are part of the GNU Project.
Since the GNU Project serves a much greater community than just the AVR folks and its stability is critical to the stability of the entire open software community, the avr-gcc developers have elected to publish AVR specific bugfixes and improvements as patches to the baseline distributions of gnu tools. Some of these patches are integrated into the gnu tools at some point, some are not. So to get the latest toolchain, it is advisable to include the patches.
Download and install WinAVR, which includes the AVR-GCC toolchain together with some other useful tools for programming the AVR processor series.WinAVR is actively maintained and has the latest patches as well as some improvements of its own (like the --format=avr option for the avr-size tool).
Most Linux distributions have an AVR-GCC toolchain. For instructions about installing AVR-GCC for your particular distribution, see the instructions below.However, the AVR-GCC toolchains packaged for the various distributions tend to be very much out of date. If you need the latest toolchain (e.g. if you are targeting one of the newer AVR processors) you probably have to build the toolchain yourself.
If you do not have access to a prebuild - up to date - toolchain you will have to build it yourself. If you search the internet, you will find many sites on how to build the avr-gcc toolchain, most of which are very much dated. However, as the basic principle is always the same you can still use them as a guideline on how to build the toolchain.
Instructions on how to build the various components of the AVR toolchain by the folks who maintain the avr-libc code. They do not include instructions for the latest patches, but a good alternative if you have problems with the other scripts.
Especially with the mess on Linux, where you have to build the toolchain yourself to get a somewhat recent version, I thought it might be a good idea to wrap a pre-build toolchain into an Eclipse Bundle (basically a plugin) and have the AVR Eclipse Plugin use it.This has currently not a high priority on my to do list. But if you are really interested in this, i could reprioritize :-)Be aware that I only would supply the Plugin integration. The actual bundeling has to be done by someone else who would be willing to maintain the toolchain bundle. Please comment at the Feature Request or write me a mail
Note: Everything below is about setting this up on a macOSsystem. However, the Windows version of the Arduino IDE also includes theAVR toolchain software so with some changes, the process should also work onWindows. Unfortunately the author has limited Windows skills so he will leaveit to someone else to figure out the details.
Step 0: Remove Any Old Toolchain PackageIf you had previously installed the AVR toolchain from the "CrossPack" distribution, you should remove that toolchain so it doesn't get in the way of the programs you are installing below. If you aren't sure if that software is installed, check for it with the command line interface operation $ ls /usr/localIf you see any file or directories listed that start with "CrossPack-AVR" that means the CrossPack software has been installed and needs to be removed.The CrossPack software has to be removed by using a command line interface operation. To remove it, use the command $ cd /usr/local $ sudo rm -rf CrossPack-AVR-20131216 CrossPack-AVRAfter that, try doing the "ls /usr/local/" operation again and check that the CrossPack entries have been removed.Step 1: Install the Arduino IDEDownload and install a version ofthe Arduino IDE that isversion 1.8.10 or later. Version 1.8.10 appears to be the first that containedthe avr-gcc software as 64-bit binaries. This is just a matter of downloadingthe ".zip" file, unzipping it to get the Arduino software with the green, roundicon, and then putting it someplace like the system Applications folder or inthe Applications folder inside your home folder. It doesn't make anydifference where it goes as long as you can find it using the Terminal programas described in the next step. 2ff7e9595c
Comments