User Tools

Site Tools


hexabusdemosetup

This is an old revision of the document!


Connecting a programmer

The Raven boards contain two microcontroller: A ATMega1284p and an ATMega3290p. Both are accessible using JTAG and ISP ports (the latter ones need to be soldered to the board). While the ATMega1284p can be programmed using the JTAG port, the JTAG functionality on the ATMega3290p is disabled via a fuse setting. I hacked one of the 50mil/100mil-adapters of the Raven Kit to accept a 6-pin ISP connector. This way, I can connect to the ISP port and flash the device using avrdude, here with a bus pirate in ISP mode:

avrdude  -c buspirate -P /dev/cu.usbserial-A700eEaD -p m3290p -U flash:w:$NAME.hex

The cable between the bus pirate and the ISP port is described here: http://hintshop.ludvig.co.nz/show/buspirate-avr-programming/

I use an external power supply:

Issuing MAC addresses

These MAC addresses have been assigned to the devices: Range: CC-B5-5A-0B-01-00 bis CC-B5-5A-0B-01-FF

USB-Stick: CC-B5-5A-0B-01-00

The MAC addresses are stored in the EEPROM storage, see also http://www.sics.se/contiki/tutorials/tutorial-running-contiki-with-uipv6-and-sicslowpan-support-on-the-atmel-raven.html . They can be modified by re-writing the EEPROM. First, extract the EEP file from the ELF:

avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  --change-section-lma .eeprom=0 -O ihex $NAME.elf $NAME.eep

The file looks like this:

$ cat ravenusbstick.eep 
:08000000021213FFFE14151695
:00000001FF

On a Linux box, the stick reports as:

# ifconfig usb0
usb0      Link encap:Ethernet  HWaddr 02:12:13:14:15:16

As you can see, the MAC address is encapsulated as “021213FFFE141516”, with a checksum following it.

NOTE: My initial plan of just modifying the EEPROM file failed. I was not able to change the adress, even using the methods described here: http://www.sics.se/contiki/tutorials/tutorial-running-contiki-with-uipv6-and-sicslowpan-support-on-the-atmel-raven.html Strange things are going on here.

Flashing the devices

I use the AVR JTAG2 adapter with avrdude. The build system generates ELF files, so it is necessary to extract fuses, EEP and flash images. The “contiki-tools” folder contains scripts for this. The general idea for this is:

echo "Extracting memory sections from ELF"
avr-objcopy -R .eeprom -R .fuse -R .signature -O ihex $NAME.elf $NAME.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  --change-section-lma .eeprom=0 -O ihex $NAME.elf $NAME.eep
echo "Make sure the fuses are set to:"
avr-objdump -d -S -j .fuse $NAME.elf

The USB Dongle

WARNING: I never managed to program the USB dongle using Mac OS. I used a WinXP machine and AVR Studio to upload the ELF file.

Fuses must be set to: Extended 0xFB, High 0x99, Low 0xDE.

In theory (see the caveat above):
cd oktobus/contiki-2.4/examples/ravenusbstick
make all
avrdude -c jtag2 -P usb -p at90usb1287 -U lfuse:w:0xDE:m -U hfuse:w:0x99:m -U efuse:w:0xFB:m

The AVR Raven

Flashing the raven board consists of two steps: Flashing the webserver and flashing the display/relay driver.

Connect to the 1284 JTAG connector, then:

cd oktobus/contiki-2.4/examples/webserver-ipv6-raven
make
avrdude -c jtag2 -P usb -p m1284p -U lfuse:w:0xE2:m -U hfuse:w:0x99:m -U efuse:w:0xFF:m
sh ../../../contiki-tools/flash-1284.sh

The fuse settings of the 3290 prevent the chip to be programmed over JTAG. I use an usbasp connected to the ISP header to change the fuse settings:

avrdude -c usbasp -p m3290 -U lfuse:w:0xE2:m -U hfuse:w:0x99:m -U efuse:w:0xFF:m
  

Now, connect to the 3290 ISP connector.

cd oktobus/contiki-2.4/platform/avr-ravenlcd
make
avrdude -c buspirate -P /dev/usbserial-XYZ -p m3290p -U lfuse:w:0xE2:m -U hfuse:w:0x99:m -U efuse:w:0xFF:m
hexabusdemosetup.1305558624.txt.gz · Last modified: 2012/10/30 10:38 (external edit)