Programming Atmel using MySmartUSB Light and Ubuntu
The MySmartUSB Light requires a USB port instead of the more common parallel or serial port. However, as soon as the programmer is plugged in, the Linux kernel will recognise it as a serial interface, so no difference there.
Software[ 4474.226058] USB Serial support registered for cp210x
[ 4474.226115] cp210x 3-2:1.0: cp210x converter detected
[ 4474.336078] usb 3-2: reset full speed USB device using uhci_hcd and address 2
[ 4474.487284] usb 3-2: cp210x converter now attached to ttyUSB0
[ 4474.487322] usbcore: registered new interface driver cp210x
[ 4474.487327] cp210x: v0.09:Silicon Labs CP210x RS232 serial adaptor driver
To program the Atmel chips, you need some software components. Luckily, they all are available through the Ubuntu repositories. Installing goes like this:
Avrdude is a command line tool for programming the chips, while binutils-avr and gcc-avr are the cross-compile tools for creating the binaries. Avr-libc is libc, the standard C library, cross-compiled for AVR chips.sudo aptitude install avrdude binutils-avr avr-libc gcc-avr
To make things easier, I found a Makefile tailored for Atmel projects. This allows compiling for and writing to microcontrollers from the command line quite easy. The Makefile is suitably commented, and after setting the correct target controller (MCU), programmer id (AVRDUDE_PROGRAMMERID), and programmer port, you are good to go.
MCU values can be found by running
and look for the 'Known MCU names' for a complete list.avr-gcc --target-help
The programmer id for MySmartUSB Light is by default 'STK500' and the port is often /dev/ttyUSB0 or /dev/ttyUSB1. Look at the dmesg output after connecting the programmer to be sure.
Anyone interested in using a GUI for writing to the chip, I can recommend AVR8-Burn-O-Mat. I cannot say for sure it will work for every AVR chip, though. There is also a very complete programming IDE from Atmel, called AVR Studio, available for free. You do have to fiddle around with Wine to make this work, but all is explained in this tutorial.
Powering the board
The programmer can also be used as a power source. It supports both a 3V and 5V current ouput, which can be set using software. For that, you have to send a specific code sequence to the port.
An overview of these command sequences can be downloaded from the myAVR site. The archive contains a bunch of txt files, each with their own sequence. For example, the sequence for setting the board to 3V is stored in the file power3V.txt.
To use these commands, you can simply cat them to the port the programmer is connected to (make sure the port is configured properly using picocom):
Note that this sequence only switches the current voltage. By default, no power is fed through the SPI connector yet. To power on the board, use the following command:cat power3V.txt > /dev/ttyUSB0
Remember that after the initial connection or programming a chip, the power is always switched off and the BoardPowerOn command must be used.cat BoardPowerOn.txt > /dev/ttyUSB0
Anyway, it sounds like you are about to have a lot of fun with the AVR :-).
Edit: Standard programming - > ISP (In System Programming)
[Comment edited on Sunday 3 October 2010 12:13]
About the programming mode: the dongle only has a ISP connector I can use for programming, so does this automatically mean I use the standard programming mode?
[Comment edited on Sunday 3 October 2010 21:48]
I think it should be
cat BoardPowerOn.txt > /dev/ttyUSB0
Comments are closed