1.**Toolchain** On Windows install [Atmel AVR Toolchain][atmelgcc] for AVR GCC compiler and [Cygwin][cygwin](or [MinGW][mingw]) for shell terminal. On Mac you can use [CrossPack][crosspack] or your favorite package manager. On Linux you can install AVR GCC with your favorite package manager.
3.**Driver** On Windows when you start DFU bootloader on the chip for the first time you will see **Found New Hardware Wizard** to install driver. If you install the device driver properly you will find a chip name like **ATmega32U4** under the **LibUSB-Win32 Devices** tree in **Device Manager**. If not you will need to update its driver in **Device Manager**. You will find the driver in the `FLIP` install directory, something like this: `C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\`. For `dfu-programmer` install the driver distributed with it.
Build the firmware using the GNU `make` command. You'll see a `<project>_<variant>.hex` file in that directory unless something unexpected occurs in build process.
Now you have a **hex** file in the current directory. This **hex** file is only needed to program your controller, other files are used for development and you may leave and forget them.
How you program the controller depends on the controller chip and its board design. To program an AVR USB chip you'll need to start it up in bootloader mode. Most boards have a push-button to load the bootloader. Consult with your controller board's manual.
Stock AVR USB chips have the DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. `FLIP` has two version of the tool, a GUI app and a command line program. If you want the GUI see the tutorial below. An open source alternative, `dfu-programmer`, also supports AVR chips; it is a command line tool and runs on Linux, Mac OSX and even Windows.
The `<controller>` part will be `atmega32u4` or `atmega32u2` in most cases. See the manual of the command for details. On Linux and Mac OSX you will need proper permissions to program a controller and you can probably use `sudo` command for this purpose. On Linux you also can configure `udev` rules to set permissions.
1. In the menu bar click **Device** -> **Select**, then choose your chip name. (In most cases **ATmega32U2** or **ATmega32U4**)
2. In the menu bar click **Settings** -> **Communication** -> **USB**, then click the **Open** button in the **USB Port Connection** dialog. At this point you'll have to plug into USB and start the bootloader.
3. In the menu bar click **File** -> **Load HEX File**, then select your firmware hex file in the File Selector dialog.
4. In the **Operations Flow** panel click the **Run** button to load the firmware binary to the chip. Note that you should keep the **Erase**, **Blank Check**, **Program** and **Verify** check boxes selected.
5. Re-connect the USB cord or click the **Start Application** button to restart your controller.
If you are using a PJRC Teensy consult with the instructions for [Teensy Loader][teensy-loader]. Or run this target with `make` after you install the command line version of it.
You may want to use another programmer like [`avrdude`][avrdude]. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in the Makefile. See below.