Using the GNU AVR toolchain on Windows 10

Содержание

This page attempts to describe a procedure for installing a complete GCC-based toolchain on a modern Windows system. I’ve developed these instructions on my Windows 10 machine, but they should work for versions of Windows as far back as Windows 7. On older versions, you might want to use WinAVR. WinAVR used to be the preferred way to get this toolchain set up on Windows, even to the point of being semi-official, but has not been maintained in years. The installer reportedly wreaks havoc on newer Windows versions, but it likely works great on XP.

Install Git

We’re going to use the bash shell installed by Git as our starting point. It’s easy to install, and if you’re using Git on Windows, you might have it already. Click the Start menu and search for Git Bash. If it comes up, you have it already. If not, download and install Git for Windows. The defaults for all of the choices in the installer will work for our purposes.

Install the Atmel GNU Toolchain

Download the Atmel AVR Toolchain for Windows from Atmel’s site and run the installer. When asked where to extract the files, click the . button and navigate to C:\Program Files, then click Extract.

toolchain installer

Install GNU Make

Download Gnu Make and launch the installer. Accept the default location for the installation. You can choose whether or not you want an icon in your start menu.

make installer

Install avrdude

. Unzip the archive, and copy the archive inside to C:\Program Files.

Update your PATH

Now we need to tell Windows where to locate all of the tools you’ve just installed when you type their names on the command line. Go to the Start menu and open the Control Panel, then go to System. From the left pane, choose Advanced System Settings. Under the Advanced tab, click the Environment Variables button.

env vars

Under User variables, select Path and click the Edit button. If you don’t already have a variable called Path, click the New button to create it, enter Path without the name, and fill out the value as described below.

The Edit window that pops up is unfortunately different depending on whether you are creating a new variable or only have one item in your path, or if you have multiple items in your path already. In the first two cases, you just get a textbox for a value. In the third case, you get a list of values. Either way, you want to add the following three values. If you get the list, add them as separate items (see screenshot below). If you get the textbox, enter them separated by semicolons. Make sure that they are entered exactly or Windows won’t be able to find the programs.

The three values to add are:

  • C:\Program Files\avr8-gnu-toolchain\bin
  • C:\Program Files (x86)\GnuWin32\bin
  • C:\Program Files\avrdude

editing vars

Click OK on all of the windows you’ve opened.

Install Drivers for your Programmer

This tutorial assumes you are going to use a FabISP, FabTinyStarISP, or other USBtiny-based programmer. If you are using one of the official Atmel programmers instead, the easiest way to get the drivers is to install Atmel Studio.

The USBtiny programmers use a generic libusb driver, but Windows 10’s driver signing policy makes the installation more complicated. Fortunately, there’s a tool that helps with this. Download Zadig and launch it. Plug in your programmer, and select the USBtinySPI device in the list. (If it doesn’t show up, go to the Options menu and click List All Devices. The driver you want to install (to the right of the green arrow) is either libusb-win32 or libusb0. Click the Install Driver button. You should only have to do this once.

zadig

Sanity Check

Everything is now installed. Let’s check that it all works.

Go to the start menu and search for Git Bash and start it. When you see instructions telling you to open your terminal in other tutorials, this is the terminal window you should use.

Check to make sure that the commands we installed work okay:

Type make -v and press enter. You should see:

If you get a command not found error instead, re-check your installation of make and your path variable setting for typos.

avr-gcc

Type avr-gcc --version and press enter. You should see:

If you get a command not found error instead, re-check your installation of the Atmel toolchain and your path variable setting for typos.

avrdude

Connect your programmer to a USB port and type: avrdude -c usbtiny -p t45 and press enter. You should see:

This means that avrdude successfully found your programmer, but failed to talk to a target board (expected because we don’t have anything conencted to the programmer right now.)

If instead you see:

check your USB driver installation (the Zadig steps).

If you get a command not found error, check your installation of avrdude and your path variable.

You should be ready to go!

alt="Creative Commons License" width="" />
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.


Источник: fab.cba.mit.edu