Special USB Build
Programming in Linux
NOTE: If you get errors like: avrdude: usb_open(): cannot read serial number “error sending control message: Operation not permitted” avrdude: usb_open(): cannot read product name “error sending control message: Operation not permitted” avrdude: usbdev_open(): error setting configuration 1: could not set config 1: Operation not permitted avrdude: usbdev_open(): did not find any USB device “usb”
Run commands with sudo or as root, or change permissions on USB device.
Programming USB Stick
To program the USB stick, run: avrdude -p at90usb1287 -c jtag2 -P usb -U flash:w:HEXFILE.hex
If you need to program fuses (only need to do this once if you haven’t before run): avrdude -p at90usb1287 -c jtag2 -P usb -U lfuse:w:0xde:m -U hfuse:w:0x91:m -U efuse:w:0xff:m
Programming RAVEN End Nodes
First, connect JTAG to port marked ‘1284’, the 10-pin header (see photo for ref).
Then run: avrdude -p atmega1284p -c jtag2 -P usb -U flash:w:HEXFILE.hex
If you need to program fuses (only need to do this once if you haven’t before run): avrdude -p atmega1284p -c jtag2 -P usb -U lfuse:w:0xe2:m -U hfuse:w:0x91:m -U efuse:w:0xff:m
Contiki-specific Programming Information
Note that the RAVEN End nodes all need unique MAC addresses programmed in. To do this you’ll need to run the following command:
^avrdude -p atmega1284p -c jtag2 -P usb -t^
This enters ’terminal mode’. Now at the terminal enable single-byte EEPROM updating with:
^avrdude> write hfuse 0 0x11
write hfuse 0 0x11^
Then you can write some random numbers to EEPROM by running “write eeprom 0
^avrdude> write eeprom 0 75 93 43 93 99 22 11
write eeprom 0 75 93 43 93 99 22 11^
This writes decimal 75 93 43 94 99 22 11 to EEPROM, start at address 0.
Then set the hfuse back:
^avrdude> write hfuse 0 0x91
write hfuse 0 0x91^
And quit with q:
^avrdude> q
q
avrdude: safemode: Fuses OK
avrdude done. Thank you.^
Contiki Example
Reference: You can see general instructions at http://www.sics.se/contiki/tutorials/tutorial-running-contiki-with-uipv6-and-sicslowpan-support-on-the-atmel-raven.html
The contiki example here runs on Linux using the RNDIS-mode driver. The following should make the demo work:
Programming Stuff
Program RavenUSB with ravenusbstick.hex, by: avrdude -p at90usb1287 -c jtag2 -P usb -U flash:w:ravenusbstick.hex
Program Raven end node with ipso.hex, after programming the FLASH be sure to use the guide in the above section to set a random MAC address, do this by programming the first several bytes of the EEPROM. If you have multiple end nodes each one needs a different address!
Running Stuff
Just plug in the USB stick, and set up radvd along with it’s local IP (ie: aaaa1/64).
Power on the Raven end node, and look on Wireshark. You should see it perform DAD (send some NS), then a RS and receive the RA back. With the RA it will configure a global address and advertise it’s global address. By looking at wireshark you can see it’s IPv6 address, just ping that address.
NB: If the node is advertising an address with a lot of ff’s, such as fe80fe:ffff:ffff:ffff or similar, the MAC address is NOT programmed in EEPROM. The node may NOT work correctly, you need to program some MAC address in.
EEM Files
Loopback Test: RavenUSB_EEM_LOOPBACK.hex
Contiki-Based:
Experimental: Contiki_EEM_March31_1624.zip
Stable: Contiki_EEM_March19_1014.zip
–Contiki_EEM_March18_0900.zip– –Contiki_EEM_March18_1431.zip– –Contiki_EEM_March17_1959.zip– –Contiki_EEM_March23.zip– –Contiki_EEM_March15_1919.zip– –Contiki_EEM_March13_1630.zip– –Contiki_RNDIS_March10_0944.zip– –Contiki_EEM_March10_0944.zip– –Contiki_RNDIS_March9_1044.zip– –Contiki_EEM_March9_1044.zip– –RavenUSB_EEM_Contiki_FLASH.hex– –RavenUSB_EEM_Contiki_EEPROM.hex– –ravenusbstick.elf–
Programming Hints
The ravenusbstick.elf can be programmed with AVR Studio, see the Contiki documentation at http://www.sics.se/contiki/tutorials/tutorial-running-contiki-with-uipv6-and-sicslowpan-support-on-the-atmel-raven.html. It includes both EEPROM and FLASH data inside one file.
The .hex files should be programmed from Linux with:
avrdude -p at90usb1287 -c jtag2 -P usb -U flash:w:RavenUSB_EEM_Contiki_FLASH.hex -U eeprom:w:RavenUSB_EEM_Contiki_EEPROM.hex
But that doesn’t seem to work?. For now use AVR Studio if you can! Or you can try using avrdude, it may not program the EEPROM.
Example Capture of EEM Loopback
Computer wishes to send the following IPv6 Frame:
^#FF0000:33 33 ff 00 00 01 26 00 2b ac 9f d4 86 dd #00A000:60 00 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 24 00 2b ff fe ac 9f d4 ff 02 00 00 00 00 00 00 00 00 00 01 ff 00 00 01 87 00 9c 99 00 00 00 00 fe 80 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 26 00 2b ac 9f d4^
Here: #FF0000:33 33 ff … 86 dd is Ethernet header computer sets up. #00A000:60 00 … 9f d4 is IPv6 packet (ND). Colours are maintained in the following examples:
The frame sent over USB FROM computer TO RavenUSB Stick. Split into two packets as endpoint size is 64-byte maximum:
| Packet 1 | 5A 40 |
|---|---|
| Packet 2 |
5A 40 is EEM Data Header, with Valid Checksum. #FF0000:33 33 ff … 86 dd is Ethernet header computer sets up. #00A000:60 00 … 9f d4 is IPv6 packet (ND). #0000FF: 71 B0 79 57 is Ethernet Checksum.
The frame sent over USB FROM RavenUSB Stick TO computer. Split into two packets as endpoint size is 64-byte maximum:
| Packet 1 | 5A 00 |
|---|---|
| Packet 2 |
5A 00 is EEM Data Header, without checksum. #FF0000:33 33 ff … 86 dd is Ethernet header computer sets up. #00A000:60 00 … 9f d4 is IPv6 packet (ND). #0000FF: DE AD BE EF is bogus checksum.
Debugging with AVR Studio
- Install AVR Studio
- Download Contiki source code from CVS (http://sourceforge.net/scm/?type=cvs&group_id=76159)
- Copy the .elf file to contiki-2.x\examples\ravenusbstick\
- Open the .elf file in AVR Studio (from the contiki-2.x\examples\ravenusbstick directory)
- It will prompt you to save the project file, just save it where it defaults to
- Select “JTAG MK-II” as platform, “AT90USB1287” as device
- Hit “Finish”
- If asked to load initilized EEPROM data, select “Yes”
- If asked to find files originally at avrgcc\gcc\dev or similar, just hit “OK” it doesn’t matter where you select
- Run the program (Debug -> Run)
- Pause it (Debug -> Break), you should see the code stopped somewhere
- Reset code and run again (Debug -> Reset, Debug -> Run)
NB: Once you cause the code you should restart it, as you may confuse the USB host due to the large delay