EE109 – Fall 2017 Introduction to Embedded Systems

EE109 – Fall 2017: Introduction to Embedded Systems


The following is to help students install a workable AVR toolchain suite on the own computers similar to what is on the iMac systems in VHE 205


The Macs in VHE 205 are all configured with a copy of the AVR toolchain that is available from and it should be possible to install this on any Mac running MacOS X 10.6 or newer.

On the Download page click on the link for the lateset version (CrossPack-AVR-20131216.dmg at this time) and download the installer. Run the installer and it should install all the files needed to compile the AVR programs and download them to the Arduinos from a Terminal window.

It should not be necessary to also install Apple's Xcode development software but if it is installed (or installed later) it should not affect the AVR toolchain.

Running the Correct "make" Program

Compiling and downloading AVR program makes extensive use of a utility program called "make", and Apple is nice enough to provide a copy of the program. Unfortunately it doesn't work, and when run all it does is tell you that you need to download and install their Xcode development package which isn't really needed for AVR programming. However the CrossPack-AVR software that you installed above comes with a perfectly functional version of "make" so with a little work you can use that instead.

First check to see if you need to make the change. Open up a Terminal window and type the command "make". If you get a response like the one below then you don't need to replace it and can skip the rest of this section.

    $ make
    make: *** No targets specified and no makefile found.  Stop.

However if it says something about how you need to install the Xcode command lines tools, and puts up a dialog box asking you to approve installing something, cancel whatever it is asking you to do and then follow these steps. First confirm which "make" program is being run and which directories the system searches to find programs to execute.

    $ which make
    $ printenv PATH

This shows that the system is now finding Apple's broken "make" in the /usr/bin directory before it finds the working version in /usr/local/Crosspack-AVR/bin directory. The solution to this is to first change the search order so the /usr/local/bin directory is before /usr/bin, and to then put a link to the working "make" in /usr/local/bin/.

Note: If your system already lists /usr/local/bin before /usr/bin, you can skip the next stop.

Run the following two commands to see the list of directories in the search path.

    $ cd /etc
    $ more paths

Edit the file to move the /usr/local/bin line to be the first line in the file. To make the change take effect, close the Terminal window and open a new one. Try the "printenv PATH" command again to confirm that the /usr/local/bin directory is listed before /usr/bin.

Now that the search path is correct, the next step is to put a copy of the functional "make" in /usr/local/bin. To do that run the following commands in the Terminal window.

    $ cd /usr/local
    $ sudo mkdir bin
    $ cd bin
    $ sudo ln -s /usr/local/CrossPack-AVR/bin/make make

The "sudo" lines above will respond with a request to have you enter your password that you use to login to the Mac so put that in.

Once the steps above are done, quit the Terminal program and then restart it. Try the "make" command again and with any luck it will respond as shown at the start of this section since a workable "make" is now being run.

Mac (and Linux) Downloading Issues

The program that downloads the binary data to the Arduino ("avrdude") needs to be told the name of the USB interface to use when contacting the Arduino. On Mac, Linux and other Unix-like systems, the USB interface is represented by a device file in the "/dev" directory, and the name of that file has to be listed on a line in the Makefile used to build and download the data. Unfortunately, the name of the device file can change depending on system's hardware and the OS being used. So it's usually necessary to look for it at least once to find the correct name. With the Arduino not plugged into the system, open a Terminal window and get a list of all the files in the /dev directory that start with "tty.usb"

    $ ls /dev/tty.usb*

In this case it found one file which must belong to some other device. Now plug the Arduino into a USB port and repeat the above search to find any differences in the list.

    $ ls /dev/tty.usb*
    /dev/tty.usbmodemfa2431		/dev/tty.usbserial-A90123ML

Now there are two files, and the new one "/dev/tty.usbmodemfa2431" must be the one for the Arduino. While this device name can be used as is, it's very possible that the name will change the next time the Arduino is plugged in. On the Mac, the first part of the name "/dev/tty.usbmodem" remains the same but the characters after that ("fa2431") may change. To avoid having to check the name each time and keep modifying the Makefile, replace the characters in the device name that may change with the '*' wild card character so the name will match anything that starts with "/dev/tty.usbmodem". As long as there is only one Arduino plugged into a USB port on the system this method should work fine.

Edit the "PROGRAMMER" line in the Makefile to have the correct device name just after the "-P".

    PROGRAMMER = -c arduino -b 115200 -P /dev/tty.usbmodem*

Mac Text Editors

The following are links to text editors that Mac users may find useful.

If you want to learn how to use the Emacs text editor, open a Terminal window and enter the command "emacs" by itself. This will start the editor and put some up an empty window. Then type "ESC x help-with-tutorial Return". That's an Escape, an 'x', then the string "help-with-tutorial" followed by a return key. This will load a tutorial file into the editor. Start reading it and follow the instructions.

Other Mac Issues

The "Makefile" has to be named just that. It can't be "Makefile.txt". The Mac sometimes hides the extensions on files so the filename on the screen may be Makefile but it's really Makefile.txt. The best way to fix this is from a Terminal windows. Find the files and do "mv Makefile.txt Makefile".


Go to the WinAVR software web site ( and click on the Download button.

Install the executable that you just downloaded. During the installation select "English", and use the default values and locations.

Go to the Arduino web site for their software ( Choose the install package for your OS (if Windows you can choose the .exe installer.)

Install the software package using the default options. At some point it may ask you to install the USB driver. Choose "Install". When done, you can click "Complete".

Plug in your Arduino UNO and if it can't install the software manually point to those drivers (or go through Device Manager and Update Driver Software with that software (under the WinAVR installation.)

Note the COM port that is assigned to your Arduino board. If you miss it, you can open the Arduino software that was just installed and click on "Tools..Serial Ports" and it should be listed there.

When working on a project, the name of the port used to interface with the Ardiuno will have to be in the Makefile. Edit the "PROGRAMMER" line in the Makefile to have the correct port information just after the "-P".

    PROGRAMMER = -c arduino -b 115200 -P com5

Windows Text Editors

The following are links to text editors that Windows users may find useful.

Other Windows Issues

The "Makefile" has to be named just that. It can't be "Makefile.txt". Windows sometimes hides the extensions on files so the filename on the screen may be Makefile but it's really Makefile.txt. The best way to fix this is from a "Command Prompt" window. Find the files and do "rename Makefile.txt Makefile".


The AVR-gcc software used for EE109 labs has been used successfully on both Debian and Ubuntu Linux system. It should also work when run as a virtual machine on a Mac or Windows system although there may be issues with getting the VM to recognize USB devices.

Installing the Software

For Debian and Ubuntu Linux the following packages need to be installed.

The installation can be done with the command

    sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude

This may also cause several other packages to be installed. Check to see if the "make" program is present on the system. If not also do "sudo apt-get install make" to install it.

Linux Downloading Issues

Linux systems work about the same as Macs when it comes to finding the name of the device file associated with the USB interface to the Arduino. It seems to use the device "/dev/ttyACM0" for the Arduino Unos, but this may not always be the case. See the information above in the Mac section for more details.

When the Arduino is connected the device file for the Arduino is created with protections that make it necessary to be the root user in order to write files to it. You can run the "make flash" command as the root user, but if this is not preferred, a configuration file can be installed that causes the protection to be set lower to where a normal user can run "make flash".

As the root user, create a text file with the following lines in it.

#Arduino UNO R3 from
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0043", MODE:="0666"
#Arduino UNO R3 from
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2a03", ATTRS{idProduct}=="0043", MODE:="0666"

Save the file with a name like "42-arduino-uno-r3.rules". The leading "42" can be changed to any other number, it just determines the order that these configuration rules are applied on system boot up.

Copy the file to the directoery "/etc/udev/rules.d", and then run the command "udevadm control --reload" to cause the system to reload the rules and make your new one take effect. Once that is done, when an Arduino is plugged in, it should have protections so "make flash" can be done.