As it seems that everyone’s sensor nodes have started using IPv6 I wanted mine to have it too. The sensor node in question is the one I built for storage room temperature monitoring some time ago. Current system uses pico]OS and uIP network stack. The uIP stack was taken from Contiki OS, which is described as the operating system for “Internet of Things”. The original uIP stack supports only IPv4, but Contiki has added IPv6 support.
However, it turned out that extracting IPv6 support from Contiki was not as easy as with the original IPv4 version. IPv6 code contained dependencies to Contiki timers (three different ones), clock module, list and memory block management functions. It turned out that most of these functions were usable as-is with pico]OS also, only etimer code needed more changes to use posTimer* functions.
To minimize differences to official Contiki code I decided to mimic the original function names that were related to packet flow. So now picoos-net -library contains tcpip_input, tcpip_output and tcpip_ipv6_output also. Device driver layer integrates to network stack through these functions.
I kept my original idea about aligning IP headers on 32-bit boundaries to allow efficient code on ARM-systems, as it allows also compiling with -Wcast-align to detect alignment errors (which cause odd effects on arm7tdmi cpus).
I did most of debugging with pico]OS unix port, which allowed debugging and testing without need to load code to microcontroller all the time.
Today I loaded the code to my Olimex LPC-E2129 board. At first system looked pretty dead, but it turned out that I had to modify the ethernet driver to accept incoming multicast packets also, otherwise icmp6 doesn’t really work at all. But after that change I was able to ping the board:
PING6(56=40+8+8 bytes) fd7b:ede2:27c7:3c:20c:29ff:fef8:d912 –> fd7b:ede2:27c7:3c:2bd:3bff:fe33:4d5
16 bytes from fd7b:ede2:27c7:3c:2bd:3bff:fe33:4d5, icmp_seq=0 hlim=64 time=8.111 ms
16 bytes from fd7b:ede2:27c7:3c:2bd:3bff:fe33:4d5, icmp_seq=1 hlim=64 time=6.177 ms
Browsing the Web Server also works nice:
It seems that Contiki uIP stack keeps evolving a lot currently, there have been a lot of changes during my port which I’ll have to merge into my version in the future. But I think that I’ll wait until next Contiki release before doing that.
Code is now available at GitHub.