Archive for March, 2008

Arduino Programmer

Friday, March 28th, 2008

This was started at http://www.thing-a-day.com/2008/02/04/day-4-thing-4-aduino-adaboot-programmer/My Bulky Prototype

It is part of the way that I do programming on the avr platform and the Arduino.

I was using the programming half of a a bulky prototype that I have been working on to program an RBBa based maze solving mouse and I looked at the pile hanging precariously off of the coffee table and thought to myself.

“I need to just build one of these. “

The finished product
Modifying Sparkfun Board. to fit in the box the input side
flea assembly blinkin lights in place
test run Translucence done  

So I did.

The programmer is based on the Auto-Reset Hack and the AdaBoot bootloader. The reset is pulled by putting a capacitor on the DTR line of the serial interface which is also the bootloader interface. Most people put the cap on the Arduino but I put it on the programmer (where it belongs). This programmer was built using the ftdi ft232rl breakout board sold by sparkfun. I had to trim it down to get it to fit in the pretty blue box i bought at Tap Plastics. The chip out of the box presents two of its 4 gpio (general pourpose i/o) pins to indicate when serial is being sent and recieved. I wired a pair of very bright leds that I had to them and then tried to pipe the light to the corners using some translucent plastic tubes and hot glue. It looks pretty cool!

The $15 Wiring Board

Monday, March 24th, 2008

This was started out as one of my things for Thing-A-Day (2008) (http://www.thing-a-day.com/2008/02/22/day-22-thing-22-the-15-wiring-board/)

This follows my work getting the wiring software platform working on some generic mega128 boards. It is somehow related to my work on reducing the costs of the Arduino runtime to less than $4

I recently found the code for an Stk500v2 based bootloader at http://www.avride.com/article/wiring/ for the new wiring platform. I have wanted to run wiring on several of the systems I have using the mega128 and the olimex header board that sparkfun sells. Between sparkfun and Ebay my per board cost is about 11 bucks. With the ftdi ft232rl usb to serial chip at $4 that would make the wiring platform affordable 🙂

My initial attempt was using Wiring 0014 which seemed pretty darned broken. It didnt take long for 0015 to come out fortunately. Once I got the bootloader to work with wiring I realized that the wiring platform requires a 32khz clock crystal to be connected to tosc1 and tosc2. On the Olimex boards there is a space for this crystal. On some other boards like the Futulec ET-AVR-stamp this had to be soldered to the legs of the processor.

Once this was added to the boards things started working. Below you can see the Futurelec ET-AVR-STAMP running my “antisocial” wiring program.

Adding and burning a different bootloader to the Arduino with the Arduino.

Saturday, March 22nd, 2008

Q

Ok so its cool to have a programmer (http://www.dorkbotpdx.org/blog/feurig/dorkbotpdx_arduino_programmer) that you can use standalone but what is the best way to know that the bootloader you just burned works?

A

You use it.

I thought I would write this up for a couple of reasons. I recently did some work with getting the arduino to work with different hardware and in the process I learned a bit about modding the arduino environment. In particular I want to add the “Adaboot” bootloader to the arduino environment, use the burn bootloader feature which was added to version 0010, and test the bootloaders as I was burning them.

AdaBoot

The Adaboot bootloader is named after Limor Fried (AKA Lady Ada http://www.ladyada.net/) who made several enhancements to the stock Arduino bootloader. It is well described on the Modern Device Companies page http://moderndevice.com/bootloader.shtml and can be downloaded from wulfden http://www.wulfden.org/freeduino/ADABOOT.shtml. Both sell kits and processors which are preloaded with the adaboot bootloader, The board they sell is a less expensive version of ladyada’s boarduino (at http://www.adafruit.com).
This method works well because just like programming in Arduino language a lot of the gnarley details like fuse and lock settings are handled by the environment. The other nice thing is that you know that the bootloader works within the environment because you just tested it using the environment.

Moving the bootloader into place

When you unzip the archive from wulfden http://www.wulfden.org/freeduino/ADABOOT_7J04b.zip you will find the source code and a premade hex file for the 168 which is named “ATmegaBOOT_168_ng.hex” when you find the bootloader that comes with the arduino for the arduino_ng you will find that its also named “ATmegaBOOT_168_ng.hex” but as you can see from the table on modern device they are most definately not the same. So we are going to name our bootloader adaboot.hex and copy it into the bootloader section on our Arduino installation and then add it to the Arduino IDE.

$ cp ATmegaBOOT_168_ng.hex /Applications/arduino-0010/hardware/bootloaders/atmega168/adaboot.hex
$ cd /Applications/arduino-0010/hardware
$ cp boards.txt boards.txt.stock
$ open boards.txt

On the mac this last command will bring up the boards.txt file in TextEdit. Copying the code from the decimillia we will create a section with our new bootloader. (the board itself is not important as long as it has the same crystal and processor).


##############################################################
dorkbotpdx.name=Dorkbotpdx Arduino Kit

dorkbotpdx.upload.protocol=stk500
dorkbotpdx.upload.maximum_size=14336
dorkbotpdx.upload.speed=19200

dorkbotpdx.bootloader.low_fuses=0xff
dorkbotpdx.bootloader.high_fuses=0xdd
dorkbotpdx.bootloader.extended_fuses=0x00
dorkbotpdx.bootloader.path=atmega168
dorkbotpdx.bootloader.file=adaboot.hex
dorkbotpdx.bootloader.unlock_bits=0x3F
dorkbotpdx.bootloader.lock_bits=0x0F

dorkbotpdx.build.mcu=atmega168
dorkbotpdx.build.f_cpu=16000000L
dorkbotpdx.build.core=arduino

When you reload your arduino software the new “board” will show up like this.

Burning it using the IDE

Select the new board.

Select the serial port used by your arduino

(I will blog later about why mine shows up as /dev/tty.usbserial-ARDWAYNO)

Attach your programmer

and select burn bootloader from the tools menu.

If all is well it will tell you its done burning the bootloader. Also you will notice that the led on pin 13 says hello (flashes) when you reset the board.

Testing it using the IDE

Now load up the blink program from the examples and push the “upload to I/O board” button.

You should notice that the led pin on 13 flashes while it uploads

If all is well it will tell you its done.

And so will your board.

Dorkbotpdx Arduino Programmer

Tuesday, March 18th, 2008

Last week Eric (dr twist) and I got carried away and scored 100 Really Bare Bones Boards (rev A) from wulfden (http://www.wulfden.org/freeduino/freeduino.shtml) for $1.10 a board with shipping, along with the last group order which we ordered enough parts to make the 100 into “kits”. In order to program the 168s I built a programmer around Dean Camera’s “Buttload” (http://www.fourwalledcubicle.com/ButtLoad.php) butterfly based programmer and the 28 pin ziff socket that Paul Stoffregen (http://dorkbotpdx.org/wiki/PaulStoffregen) offered to loan us.

Unfortunately I miss-wired the socket so I couldn’t program the chips last night. This was a good thing because I actually got to interact with the rest of the group. Our group is growing surprisingly interesting.

The programmer has 3 modes. In the first mode it simply acts as a programmer. In the second mode it pretends to be a programmer but stores the programs and fuse bits settings in its on board eeprom. This can then be programmed independently of the host. This third mode was the reason that I chose to use this software. I can loan the programmer with the arduino to anyone in th group who needs it.

Theory

The programmer has 3 major components. The ftdi FT232R, the Atmel Butterfly, and the “Buttload” software. Looking Dean Cameras Buttload site http://www.fourwalledcubicle.com/ButtLoad.php; and a site by Nard Awater which talks about turning the butterfly into a usb device http://aplomb.nl/TechStuff/BLBF/BLBF.html. I grabbed one of my 3 butterflies, my last unused ftdi breakout board and figured (along with Paul’s offering to loan us a ZIF socket) I would have a programmer by Monday.

Practice

Butterfly/FTDI connection

The butterfly contains an on-board level shifting circuit that inverts the RS232 signals and provides the negative swing by charging a capacitor. The technique used by Nard Awater to communicate with the butterfly is to short the capacitor to ground and then program the ftdi chips to invert the txt and rxd signals. Like many hardware utilities this requires an OBSCENING windows machine. Since I had to dig up an old laptop to upgrade the flash on my Xbee radios I was able to do it. The utility on the FTDI web site http://www.ftdichip.com/Resources/Utilities.htm is called MPROG and it lets you invert the signals, configure the behavior of the CBUS lines, and rename the chip to something you can remember (in this case my butterfly shows up as /dev/tty.usbserial-MYBUTT01).

I shorted the capacitor (c300) on the butterfly connected the TXD, RXD and Ground directly to the serial port (grey cable in photo).

Even though windows was required I still prefer this method to removing the level shifting circuit (Though I hear Nick Lott has done it I have destroyed butterflies and never succeeded in this method). It also beats building both ends of the rs232 standard to move serial less than 2 inches.

power

I also wired the 3.3v out on the FT232 board to the butterfly to provide power.

upload name portion of the standard butterfly firmware. It took me a while to figure out that the firmware requires that you set up the baud rate to 19200 baud and I wound up modifying 2 butterflies in the process.

Firmware

The firmware for the programmer is on avrfreaks http://www.avrfreaks.net/index.php?module=Freaks%20Files&func=viewFile&id=2419&showinfo=1
and like all avrfreak’s downloads you will need to register and log in.
The butterfly bootloader has a magic handshake going on that I can never figure out right but it goes something like select jump to bootloader on the board, load startup avrdude. Press and the joystick on the board until it starts and then let go. (it was pretty late by the time I got to this part so I will have to revisit this when I do another butterfly firmware upgrade).

Connecting the socket.

I adapted the generalized circuit described in Awaters zip file.

In order to use the ISP programmer the socket also requires a VCC AVCC and ground to be wired. While the BUTTLOAD programmer can produce the xtal1 signal it is extremely slow and Dean doesn’t recommend it except for foobared fuze recovery (thats why its called recovery mode). So I wired a 16mhz ceramic resonator to the socket as well.

It BURNS.

I wasnt able to test my wiring until I went to the dorkbot meeting (we meet every two weeks) and Paul brought his 28 pin Zif. I plugged it in and put one of our brand new atmega168s in it. Before I could get the cabling done and fire up a window to program it I touched the new chip and burned my finger. I pulled the chip and went back to the conversation I was having until I could get the burner home and check my work. If anyone really demanded a bootloader, I could have done it the old way by plugging the new chip into my Arduino and burning it with my Avrisp-mkII.
Once I got it home I noticed that the socket I had installed was not cut down to 28 pins but 32! On the right side I had counted from the top end. Once this was remedied I went to checking out the software.

No Really

When I fired up avrdude I began to get sync errors. I went back to the lists and the manual and tried varying the programming speed and the baud rates. I finally decided to test the programming to the memory and this worked fine. So I went back to the output side of the circuit and found that the SCK and the MISO lines were reversed. When I tried the actual chip again it said no chip was present. I reread the manual made notes for myself and called it a night.
In the morning it was pretty clear. I had assumed for some reason that the programmer would provide a complete reset but then realized that most targets would have a 10 k pullup and indeed the reset in the default configuration tristates so that it can be left in place.The 10k pullup resitor on the reset line can be omited as long as you remember to set the RESET mode to LOGIC in the settings menu on the programmer. Things worked fine after that.