At the moment I am building a small demo based on the AVR Raven and Contiki. I was running into some trouble with building the Firmwares on my Mac – this is the documentation of the workarounds.
The Contiki build system depends on some GNU utilities that are not installed. Using the following steps I was able to compile for the “native” (i.a. Mac OS) target:
- Install GNU binutils using MacPorts.
- Edit “cpu/native/Makefile.native” and adjust the “Compiler Definitions” section like this:
### Compiler definitions
CC = gcc
LD = gcc
AS = as
NM = nm
# Use GNU ar instead of /usr/bin/ar
AR = gar
OBJCOPY = objcopy
STRIP = strip
CFLAGSWERROR=-Werror -pedantic -std=c99 -Werror
CFLAGSNO = -Wall -g -I/usr/local/include $(CFLAGSWERROR)
CFLAGS += $(CFLAGSNO) -D_XOPEN_SOURCE=500 -O
# Simplify ld arguments
#LDFLAGS = -Wl,-Map=contiki-$(TARGET).map,-export-dynamic
LDFLAGS = -Wl
Another issue is the ELF binaries for the AVR Raven boards. These files contain all components of the programs: flash and eeprom
images as well as fuse settings. Unfortunately, avrdude cannot read the ELF format. So you have to extract the flash manually:
$ avr-objcopy -R .eeprom -R .fuse -R .signature -O ihex $NAME.elf $NAME.hex
It works similar for the EEPROM section (where the IP data is stored):
$ avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex webserver6.elf webserver6.eep
You can also check which fuse settings are used:
$ avr-objdump -d -S -j .fuse webserver6.elf
webserver6.elf: file format elf32-avr
Disassembly of section .fuse:
820000: e2 99 ff
The directory structure of Contiki is somewhat overwhelming. I am currently working in these directories:
- contiki-2.4/platform/avr-ravenlcd: This is where the code for the ATMega3290p lives. Run make here and upload.
- contiki-2.4/platform/avr-raven: The ATMega1284p code lives here, this is where most patches are. Don’t run make here!
- contiki-2.4/examples/webserver-ipv6-raven: Run make here for the ATMega1284p code. This builds the webserver code and includes the platform/avr-raven dir.
In addition, I have a serial terminal for debugging output:
screen -U /dev/cu.SLAB_USBtoUART 57600