Mac users will need to install Homebrew. Homebrew is a package manager for MacOS.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
You will then need to install avr-libc from the avr repository.
brew tap osx-cross/avr
Now you can install it.
brew install avr-libc
You will also need avrdude to handle the C to hex code conversion and programming the microcontroller.
brew install avrdude --with-usb
You can install the avr dependencies with
sudo apt-get install gcc-avr binutils-avr avr-libc
If you want to use the debugging environment, you will install an additional package
sudo apt-get install gdb-avr
You will also need avrdude to handle the C to hex code conversion and programming the microcontroller.
sudo apt-get install avrdude
You will need to write your program in C. If we have a file called blink.c
and we want to program our ATmega1284, we can run the following commands.
avr-gcc -g -Os -mmcu=atmega1284 -c blink.c
avr-gcc -g -mmcu=atmega1284 -o blink.elf blink.o
avr-objcopy -j .text -j .data -O ihex blink.elf blink.hex
avr-size --format=avr --mcu=atmega1284 blink.elf
You've now created the .hex
file that will be used by your microcontroller. To program your program your microcontroller (assuming the 1284), you will run the following commands.
avrdude -c atmelice_isp -p m1284 -P /dev/ttyUSB0 -b 19200 -U flash:w:blink.hex