From b706c48efd9d822e38fcfde2d09a202fc0fcfd18 Mon Sep 17 00:00:00 2001 From: dak664 Date: Tue, 3 Aug 2010 19:55:42 +0000 Subject: [PATCH] Add experimental RPL code Change RF channel to 26 for econotag compatibility --- platform/avr-ravenusb/Makefile.avr-ravenusb | 7 +- platform/avr-ravenusb/contiki-conf.h | 73 +++++++++++++++++---- platform/avr-ravenusb/contiki-raven-main.c | 15 +++-- platform/avr-ravenusb/sicslow_ethernet.c | 6 ++ 4 files changed, 83 insertions(+), 18 deletions(-) diff --git a/platform/avr-ravenusb/Makefile.avr-ravenusb b/platform/avr-ravenusb/Makefile.avr-ravenusb index a0b3dde1d..728c292ec 100644 --- a/platform/avr-ravenusb/Makefile.avr-ravenusb +++ b/platform/avr-ravenusb/Makefile.avr-ravenusb @@ -17,10 +17,15 @@ USB = uart_usb_lib.c \ storage_task.c \ avr_flash.c +#As of August 2010 the following are needed for rpl. They need explicit inclusion since CONTIKI_NO_NET=1 +#The tcpip_input routine in tcpip.c must be commented out; it expects a tcpip process and conflicts with the one in fakeuip.c +#RPL = rpl.c rpl-dag.c rpl-icmp6.c rpl-timers.c rpl-of-etx.c uip-ds6.c uip-icmp6.c uip-nd6.c uip6.c neighbor-info.c neighbor-attr.c tcpip.c uip-split.c + CONTIKI_TARGET_SOURCEFILES += cfs-eeprom.c eeprom.c random.c \ mmem.c contiki-raven-default-init-lowlevel.c \ contiki-raven-default-init-net.c contiki-raven-main.c \ - sicslow_ethernet.c queuebuf.c packetbuf.c\ + sicslow_ethernet.c queuebuf.c packetbuf.c \ + $(RPL) \ $(USB) USB_INCLUDES = -I$(CONTIKI_CPU)/dev/usb diff --git a/platform/avr-ravenusb/contiki-conf.h b/platform/avr-ravenusb/contiki-conf.h index eb89d94d7..be795be39 100644 --- a/platform/avr-ravenusb/contiki-conf.h +++ b/platform/avr-ravenusb/contiki-conf.h @@ -33,29 +33,27 @@ /** * \file - * Configuration for sample STK 501 Contiki kernel + * Configuration for RZRAVEN USB stick "jackdaw" * * \author - * Simon Barner + * David Kopf */ #ifndef __CONTIKI_CONF_H__ #define __CONTIKI_CONF_H__ -#include - -typedef int32_t s32_t; - -/* - * MCU and clock rate - */ +/* MCU and clock rate */ #define MCU_MHZ 8 #define PLATFORM PLATFORM_AVR #define RAVEN_REVISION RAVENUSB_C -/* Cock ticks per second */ +/* Clock ticks per second */ #define CLOCK_CONF_SECOND 125 +/* Since clock_time_t is 16 bits, maximum interval is 524 seconds */ +#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /*Default uses 600*/ + /* Maximum time interval (used for timers) */ #define INFINITE_TIME 0xffff @@ -106,8 +104,10 @@ typedef int32_t s32_t; #define UIP_CONF_TCP_SPLIT 1 #define UIP_CONF_STATISTICS 1 -#define USB_CONF_CDC 1 +/* Disable mass storage enumeration for more debug string space */ #define USB_CONF_STORAGE 1 +/* Use either USB CDC or RS232 for stdout (or neither) */ +#define USB_CONF_CDC 1 //#define USB_CONF_RS232 1 #ifdef RF230BB @@ -158,6 +158,54 @@ typedef int32_t s32_t; #error Network configuration not specified! #endif /* Network setup */ +#if 0 /* RPL */ +/* Not completely working yet. Link local pings work but address prefixes do not get assigned */ +/* Since the jackdaw has no uip stack additional modules must be included, uncomment the line in /plaftorm/avr-ravenusb/Makefile.avr-ravenusb */ + +//#define UIP_CONF_ROUTER 1 +#define UIP_CONF_IPV6_RPL 1 +#undef UIP_CONF_TCP +#define UIP_CONF_TCP 0 +//#undef UIP_FALLBACK_INTERFACE +//#define UIP_FALLBACK_INTERFACE rpl_interface + +#if 0 //too much RAM! +/* Handle 10 neighbors */ +#define UIP_CONF_DS6_NBR_NBU 10 +/* Handle 10 routes */ +#define UIP_CONF_DS6_ROUTE_NBU 10 + +#define UIP_CONF_ND6_SEND_RA 0 +#define UIP_CONF_ND6_REACHABLE_TIME 600000 +#define UIP_CONF_ND6_RETRANS_TIMER 10000 +#undef UIP_CONF_IPV6_QUEUE_PKT +#define UIP_CONF_IPV6_QUEUE_PKT 1 +//#define UIP_CONF_IPV6_CHECKS 1 +#define UIP_CONF_NETIF_MAX_ADDRESSES 3 +#define UIP_CONF_ND6_MAX_PREFIXES 3 +#define UIP_CONF_ND6_MAX_NEIGHBORS 4 +#define UIP_CONF_ND6_MAX_DEFROUTERS 2 +#define UIP_CONF_IP_FORWARD 0 +#define UIP_CONF_BUFFER_SIZE 240 +#define UIP_CONF_ICMP_DEST_UNREACH 1 +#define UIP_CONF_DHCP_LIGHT + +#undef UIP_CONF_LLH_LEN +#define UIP_CONF_LLH_LEN 0 +//#define UIP_CONF_RECEIVE_WINDOW 48 +//#define UIP_CONF_TCP_MSS 48 +#undef UIP_CONF_UDP_CONNS +#define UIP_CONF_UDP_CONNS 12 +#undef UIP_CONF_FWCACHE_SIZE +#define UIP_CONF_FWCACHE_SIZE 30 +#define UIP_CONF_BROADCAST 1 +#define UIP_ARCH_IPCHKSUM 1 +#define UIP_CONF_PINGADDRCONF 0 +#define UIP_CONF_LOGGING 0 +#endif +#endif /* RPL */ + + #endif /* RF230BB */ /* Route-Under-MAC uses 16-bit short addresses */ @@ -166,6 +214,9 @@ typedef int32_t s32_t; #define UIP_DATA_RUM_OFFSET 5 #endif +#include + +typedef int32_t s32_t; typedef unsigned short clock_time_t; typedef unsigned char u8_t; typedef unsigned short u16_t; diff --git a/platform/avr-ravenusb/contiki-raven-main.c b/platform/avr-ravenusb/contiki-raven-main.c index 52cb65d97..e221db69f 100644 --- a/platform/avr-ravenusb/contiki-raven-main.c +++ b/platform/avr-ravenusb/contiki-raven-main.c @@ -178,7 +178,7 @@ static void initialize(void) { memcpy(&uip_lladdr.addr, &addr.u8, 8); rf230_set_pan_addr(IEEE802154_PANID, 0, (uint8_t *)&addr.u8); - rf230_set_channel(24); + rf230_set_channel(26); rimeaddr_set_node_addr(&addr); // set_rime_addr(); @@ -189,11 +189,6 @@ static void initialize(void) { NETSTACK_MAC.init(); NETSTACK_NETWORK.init(); -#if UIP_CONF_ROUTER - rime_init(rime_udp_init(NULL)); - uip_router_register(&rimeroute); -#endif - #if ANNOUNCE && USB_CONF_RS232 printf_P(PSTR("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n"),addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]); printf_P(PSTR("%s %s, channel %u"),NETSTACK_MAC.name, NETSTACK_RDC.name,rf230_get_channel()); @@ -206,6 +201,14 @@ static void initialize(void) { printf_P(PSTR("\n")); #endif +#if UIP_CONF_IPV6_RPL +/* Normally tcpip process does this, but we don't have one. + * A Compiler warning will occur since no rpl.h header include + * Still experimental, pings work to link local address only + */ + rpl_init(); +#endif + #else /* RF230BB */ /* The order of starting these is important! */ process_start(&mac_process, NULL); diff --git a/platform/avr-ravenusb/sicslow_ethernet.c b/platform/avr-ravenusb/sicslow_ethernet.c index fab2d3e9f..4e84f1e7b 100644 --- a/platform/avr-ravenusb/sicslow_ethernet.c +++ b/platform/avr-ravenusb/sicslow_ethernet.c @@ -294,6 +294,12 @@ uint8_t prefixBuffer[PREFIX_BUFFER_SIZE][3]; /* 6lowpan max size + ethernet header size + 1 */ uint8_t raw_buf[127+ UIP_LLH_LEN +1]; +/* RPL uses some core tcpip routines which includes another tcpip_input */ +#if UIP_CONF_IPV6_RPL +#warning --------------------------------------------------------------- +#warning For RPL comment out the tcpip_input routine in core/net/tcpip.c +#warning --------------------------------------------------------------- +#endif void tcpip_input( void ) { // printf("tcpip_input");