From 38267bfd5a932d044f683ab97bcc671ed9feeaf7 Mon Sep 17 00:00:00 2001 From: David Kopf Date: Sat, 11 Feb 2012 14:58:35 -0500 Subject: [PATCH 01/11] Webserver-nano: Add page load times, remove workaround code for bug in arm strformat.c, correct the double count of leading zeros there. --- apps/webserver-nano/httpd-cgi.c | 54 +++++++++++-------------------- apps/webserver-nano/httpd.c | 3 ++ apps/webserver-nano/httpd.h | 49 +++++++++++++++++++++++++++- cpu/arm/common/dbg-io/strformat.c | 1 + 4 files changed, 71 insertions(+), 36 deletions(-) diff --git a/apps/webserver-nano/httpd-cgi.c b/apps/webserver-nano/httpd-cgi.c index fa72a6340..9d62bc5b9 100644 --- a/apps/webserver-nano/httpd-cgi.c +++ b/apps/webserver-nano/httpd-cgi.c @@ -259,12 +259,16 @@ PT_THREAD(header(struct httpd_state *s, char *ptr)) #endif /* WEBSERVER_CONF_HEADER */ #if WEBSERVER_CONF_FILESTATS -static char *thisfilename; //todo move to s->ptr /*---------------------------------------------------------------------------*/ static unsigned short generate_file_stats(void *arg) { + struct httpd_state *s = (struct httpd_state *)arg; +#if WEBSERVER_CONF_LOADTIME + static const char httpd_cgi_filestat1[] HTTPD_STRING_ATTR = "



This page has been sent %u times (%1u.%u sec)"; +#else static const char httpd_cgi_filestat1[] HTTPD_STRING_ATTR = "



This page has been sent %u times"; +#endif static const char httpd_cgi_filestat2[] HTTPD_STRING_ATTR = "%s%d"; static const char httpd_cgi_filestat3[] HTTPD_STRING_ATTR = "%5u"; char tmp[20]; @@ -272,11 +276,17 @@ generate_file_stats(void *arg) u16_t i; unsigned short numprinted; /* Transfer arg from whichever flash that contains the html file to RAM */ - httpd_fs_cpy(&tmp, (char *)arg, 20); + httpd_fs_cpy(&tmp, s->u.ptr, 20); /* Count for this page, with common page footer */ if (tmp[0]=='.') { - numprinted=httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_filestat1, httpd_fs_open(thisfilename, 0)); +#if WEBSERVER_CONF_LOADTIME + s->pagetime = clock_time() - s->pagetime; + numprinted=httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_filestat1, httpd_fs_open(s->filename, 0), + (unsigned int)s->pagetime/CLOCK_SECOND,(unsigned int)s->pagetime%CLOCK_SECOND); +#else + numprinted=httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_filestat1, httpd_fs_open(s->filename, 0)); +#endif /* Count for all files */ /* Note buffer will overflow if there are too many files! */ @@ -310,13 +320,10 @@ PT_THREAD(file_stats(struct httpd_state *s, char *ptr)) { PSOCK_BEGIN(&s->sout); -//printf("s->filename is %c%c%c%c%c%c",s->filename[0],s->filename[1],s->filename[2],s->filename[3],s->filename[4],s->filename[5]); -//printf("s->filename string is %s",s->filename); - thisfilename=&s->filename[0]; //temporary way to pass filename to generate_file_stats -// printf("thisfilename is %s",thisfilename); //minimal net wants this - - PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, (void *) ptr); + /* Pass string after cgi invocation to the generator */ + s->u.ptr = ptr; + PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, s); PSOCK_END(&s->sout); } @@ -632,12 +639,6 @@ uint8_t c; h=h-days*24; numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor3d, days,h,m,s); } -/* TODO: some gcc's have a bug with %02d format that adds an extra char after the string terminator. - * Seen with arm-none-eabi-gcc.exe (Sourcery G++ Lite 2008q3-66) 4.3.2 - * Quick cosmetic fix to strip that off: */ - if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;} - else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;} - else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;} #if 0 if (sleepseconds) { @@ -667,25 +668,14 @@ uint8_t c; sl=energest_total_time[ENERGEST_TYPE_CPU].current/RTIMER_ARCH_SECOND; h=(10000UL*sl)/seconds;p1=h/100;p2=h-p1*100;h=sl/3600;s=sl-h*3600;m=s/60;s=s-m*60; numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor4, h,m,s,p1,p2); - if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;} - else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;} - else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;} - else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;} sl=energest_total_time[ENERGEST_TYPE_TRANSMIT].current/RTIMER_ARCH_SECOND; h=(10000UL*sl)/seconds;p1=h/100;p2=h-p1*100;h=sl/3600;s=sl-h*3600;m=s/60;s=s-m*60; numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor10, h,m,s,p1,p2); - if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;} - else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;} - else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;} - else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;} + sl=energest_total_time[ENERGEST_TYPE_LISTEN].current/RTIMER_ARCH_SECOND; h=(10000UL*sl)/seconds;p1=h/100;p2=h-p1*100;h=sl/3600;s=sl-h*3600;m=s/60;s=s-m*60; numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor11, h,m,s,p1,p2); - if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;} - else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;} - else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;} - else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;} } #endif /* ENERGEST_CONF_ON */ @@ -700,18 +690,12 @@ uint8_t c; h=((10000UL*compower_idle_activity.transmit)/RTIMER_ARCH_SECOND)/seconds; p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60; numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor31, h,m,s,p1,p2); - if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;} - else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;} - else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;} - else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;} + s=compower_idle_activity.listen/RTIMER_ARCH_SECOND; h=((10000UL*compower_idle_activity.listen)/RTIMER_ARCH_SECOND)/seconds; p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60; numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor32, h,m,s,p1,p2); - if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;} - else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;} - else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;} - else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;} + } #endif diff --git a/apps/webserver-nano/httpd.c b/apps/webserver-nano/httpd.c index 6c4afa72f..7971832b8 100644 --- a/apps/webserver-nano/httpd.c +++ b/apps/webserver-nano/httpd.c @@ -432,6 +432,9 @@ PT_THREAD(handle_input(struct httpd_state *s)) #if WEBSERVER_CONF_LOG webserver_log_file(&uip_conn->ripaddr, s->filename); // webserver_log(httpd_query); +#endif +#if WEBSERVER_CONF_LOADTIME + s->pagetime = clock_time(); #endif s->state = STATE_OUTPUT; while(1) { diff --git a/apps/webserver-nano/httpd.h b/apps/webserver-nano/httpd.h index 0ea508d9d..6233edf81 100644 --- a/apps/webserver-nano/httpd.h +++ b/apps/webserver-nano/httpd.h @@ -52,6 +52,8 @@ #ifndef WEBSERVER_CONF_NANO #if CONTIKI_TARGET_SKY || CONTIKI_TARGET_STK500 #define WEBSERVER_CONF_NANO 1 +#elif CONTIKI_TARGET_REDBEE_ECONOTAG || CONTIKI_TARGET_AVR_RAVEN || CONTIKI_TARGET_AVR_ATMEGA128RFA1 +#define WEBSERVER_CONF_NANO 2 #else #define WEBSERVER_CONF_NANO 3 #endif @@ -73,6 +75,7 @@ //#define WEBSERVER_CONF_HEADER_W3C 1 //Proper header #define WEBSERVER_CONF_HEADER_MENU 1 //with links to other pages //#define WEBSERVER_CONF_HEADER_ICON 1 //with favicon +#define WEBSERVER_CONF_LOADTIME 0 //show load time in filestats #define WEBSERVER_CONF_FILESTATS 1 #define WEBSERVER_CONF_TCPSTATS 0 #define WEBSERVER_CONF_PROCESSES 0 @@ -101,7 +104,47 @@ extern char httpd_query[WEBSERVER_CONF_PASSQUERY]; #elif WEBSERVER_CONF_NANO==2 /* webserver-mini having more content */ -#error webserver-micro not implemented +#define WEBSERVER_CONF_CONNS 2 +#define WEBSERVER_CONF_NAMESIZE 20 +#define WEBSERVER_CONF_BUFSIZE 40 +/* Allow include in .shtml pages, e.g. %!: /header.html */ +#define WEBSERVER_CONF_INCLUDE 1 +/* Allow cgi in .shtml pages, e.g. %! file-stats . */ +#define WEBSERVER_CONF_CGI 1 +/* MAX_SCRIPT_NAME_LENGTH should be at least the maximum file name length+2 for %!: includes */ +#define MAX_SCRIPT_NAME_LENGTH WEBSERVER_CONF_NAMESIZE+2 +/* Enable specific cgi's */ +#define WEBSERVER_CONF_HEADER 1 +//#define WEBSERVER_CONF_HEADER_W3C 1 //Proper header +#define WEBSERVER_CONF_HEADER_MENU 1 //with links to other pages +//#define WEBSERVER_CONF_HEADER_ICON 1 //with favicon +#define WEBSERVER_CONF_LOADTIME 1 +#define WEBSERVER_CONF_FILESTATS 1 +#define WEBSERVER_CONF_TCPSTATS 1 +#define WEBSERVER_CONF_PROCESSES 1 +#define WEBSERVER_CONF_ADDRESSES 1 +#define WEBSERVER_CONF_NEIGHBORS 1 +#define WEBSERVER_CONF_ROUTES 1 +#define WEBSERVER_CONF_SENSORS 1 +//#define WEBSERVER_CONF_TICTACTOE 1 //Needs passquery of at least 10 chars +#define WEBSERVER_CONF_AJAX 1 +//#define WEBSERVER_CONF_PASSQUERY 10 +#if WEBSERVER_CONF_PASSQUERY +extern char httpd_query[WEBSERVER_CONF_PASSQUERY]; +#endif +/* Enable specific file types */ +#define WEBSERVER_CONF_JPG 1 +#define WEBSERVER_CONF_PNG 1 +#define WEBSERVER_CONF_GIF 1 +#define WEBSERVER_CONF_TXT 1 +#define WEBSERVER_CONF_CSS 1 +#define WEBSERVER_CONF_BIN 1 + +/* Log page accesses */ +#define WEBSERVER_CONF_LOG 1 +/* Include referrer in log */ +#define WEBSERVER_CONF_REFERER 1 + #elif WEBSERVER_CONF_NANO==3 /* webserver-mini having all content */ @@ -119,6 +162,7 @@ extern char httpd_query[WEBSERVER_CONF_PASSQUERY]; //#define WEBSERVER_CONF_HEADER_W3C 1 //Proper header #define WEBSERVER_CONF_HEADER_MENU 1 //with links to other pages //#define WEBSERVER_CONF_HEADER_ICON 1 //with favicon +#define WEBSERVER_CONF_LOADTIME 1 #define WEBSERVER_CONF_FILESTATS 1 #define WEBSERVER_CONF_TCPSTATS 1 #define WEBSERVER_CONF_PROCESSES 1 @@ -213,6 +257,9 @@ struct httpd_state { char *scriptptr; int scriptlen; #endif +#if WEBSERVER_CONF_LOADTIME + clock_time_t pagetime; +#endif #if WEBSERVER_CONF_CGI union { unsigned short count; diff --git a/cpu/arm/common/dbg-io/strformat.c b/cpu/arm/common/dbg-io/strformat.c index a7834152b..13b91a563 100644 --- a/cpu/arm/common/dbg-io/strformat.c +++ b/cpu/arm/common/dbg-io/strformat.c @@ -503,6 +503,7 @@ format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap) if ((flags & JUSTIFY_MASK) == JUSTIFY_RIGHT) { if (flags & PAD_ZERO) { precision_fill += field_fill; + field_fill = 0; /* Do not double count padding */ } else { CHECKCB(fill_space(ctxt,field_fill)); } From 9d6542d49b3c13b2818486b16c9b0375fb3ce6e0 Mon Sep 17 00:00:00 2001 From: David Kopf Date: Sat, 11 Feb 2012 15:03:24 -0500 Subject: [PATCH 02/11] Fix minimal-net webserver6, broken after native border router changes. --- cpu/native/net/wpcap-drv.c | 3 +-- cpu/native/net/wpcap.c | 13 +++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cpu/native/net/wpcap-drv.c b/cpu/native/net/wpcap-drv.c index e447ed84c..bbba1bdf4 100644 --- a/cpu/native/net/wpcap-drv.c +++ b/cpu/native/net/wpcap-drv.c @@ -28,7 +28,6 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: wpcap-drv.c,v 1.7 2010/10/19 18:29:04 adamdunkels Exp $ */ #include "contiki-net.h" @@ -86,7 +85,7 @@ pollhandler(void) if(uip_len > 0) { #if UIP_CONF_IPV6 if(BUF->type == uip_htons(UIP_ETHTYPE_IPV6)) { - printf("wpcap poll calls tcpip"); +// printf("wpcap poll calls tcpip"); tcpip_input(); } else #endif /* UIP_CONF_IPV6 */ diff --git a/cpu/native/net/wpcap.c b/cpu/native/net/wpcap.c index b289322fb..6daf737ec 100644 --- a/cpu/native/net/wpcap.c +++ b/cpu/native/net/wpcap.c @@ -167,6 +167,10 @@ static struct pcap *(* pcap_open_live)(char *, int, int, int, char *); static int (* pcap_next_ex)(struct pcap *, struct pcap_pkthdr **, unsigned char **); static int (* pcap_sendpacket)(struct pcap *, unsigned char *, int); +#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) +#define BUF ((struct uip_eth_hdr *)&uip_buf[0]) +#define IPBUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN]) + #ifdef UIP_FALLBACK_INTERFACE static struct pcap *pfall; struct in_addr addrfall; @@ -183,14 +187,9 @@ init(void) /*---------------------------------------------------------------------------*/ u8_t wfall_send(uip_lladdr_t *lladdr); #if FALLBACK_HAS_ETHERNET_HEADERS -#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) -#define BUF ((struct uip_eth_hdr *)&uip_buf[0]) +#undef IPBUF #define IPBUF ((struct uip_tcpip_hdr *)&uip_buf[14]) static uip_ipaddr_t last_sender; -#else -#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) -#define BUF ((struct uip_eth_hdr *)&uip_buf[0]) -#define IPBUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN]) #endif static void @@ -375,6 +374,8 @@ init_pcap(struct in_addr addr) } #ifdef UIP_FALLBACK_INTERFACE log_message("init_pcap: Opened as primary interface",""); +#else + log_message("init_pcap: Opened as interface",""); #endif // pcap_setdirection(PCAP_D_IN); //Not implemented in windows yet? set_ethaddr(addr); From 0327fe30201889de1558a9d73d85ec4102d3bb5e Mon Sep 17 00:00:00 2001 From: David Kopf Date: Sat, 11 Feb 2012 15:15:00 -0500 Subject: [PATCH 03/11] Turn off RDC before SLIP prefix interchange. Disable SIN/SUT prints, leave off-route prints. --- examples/ipv6/rpl-border-router/border-router.c | 11 +++++++---- examples/ipv6/rpl-border-router/slip-bridge.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/ipv6/rpl-border-router/border-router.c b/examples/ipv6/rpl-border-router/border-router.c index db1b1058d..418425ff9 100644 --- a/examples/ipv6/rpl-border-router/border-router.c +++ b/examples/ipv6/rpl-border-router/border-router.c @@ -225,6 +225,7 @@ PROCESS_THREAD(border_router_process, ev, data) rpl_dag_t *dag; PROCESS_BEGIN(); + prefix_set = 0; PROCESS_PAUSE(); @@ -233,6 +234,12 @@ PROCESS_THREAD(border_router_process, ev, data) PRINTF("RPL-Border router started\n"); + /* The border router runs with a 100% duty cycle in order to ensure high + packet reception rates. + Note if the MAC RDC is not turned off now, aggressive power management of the + cpu will interfere with establishing the SLIP connection */ + NETSTACK_MAC.off(1); + /* Request prefix until it has been received */ while(!prefix_set) { etimer_set(&et, CLOCK_SECOND); @@ -250,10 +257,6 @@ PROCESS_THREAD(border_router_process, ev, data) print_local_addresses(); #endif - /* The border router runs with a 100% duty cycle in order to ensure high - packet reception rates. */ - NETSTACK_MAC.off(1); - while(1) { PROCESS_YIELD(); if (ev == sensors_event && data == &button_sensor) { diff --git a/examples/ipv6/rpl-border-router/slip-bridge.c b/examples/ipv6/rpl-border-router/slip-bridge.c index 61ea5a358..3b4d26af7 100644 --- a/examples/ipv6/rpl-border-router/slip-bridge.c +++ b/examples/ipv6/rpl-border-router/slip-bridge.c @@ -57,7 +57,7 @@ static uip_ipaddr_t last_sender; static void slip_input_callback(void) { - PRINTF("SIN: %u\n", uip_len); + // PRINTF("SIN: %u\n", uip_len); if(uip_buf[0] == '!') { PRINTF("Got configuration message of type %c\n", uip_buf[1]); uip_len = 0; @@ -113,7 +113,7 @@ output(void) PRINT6ADDR(&UIP_IP_BUF->destipaddr); PRINTF("\n"); } else { - PRINTF("SUT: %u\n", uip_len); + // PRINTF("SUT: %u\n", uip_len); slip_send(); } } From 20a5c794dd1c83151a9087903b88550b7f1f7834 Mon Sep 17 00:00:00 2001 From: David Kopf Date: Sat, 11 Feb 2012 15:19:28 -0500 Subject: [PATCH 04/11] Move address initialization to after proce_init. Something in that now wiping the address array. --- platform/minimal-net/contiki-main.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/platform/minimal-net/contiki-main.c b/platform/minimal-net/contiki-main.c index 9e28979f9..cf09c2718 100644 --- a/platform/minimal-net/contiki-main.c +++ b/platform/minimal-net/contiki-main.c @@ -29,7 +29,6 @@ * * This file is part of the Contiki OS * - * $Id: contiki-main.c,v 1.25 2010/10/19 18:29:05 adamdunkels Exp $ * */ @@ -222,6 +221,9 @@ main(void) printf("RPL enabled\n"); #endif + procinit_init(); + autostart_start(autostart_processes); + /* Set default IP addresses if not specified */ #if !UIP_CONF_IPV6 { @@ -274,7 +276,17 @@ main(void) } #endif /* !UIP_CONF_IPV6_RPL */ -#if !RPL_BORDER_ROUTER /* Border router process prints addresses later */ +#endif /* !UIP_CONF_IPV6 */ + + // procinit_init(); + // autostart_start(autostart_processes); + + /* Make standard output unbuffered. */ + setvbuf(stdout, (char *)NULL, _IONBF, 0); + + printf("\n*******%s online*******\n",CONTIKI_VERSION_STRING); + +#if UIP_CONF_IPV6 && !RPL_BORDER_ROUTER /* Border router process prints addresses later */ { uint8_t i; for(i = 0; i < UIP_DS6_ADDR_NB; i++) { @@ -285,16 +297,7 @@ main(void) } } } -#endif /* !RPL_BORDER_ROUTER */ -#endif /* !UIP_CONF_IPV6 */ - - procinit_init(); - autostart_start(autostart_processes); - - /* Make standard output unbuffered. */ - setvbuf(stdout, (char *)NULL, _IONBF, 0); - - printf("\n*******%s online*******\n",CONTIKI_VERSION_STRING); +#endif while(1) { fd_set fds; From 9f54eeacd70abec6ed2d6dd992eab6866a2da158 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Sat, 4 Feb 2012 21:50:43 -0500 Subject: [PATCH 05/11] Provide a way to add additional APPS search directories. E.g. in a makefile do: APPDIRS += ${addprefix ../apps/, $(APPS)} --- Makefile.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.include b/Makefile.include index 68cba85bb..710725806 100644 --- a/Makefile.include +++ b/Makefile.include @@ -93,9 +93,9 @@ PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFI ifdef APPS APPDIRS += ${wildcard ${addprefix $(CONTIKI)/apps/, $(APPS)} \ - ${addprefix $(CONTIKI)/platform/$(TARGET)/apps/, $(APPS)} \ - ${addprefix , $(APPS)}} - APPINCLUDES = ${foreach APP, $(APPS), ${wildcard \ + ${addprefix $(CONTIKI)/platform/$(TARGET)/apps/, $(APPS)} \ + ${addprefix , $(APPS)}} + APPINCLUDES = ${foreach APP, $(APPS), ${wildcard ${foreach DIR, $(APPDIRS), $(DIR)/Makefile.$(APP)} \ $(CONTIKI)/apps/$(APP)/Makefile.$(APP) \ $(CONTIKI)/platform/$(TARGET)/apps/$(APP)/Makefile.$(APP) \ $(APP)/Makefile.$(APP)}} From e13dc1d5eef200d13d8f3ecb4b3edfd779c81f67 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Fri, 10 Feb 2012 10:57:37 -0500 Subject: [PATCH 06/11] Provide a way to add additional TARGET search directories. E.g. in a makefile do: TARGETDIRS += ../targets This will search for targets in ../targets as well as $(CONTIKI)/platforms A error will occur if more than one targets with the same name are found. --- Makefile.include | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile.include b/Makefile.include index 710725806..ceccb9c7b 100644 --- a/Makefile.include +++ b/Makefile.include @@ -107,7 +107,7 @@ endif ### Include target makefile (TODO Unsafe?) -target_makefile := $(wildcard $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET)) +target_makefile := $(wildcard ${realpath $(CONTIKI)}/platform/$(TARGET)/Makefile.$(TARGET) ${foreach TDIR, $(TARGETDIRS), $(TDIR)/$(TARGET)/Makefile.$(TARGET)}) # Check if the target makefile exists, and create the object directory if necessary. ifeq ($(strip $(target_makefile)),) @@ -116,7 +116,10 @@ else ifeq (${wildcard $(OBJECTDIR)},) DUMMY := ${shell mkdir $(OBJECTDIR)} endif - include $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET) + ifneq (1, ${words $(target_makefile)}) + ${error More than one TARGET Makefile found: $(target_makefile)} + endif + include $(target_makefile) endif ### Forward comma-separated list of arbitrary defines to the compiler @@ -126,13 +129,13 @@ CFLAGS += ${addprefix -D,${subst $(COMMA), ,$(DEFINES)}} ### Setup directory search path for source and header files -CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \ +CONTIKI_TARGET_DIRS_CONCAT = ${addprefix ${dir $(target_makefile)}, \ $(CONTIKI_TARGET_DIRS)} CONTIKI_CPU_DIRS_CONCAT = ${addprefix $(CONTIKI_CPU)/, \ $(CONTIKI_CPU_DIRS)} SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) \ - $(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(APPDIRS) + $(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(APPDIRS) ${dir $(target_makefile)} vpath %.c $(SOURCEDIRS) vpath %.S $(SOURCEDIRS) From bde97a0356f3fd2de2ca0d76b17cc075fadca91f Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Fri, 10 Feb 2012 11:51:35 -0500 Subject: [PATCH 07/11] add emacs mode hint to Makefile.include --- Makefile.include | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.include b/Makefile.include index ceccb9c7b..e8251c921 100644 --- a/Makefile.include +++ b/Makefile.include @@ -1,3 +1,5 @@ +# -*- makefile -*- + ifndef CONTIKI ${error CONTIKI not defined! You must specify where CONTIKI resides} endif From ee8f2c669e8813bc467af9578ba744e260ccc909 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Fri, 10 Feb 2012 11:04:23 -0500 Subject: [PATCH 08/11] mc1322x: remove symbols.{c,h} --- cpu/mc1322x/Makefile.mc1322x | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cpu/mc1322x/Makefile.mc1322x b/cpu/mc1322x/Makefile.mc1322x index de691bd88..724570a13 100644 --- a/cpu/mc1322x/Makefile.mc1322x +++ b/cpu/mc1322x/Makefile.mc1322x @@ -107,14 +107,10 @@ CUSTOM_RULE_C_TO_CO=yes %_$(TARGET).bin: %.elf $(OBJCOPY) -O binary $< $@ -symbols.c: - cp ${CONTIKI}/tools/empty-symbols.c symbols.c - cp ${CONTIKI}/tools/empty-symbols.h symbols.h - %.$(TARGET): %_$(TARGET).bin @ -%.elf: $(OBJECTDIR)/board.h %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a $(STARTUP) $(OBJECTDIR)/symbols.o +%.elf: $(OBJECTDIR)/board.h %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a $(STARTUP) $(CC) $(LDFLAGS) $(CFLAGS) -nostartfiles -o $@ $(filter-out %.a,$^) $(filter %.a,$^) $(filter %.a,$^) From 43062b6d74ca8cf093c065322e41fa740d4ad3ea Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Fri, 10 Feb 2012 11:01:59 -0500 Subject: [PATCH 09/11] mc1322x: change how board.h works to allow default board.h (defaults to econotag) --- cpu/mc1322x/Makefile.mc1322x | 4 ++-- cpu/mc1322x/board/Makefile.board | 20 -------------------- cpu/mc1322x/board/board.h | 8 ++++++++ 3 files changed, 10 insertions(+), 22 deletions(-) delete mode 100644 cpu/mc1322x/board/Makefile.board create mode 100644 cpu/mc1322x/board/board.h diff --git a/cpu/mc1322x/Makefile.mc1322x b/cpu/mc1322x/Makefile.mc1322x index 724570a13..dd9d48162 100644 --- a/cpu/mc1322x/Makefile.mc1322x +++ b/cpu/mc1322x/Makefile.mc1322x @@ -74,9 +74,9 @@ CFLAGS += -I$(OBJECTDIR) -I$(CONTIKI_CPU)/board -DBOARD=$(TARGET) $(OBJECTDIR)/board.h: $(OBJECTDIR) ifneq (,$(findstring Windows,$(OS))) ${info Cygwin detected.} - ln -f $(CONTIKI_CPU)/board/$(TARGET).h $(OBJECTDIR)/board.h + ln -f $(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h else - ln -sf ../$(CONTIKI_CPU)/board/$(TARGET).h $(OBJECTDIR)/board.h + ln -sf ../$(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h endif diff --git a/cpu/mc1322x/board/Makefile.board b/cpu/mc1322x/board/Makefile.board deleted file mode 100644 index a5b2cb800..000000000 --- a/cpu/mc1322x/board/Makefile.board +++ /dev/null @@ -1,20 +0,0 @@ -# -*- makefile -*- - -BOARDS := redbee-dev redbee-r1 redbee-usb redbee-econotag quahogcon freescale-ncb - -OBJDIR := obj_$(BOARD)_board -CFLAGS += -I$(OBJDIR) -I$(MC1322X)/board -DBOARD=$(BOARD) - -$(OBJDIR): -ifndef BOARD - ${warning BOARD not defined} - ${warning echo "make BOARD=foo"} - ${warning "boards: $(BOARDS)"} - ${error you must define BOARD} -endif - @echo "setup object directory for dev board" - mkdir $(OBJDIR) - -$(OBJDIR)/board.h: $(OBJDIR) - ln -sf ../$(MC1322X)/board/$(BOARD).h $(OBJDIR)/board.h - diff --git a/cpu/mc1322x/board/board.h b/cpu/mc1322x/board/board.h new file mode 100644 index 000000000..7ecf4a389 --- /dev/null +++ b/cpu/mc1322x/board/board.h @@ -0,0 +1,8 @@ +#ifndef BOARD +BOARD = redbee-econotag +#endif + +#if BOARD == redbee-econotag +#include "redbee-econotag.h" +#endif + From 2c9316c5fa0cc3e034fc9a4b6e3c6e0918f9b1df Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Thu, 16 Feb 2012 15:51:32 +0100 Subject: [PATCH 10/11] more informative error messages at simulation error --- .../apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java | 6 +++++- tools/cooja/java/se/sics/cooja/Simulation.java | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java index 73fb45907..f71d29fe2 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java @@ -335,7 +335,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc if (t < lastExecute) { throw new RuntimeException("Bad event ordering: " + lastExecute + " < " + t); } - + /* Execute MSPSim-based mote */ /* TODO Try-catch overhead */ try { @@ -345,6 +345,10 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc lastExecute = t; } catch (EmulationException e) { String stackTraceOutput = sendCLICommandAndPrint("stacktrace"); + if (stackTraceOutput == null) { + stackTraceOutput = ""; + } + stackTraceOutput = e.getMessage() + "\n\n" + stackTraceOutput; throw (ContikiError) new ContikiError(stackTraceOutput).initCause(e); } diff --git a/tools/cooja/java/se/sics/cooja/Simulation.java b/tools/cooja/java/se/sics/cooja/Simulation.java index 6d01be202..972acda22 100644 --- a/tools/cooja/java/se/sics/cooja/Simulation.java +++ b/tools/cooja/java/se/sics/cooja/Simulation.java @@ -253,8 +253,8 @@ public class Simulation extends Observable implements Runnable { this.setChanged(); this.notifyObservers(this); + TimeEvent nextEvent = null; try { - TimeEvent nextEvent; while (isRunning) { /* Handle all poll requests */ @@ -289,7 +289,11 @@ public class Simulation extends Observable implements Runnable { /* Quit simulator if in test mode */ System.exit(1); } else { - GUI.showErrorDialog(GUI.getTopParentContainer(), "Simulation error", e, false); + String title = "Simulation error"; + if (nextEvent instanceof MoteTimeEvent) { + title += ": " + ((MoteTimeEvent)nextEvent).getMote(); + } + GUI.showErrorDialog(GUI.getTopParentContainer(), title, e, false); } } } From 68591919e6d2dd32a8a6b882abb9a2c541727582 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Thu, 16 Feb 2012 11:17:15 -0500 Subject: [PATCH 11/11] mc1322x: add -MMD to Makefile.mc1322x to correctly create dependencies --- cpu/mc1322x/Makefile.mc1322x | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/mc1322x/Makefile.mc1322x b/cpu/mc1322x/Makefile.mc1322x index dd9d48162..389185b05 100644 --- a/cpu/mc1322x/Makefile.mc1322x +++ b/cpu/mc1322x/Makefile.mc1322x @@ -58,7 +58,7 @@ CFLAGSNO = -I. -I$(CONTIKI)/core -I$(CONTIKI_CPU) -I$(CONTIKI_CPU)/loader \ -DWITH_ASCII -DMCK=$(MCK) \ -Werror $(ARCH_FLAGS) -g -CFLAGS += $(CFLAGSNO) -Os -DRUN_AS_SYSTEM -DROM_RUN -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -DTEXT_BASE=$(TEXT_BASE) -fno-builtin-printf -fno-builtin-sprintf +CFLAGS += $(CFLAGSNO) -Os -DRUN_AS_SYSTEM -DROM_RUN -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -DTEXT_BASE=$(TEXT_BASE) -fno-builtin-printf -fno-builtin-sprintf -MMD LDFLAGS += -T $(LINKERSCRIPT) -nostartfiles -static -u_start -Wl,-Map=contiki-$(TARGET).map,-export-dynamic AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) -gstabs