Aug 022011
AVR minus Arduino

Arduino’s hardware is great and plentiful available, but for bare bones, the single microcontroller is all you need.

So I got myself some ATmega328P chips (250 Yen a piece) to set up a minimal Arduino like described here. All I need is an Arduino to program the blank chip. Got that, so I was hopeful.

First step is to burn a bootloader via the ISP interface of the 328P. Worked flawlessly. Infact, I tried all variations of bootloaders: with external clock and without, and the normal bootloader as well as OptiBoot. All of them looked ok: after reset an LED connected to digital pin 13 blinks with the usual “there is no program” sequence. But all attempts to program something using the serial connection failed with

avrdude: stk500_recv(): programmer is not responding

errors. I tried all possible board types and I tried to use avrdude using all possible baud rates. Nothing worked.

After spending countless hours trying to find a solution I gave up and skipped the Arduino interface part and its abstraction. The benefit is that I know exactly what is happening and the serial port now is free and available for other uses beside programming.

I found a good (and simple) example here and here I found how to use avrdude correctly:

avrdude -v -p m328p -c avrisp -P /dev/ttyUSB0 -b 19200 -e -U flash:w:demo.hex

This is using an Arduino as programmer acting as an avrisp programmer to program the ATmega328P. Worked on the first try.

Some more examples:

  • And to read the config and fuse bits:
avrdude -v -p m328p -c avrisp -P /dev/ttyUSB0 -b 19200
  • To program the fuse bits (fuse bit values taken from here) and erase the flash memory (-e):
avrdude -v -p m328p -c avrisp -P /dev/ttyUSB0 -b 19200 -e -U lfuse:w:0xE2:m -U hfuse:w:0xDA:m -U efuse:w:0xFD:m

On an unrelated note: During the next days, so time permits, I’ll check out this and this. This looks helpful too. Then I can get rid of the Arduino IDE, but keep the libraries.