EE109 – Fall 2022 Introduction to Embedded Systems

EE109 – Fall 2022: Introduction to Embedded Systems

Toolchain

The following is to help students install a workable AVR toolchain suite on the own computers.

MacOS

Instructions for installing an AVR toolchain for Mac is available on this web page.

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.

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.

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 "cu.usb"

    $ ls /dev/cu.usb*
    /dev/cu.usbserial-A90123ML
    $

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/cu.usb*
    /dev/cu.usbmodem141301		/dev/cu.usbserial-A90123ML
    $

Now there are two files, and the new one "/dev/cu.usbmodem141301" 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/cu.usbmodem" remains the same but the characters after that ("141301") 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/cu.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/cu.usbmodem*

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".

Windows

Instructions for installing an AVR toolchain for Windows is available on this web page.

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".

Linux

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

Instructions for installing an AVR toolchain for Linux is available on this web page.

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 Arduino.cc
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0043", MODE:="0666"
#Arduino UNO R3 from Arduino.org
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.