Sunday, July 6, 2014

Using AVRDUDE with Arduino bootloader

I am working on a home built CNC project that uses Atmel processors as controller. In the process, I had gone through much trouble to load the firmware using the AVRDUDE through the Arduino bootloader on the chip. Here is to share my finding since I have a little trouble finding this information on the internet.

Basically the Arduino bootloader is default to 57600 baud 8-N-1 (circa 2014). Everywhere I searched on Internet (including the official Arduino bootloader page) has dated information, and specified as 17600.

The other information is that the programmer protocol must be set to "arduino" for AVRDUDE. So here is the correct commandline options for it:

avrdude -v -v -c arduino -b 57600 -P com9 -p atmega328p ....

Note that the baud rate (57600) has to be explicitly specified for this to work. I also found this information mentioned in this Sparkfun forum post, which is where I got the idea originally.

One more small caution with loading with AVRDUDE instead of Arduino IDE is that one will need to make sure that the chips is in bootload mode when AVRDUDE attempts to write to it. One way to do it is to perform a board reset (through a switch or short the right pin). But the modern Arduino bootloaders stays in the bootload mode in a very short time (mine is half a second), so you will have to reset it in a relatively short time window. But if the code is load through Arduino IDE (and proper Arduino hardware setup) there is no such reset needed. The way that Arduino IDE does it without using the reset is to use the DTR line (of the serial communication) to trigger the reset. On my setup I just connect the DTR of my FT232R module to a line marked GRN on my Arduino Mini Pro, and it works well without needing me to press the reset button any more for loading.

A few more words, I am using these Arduino boards essentially as a AVR processor board. The Arduinoo boards are cheap and readily available (thanks to industry scale and China), and it helps me to avoid soldering the tiny surface mount chips.


No comments: