Categories
ATMEL

Installing AVR Development Tools on an iMac

Setting up an iMac to develop software for the Atmel AVR microcontroller (i.e. Not Arduino) is quite straightforward however you do need to have the Homebrew package manager installed.

If you have not got Homebrew then you can install it by opening up a terminal window and entering the following command:-

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

The AVR development tools can now be installed by entering the following commands in the terminal window:-

brew tap osx-cross/avr
brew install avr-gcc
brew install avrdude

Once this has been done a single source file containing an AVR program can be compiled for an AVR microcontroller as follows (update microcontroller to reflect the one you are using):-

avr-gcc -std=c99 -O3 -mmcu=atmega32a main.c -o main.elf
avr-objcopy -j .text -j .data -O ihex main.elf main.hex

Now connect the AVR microcontroller to your AVR programmer, and your AVR programmer to your computer. You should now be able to use avrdude to program your microcontroller.

Programming AVR using usbasp

avrdude -p m32 -c usbasp -P usb -e -U flash:w:main.hex

Programming AVR using JTAG and AVRDRAGON

avrdude -p m32 -c dragon_jtag -P usb -e -U flash:w:main.hex
Categories
ATMEL General

Installing AVR Development Tools on Debian Linux

Setting up Debian Linux to develop software for the Atmel AVR microcontroller (i.e. Not Arduino) is quite straightforward and simply involves installed several packages as show below:-

  • sudo apt install binutils
  • sudo apt install gcc-avr
  • sudo apt install avr-libc
  • sudo apt install uisp
  • sudo apt install avrdude

Once this has been done a single source file containing an AVR program can be compiled for an AVR microcontroller as follows (update microcontroller to reflect the one you are using):-

avr-gcc -std=c99 -O3 -mmcu=atmega32a main.c -o main.elf
avr-objcopy -j .text -j .data -O ihex main.elf main.hex

Now connect the AVR microcontroller to your AVR programmer, and your AVR programmer to your computer. You should now be able to use avrdude to program your microcontroller.

Programming AVR using usbasp

avrdude -p m32 -c usbasp -P usb -e -U flash:w:main.hex

Programming AVR using JTAG and AVRDRAGON

avrdude -p m32 -c dragon_jtag -P usb -e -U flash:w:main.hex
Categories
ATMEL General

Re-Install AVRDRAGON Firmware

My ATMEL AVRDRAGON started responding with “bad response to enter progmode” – Unpluging the device and rebooting the computer didn’t solve the problem.

I have seen this error before however I only remembered when I found the solution again – the firmware on the dragon needs to be reflashed – I’m sure there must be another way but this seems to fix it – Hence why I am making a note of it here before it happens again.

I normally use a Linux System when developing AVR software however it is the AVRDRAGON’s firmware that needs to be re-flashed and the tool is only available on windows. Luckily I still have an old Windows machine around with Atmel Studio 7 installed.

Open up a command prompt on a Windows System containing Atmel Studio 7 – it will probably work with other versions but you will have to update the paths.

cd "c:\Program Files (x86)\Atmel\Studio\7.0\atbackend"
atfw -t avrdragon -a ..\tools\AVRDragon\dragon_fw.zip

All done – the AVRDRAGON should be working normally again.