AVR-GCC and AVRDUDE
In this practical you will configure the tools used to compile C programmes for AVR microcontrollers and upload the resulting firmware to a development board. You will also check that the tools are accessible from Git Bash before moving on to the next laboratory.
1. Understanding the AVR tools
| Tool | Purpose |
|---|---|
avr-gcc | Compiles C code for the selected AVR microcontroller. |
avr-objcopy | Converts compiled firmware into a format such as Intel HEX for uploading. |
avrdude | Communicates with a supported programmer or bootloader to write firmware to the microcontroller. |
make | Optional build automation tool; reads a file named Makefile containing build instructions. |
2. Configure your environment
The following instructions use Git Bash on Windows. The specified locations correspond to Arduino-installed AVR tools; they may differ if Arduino IDE was installed elsewhere or if different tool versions are installed.
-
Open Git Bash and edit your Bash startup file.
nano ~/.bashrc -
Choose the appropriate environment below and append both
export PATH=...lines to~/.bashrc.export PATH="$PATH:/c/ProgramData/arduino-ide-v2/Local/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin" export PATH="$PATH:/c/ProgramData/arduino-ide-v2/Local/Arduino15/packages/arduino/tools/avrdude/8.0.0-arduino1/bin"These paths correspond to the university installation described in this workbook.
export PATH="$PATH:/c/Users/yourusername/AppData/Local/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin" export PATH="$PATH:/c/Users/yourusername/AppData/Local/Arduino15/packages/arduino/tools/avrdude/8.0.0-arduino1/bin"Replace
yourusernamewith your Windows username, and adjust the paths if your Arduino installation uses different version directories. -
Save the changes in
nanousing Ctrl+O and Enter; exit with Ctrl+X. -
Reload the configuration in the current shell.
source ~/.bashrc -
Check that the shell can find both tools and display their versions.
command -v avr-gcc command -v avrdude avr-gcc --version avrdude -vIf a command is not found
Confirm that each directory exists on your computer and contains the corresponding executable. The names
7.3.0-atmel3.6.1-arduino7and8.0.0-arduino1are version-specific; an Arduino IDE update may install different folders. Ensure you have reloaded~/.bashrcafter editing it.