From 3d3ad9e2c2b7cc4cdd8791e2eeb17d6b59c514de Mon Sep 17 00:00:00 2001 From: dak664 Date: Wed, 1 Dec 2010 16:23:55 +0000 Subject: [PATCH] Fixes to allow ipv4 (hello world) builds --- examples/hello-world/Makefile | 3 +++ platform/avr-raven/contiki-conf.h | 23 ++++++++++++++++------- platform/avr-ravenusb/contiki-conf.h | 16 ++++++++++------ platform/avr-ravenusb/httpd-simple-avr.c | 10 ++++------ platform/avr-rcb/Makefile.avr-rcb | 12 ++---------- platform/avr-rcb/contiki-conf.h | 5 ++++- platform/avr-rcb/contiki-rcb-main.c | 17 ++++++++++++++++- 7 files changed, 55 insertions(+), 31 deletions(-) diff --git a/examples/hello-world/Makefile b/examples/hello-world/Makefile index 63efcf852..10aeb8ed9 100644 --- a/examples/hello-world/Makefile +++ b/examples/hello-world/Makefile @@ -2,6 +2,9 @@ #make TARGET=avr-raven hello-world.elf #Load the .elf in AVR Studio and connect a hapsim terminal to the 1284p simulation. +#Do $make clean when switching between ipv4 and ipv6 builds on a platform. +#Otherwise the library will contain duplicate or unresolved modules. + CONTIKI_PROJECT = hello-world all: $(CONTIKI_PROJECT) diff --git a/platform/avr-raven/contiki-conf.h b/platform/avr-raven/contiki-conf.h index b6e981877..495bb8318 100644 --- a/platform/avr-raven/contiki-conf.h +++ b/platform/avr-raven/contiki-conf.h @@ -167,25 +167,34 @@ #define UIP_CONF_UDP_CHECKSUMS 1 #define UIP_CONF_TCP_SPLIT 1 -#if 0 /* RPL */ -/* Define these to reduce tx power and ignore weak rx packets for testing a miniature multihop network. +/* ************************************************************************** */ +//#pragma mark RPL Settings +/* ************************************************************************** */ +#if UIP_CONF_IPV6 //Allows hello-world ip4 to compile +#define UIP_CONF_IPV6_RPL 0 +#endif +#if UIP_CONF_IPV6_RPL + +/* Define MAX_*X_POWER to reduce tx power and ignore weak rx packets for testing a miniature multihop network. * Leave undefined for full power and sensitivity. * tx=0 (3dbm, default) to 15 (-17.2dbm) * RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm) * else the rssi register is used having range 0 (91dBm) to 28 (-10dBm) - * For simplicity RF230_MIN_RX_POWER is based on the rssi value and multiplied by 3 when autoack is set. + * For simplicity RF230_MIN_RX_POWER is based on the energy-detect value and divided by 3 when autoack is not set. * On the RF230 a reduced rx power threshold will not prevent autoack if enabled and requested. + * These numbers applied to both Raven and Jackdaw give a maximum communication distance of about 15 cm + * and a 10 meter range to a full-sensitivity RF230 sniffer. */ -#define RF230_MAX_TX_POWER 15 -#define RF230_MIN_RX_POWER 30 +//#define RF230_MAX_TX_POWER 15 +//#define RF230_MIN_RX_POWER 30 #define UIP_CONF_ROUTER 1 #define UIP_CONF_IPV6_RPL 1 /* Handle 10 neighbors */ -#define UIP_CONF_DS6_NBR_NBU 4 +#define UIP_CONF_DS6_NBR_NBU 10 /* Handle 10 routes */ -#define UIP_CONF_DS6_ROUTE_NBU 4 +#define UIP_CONF_DS6_ROUTE_NBU 10 #define UIP_CONF_ND6_SEND_RA 0 #define UIP_CONF_ND6_REACHABLE_TIME 600000 diff --git a/platform/avr-ravenusb/contiki-conf.h b/platform/avr-ravenusb/contiki-conf.h index 6b8730e32..ca3a6ecc3 100644 --- a/platform/avr-ravenusb/contiki-conf.h +++ b/platform/avr-ravenusb/contiki-conf.h @@ -210,7 +210,7 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len); * The tx pad is the middle one behind the jackdaw leds. * RS232 output will work with or without enabling the USB serial port */ -#define USB_CONF_RS232 1 +#define USB_CONF_RS232 0 /* Disable mass storage enumeration for more program space */ //#define USB_CONF_STORAGE 1 /* TODO: Mass storage is currently broken */ @@ -281,8 +281,9 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len); /* ************************************************************************** */ //#pragma mark RPL Settings /* ************************************************************************** */ - +#if UIP_CONF_IPV6 //Allows hello-world ip4 to compile #define UIP_CONF_IPV6_RPL 0 +#endif #if UIP_CONF_IPV6_RPL @@ -297,7 +298,7 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len); buffer_length = uip_len - uip_l2_l3_icmp_hdr_len + UIP_LLH_LEN; //Add jackdaw ethernet header */ -/* Define these to reduce tx power and ignore weak rx packets for testing a miniature multihop network. +/* Define MAX_*X_POWER to reduce tx power and ignore weak rx packets for testing a miniature multihop network. * Leave undefined for full power and sensitivity. * tx=0 (3dbm, default) to 15 (-17.2dbm) * RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm) @@ -311,6 +312,7 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len); //#define RF230_MIN_RX_POWER 30 #define UIP_CONF_ROUTER 1 +#define UIP_CONF_ROUTER_RECEIVE_RA 1 #define RPL_BORDER_ROUTER 1 #define RPL_CONF_STATS 0 #define UIP_CONF_BUFFER_SIZE 1300 @@ -331,9 +333,10 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len); #define UIP_CONF_PINGADDRCONF 0 #define UIP_CONF_LOGGING 0 #undef UIP_CONF_MAX_CONNECTIONS -#define UIP_CONF_MAX_CONNECTIONS 1 +#define UIP_CONF_MAX_CONNECTIONS 2 #undef UIP_CONF_MAX_LISTENPORTS -#define UIP_CONF_MAX_LISTENPORTS 3 +#define UIP_CONF_MAX_LISTENPORTS 2 +#define UIP_CONF_UDP_CONNS 6 /* Optional, TCP needed to serve the RPL neighbor web page currently hard coded at bbbb::11 */ /* The RPL neighbors can also be viewed using the jack menu */ @@ -348,13 +351,14 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len); #define UIP_CONF_DS6_NBR_NBU 5 #undef UIP_CONF_DS6_ROUTE_NBU #define UIP_CONF_DS6_ROUTE_NBU 5 +#undef UIP_CONF_MAX_CONNECTIONS +#define UIP_CONF_MAX_CONNECTIONS 2 #endif #define UIP_CONF_ICMP_DEST_UNREACH 1 #define UIP_CONF_DHCP_LIGHT -#define UIP_CONF_UDP_CONNS 12 #undef UIP_CONF_FWCACHE_SIZE #define UIP_CONF_FWCACHE_SIZE 30 #define UIP_CONF_BROADCAST 1 diff --git a/platform/avr-ravenusb/httpd-simple-avr.c b/platform/avr-ravenusb/httpd-simple-avr.c index c17f64576..6e634f642 100644 --- a/platform/avr-ravenusb/httpd-simple-avr.c +++ b/platform/avr-ravenusb/httpd-simple-avr.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: httpd-simple-avr.c,v 1.5 2010/11/29 21:21:36 dak664 Exp $ + * $Id: httpd-simple-avr.c,v 1.6 2010/12/01 16:23:55 dak664 Exp $ */ /** @@ -253,15 +253,15 @@ extern uip_ds6_route_t uip_ds6_routing_table[]; static PT_THREAD(generate_routes(struct httpd_state *s)) { - static int i; + int i; PSOCK_BEGIN(&s->sout); PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, TOP1); PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, TOP2); +#if UIP_CONF_IPV6 //allow ip4 builds blen = 0; ADD("

Neighbors [%u max]

",UIP_DS6_NBR_NB); -#if UIP_CONF_IPV6 for(i = 0; i < UIP_DS6_NBR_NB; i++) { if(uip_ds6_nbr_cache[i].isused) { ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr); @@ -272,12 +272,10 @@ PT_THREAD(generate_routes(struct httpd_state *s)) // } } } -#endif ADD("

Routes [%u max]

",UIP_DS6_ROUTE_NB); PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf); blen = 0; -#if UIP_CONF_IPV6 for(i = 0; i < UIP_DS6_ROUTE_NB; i++) { if(uip_ds6_routing_table[i].isused) { ipaddr_add(&uip_ds6_routing_table[i].ipaddr); @@ -294,11 +292,11 @@ PT_THREAD(generate_routes(struct httpd_state *s)) blen = 0; } } -#endif if(blen > 0) { PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf); blen = 0; } +#endif /* UIP_CONF_IPV6 */ PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, BOTTOM); diff --git a/platform/avr-rcb/Makefile.avr-rcb b/platform/avr-rcb/Makefile.avr-rcb index d9b2f5b88..96dcd0cd3 100644 --- a/platform/avr-rcb/Makefile.avr-rcb +++ b/platform/avr-rcb/Makefile.avr-rcb @@ -1,4 +1,4 @@ -CONTIKI_TARGET_DIRS = . rf230 apps net loader +CONTIKI_TARGET_DIRS = . apps net loader CONTIKI_CORE=contiki-rcb-main CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o @@ -27,12 +27,4 @@ AVRDUDE_OPTIONS=-V include $(CONTIKIAVR)/Makefile.avr - -# Source for AT86RF230 -include $(CONTIKI)/cpu/avr/radio/rf230/Makefile.rf230 - -# Source for Atmel/Cisco 802.15.4'ish MAC -include $(CONTIKI)/cpu/avr/radio/mac/Makefile.mac - -# Source for IEEE 802.15.4 manager interface -include $(CONTIKI)/cpu/avr/radio/ieee-manager/Makefile.ieee-manager +include $(CONTIKIAVR)/radio/Makefile.radio diff --git a/platform/avr-rcb/contiki-conf.h b/platform/avr-rcb/contiki-conf.h index 313f11fb8..849575b1a 100644 --- a/platform/avr-rcb/contiki-conf.h +++ b/platform/avr-rcb/contiki-conf.h @@ -70,6 +70,8 @@ typedef int32_t s32_t; #define CCIF #define CLIF +//#define UIP_CONF_IPV6 1 //Let makefile determine this so ipv4 hello-world will compile + #define RIMEADDR_CONF_SIZE 8 #define PACKETBUF_CONF_HDR_SIZE 0 @@ -94,7 +96,6 @@ typedef int32_t s32_t; #define UIP_CONF_IP_FORWARD 0 #define UIP_CONF_FWCACHE_SIZE 0 -#define UIP_CONF_IPV6 1 #define UIP_CONF_IPV6_CHECKS 1 #define UIP_CONF_IPV6_QUEUE_PKT 0 #define UIP_CONF_IPV6_REASSEMBLY 0 @@ -102,7 +103,9 @@ typedef int32_t s32_t; #define UIP_CONF_ND6_MAX_PREFIXES 3 #define UIP_CONF_ND6_MAX_NEIGHBORS 4 #define UIP_CONF_ND6_MAX_DEFROUTERS 2 +#if UIP_CONF_IPV6 //tcpip.c error on ipv4 build if UIP_CONF_ICMP6 defined #define UIP_CONF_ICMP6 1 +#endif #define UIP_CONF_UDP 1 #define UIP_CONF_UDP_CHECKSUMS 1 diff --git a/platform/avr-rcb/contiki-rcb-main.c b/platform/avr-rcb/contiki-rcb-main.c index 28504553b..9c562bff8 100644 --- a/platform/avr-rcb/contiki-rcb-main.c +++ b/platform/avr-rcb/contiki-rcb-main.c @@ -39,11 +39,19 @@ #include "lib/mmem.h" #include "loader/symbols-def.h" #include "loader/symtab.h" + +#if RF230BB //radio driver using contiki core mac +#include "radio/rf230bb/rf230bb.h" +#include "net/mac/frame802154.h" +#include "net/mac/framer-802154.h" +#include "net/sicslowpan.h" +#else //radio driver using Atmel/Cisco 802.15.4'ish MAC #include #include "mac.h" #include "sicslowmac.h" #include "sicslowpan.h" #include "ieee-15-4-manager.h" +#endif /*RF230BB*/ #include "contiki.h" #include "contiki-net.h" @@ -65,7 +73,11 @@ FUSES = PROCESS(rcb_leds, "RCB leds process"); +#if RF230BB +PROCINIT(&etimer_process, &tcpip_process, &rcb_leds); +#else PROCINIT(&etimer_process, &mac_process, &tcpip_process, &rcb_leds); +#endif /* Put default MAC address in EEPROM */ uint8_t mac_address[8] EEMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55}; @@ -103,8 +115,11 @@ PROCESS_THREAD(rcb_leds, ev, data) while(1) { PROCESS_YIELD(); - +#if UIP_CONF_IPV6 if (ev == ICMP6_ECHO_REQUEST) { +#else + if (1) { +#endif LEDOn(LED2); etimer_set(&et, CLOCK_SECOND/10); } else {