Guide: How to use an Arduino as an In System Programmer (ISP)
I recently bought the “Graphic LCD Serial Backpack” from Sparkfun. When reading the comments for the product. I discovered that a user named “SummoningDark”, had made a new improved firmware. A lot of people asked Sparkfun to change the official firmware with the new one, so i decided to check it out. The problem were that I do not own a programmer, so at first I thought that I had to buy one. But after some googling I found out that the Arduino could actually be used as an In System Programmer (ISP).
After a lot of work I finally got it working and it has really improved the perfomance of the screen. The speed is much higher (SummoningDark says 10 times) and there are no more bugs (with the old firmware the screen would suddenly write the text or a line a odd place).
I will now try to explain as best as I can, how to upload the new firmware.
NB: You can also use this guide if you need a different bootloader or another hex file on any AVR. This is just meant as an example.
1) Start up the Arduino IDE
2) Go to File>Exampels>ArduinoISP and upload the software onto your Arduino – if your .hex file is more than 255bytes, you should use the newest version found on this page: http://code.google.com/p/mega-isp/issues/detail?id=14&can=1 (Version dev04b is confirmed to work)
3) Now you have to install AVRDude. I recommend downloading CrossPack for Max OX and WinAVR for Windows as it includes all you will need. Including an AVR compiler and AVRDude.
4) Download the program your want to upload. In my case it is the new firmware for the Serial Backpack
5) Compile the program to make a hex file, this can be done by typing “make all” in a terminal while inside the folder (use “cd” and then the path to the folder – see step 11 for help)
You might have to change some setting for it to work. If there is already an hex file (as in my example) you can just skip this step
6) Now connect the Arduino to the device you want to program. The pin used by the Arduino are as follows:
You have to connect these pins including VCC (5V with the Serial BackPack) and GND to the ISP header on your device like so:
The orientation of the ISP header on the backpack is like so:
If you are programming an AVR directly or an Arduino board. See this page for information: http://arduino.cc/en/Tutorial/ArduinoISP
You might also want to connect three LED’s (with resistors) on the following pins:
7) The next thing you have to do is to connect a 120 ohm resistors (I use a 100 ohm and two 10 ohm resistors) between the 5V and reset headers on the Arduino to disable auto reset on serial connection. See this post for further information – some people do not need this small hack, so if you have problems to get it working, try without the 120 ohm resistor
8 ) Start up a terminal program. On a Mac simply find the terminal app in the programs folder. If you are using Windows open “run” and type “cmd”. Your should now have a terminal window open
9) Now you have to figure out what port your Arduino is using. On a Mac simply type “ls -l /dev/cu.*” in the terminal and all your serial ports should pop up. If you are using Windows open Device Manager>ports and find your Arduino’s COM-port. My port is: “/dev/cu.usbserial-A700dX8R”, so I will use it in the following example
10) Write the following command in the terminal:
avrdude -p m168 -P /dev/cu.usbserial-A700dX8R -c avrisp -b 19200
“/dev/cu.usbserial-A700dX8R” should be replaced by your port. If your Arduino is on COM port 1, you should write “com1” instead. “m168” means that the target is a ATmega168 see this link for other aliases.
The teminal will print out something like this:
Reading | ################################################## | 100% 0.13s
avrdude: Device signature = 0x1e9406
avrdude: safemode: Fuses OK
avrdude done. Thank you.
Where 0x1e9406 is atmega168 device signature (look in avrdude.conf for other signatures)
11) If everything worked well it is now time for programming your device. The first thing you have to do is go inside the folder where your hex file is located. In my case I just copied the folder “trunk” to the main directory in the harddisk. Your should then use the following command:
cd /trunk
12) Next step is almost the same as 10), but this time you should add -U flash:w:filename to the command. Where “filename” should be replaced with the name of your hex file. In my case the name is “main.hex” so the command should look like this:
avrdude -p m168 -P /dev/cu.usbserial-A700dX8R -c avrisp -b 19200 -U flash:w:main.hex
The terminal will then print something like this:
Reading | ################################################## | 100% 0.13s
avrdude: Device signature = 0x1e9406
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (11210 bytes):
Writing | ################################################## | 100% 14.03s
avrdude: 11210 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 11210 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 12.89s
avrdude: verifying ...
avrdude: 11210 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
You should now – hopefully – have a new firmware on your device 🙂
Hope this will be a help to some, because it really took me a long time figuring all this out.
Recent Comments