From 14ad14e7d3d8c49ceaf0fbfdc06d550ba1adda3b Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 17 Dec 2017 01:20:38 +0000 Subject: [PATCH 01/34] Remove nrf52832.a on make clean When building for nrf52dk, `make clean` does not remove `nrf52832.a`. This commit fixes this. --- arch/cpu/nrf52832/Makefile.nrf52832 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/cpu/nrf52832/Makefile.nrf52832 b/arch/cpu/nrf52832/Makefile.nrf52832 index 9f76177bb..567270834 100644 --- a/arch/cpu/nrf52832/Makefile.nrf52832 +++ b/arch/cpu/nrf52832/Makefile.nrf52832 @@ -178,6 +178,8 @@ vpath %.s $(ASM_PATHS) OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS) +CLEAN += nrf52832.a + TARGET_LIBS= nrf52832.a $(NRF52_SDK_ROOT)/components/iot/ble_6lowpan/lib/ble_6lowpan.a nrf52832.a: $(OBJECTS) From 53bbd6f2e8be0b45d59fc552ff63f9b392d8ff5a Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 17 Dec 2017 01:54:43 +0000 Subject: [PATCH 02/34] Gitignore saved defines --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 035e0c7c5..74bef3888 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ *~ obj_* Makefile.target +Makefile.*.defines tools/doxygen/html patches-* tools/tunslip From b5fa28e2d497d1a726f009ef3c4621bec168a759 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 17 Dec 2017 21:31:39 +0000 Subject: [PATCH 03/34] Link without using an archive file For reasons discussed long ago and that have to do with how ld handles weak symbols, it was decided that it was preferable to link using an explicit list of object files, instead of adding object files to an archive first and then linking using this archive. This was applied for the CC2538, but not for CC13xx/CC26xx. This pull applies this link logic to all CM3s. For this to work with the Contiki-NG build system, we need `.SECONDEXPANSION:`, so this pull moves that to the common CM3 Makefile. --- arch/cpu/arm/cortex-m/cm3/Makefile.cm3 | 4 +++- arch/cpu/cc2538/Makefile.cc2538 | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 b/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 index 8baf1651d..a422d3080 100644 --- a/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 +++ b/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 @@ -17,7 +17,9 @@ CPU_STARTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CPU_START_SOURCEFILES ### Compilation rules CUSTOM_RULE_LINK = 1 -%.elf: $(CPU_STARTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(LDSCRIPT) +.SECONDEXPANSION: + +%.elf: $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(LDSCRIPT) $(TRACE_LD) $(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -lm -o $@ diff --git a/arch/cpu/cc2538/Makefile.cc2538 b/arch/cpu/cc2538/Makefile.cc2538 index 18213ca74..c0a2bb2f0 100644 --- a/arch/cpu/cc2538/Makefile.cc2538 +++ b/arch/cpu/cc2538/Makefile.cc2538 @@ -36,8 +36,6 @@ CPU_START_SOURCEFILES = startup-gcc.c CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES) CONTIKI_SOURCEFILES += $(USB_SOURCEFILES) -.SECONDEXPANSION: - ### Always re-build ieee-addr.o in case the command line passes a new NODEID FORCE: From 38987352c445d558db024ca62f327c7b0c978a57 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 17 Dec 2017 22:24:48 +0000 Subject: [PATCH 04/34] Change variables to static --- arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 2 +- arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index a354fdd4b..cf1676570 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -209,7 +209,7 @@ static const output_config_t output_power[] = { #define OUTPUT_POWER_UNKNOWN 0xFFFF /* Default TX Power - position in output_power[] */ -const output_config_t *tx_power_current = &output_power[0]; +static const output_config_t *tx_power_current = &output_power[0]; /*---------------------------------------------------------------------------*/ static volatile int8_t last_rssi = 0; static volatile uint8_t last_corr_lqi = 0; diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index 61581f20a..f9f49e9a0 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -203,7 +203,7 @@ extern const prop_mode_tx_power_config_t TX_POWER_DRIVER[]; #define OUTPUT_POWER_UNKNOWN 0xFFFF /* Default TX Power - position in output_power[] */ -const prop_mode_tx_power_config_t *tx_power_current = &TX_POWER_DRIVER[1]; +static const prop_mode_tx_power_config_t *tx_power_current = &TX_POWER_DRIVER[1]; /*---------------------------------------------------------------------------*/ #ifdef PROP_MODE_CONF_LO_DIVIDER #define PROP_MODE_LO_DIVIDER PROP_MODE_CONF_LO_DIVIDER From 7e5ab3bf7c6404cbb52754a2353ff533ba82f1c5 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 17 Dec 2017 23:23:07 -0800 Subject: [PATCH 05/34] CI tests: cleaner compilation artifacts --- tests/00-doxygen/Makefile | 10 +++++----- tests/Makefile.compile-test | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/00-doxygen/Makefile b/tests/00-doxygen/Makefile index a5dfac35b..3d99c5d00 100644 --- a/tests/00-doxygen/Makefile +++ b/tests/00-doxygen/Makefile @@ -30,15 +30,15 @@ DOCDIR=../../tools/doxygen all: clean summary doxygen: - @make -C $(DOCDIR) 2> doxygen.runerr > doxygen.runlog + @make -C $(DOCDIR) 2> doxygen.err > /dev/null summary: doxygen @( \ 1> summary; \ - if [ -s doxygen.runerr ] ; then \ + if [ -s doxygen.err ] ; then \ echo "Doxygen: TEST FAIL" | tee summary; \ echo "Errors:"; \ - cat doxygen.runerr; \ + cat doxygen.err; \ fi ; \ if [ -s $(DOCDIR)/doxygen.log ] ; then \ echo "Doxygen: TEST FAIL" | tee summary; \ @@ -49,10 +49,10 @@ summary: doxygen echo "Doxygen: TEST OK (no warning nor error)" | tee summary; \ fi ; \ ) - @rm doxygen.runlog doxygen.runerr + @rm doxygen.err @echo "========== Summary ==========" @cat summary clean: - @rm -f summary doxygen.runlog doxygen.runerr + @rm -f summary doxygen.err @make -C $(DOCDIR) clean diff --git a/tests/Makefile.compile-test b/tests/Makefile.compile-test index 28904194d..6c7df5835 100644 --- a/tests/Makefile.compile-test +++ b/tests/Makefile.compile-test @@ -41,10 +41,10 @@ define dooneexample @echo -n Building example $(3): $(1) $(4) for target $(2) @((cd $(EXAMPLESDIR)/$(1); \ make $(4) TARGET=$(2) clean && make -j $(4) TARGET=$(2) WERROR=1) > \ - /dev/null 2>make.runerr && \ + /dev/null 2>make.err && \ (echo " -> OK" && printf "%-75s %-35s %-20s TEST OK\n" "$(1)" "$(4)" "$(2)" > $(3)-$(subst /,-,$(1))$(2).testlog) || \ - (echo " -> FAIL" && printf "%-75s %-35s %-20s TEST FAIL\n" "$(1)" "$(4)" "$(2)" > $(3)-$(subst /,-,$(1))$(2).testlog ; cat make.runerr)) -@rm -f make.runerr + (echo " -> FAIL" && printf "%-75s %-35s %-20s TEST FAIL\n" "$(1)" "$(4)" "$(2)" > $(3)-$(subst /,-,$(1))$(2).testlog ; cat make.err)) +@rm -f make.err endef define doexample From 3bbcc6288ff74be6da9b6943228fd33dc915360d Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 17 Dec 2017 17:58:09 +0000 Subject: [PATCH 06/34] Include board.h after configuration is fully known --- arch/platform/srf06-cc26xx/contiki-conf.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/platform/srf06-cc26xx/contiki-conf.h b/arch/platform/srf06-cc26xx/contiki-conf.h index 07c8f285a..718efc3f6 100644 --- a/arch/platform/srf06-cc26xx/contiki-conf.h +++ b/arch/platform/srf06-cc26xx/contiki-conf.h @@ -70,12 +70,12 @@ /* Platform-specific define to signify sensor reading failure */ #define CC26XX_SENSOR_READING_ERROR 0x80000000 /*---------------------------------------------------------------------------*/ -/* board.h assumes that basic configuration is done */ -#include "board.h" -/*---------------------------------------------------------------------------*/ /* Include CPU-related configuration */ #include "cc13xx-cc26xx-conf.h" /*---------------------------------------------------------------------------*/ +/* board.h assumes that basic configuration is done */ +#include "board.h" +/*---------------------------------------------------------------------------*/ #endif /* CONTIKI_CONF_H */ /** @} */ From 6339b64064a78e6035fb7fbfbfb651a5ded9e8f8 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 15 Dec 2017 07:28:51 -0800 Subject: [PATCH 07/34] Update Cooja submodule --- tools/cooja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cooja b/tools/cooja index 1256b2999..c1a1b4fdc 160000 --- a/tools/cooja +++ b/tools/cooja @@ -1 +1 @@ -Subproject commit 1256b299930b57f4c1d5512f8e96aa22a327591c +Subproject commit c1a1b4fdc9329b6cf22a7740145f448841ac2254 From 4b43e4971b35980f764a7d82cde17dd5c57019e9 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 7 Dec 2017 16:35:16 +0100 Subject: [PATCH 08/34] Fix compilation error when not in Router mode --- os/net/ipv6/uip-nd6.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/os/net/ipv6/uip-nd6.c b/os/net/ipv6/uip-nd6.c index 5c01de392..5b0fb0817 100644 --- a/os/net/ipv6/uip-nd6.c +++ b/os/net/ipv6/uip-nd6.c @@ -115,7 +115,7 @@ static uip_ds6_nbr_t *nbr; /** Pointer to a nbr cache entry*/ static uip_ds6_addr_t *addr; /** Pointer to an interface address */ #endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */ -#if UIP_ND6_SEND_NS || !UIP_CONF_ROUTER +#if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER static uip_ds6_defrt_t *defrt; /** Pointer to a router list entry */ #endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */ @@ -973,7 +973,7 @@ ra_input(void) default: LOG_DBG("Updating timer of prefix "); LOG_DBG_6ADDR(&prefix->ipaddr); - LOG_DBG_(" new value %lu\n", uip_ntohl(nd6_opt_prefix_info->validlt)); + LOG_DBG_(" new value %lu\n", (unsigned long)uip_ntohl(nd6_opt_prefix_info->validlt)); stimer_set(&prefix->vlifetime, uip_ntohl(nd6_opt_prefix_info->validlt)); prefix->isinfinite = 0; @@ -999,7 +999,7 @@ ra_input(void) LOG_DBG("Updating timer of address "); LOG_DBG_6ADDR(&addr->ipaddr); LOG_DBG_(" new value %lu\n", - uip_ntohl(nd6_opt_prefix_info->validlt)); + (unsigned long)uip_ntohl(nd6_opt_prefix_info->validlt)); stimer_set(&addr->vlifetime, uip_ntohl(nd6_opt_prefix_info->validlt)); } else { From 425b463df814aca19d05505541e22c3659b834cb Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 7 Dec 2017 15:34:34 +0100 Subject: [PATCH 09/34] Fix logic of RA flags related to RDNSS --- os/net/ipv6/uip-nd6.c | 22 ++++++++++------------ os/net/ipv6/uip-nd6.h | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/os/net/ipv6/uip-nd6.c b/os/net/ipv6/uip-nd6.c index 5c01de392..97545c749 100644 --- a/os/net/ipv6/uip-nd6.c +++ b/os/net/ipv6/uip-nd6.c @@ -1027,18 +1027,16 @@ ra_input(void) break; #if UIP_ND6_RA_RDNSS case UIP_ND6_OPT_RDNSS: - if(UIP_ND6_RA_BUF->flags_reserved & (UIP_ND6_O_FLAG << 6)) { - LOG_DBG("Processing RDNSS option\n"); - uint8_t naddr = (UIP_ND6_OPT_RDNSS_BUF->len - 1) / 2; - uip_ipaddr_t *ip = (uip_ipaddr_t *)(&UIP_ND6_OPT_RDNSS_BUF->ip); - LOG_DBG("got %d nameservers\n", naddr); - while(naddr-- > 0) { - LOG_DBG("nameserver: "); - LOG_DBG_6ADDR(ip); - LOG_DBG_(" lifetime: %lx\n", uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime)); - uip_nameserver_update(ip, uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime)); - ip++; - } + LOG_DBG("Processing RDNSS option\n"); + uint8_t naddr = (UIP_ND6_OPT_RDNSS_BUF->len - 1) / 2; + uip_ipaddr_t *ip = (uip_ipaddr_t *)(&UIP_ND6_OPT_RDNSS_BUF->ip); + LOG_DBG("got %d nameservers\n", naddr); + while(naddr-- > 0) { + LOG_DBG("nameserver: "); + LOG_DBG_6ADDR(ip); + LOG_DBG_(" lifetime: %lx\n", (unsigned long)uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime)); + uip_nameserver_update(ip, uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime)); + ip++; } break; #endif /* UIP_ND6_RA_RDNSS */ diff --git a/os/net/ipv6/uip-nd6.h b/os/net/ipv6/uip-nd6.h index 43b989490..2c1e3226b 100644 --- a/os/net/ipv6/uip-nd6.h +++ b/os/net/ipv6/uip-nd6.h @@ -118,7 +118,7 @@ be added regardless of their reachability and liveness. */ #define UIP_ND6_MIN_RA_INTERVAL UIP_CONF_ND6_MIN_RA_INTERVAL #endif #define UIP_ND6_M_FLAG 0 -#define UIP_ND6_O_FLAG (UIP_ND6_RA_RDNSS || UIP_ND6_RA_DNSSL) +#define UIP_ND6_O_FLAG 0 #ifndef UIP_CONF_ROUTER_LIFETIME #define UIP_ND6_ROUTER_LIFETIME 3 * UIP_ND6_MAX_RA_INTERVAL #else From ca16bf1bd294d63f3ebbe982803379fe7a38c89b Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 7 Dec 2017 16:20:53 +0100 Subject: [PATCH 10/34] Make select timeout user configurable for native platform --- arch/platform/native/platform.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/platform/native/platform.c b/arch/platform/native/platform.c index 02fad921c..a63ecd396 100644 --- a/arch/platform/native/platform.c +++ b/arch/platform/native/platform.c @@ -76,6 +76,12 @@ #define SELECT_MAX 8 #endif +#ifdef SELECT_CONF_TIMEOUT +#define SELECT_TIMEOUT SELECT_CONF_TIMEOUT +#else +#define SELECT_TIMEOUT 1000 +#endif + static const struct select_callback *select_callback[SELECT_MAX]; static int select_max = 0; @@ -252,7 +258,7 @@ platform_main_loop() retval = process_run(); tv.tv_sec = 0; - tv.tv_usec = retval ? 1 : 1000; + tv.tv_usec = retval ? 1 : SELECT_TIMEOUT; FD_ZERO(&fdr); FD_ZERO(&fdw); From 9fe252d1071c6467969a2f6f766925edf7792621 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Mon, 11 Dec 2017 09:21:12 +0100 Subject: [PATCH 11/34] Make stdin select callback configurable --- arch/platform/native/platform.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/platform/native/platform.c b/arch/platform/native/platform.c index a63ecd396..e12641414 100644 --- a/arch/platform/native/platform.c +++ b/arch/platform/native/platform.c @@ -82,6 +82,12 @@ #define SELECT_TIMEOUT 1000 #endif +#ifdef SELECT_CONF_STDIN +#define SELECT_STDIN SELECT_CONF_STDIN +#else +#define SELECT_STDIN 1 +#endif + static const struct select_callback *select_callback[SELECT_MAX]; static int select_max = 0; @@ -122,6 +128,7 @@ select_set_callback(int fd, const struct select_callback *callback) return 0; } /*---------------------------------------------------------------------------*/ +#if SELECT_STDIN static int stdin_set_fd(fd_set *rset, fd_set *wset) { @@ -141,6 +148,7 @@ stdin_handle_fd(fd_set *rset, fd_set *wset) const static struct select_callback stdin_fd = { stdin_set_fd, stdin_handle_fd }; +#endif /* SELECT_STDIN */ /*---------------------------------------------------------------------------*/ static void set_lladdr(void) @@ -246,7 +254,9 @@ platform_init_stage_three() void platform_main_loop() { +#if SELECT_STDIN select_set_callback(STDIN_FILENO, &stdin_fd); +#endif /* SELECT_STDIN */ while(1) { fd_set fdr; fd_set fdw; From c26aed5565eed273f6715be7fd9b88c77e6c6f4f Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Mon, 11 Dec 2017 11:09:37 +0100 Subject: [PATCH 12/34] Always select a global address within the DODAG --- os/net/rpl-classic/rpl-icmp6.c | 18 +++++++++++++----- os/net/rpl-lite/rpl.c | 10 +++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/os/net/rpl-classic/rpl-icmp6.c b/os/net/rpl-classic/rpl-icmp6.c index c5114fd14..6d9a2bca3 100644 --- a/os/net/rpl-classic/rpl-icmp6.c +++ b/os/net/rpl-classic/rpl-icmp6.c @@ -141,15 +141,23 @@ get_global_addr(uip_ipaddr_t *addr) { int i; int state; + uip_ipaddr_t *prefix = NULL; + uint8_t prefix_length = 0; + rpl_dag_t *dag = rpl_get_any_dag(); + + if(dag != NULL && dag->prefix_info.length != 0) { + prefix = &dag->prefix_info.prefix; + prefix_length = dag->prefix_info.length; + } for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; if(uip_ds6_if.addr_list[i].isused && - (state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) { - if(!uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr)) { - memcpy(addr, &uip_ds6_if.addr_list[i].ipaddr, sizeof(uip_ipaddr_t)); - return 1; - } + state == ADDR_PREFERRED && + !uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr) && + (prefix == NULL || uip_ipaddr_prefixcmp(prefix, &uip_ds6_if.addr_list[i].ipaddr, prefix_length))) { + memcpy(addr, &uip_ds6_if.addr_list[i].ipaddr, sizeof(uip_ipaddr_t)); + return 1; } } return 0; diff --git a/os/net/rpl-lite/rpl.c b/os/net/rpl-lite/rpl.c index 76d49d562..29eca52b0 100644 --- a/os/net/rpl-lite/rpl.c +++ b/os/net/rpl-lite/rpl.c @@ -71,12 +71,20 @@ rpl_get_global_address(void) int i; uint8_t state; uip_ipaddr_t *ipaddr = NULL; + uip_ipaddr_t *prefix = NULL; + uint8_t prefix_length = 0; + + if(curr_instance.used && curr_instance.dag.prefix_info.length != 0) { + prefix = &curr_instance.dag.prefix_info.prefix; + prefix_length = curr_instance.dag.prefix_info.length; + } for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; if(uip_ds6_if.addr_list[i].isused && state == ADDR_PREFERRED && - !uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr)) { + !uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr) && + (prefix == NULL || uip_ipaddr_prefixcmp(prefix, &uip_ds6_if.addr_list[i].ipaddr, prefix_length))) { ipaddr = &uip_ds6_if.addr_list[i].ipaddr; } } From d0ca150a384b0f5e0f23b61e78b91b0fe3394bb4 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 22 Dec 2017 11:22:38 +0100 Subject: [PATCH 13/34] Document new native platform defines --- arch/platform/native/platform.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/platform/native/platform.c b/arch/platform/native/platform.c index e12641414..4d1a1421c 100644 --- a/arch/platform/native/platform.c +++ b/arch/platform/native/platform.c @@ -70,23 +70,43 @@ #define LOG_MODULE "Native" #define LOG_LEVEL LOG_LEVEL_MAIN +/*---------------------------------------------------------------------------*/ +/** + * \name Native Platform Configuration + * + * @{ + */ + +/* + * Defines the maximum number of file descriptors monitored by the platform + * main loop. + */ #ifdef SELECT_CONF_MAX #define SELECT_MAX SELECT_CONF_MAX #else #define SELECT_MAX 8 #endif +/* + * Defines the timeout (in msec) of the select operation if no monitored file + * descriptors becomes ready. + */ #ifdef SELECT_CONF_TIMEOUT #define SELECT_TIMEOUT SELECT_CONF_TIMEOUT #else #define SELECT_TIMEOUT 1000 #endif +/* + * Adds the STDIN file descriptor to the list of monitored file descriptors. + */ #ifdef SELECT_CONF_STDIN #define SELECT_STDIN SELECT_CONF_STDIN #else #define SELECT_STDIN 1 #endif +/** @} */ +/*---------------------------------------------------------------------------*/ static const struct select_callback *select_callback[SELECT_MAX]; static int select_max = 0; From acbe590b52cbd840ab730dfcd0208d3d17644a6a Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 8 Dec 2017 13:14:22 +0100 Subject: [PATCH 14/34] Don't override UIP_CONF_BYTE_ORDER in contiki-conf.h for native platform --- arch/platform/native/contiki-conf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/platform/native/contiki-conf.h b/arch/platform/native/contiki-conf.h index c315b8e18..5e45a6053 100644 --- a/arch/platform/native/contiki-conf.h +++ b/arch/platform/native/contiki-conf.h @@ -69,7 +69,9 @@ typedef int32_t s32_t; typedef unsigned short uip_stats_t; +#ifndef UIP_CONF_BYTE_ORDER #define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN +#endif #if NETSTACK_CONF_WITH_IPV6 From 511497b3b6b90376ebde3f3bf6e5d699f74b50f1 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 8 Dec 2017 13:13:59 +0100 Subject: [PATCH 15/34] Make uip_stats_t int instead of short for native --- arch/platform/native/contiki-conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/platform/native/contiki-conf.h b/arch/platform/native/contiki-conf.h index 5e45a6053..3a0329a82 100644 --- a/arch/platform/native/contiki-conf.h +++ b/arch/platform/native/contiki-conf.h @@ -67,7 +67,7 @@ typedef uint16_t u16_t; typedef uint32_t u32_t; typedef int32_t s32_t; -typedef unsigned short uip_stats_t; +typedef unsigned int uip_stats_t; #ifndef UIP_CONF_BYTE_ORDER #define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN From 84ea0971bc5b101764126b49f303badc6b2b1ed0 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 18 Dec 2017 06:41:31 -0800 Subject: [PATCH 16/34] Remove obsolete flag AUTOSTART_ENABLE, as well as .co and .ce files --- Makefile.include | 18 ++---------------- arch/cpu/arm/cortex-m/cm3/Makefile.cm3 | 2 +- arch/cpu/arm/cortex-m/cm4/Makefile.cm4 | 4 ++-- arch/cpu/msp430/Makefile.msp430 | 11 +---------- arch/platform/cooja/Makefile.cooja | 2 +- arch/platform/cooja/contiki-cooja-main.c | 1 - arch/platform/jn516x/Makefile.jn516x | 4 ++-- arch/platform/sky/platform.c | 1 - os/services/unit-test/example-test.c | 7 +++---- os/sys/autostart.h | 5 ----- 10 files changed, 12 insertions(+), 43 deletions(-) diff --git a/Makefile.include b/Makefile.include index 3b8c41605..c7c191f03 100644 --- a/Makefile.include +++ b/Makefile.include @@ -8,7 +8,7 @@ endif # Setting this option is also important for tests on Cooja motes to check for warnings. WERROR ?= 1 -include $(CONTIKI)/Makefile.identify-target +include $(CONTIKI)/Makefile.identify-target ifeq ($(DEFINES),) -include Makefile.$(TARGET).defines @@ -241,7 +241,6 @@ clean: -rm -f *~ *core core *.srec \ *.lst *.map \ *.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \ - *.ce *.co rm -rf $(CLEAN) -rm -rf $(OBJECTDIR) @@ -250,13 +249,6 @@ distclean: clean -include $(CONTIKI)/arch/platform/$(TARGET)/Makefile.customrules-$(TARGET) -ifndef CUSTOM_RULE_C_TO_CE -%.ce: %.c - $(TRACE_CC) - $(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@ - $(STRIP) --strip-unneeded -g -x $@ -endif - ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O $(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(TRACE_CC) @@ -300,12 +292,6 @@ ifndef CUSTOM_RULE_C_TO_E $(Q)$(CC) $(CFLAGS) -E $< -o $@ endif -ifndef CUSTOM_RULE_C_TO_CO -%.co: %.c - $(TRACE_CC) - $(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@ -endif - ifndef AROPTS AROPTS = rcf endif @@ -321,7 +307,7 @@ ifndef LD endif ifndef CUSTOM_RULE_LINK -%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a +%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(TRACE_LD) $(Q)$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} \ ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ diff --git a/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 b/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 index a422d3080..f5547fea0 100644 --- a/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 +++ b/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 @@ -19,7 +19,7 @@ CUSTOM_RULE_LINK = 1 .SECONDEXPANSION: -%.elf: $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(LDSCRIPT) +%.elf: $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(LDSCRIPT) $(TRACE_LD) $(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -lm -o $@ diff --git a/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 b/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 index ca79428f1..78367b0eb 100644 --- a/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 +++ b/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 @@ -6,8 +6,8 @@ LDFLAGS += -mcpu=cortex-m4 ### Compilation rules CUSTOM_RULE_LINK=1 -%.elf: $(TARGET_STARTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(TARGET_LIBS) +%.elf: $(TARGET_STARTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(TARGET_LIBS) $(TRACE_LD) - $(Q)$(CC) $(LDFLAGS) ${filter %o %.co %.a,$^} -o $@ + $(Q)$(CC) $(LDFLAGS) ${filter %.o %.a,$^} -o $@ include $(CONTIKI)/arch/cpu/arm/cortex-m/Makefile.cortex-m diff --git a/arch/cpu/msp430/Makefile.msp430 b/arch/cpu/msp430/Makefile.msp430 index f7267b694..ec8c33664 100644 --- a/arch/cpu/msp430/Makefile.msp430 +++ b/arch/cpu/msp430/Makefile.msp430 @@ -108,11 +108,6 @@ ifeq ($(HOST_OS),Windows) @$(FINALIZE_CYGWIN_DEPENDENCY) endif -CUSTOM_RULE_C_TO_CO = 1 -%.co: %.c - $(TRACE_CC) - $(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@ - AROPTS = -o else @@ -195,10 +190,6 @@ PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)} $(CC) $(CFLAGS) -c $< -o $@ $(STRIP) --strip-unneeded -g -x $@ -%.cm: %.co - $(LD) -i -r --unresolved-symbols=ignore-in-object-files -mmsp430x149 -o $@ $^ - $(STRIP) --strip-unneeded -g -x $@ - %-stripped.o: %.o $(STRIP) --strip-unneeded -g -x -o $@ $< @@ -206,7 +197,7 @@ PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)} mv $< $@ ifdef IAR -%.ihex: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a +%.ihex: %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(LD) $(LDFLAGSNO) -Fintel-extended $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ else %.ihex: %.$(TARGET) diff --git a/arch/platform/cooja/Makefile.cooja b/arch/platform/cooja/Makefile.cooja index 9f41dbaad..853e7eaf5 100644 --- a/arch/platform/cooja/Makefile.cooja +++ b/arch/platform/cooja/Makefile.cooja @@ -38,7 +38,7 @@ endif ## QUICKSTART MAIN_OBJ = $(OBJECTDIR)/$(LIBNAME).o ARCHIVE = $(OBJECTDIR)/$(LIBNAME).a JNILIB = $(OBJECTDIR)/$(LIBNAME).$(TARGET) -CONTIKI_APP_OBJ = $(CONTIKI_APP).co +CONTIKI_APP_OBJ = $(CONTIKI_APP).o # Modules MODULES += os/net os/net/mac os/net/mac/framer diff --git a/arch/platform/cooja/contiki-cooja-main.c b/arch/platform/cooja/contiki-cooja-main.c index 39793d12c..d418e7039 100644 --- a/arch/platform/cooja/contiki-cooja-main.c +++ b/arch/platform/cooja/contiki-cooja-main.c @@ -45,7 +45,6 @@ #include "sys/clock.h" #include "sys/etimer.h" #include "sys/cooja_mt.h" -#include "sys/autostart.h" #include "sys/log.h" #include "lib/random.h" diff --git a/arch/platform/jn516x/Makefile.jn516x b/arch/platform/jn516x/Makefile.jn516x index bb654ceb8..d7aa80992 100644 --- a/arch/platform/jn516x/Makefile.jn516x +++ b/arch/platform/jn516x/Makefile.jn516x @@ -236,7 +236,7 @@ ABS_APPLIBS = $(addsuffix _$(JENNIC_CHIP_FAMILY).a,$(addprefix $(COMPONENTS_BASE ifneq ($(wildcard $(SDK_BASE_DIR)/Components/Library/*),) # The SDK is fully installed, proceed to linking and objcopy to ready-to-upload .jn516x.bin file -%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(ABS_APPLIBS) +%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(ABS_APPLIBS) echo ${filter %.a,$^} $(Q)$(CC) -Wl,--gc-sections $(LDFLAGS) -T$(LINKCMD) -o $@ -Wl,--start-group \ $(patsubst /cygdrive/c/%,c:/%,${filter-out %.a,$^}) \ @@ -245,7 +245,7 @@ ifneq ($(wildcard $(SDK_BASE_DIR)/Components/Library/*),) $(OBJCOPY) -S -O binary $@ $@.bin else # The SDK does not include libraries, only build objects and libraries, skip linking -%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a +%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a echo Creating empty $@ touch $@ endif diff --git a/arch/platform/sky/platform.c b/arch/platform/sky/platform.c index 5bbce5286..d71471340 100644 --- a/arch/platform/sky/platform.c +++ b/arch/platform/sky/platform.c @@ -51,7 +51,6 @@ #include "sys/node-id.h" #include "cfs-coffee-arch.h" #include "cfs/cfs-coffee.h" -#include "sys/autostart.h" #if DCOSYNCH_CONF_ENABLED static struct timer mgt_timer; diff --git a/os/services/unit-test/example-test.c b/os/services/unit-test/example-test.c index b40dc525f..04192642f 100644 --- a/os/services/unit-test/example-test.c +++ b/os/services/unit-test/example-test.c @@ -37,12 +37,12 @@ #include "contiki.h" #include "unit-test.h" -/* Register two unit tests that will be executed by using +/* Register two unit tests that will be executed by using the UNIT_TEST_RUN macro. */ UNIT_TEST_REGISTER(arithmetic, "Arith ops"); UNIT_TEST_REGISTER(string, "String ops"); -/* arithmetic: Demonstrates a test that succeeds. The exit point will be +/* arithmetic: Demonstrates a test that succeeds. The exit point will be the line where UNIT_TEST_END is called. */ UNIT_TEST(arithmetic) { @@ -58,7 +58,7 @@ UNIT_TEST(arithmetic) UNIT_TEST_END(); } -/* string: Demonstrates a test that fails. The exit point will be +/* string: Demonstrates a test that fails. The exit point will be the line where the call to UNIT_TEST_ASSERT fails. */ UNIT_TEST(string) { @@ -72,7 +72,6 @@ UNIT_TEST(string) } PROCESS(test_process, "Unit testing"); -AUTOSTART_PROCESSES(&test_process); PROCESS_THREAD(test_process, ev, data) { diff --git a/os/sys/autostart.h b/os/sys/autostart.h index a2cd10eb7..8a671b363 100644 --- a/os/sys/autostart.h +++ b/os/sys/autostart.h @@ -44,13 +44,8 @@ #include "sys/process.h" #if ! CC_NO_VA_ARGS -#if AUTOSTART_ENABLE #define AUTOSTART_PROCESSES(...) \ struct process * const autostart_processes[] = {__VA_ARGS__, NULL} -#else /* AUTOSTART_ENABLE */ -#define AUTOSTART_PROCESSES(...) \ -extern int _dummy -#endif /* AUTOSTART_ENABLE */ #else #error "C compiler must support __VA_ARGS__ macro" #endif From 2fd6fa1fd6be64eada54c1fd3b4f7d91f78d2711 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 18 Dec 2017 07:58:17 -0800 Subject: [PATCH 17/34] Automatically compile .c files from PROJECTDIRS --- Makefile.include | 1 + examples/coap/Makefile | 18 +++++------------- .../res-plugtest-create1.c | 0 .../res-plugtest-create2.c | 0 .../res-plugtest-create3.c | 0 .../res-plugtest-large-create.c | 0 .../res-plugtest-large-update.c | 0 .../res-plugtest-large.c | 0 .../res-plugtest-links.c | 0 .../res-plugtest-locquery.c | 0 .../res-plugtest-longpath.c | 0 .../res-plugtest-multi.c | 0 .../res-plugtest-obs.c | 0 .../res-plugtest-path.c | 0 .../res-plugtest-query.c | 0 .../res-plugtest-separate.c | 0 .../res-plugtest-test.c | 0 .../res-plugtest-validate.c | 0 .../cc26xx/cc26xx-web-demo/Makefile | 8 +------- .../jn516x/rpl/coap-dongle-node/Makefile | 1 - .../jn516x/rpl/coap-dr1175-node/Makefile | 1 - .../jn516x/rpl/coap-dr1199-node/Makefile | 1 - .../platform-specific/jn516x/rpl/node/Makefile | 1 - .../tsch/simple-sensor-network/node/Makefile | 1 - .../tsch/tx-power-verification/node/Makefile | 1 - .../rpl-border-router/Makefile | 1 - .../jn516x/tsch/uart1-test-node/Makefile | 1 - .../nrf52dk/coap-demo/Makefile | 6 +----- examples/rpl-border-router/Makefile | 1 - examples/rpl-border-router/embedded/Makefile | 4 ---- examples/rpl-border-router/native/Makefile | 4 ---- examples/slip-radio/sky/Makefile.sky | 3 --- 32 files changed, 8 insertions(+), 45 deletions(-) rename examples/coap/{resources => resources-plugtest}/res-plugtest-create1.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-create2.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-create3.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-large-create.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-large-update.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-large.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-links.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-locquery.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-longpath.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-multi.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-obs.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-path.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-query.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-separate.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-test.c (100%) rename examples/coap/{resources => resources-plugtest}/res-plugtest-validate.c (100%) diff --git a/Makefile.include b/Makefile.include index c7c191f03..d6753ad6c 100644 --- a/Makefile.include +++ b/Makefile.include @@ -58,6 +58,7 @@ oname = ${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}} CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}} +PROJECT_SOURCEFILES += ${foreach d, $(PROJECTDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}} PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}} # Provide way to create $(OBJECTDIR) if it has been removed by make clean diff --git a/examples/coap/Makefile b/examples/coap/Makefile index 1c8f2d21e..8b0cc3b7a 100644 --- a/examples/coap/Makefile +++ b/examples/coap/Makefile @@ -3,20 +3,12 @@ all: coap-example-server coap-example-client CONTIKI=../.. -# automatically build RESTful resources -REST_RESOURCES_DIR = ./resources -ifndef TARGET -REST_RESOURCES_FILES = $(notdir $(shell find $(REST_RESOURCES_DIR) -name '*.c')) -else -ifeq ($(TARGET), native) -REST_RESOURCES_FILES = $(notdir $(shell find $(REST_RESOURCES_DIR) -name '*.c')) -else -REST_RESOURCES_FILES = $(notdir $(shell find $(REST_RESOURCES_DIR) -name '*.c' ! -name 'res-plugtest*')) +# build RESTful resources +include $(CONTIKI)/Makefile.identify-target +ifeq ($(TARGET),native) + PROJECTDIRS += ./resources-plugtest endif -endif - -PROJECTDIRS += $(REST_RESOURCES_DIR) -PROJECT_SOURCEFILES += $(REST_RESOURCES_FILES) +PROJECTDIRS += ./resources # Include the CoAP implementation MODULES += os/net/app-layer/coap diff --git a/examples/coap/resources/res-plugtest-create1.c b/examples/coap/resources-plugtest/res-plugtest-create1.c similarity index 100% rename from examples/coap/resources/res-plugtest-create1.c rename to examples/coap/resources-plugtest/res-plugtest-create1.c diff --git a/examples/coap/resources/res-plugtest-create2.c b/examples/coap/resources-plugtest/res-plugtest-create2.c similarity index 100% rename from examples/coap/resources/res-plugtest-create2.c rename to examples/coap/resources-plugtest/res-plugtest-create2.c diff --git a/examples/coap/resources/res-plugtest-create3.c b/examples/coap/resources-plugtest/res-plugtest-create3.c similarity index 100% rename from examples/coap/resources/res-plugtest-create3.c rename to examples/coap/resources-plugtest/res-plugtest-create3.c diff --git a/examples/coap/resources/res-plugtest-large-create.c b/examples/coap/resources-plugtest/res-plugtest-large-create.c similarity index 100% rename from examples/coap/resources/res-plugtest-large-create.c rename to examples/coap/resources-plugtest/res-plugtest-large-create.c diff --git a/examples/coap/resources/res-plugtest-large-update.c b/examples/coap/resources-plugtest/res-plugtest-large-update.c similarity index 100% rename from examples/coap/resources/res-plugtest-large-update.c rename to examples/coap/resources-plugtest/res-plugtest-large-update.c diff --git a/examples/coap/resources/res-plugtest-large.c b/examples/coap/resources-plugtest/res-plugtest-large.c similarity index 100% rename from examples/coap/resources/res-plugtest-large.c rename to examples/coap/resources-plugtest/res-plugtest-large.c diff --git a/examples/coap/resources/res-plugtest-links.c b/examples/coap/resources-plugtest/res-plugtest-links.c similarity index 100% rename from examples/coap/resources/res-plugtest-links.c rename to examples/coap/resources-plugtest/res-plugtest-links.c diff --git a/examples/coap/resources/res-plugtest-locquery.c b/examples/coap/resources-plugtest/res-plugtest-locquery.c similarity index 100% rename from examples/coap/resources/res-plugtest-locquery.c rename to examples/coap/resources-plugtest/res-plugtest-locquery.c diff --git a/examples/coap/resources/res-plugtest-longpath.c b/examples/coap/resources-plugtest/res-plugtest-longpath.c similarity index 100% rename from examples/coap/resources/res-plugtest-longpath.c rename to examples/coap/resources-plugtest/res-plugtest-longpath.c diff --git a/examples/coap/resources/res-plugtest-multi.c b/examples/coap/resources-plugtest/res-plugtest-multi.c similarity index 100% rename from examples/coap/resources/res-plugtest-multi.c rename to examples/coap/resources-plugtest/res-plugtest-multi.c diff --git a/examples/coap/resources/res-plugtest-obs.c b/examples/coap/resources-plugtest/res-plugtest-obs.c similarity index 100% rename from examples/coap/resources/res-plugtest-obs.c rename to examples/coap/resources-plugtest/res-plugtest-obs.c diff --git a/examples/coap/resources/res-plugtest-path.c b/examples/coap/resources-plugtest/res-plugtest-path.c similarity index 100% rename from examples/coap/resources/res-plugtest-path.c rename to examples/coap/resources-plugtest/res-plugtest-path.c diff --git a/examples/coap/resources/res-plugtest-query.c b/examples/coap/resources-plugtest/res-plugtest-query.c similarity index 100% rename from examples/coap/resources/res-plugtest-query.c rename to examples/coap/resources-plugtest/res-plugtest-query.c diff --git a/examples/coap/resources/res-plugtest-separate.c b/examples/coap/resources-plugtest/res-plugtest-separate.c similarity index 100% rename from examples/coap/resources/res-plugtest-separate.c rename to examples/coap/resources-plugtest/res-plugtest-separate.c diff --git a/examples/coap/resources/res-plugtest-test.c b/examples/coap/resources-plugtest/res-plugtest-test.c similarity index 100% rename from examples/coap/resources/res-plugtest-test.c rename to examples/coap/resources-plugtest/res-plugtest-test.c diff --git a/examples/coap/resources/res-plugtest-validate.c b/examples/coap/resources-plugtest/res-plugtest-validate.c similarity index 100% rename from examples/coap/resources/res-plugtest-validate.c rename to examples/coap/resources-plugtest/res-plugtest-validate.c diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile b/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile index 88b4b0184..bc8fd02ca 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile @@ -1,12 +1,6 @@ all: cc26xx-web-demo -REST_RESOURCES_DIR = ./resources - -REST_RESOURCES_FILES += res-leds.c res-toggle-leds.c res-device.c -REST_RESOURCES_FILES += res-sensors.c res-ble-advd.c res-net.c - -PROJECTDIRS += $(REST_RESOURCES_DIR) -PROJECT_SOURCEFILES += $(REST_RESOURCES_FILES) +PROJECTDIRS += ./resources PROJECT_SOURCEFILES += cetic-6lbr-client.c coap-server.c net-uart.c mqtt-client.c PROJECT_SOURCEFILES += httpd-simple.c diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile index 1b13ef3e0..68dfc3104 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile @@ -9,7 +9,6 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile index 9a393ff14..8ff775250 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile @@ -9,7 +9,6 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile index 32231f636..dc8ee8490 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile @@ -9,7 +9,6 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/node/Makefile b/examples/platform-specific/jn516x/rpl/node/Makefile index 37f6c7c79..d581bb235 100644 --- a/examples/platform-specific/jn516x/rpl/node/Makefile +++ b/examples/platform-specific/jn516x/rpl/node/Makefile @@ -7,6 +7,5 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile index df37a89af..691dc94ec 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile @@ -6,7 +6,6 @@ JN516x_WITH_DONGLE = 1 CONTIKI=../../../../../.. PROJECTDIRS += .. ../../tools -PROJECT_SOURCEFILES += rpl-tools.c MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap MODULES += os/services/orchestra os/lib/json diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile index 977210702..b4846ed91 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile @@ -6,7 +6,6 @@ JN516x_WITH_DONGLE = 1 CONTIKI=../../../../../.. PROJECTDIRS += .. ../../tools -PROJECT_SOURCEFILES += rpl-tools.c MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile index c88fa5a2b..b3b1fd9a4 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile @@ -8,7 +8,6 @@ CONTIKI=../../../../../.. PROJECT_SOURCEFILES += slip-bridge.c slip.c PROJECTDIRS += .. ../../tools -PROJECT_SOURCEFILES += rpl-tools.c MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile index ca520969d..fdd38cc9e 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile @@ -7,7 +7,6 @@ TARGET_WITH_UART1 = 1 CONTIKI=../../../../.. PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/nrf52dk/coap-demo/Makefile b/examples/platform-specific/nrf52dk/coap-demo/Makefile index 6d9639da0..02f87b5d6 100644 --- a/examples/platform-specific/nrf52dk/coap-demo/Makefile +++ b/examples/platform-specific/nrf52dk/coap-demo/Makefile @@ -16,11 +16,7 @@ CFLAGS += -DDEVICE_NAME=\"nRF52-DK-CoAP-Server\" endif # automatically build RESTful resources -REST_RESOURCES_DIR = ./resources -REST_RESOURCES_FILES = $(notdir $(shell find $(REST_RESOURCES_DIR) -name '*.c' ! -name 'res-plugtest*')) - -PROJECTDIRS += $(REST_RESOURCES_DIR) -PROJECT_SOURCEFILES += $(REST_RESOURCES_FILES) +PROJECTDIRS += ./resources # REST Engine shall use Erbium CoAP implementation MODULES += os/net/app-layer/coap diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index 76c07cb8b..aaa8ab6cf 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -15,7 +15,6 @@ endif include $(SOURCES_DIR)/Makefile PROJECTDIRS += $(SOURCES_DIR) -PROJECT_SOURCEFILES += httpd-simple.c webserver.c border-router-common.c CFLAGS += -DPROJECT_CONF_PATH=\"$(SOURCES_DIR)/project-conf.h\" include $(CONTIKI)/Makefile.include diff --git a/examples/rpl-border-router/embedded/Makefile b/examples/rpl-border-router/embedded/Makefile index 5faba70c8..8c899e8b1 100644 --- a/examples/rpl-border-router/embedded/Makefile +++ b/examples/rpl-border-router/embedded/Makefile @@ -2,10 +2,6 @@ ### add more source files to the build or define make variables. -include $(SOURCES_DIR)/$(TARGET)/Makefile.$(TARGET) -PROJECTDIRS += $(SOURCES_DIR)/$(TARGET) - -PROJECT_SOURCEFILES += slip-bridge.c border-router-embedded.c - $(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c (cd $(CONTIKI)/tools && $(MAKE) tunslip6) diff --git a/examples/rpl-border-router/native/Makefile b/examples/rpl-border-router/native/Makefile index 30690df0f..f04626c8e 100644 --- a/examples/rpl-border-router/native/Makefile +++ b/examples/rpl-border-router/native/Makefile @@ -1,9 +1,5 @@ MODULES += os/services/slip-cmd -PROJECT_SOURCEFILES += border-router-native.c -PROJECT_SOURCEFILES += border-router-cmds.c tun-bridge.c -PROJECT_SOURCEFILES += slip-config.c slip-dev.c border-router-mac.c - MAKE_MAC = MAKE_MAC_OTHER MAKE_NET = MAKE_NET_IPV6 diff --git a/examples/slip-radio/sky/Makefile.sky b/examples/slip-radio/sky/Makefile.sky index 83a91472d..17fefd5ee 100644 --- a/examples/slip-radio/sky/Makefile.sky +++ b/examples/slip-radio/sky/Makefile.sky @@ -1,4 +1 @@ -PROJECT_SOURCEFILES += slip-radio-cc2420.c slip-radio-sky-sensors.c -PROJECT_SOURCEFILES += slip-radio-putchar.c - CFLAGS += -DTARGET_CONF_PATH=\"target-conf.h\" From e744f0a5054589d404cc16ff4f47551d3170dafc Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 18 Dec 2017 08:30:58 -0800 Subject: [PATCH 18/34] Refactor rpl-border-router makefile --- examples/rpl-border-router/Makefile | 10 ++++------ .../embedded/{Makefile => Makefile.embedded} | 1 + .../native/{Makefile => Makefile.native} | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) rename examples/rpl-border-router/embedded/{Makefile => Makefile.embedded} (95%) rename examples/rpl-border-router/native/{Makefile => Makefile.native} (67%) diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index aaa8ab6cf..cb6179a1b 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -1,19 +1,17 @@ -PROJECTDIRS += common -PREFIX ?= fd00::1/64 +CONTIKI_PROJECT = border-router +all: $(CONTIKI_PROJECT) CONTIKI = ../.. --include $(CONTIKI)/Makefile.identify-target - -all: border-router.$(TARGET) +include $(CONTIKI)/Makefile.identify-target ifeq ($(TARGET),native) SOURCES_DIR = native else SOURCES_DIR = embedded endif - include $(SOURCES_DIR)/Makefile +PROJECTDIRS += common PROJECTDIRS += $(SOURCES_DIR) CFLAGS += -DPROJECT_CONF_PATH=\"$(SOURCES_DIR)/project-conf.h\" diff --git a/examples/rpl-border-router/embedded/Makefile b/examples/rpl-border-router/embedded/Makefile.embedded similarity index 95% rename from examples/rpl-border-router/embedded/Makefile rename to examples/rpl-border-router/embedded/Makefile.embedded index 8c899e8b1..302c3fc31 100644 --- a/examples/rpl-border-router/embedded/Makefile +++ b/examples/rpl-border-router/embedded/Makefile.embedded @@ -5,6 +5,7 @@ $(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c (cd $(CONTIKI)/tools && $(MAKE) tunslip6) +PREFIX ?= fd00::1/64 connect-router: $(CONTIKI)/tools/tunslip6 sudo $(CONTIKI)/tools/tunslip6 $(PREFIX) diff --git a/examples/rpl-border-router/native/Makefile b/examples/rpl-border-router/native/Makefile.native similarity index 67% rename from examples/rpl-border-router/native/Makefile rename to examples/rpl-border-router/native/Makefile.native index f04626c8e..62f7221a0 100644 --- a/examples/rpl-border-router/native/Makefile +++ b/examples/rpl-border-router/native/Makefile.native @@ -3,5 +3,6 @@ MODULES += os/services/slip-cmd MAKE_MAC = MAKE_MAC_OTHER MAKE_NET = MAKE_NET_IPV6 +PREFIX ?= fd00::1/64 connect-router: border-router.native - sudo ./border-router.native fd00::1/64 + sudo ./border-router.native $(PREFIX) From c2d301a434c1d19a69181d08344fc48419c5bc67 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 18 Dec 2017 08:31:23 -0800 Subject: [PATCH 19/34] Remove unnecessary '-' before inclusion of Makefile.identify-target --- examples/sensniff/Makefile | 2 +- examples/slip-radio/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/sensniff/Makefile b/examples/sensniff/Makefile index 2bb2549b1..1ec70a7c7 100644 --- a/examples/sensniff/Makefile +++ b/examples/sensniff/Makefile @@ -4,7 +4,7 @@ CONTIKI = ../.. PROJECT_SOURCEFILES += sensniff-mac.c netstack.c PROJECTDIRS += pool $(TARGET) --include $(CONTIKI)/Makefile.identify-target +include $(CONTIKI)/Makefile.identify-target ### Optionally, the target can add its own Makefile, to do things like e.g. ### add more source files to the build or define make variables. diff --git a/examples/slip-radio/Makefile b/examples/slip-radio/Makefile index d59b5e240..15c0ec1b0 100644 --- a/examples/slip-radio/Makefile +++ b/examples/slip-radio/Makefile @@ -3,7 +3,7 @@ all: $(CONTIKI_PROJECT) MODULES += os/services/slip-cmd CONTIKI=../.. --include $(CONTIKI)/Makefile.identify-target +include $(CONTIKI)/Makefile.identify-target ### Optionally, the target can add its own Makefile, to do things like e.g. ### add more source files to the build or define make variables. From a0961ac2a1a0f73d157e5f5ff3f322ecae5e5004 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 18 Dec 2017 09:21:47 -0800 Subject: [PATCH 20/34] Build system: automatically include Makefiles from PROJECTDIRS --- Makefile.include | 2 ++ examples/rpl-border-router/Makefile | 12 ++++++------ .../rpl-border-router/embedded/Makefile.embedded | 4 ---- examples/rpl-border-router/embedded/sky/Makefile.sky | 2 -- examples/sensniff/Makefile | 6 +----- examples/slip-radio/Makefile | 4 ---- 6 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Makefile.include b/Makefile.include index d6753ad6c..c8c9c4597 100644 --- a/Makefile.include +++ b/Makefile.include @@ -60,6 +60,8 @@ CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFI PROJECT_SOURCEFILES += ${foreach d, $(PROJECTDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}} PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}} +PROJECT_INCLUDES = ${strip ${wildcard ${foreach d, $(PROJECTDIRS), $(d)/Makefile.${notdir $(d)}}}} +-include $(PROJECT_INCLUDES) # Provide way to create $(OBJECTDIR) if it has been removed by make clean $(OBJECTDIR): diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index cb6179a1b..0870aacd9 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -5,14 +5,14 @@ CONTIKI = ../.. include $(CONTIKI)/Makefile.identify-target ifeq ($(TARGET),native) - SOURCES_DIR = native + PROJECTDIRS += native + CFLAGS += -DPROJECT_CONF_PATH=\"native/project-conf.h\" else - SOURCES_DIR = embedded + PROJECTDIRS += embedded + # For embedded platforms, include platform-specific directory + PROJECTDIRS += embedded/$(TARGET) + CFLAGS += -DPROJECT_CONF_PATH=\"embedded/project-conf.h\" endif -include $(SOURCES_DIR)/Makefile - PROJECTDIRS += common -PROJECTDIRS += $(SOURCES_DIR) -CFLAGS += -DPROJECT_CONF_PATH=\"$(SOURCES_DIR)/project-conf.h\" include $(CONTIKI)/Makefile.include diff --git a/examples/rpl-border-router/embedded/Makefile.embedded b/examples/rpl-border-router/embedded/Makefile.embedded index 302c3fc31..c62f7df54 100644 --- a/examples/rpl-border-router/embedded/Makefile.embedded +++ b/examples/rpl-border-router/embedded/Makefile.embedded @@ -1,7 +1,3 @@ -### Optionally, the target can add its own Makefile, to do things like e.g. -### add more source files to the build or define make variables. --include $(SOURCES_DIR)/$(TARGET)/Makefile.$(TARGET) - $(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c (cd $(CONTIKI)/tools && $(MAKE) tunslip6) diff --git a/examples/rpl-border-router/embedded/sky/Makefile.sky b/examples/rpl-border-router/embedded/sky/Makefile.sky index c3d097481..17fefd5ee 100644 --- a/examples/rpl-border-router/embedded/sky/Makefile.sky +++ b/examples/rpl-border-router/embedded/sky/Makefile.sky @@ -1,3 +1 @@ -PROJECT_SOURCEFILES += slip-bridge-putchar.c - CFLAGS += -DTARGET_CONF_PATH=\"target-conf.h\" diff --git a/examples/sensniff/Makefile b/examples/sensniff/Makefile index 1ec70a7c7..3c04da8e4 100644 --- a/examples/sensniff/Makefile +++ b/examples/sensniff/Makefile @@ -4,11 +4,7 @@ CONTIKI = ../.. PROJECT_SOURCEFILES += sensniff-mac.c netstack.c PROJECTDIRS += pool $(TARGET) -include $(CONTIKI)/Makefile.identify-target - -### Optionally, the target can add its own Makefile, to do things like e.g. -### add more source files to the build or define make variables. --include $(TARGET)/Makefile.$(TARGET) +include $(CONTIKI)/Makefile.identify-target all: $(CONTIKI_PROJECT) diff --git a/examples/slip-radio/Makefile b/examples/slip-radio/Makefile index 15c0ec1b0..85c9e35b1 100644 --- a/examples/slip-radio/Makefile +++ b/examples/slip-radio/Makefile @@ -5,10 +5,6 @@ MODULES += os/services/slip-cmd CONTIKI=../.. include $(CONTIKI)/Makefile.identify-target -### Optionally, the target can add its own Makefile, to do things like e.g. -### add more source files to the build or define make variables. --include $(TARGET)/Makefile.$(TARGET) - PROJECTDIRS += $(TARGET) PROJECT_SOURCEFILES += slip-net.c From 81d1b1bd80b0d84582284fdc1edcec54badf3161 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 19 Dec 2017 05:29:55 -0800 Subject: [PATCH 21/34] PROJECTDIR now turned into modules via MODULES_REL --- Makefile.include | 18 ++++++------------ arch/cpu/arm/common/usb/Makefile.usb | 2 +- examples/coap/Makefile | 4 ++-- .../cc26xx/cc26xx-web-demo/Makefile | 2 +- .../jn516x/rpl/coap-dongle-node/Makefile | 2 +- .../jn516x/rpl/coap-dr1175-node/Makefile | 2 +- .../jn516x/rpl/coap-dr1199-node/Makefile | 2 +- .../platform-specific/jn516x/rpl/node/Makefile | 2 +- .../tsch/simple-sensor-network/node/Makefile | 2 +- .../tsch/tx-power-verification/node/Makefile | 2 +- .../rpl-border-router/Makefile | 2 +- .../jn516x/tsch/uart1-test-node/Makefile | 2 +- .../nrf52dk/coap-demo/Makefile | 2 +- examples/rpl-border-router/Makefile | 8 ++++---- examples/sensniff/Makefile | 2 +- examples/slip-radio/Makefile | 2 +- tools/sky/uip6-bridge/Makefile | 2 +- 17 files changed, 26 insertions(+), 32 deletions(-) diff --git a/Makefile.include b/Makefile.include index c8c9c4597..3bf19bd37 100644 --- a/Makefile.include +++ b/Makefile.include @@ -57,11 +57,7 @@ MODULES += os os/net os/net/mac os/storage oname = ${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}} CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}} - -PROJECT_SOURCEFILES += ${foreach d, $(PROJECTDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}} PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}} -PROJECT_INCLUDES = ${strip ${wildcard ${foreach d, $(PROJECTDIRS), $(d)/Makefile.${notdir $(d)}}}} --include $(PROJECT_INCLUDES) # Provide way to create $(OBJECTDIR) if it has been removed by make clean $(OBJECTDIR): @@ -166,14 +162,12 @@ else CFLAGS += -DUIP_CONF_IPV6_RPL=0 endif -ifdef MODULES - UNIQUEMODULES = $(call uniq,$(MODULES)) - MODULEDIRS = ${wildcard ${addprefix $(CONTIKI)/, $(UNIQUEMODULES)}} - MODULES_SOURCES = ${foreach d, $(MODULEDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}} - MODULES_INCLUDES = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/Makefile.${notdir $(d)}}} - include $(MODULES_INCLUDES) - CONTIKI_SOURCEFILES += $(MODULES_SOURCES) -endif +MODULEDIRS = $(MODULES_REL) ${wildcard ${addprefix $(CONTIKI)/, $(MODULES)}} +UNIQUEMODULES = $(call uniq,$(MODULEDIRS)) +MODULES_SOURCES = ${foreach d, $(MODULEDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}} +MODULES_INCLUDES = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/Makefile.${notdir $(d)}}} +include $(MODULES_INCLUDES) +CONTIKI_SOURCEFILES += $(MODULES_SOURCES) ### Verbosity control. Use make V=1 to get verbose builds. diff --git a/arch/cpu/arm/common/usb/Makefile.usb b/arch/cpu/arm/common/usb/Makefile.usb index 3286ca365..05266cf7b 100644 --- a/arch/cpu/arm/common/usb/Makefile.usb +++ b/arch/cpu/arm/common/usb/Makefile.usb @@ -6,7 +6,7 @@ endif STRUCTGEN = structgen -PROJECTDIRS += $(BUILTSRCDIR) +MODULES_REL += $(BUILTSRCDIR) USB_STRING_DESCRIPTORS ?= $(CONTIKI_CPU_ARM)/common/usb/cdc-acm/string-descriptors.xml diff --git a/examples/coap/Makefile b/examples/coap/Makefile index 8b0cc3b7a..379ffb104 100644 --- a/examples/coap/Makefile +++ b/examples/coap/Makefile @@ -6,9 +6,9 @@ CONTIKI=../.. # build RESTful resources include $(CONTIKI)/Makefile.identify-target ifeq ($(TARGET),native) - PROJECTDIRS += ./resources-plugtest + MODULES_REL += ./resources-plugtest endif -PROJECTDIRS += ./resources +MODULES_REL += ./resources # Include the CoAP implementation MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile b/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile index bc8fd02ca..bc024b826 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile @@ -1,6 +1,6 @@ all: cc26xx-web-demo -PROJECTDIRS += ./resources +MODULES_REL += ./resources PROJECT_SOURCEFILES += cetic-6lbr-client.c coap-server.c net-uart.c mqtt-client.c PROJECT_SOURCEFILES += httpd-simple.c diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile index 68dfc3104..1b39fbae3 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile @@ -8,7 +8,7 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json -PROJECTDIRS += .. ../tools +MODULES_REL += .. ../tools MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile index 8ff775250..79a7e7f13 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile @@ -8,7 +8,7 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json -PROJECTDIRS += .. ../tools +MODULES_REL += .. ../tools MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile index dc8ee8490..a5887a8ef 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile @@ -8,7 +8,7 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json -PROJECTDIRS += .. ../tools +MODULES_REL += .. ../tools MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/node/Makefile b/examples/platform-specific/jn516x/rpl/node/Makefile index d581bb235..83cd48869 100644 --- a/examples/platform-specific/jn516x/rpl/node/Makefile +++ b/examples/platform-specific/jn516x/rpl/node/Makefile @@ -6,6 +6,6 @@ TARGET ?= jn516x CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH -PROJECTDIRS += .. ../tools +MODULES_REL += .. ../tools include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile index 691dc94ec..2e7e32585 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile @@ -5,7 +5,7 @@ JN516x_WITH_DONGLE = 1 CONTIKI=../../../../../.. -PROJECTDIRS += .. ../../tools +MODULES_REL += .. ../../tools MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap MODULES += os/services/orchestra os/lib/json diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile index b4846ed91..3884b9d30 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile @@ -5,7 +5,7 @@ JN516x_WITH_DONGLE = 1 CONTIKI=../../../../../.. -PROJECTDIRS += .. ../../tools +MODULES_REL += .. ../../tools MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile index b3b1fd9a4..3773e04a5 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile @@ -7,7 +7,7 @@ CONTIKI=../../../../../.. PROJECT_SOURCEFILES += slip-bridge.c slip.c -PROJECTDIRS += .. ../../tools +MODULES_REL += .. ../../tools MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile index fdd38cc9e..640495432 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile @@ -6,7 +6,7 @@ TARGET_WITH_UART1 = 1 CONTIKI=../../../../.. -PROJECTDIRS += .. ../tools +MODULES_REL += .. ../tools MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/nrf52dk/coap-demo/Makefile b/examples/platform-specific/nrf52dk/coap-demo/Makefile index 02f87b5d6..37b4cef4d 100644 --- a/examples/platform-specific/nrf52dk/coap-demo/Makefile +++ b/examples/platform-specific/nrf52dk/coap-demo/Makefile @@ -16,7 +16,7 @@ CFLAGS += -DDEVICE_NAME=\"nRF52-DK-CoAP-Server\" endif # automatically build RESTful resources -PROJECTDIRS += ./resources +MODULES_REL += ./resources # REST Engine shall use Erbium CoAP implementation MODULES += os/net/app-layer/coap diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index 0870aacd9..80bdf5c85 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -5,14 +5,14 @@ CONTIKI = ../.. include $(CONTIKI)/Makefile.identify-target ifeq ($(TARGET),native) - PROJECTDIRS += native + MODULES_REL += native CFLAGS += -DPROJECT_CONF_PATH=\"native/project-conf.h\" else - PROJECTDIRS += embedded + MODULES_REL += embedded # For embedded platforms, include platform-specific directory - PROJECTDIRS += embedded/$(TARGET) + MODULES_REL += embedded/$(TARGET) CFLAGS += -DPROJECT_CONF_PATH=\"embedded/project-conf.h\" endif -PROJECTDIRS += common +MODULES_REL += common include $(CONTIKI)/Makefile.include diff --git a/examples/sensniff/Makefile b/examples/sensniff/Makefile index 3c04da8e4..a3c3286f2 100644 --- a/examples/sensniff/Makefile +++ b/examples/sensniff/Makefile @@ -2,7 +2,7 @@ CONTIKI_PROJECT = sensniff CONTIKI = ../.. PROJECT_SOURCEFILES += sensniff-mac.c netstack.c -PROJECTDIRS += pool $(TARGET) +MODULES_REL += pool $(TARGET) include $(CONTIKI)/Makefile.identify-target diff --git a/examples/slip-radio/Makefile b/examples/slip-radio/Makefile index 85c9e35b1..3ab7bffa3 100644 --- a/examples/slip-radio/Makefile +++ b/examples/slip-radio/Makefile @@ -5,7 +5,7 @@ MODULES += os/services/slip-cmd CONTIKI=../.. include $(CONTIKI)/Makefile.identify-target -PROJECTDIRS += $(TARGET) +MODULES_REL += $(TARGET) PROJECT_SOURCEFILES += slip-net.c # custom net layer, but with IPv6 enabled diff --git a/tools/sky/uip6-bridge/Makefile b/tools/sky/uip6-bridge/Makefile index ce605851e..55da6798e 100644 --- a/tools/sky/uip6-bridge/Makefile +++ b/tools/sky/uip6-bridge/Makefile @@ -12,7 +12,7 @@ ifndef TARGET TARGET=sky endif -PROJECTDIRS = dev +MODULES_REL += dev PROJECT_SOURCEFILES = fakeuip.c sicslow_ethernet.c all: uip6-bridge-tap.sky From e63d428a917b4755822985b120af36c7e7448b6a Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 19 Dec 2017 07:10:23 -0800 Subject: [PATCH 22/34] RPL BR: more rafactoring: move project-conf and sky module to project top-level --- examples/rpl-border-router/Makefile | 9 +-- .../rpl-border-router/embedded/project-conf.h | 55 ------------------- .../embedded/sky/Makefile.sky | 1 - .../rpl-border-router/native/Makefile.native | 1 + .../native/{project-conf.h => module-conf.h} | 12 ---- examples/rpl-border-router/sky/Makefile.sky | 1 + .../sky/target-conf.h => sky/module-conf.h} | 5 -- .../{embedded => }/sky/slip-bridge-putchar.c | 0 8 files changed, 4 insertions(+), 80 deletions(-) delete mode 100644 examples/rpl-border-router/embedded/project-conf.h delete mode 100644 examples/rpl-border-router/embedded/sky/Makefile.sky rename examples/rpl-border-router/native/{project-conf.h => module-conf.h} (88%) create mode 100644 examples/rpl-border-router/sky/Makefile.sky rename examples/rpl-border-router/{embedded/sky/target-conf.h => sky/module-conf.h} (89%) rename examples/rpl-border-router/{embedded => }/sky/slip-bridge-putchar.c (100%) diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index 80bdf5c85..3c2aae020 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -4,15 +4,10 @@ CONTIKI = ../.. include $(CONTIKI)/Makefile.identify-target -ifeq ($(TARGET),native) - MODULES_REL += native - CFLAGS += -DPROJECT_CONF_PATH=\"native/project-conf.h\" -else +ifneq ($(TARGET),native) MODULES_REL += embedded - # For embedded platforms, include platform-specific directory - MODULES_REL += embedded/$(TARGET) - CFLAGS += -DPROJECT_CONF_PATH=\"embedded/project-conf.h\" endif +MODULES_REL += $(TARGET) MODULES_REL += common include $(CONTIKI)/Makefile.include diff --git a/examples/rpl-border-router/embedded/project-conf.h b/examples/rpl-border-router/embedded/project-conf.h deleted file mode 100644 index 30ef25b90..000000000 --- a/examples/rpl-border-router/embedded/project-conf.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef PROJECT_ROUTER_CONF_H_ -#define PROJECT_ROUTER_CONF_H_ -/*---------------------------------------------------------------------------*/ -/* Include target-specific header */ -#ifdef TARGET_CONF_PATH -#include TARGET_CONF_PATH -#endif /* TARGET_CONF_PATH */ -/*---------------------------------------------------------------------------*/ -#ifndef UIP_FALLBACK_INTERFACE -#define UIP_FALLBACK_INTERFACE rpl_interface -#endif - -#ifndef WEBSERVER_CONF_CFS_CONNS -#define WEBSERVER_CONF_CFS_CONNS 2 -#endif - -#ifndef BORDER_ROUTER_CONF_WEBSERVER -#define BORDER_ROUTER_CONF_WEBSERVER 1 -#endif - -#if BORDER_ROUTER_CONF_WEBSERVER -#define UIP_CONF_TCP 1 -#endif - -#endif /* PROJECT_ROUTER_CONF_H_ */ diff --git a/examples/rpl-border-router/embedded/sky/Makefile.sky b/examples/rpl-border-router/embedded/sky/Makefile.sky deleted file mode 100644 index 17fefd5ee..000000000 --- a/examples/rpl-border-router/embedded/sky/Makefile.sky +++ /dev/null @@ -1 +0,0 @@ -CFLAGS += -DTARGET_CONF_PATH=\"target-conf.h\" diff --git a/examples/rpl-border-router/native/Makefile.native b/examples/rpl-border-router/native/Makefile.native index 62f7221a0..4a9dbcd2d 100644 --- a/examples/rpl-border-router/native/Makefile.native +++ b/examples/rpl-border-router/native/Makefile.native @@ -1,3 +1,4 @@ +CFLAGS += -DTARGET_CONF_PATH=\"native/module-conf.h\" MODULES += os/services/slip-cmd MAKE_MAC = MAKE_MAC_OTHER diff --git a/examples/rpl-border-router/native/project-conf.h b/examples/rpl-border-router/native/module-conf.h similarity index 88% rename from examples/rpl-border-router/native/project-conf.h rename to examples/rpl-border-router/native/module-conf.h index 841a31f67..6527738ad 100644 --- a/examples/rpl-border-router/native/project-conf.h +++ b/examples/rpl-border-router/native/module-conf.h @@ -27,13 +27,6 @@ * SUCH DAMAGE. */ -#ifndef PROJECT_ROUTER_CONF_H_ -#define PROJECT_ROUTER_CONF_H_ - -#define BORDER_ROUTER_CONF_WEBSERVER 1 - -#define UIP_FALLBACK_INTERFACE rpl_interface - /* use a non-default network driver */ #define NETSTACK_CONF_NETWORK sicslowpan_driver @@ -42,14 +35,9 @@ #define SLIP_DEV_CONF_SEND_DELAY (CLOCK_SECOND / 32) -#define WEBSERVER_CONF_CFS_CONNS 2 - #define SERIALIZE_ATTRIBUTES 1 -#define UIP_CONF_TCP 1 #define CMD_CONF_OUTPUT border_router_cmd_output /* used by wpcap (see /cpu/native/net/wpcap-drv.c) */ #define SELECT_CALLBACK 1 - -#endif /* PROJECT_ROUTER_CONF_H_ */ diff --git a/examples/rpl-border-router/sky/Makefile.sky b/examples/rpl-border-router/sky/Makefile.sky new file mode 100644 index 000000000..0058cf47f --- /dev/null +++ b/examples/rpl-border-router/sky/Makefile.sky @@ -0,0 +1 @@ +CFLAGS += -DTARGET_CONF_PATH=\"sky/module-conf.h\" diff --git a/examples/rpl-border-router/embedded/sky/target-conf.h b/examples/rpl-border-router/sky/module-conf.h similarity index 89% rename from examples/rpl-border-router/embedded/sky/target-conf.h rename to examples/rpl-border-router/sky/module-conf.h index 70cdab319..f9c7b408c 100644 --- a/examples/rpl-border-router/embedded/sky/target-conf.h +++ b/examples/rpl-border-router/sky/module-conf.h @@ -29,13 +29,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ -#ifndef TARGET_CONF_H_ -#define TARGET_CONF_H_ -/*---------------------------------------------------------------------------*/ /* Save some RAM and ROM */ #define QUEUEBUF_CONF_NUM 4 #define UIP_CONF_BUFFER_SIZE 140 #define BORDER_ROUTER_CONF_WEBSERVER 0 /*---------------------------------------------------------------------------*/ -#endif /* TARGET_CONF_H_ */ -/*---------------------------------------------------------------------------*/ diff --git a/examples/rpl-border-router/embedded/sky/slip-bridge-putchar.c b/examples/rpl-border-router/sky/slip-bridge-putchar.c similarity index 100% rename from examples/rpl-border-router/embedded/sky/slip-bridge-putchar.c rename to examples/rpl-border-router/sky/slip-bridge-putchar.c From cf262c57c82cc9d9c5746d0087a188f844600605 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 19 Dec 2017 07:23:43 -0800 Subject: [PATCH 23/34] RPL BR and slip-radio: use c flag '-imacros' to include module-specific defines --- examples/rpl-border-router/native/Makefile.native | 2 +- .../native/{module-conf.h => module-macros.h} | 0 examples/rpl-border-router/sky/Makefile.sky | 2 +- .../sky/{module-conf.h => module-macros.h} | 0 examples/slip-radio/project-conf.h | 6 +----- examples/slip-radio/sky/Makefile.sky | 2 +- examples/slip-radio/sky/{target-conf.h => module-macros.h} | 5 ----- 7 files changed, 4 insertions(+), 13 deletions(-) rename examples/rpl-border-router/native/{module-conf.h => module-macros.h} (100%) rename examples/rpl-border-router/sky/{module-conf.h => module-macros.h} (100%) rename examples/slip-radio/sky/{target-conf.h => module-macros.h} (89%) diff --git a/examples/rpl-border-router/native/Makefile.native b/examples/rpl-border-router/native/Makefile.native index 4a9dbcd2d..ee0fae43f 100644 --- a/examples/rpl-border-router/native/Makefile.native +++ b/examples/rpl-border-router/native/Makefile.native @@ -1,4 +1,4 @@ -CFLAGS += -DTARGET_CONF_PATH=\"native/module-conf.h\" +CFLAGS += -imacros native/module-macros.h MODULES += os/services/slip-cmd MAKE_MAC = MAKE_MAC_OTHER diff --git a/examples/rpl-border-router/native/module-conf.h b/examples/rpl-border-router/native/module-macros.h similarity index 100% rename from examples/rpl-border-router/native/module-conf.h rename to examples/rpl-border-router/native/module-macros.h diff --git a/examples/rpl-border-router/sky/Makefile.sky b/examples/rpl-border-router/sky/Makefile.sky index 0058cf47f..f4e066c2e 100644 --- a/examples/rpl-border-router/sky/Makefile.sky +++ b/examples/rpl-border-router/sky/Makefile.sky @@ -1 +1 @@ -CFLAGS += -DTARGET_CONF_PATH=\"sky/module-conf.h\" +CFLAGS += -imacros sky/module-macros.h diff --git a/examples/rpl-border-router/sky/module-conf.h b/examples/rpl-border-router/sky/module-macros.h similarity index 100% rename from examples/rpl-border-router/sky/module-conf.h rename to examples/rpl-border-router/sky/module-macros.h diff --git a/examples/slip-radio/project-conf.h b/examples/slip-radio/project-conf.h index 2f05bec5e..4283d0249 100644 --- a/examples/slip-radio/project-conf.h +++ b/examples/slip-radio/project-conf.h @@ -29,11 +29,7 @@ #ifndef PROJECT_CONF_H_ #define PROJECT_CONF_H_ -/*---------------------------------------------------------------------------*/ -/* Include target-specific header */ -#ifdef TARGET_CONF_PATH -#include TARGET_CONF_PATH -#endif /* TARGET_CONF_PATH */ + /*---------------------------------------------------------------------------*/ #define UIP_CONF_ROUTER 0 diff --git a/examples/slip-radio/sky/Makefile.sky b/examples/slip-radio/sky/Makefile.sky index 17fefd5ee..f4e066c2e 100644 --- a/examples/slip-radio/sky/Makefile.sky +++ b/examples/slip-radio/sky/Makefile.sky @@ -1 +1 @@ -CFLAGS += -DTARGET_CONF_PATH=\"target-conf.h\" +CFLAGS += -imacros sky/module-macros.h diff --git a/examples/slip-radio/sky/target-conf.h b/examples/slip-radio/sky/module-macros.h similarity index 89% rename from examples/slip-radio/sky/target-conf.h rename to examples/slip-radio/sky/module-macros.h index 08fa66512..cbf6a3827 100644 --- a/examples/slip-radio/sky/target-conf.h +++ b/examples/slip-radio/sky/module-macros.h @@ -29,9 +29,6 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ -#ifndef TARGET_CONF_H_ -#define TARGET_CONF_H_ -/*---------------------------------------------------------------------------*/ #define QUEUEBUF_CONF_NUM 4 #define UIP_CONF_BUFFER_SIZE 140 @@ -39,5 +36,3 @@ #define SLIP_RADIO_CONF_SENSORS slip_radio_sky_sensors #define UART1_CONF_RX_WITH_DMA 1 /*---------------------------------------------------------------------------*/ -#endif /* TARGET_CONF_H_ */ -/*---------------------------------------------------------------------------*/ From 070b493391c7fbb98c6f53c9935a0ccb99cedd30 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 19 Dec 2017 08:24:25 -0800 Subject: [PATCH 24/34] Automatically include module-macros.h when provided by modules --- Makefile.include | 10 +++++++++- examples/rpl-border-router/native/Makefile.native | 1 - examples/rpl-border-router/sky/Makefile.sky | 1 - examples/slip-radio/sky/Makefile.sky | 1 - 4 files changed, 9 insertions(+), 4 deletions(-) delete mode 100644 examples/rpl-border-router/sky/Makefile.sky delete mode 100644 examples/slip-radio/sky/Makefile.sky diff --git a/Makefile.include b/Makefile.include index 3bf19bd37..b1344c18f 100644 --- a/Makefile.include +++ b/Makefile.include @@ -165,9 +165,17 @@ endif MODULEDIRS = $(MODULES_REL) ${wildcard ${addprefix $(CONTIKI)/, $(MODULES)}} UNIQUEMODULES = $(call uniq,$(MODULEDIRS)) MODULES_SOURCES = ${foreach d, $(MODULEDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}} +CONTIKI_SOURCEFILES += $(MODULES_SOURCES) + +# Include module-specific makefiles MODULES_INCLUDES = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/Makefile.${notdir $(d)}}} include $(MODULES_INCLUDES) -CONTIKI_SOURCEFILES += $(MODULES_SOURCES) + +# C-include module-specific macros using -imacros +MODULES_IMACROS = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/module-macros.h}} +ifneq ($(MODULES_IMACROS),) + CFLAGS += ${foreach d, $(MODULES_IMACROS), -imacros $(d)} +endif ### Verbosity control. Use make V=1 to get verbose builds. diff --git a/examples/rpl-border-router/native/Makefile.native b/examples/rpl-border-router/native/Makefile.native index ee0fae43f..62f7221a0 100644 --- a/examples/rpl-border-router/native/Makefile.native +++ b/examples/rpl-border-router/native/Makefile.native @@ -1,4 +1,3 @@ -CFLAGS += -imacros native/module-macros.h MODULES += os/services/slip-cmd MAKE_MAC = MAKE_MAC_OTHER diff --git a/examples/rpl-border-router/sky/Makefile.sky b/examples/rpl-border-router/sky/Makefile.sky deleted file mode 100644 index f4e066c2e..000000000 --- a/examples/rpl-border-router/sky/Makefile.sky +++ /dev/null @@ -1 +0,0 @@ -CFLAGS += -imacros sky/module-macros.h diff --git a/examples/slip-radio/sky/Makefile.sky b/examples/slip-radio/sky/Makefile.sky deleted file mode 100644 index f4e066c2e..000000000 --- a/examples/slip-radio/sky/Makefile.sky +++ /dev/null @@ -1 +0,0 @@ -CFLAGS += -imacros sky/module-macros.h From 89c4f5e509ffffd42bc541f35bab97010deb8894 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 19 Dec 2017 08:44:40 -0800 Subject: [PATCH 25/34] RPL BR: rework such as the main .c file defines its own process --- examples/rpl-border-router/border-router.c | 27 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/examples/rpl-border-router/border-router.c b/examples/rpl-border-router/border-router.c index 30b6d6150..668b1d6dd 100644 --- a/examples/rpl-border-router/border-router.c +++ b/examples/rpl-border-router/border-router.c @@ -32,11 +32,28 @@ #include "contiki.h" -PROCESS_NAME(border_router_process); +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "RPL BR" +#define LOG_LEVEL LOG_LEVEL_INFO +/* Declare and auto-start this file's process */ +PROCESS(contiki_ng_br, "Contiki-NG Border Router"); +AUTOSTART_PROCESSES(&contiki_ng_br); + +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(contiki_ng_br, ev, data) +{ + PROCESS_BEGIN(); + + PROCESS_NAME(border_router_process); + process_start(&border_router_process, NULL); #if BORDER_ROUTER_CONF_WEBSERVER -PROCESS_NAME(webserver_nogui_process); -AUTOSTART_PROCESSES(&border_router_process, &webserver_nogui_process); -#else /* BORDER_ROUTER_CONF_WEBSERVER */ -AUTOSTART_PROCESSES(&border_router_process); + PROCESS_NAME(webserver_nogui_process); + process_start(&webserver_nogui_process, NULL); #endif /* BORDER_ROUTER_CONF_WEBSERVER */ + + LOG_INFO("Contiki-NG Border Router started\n"); + + PROCESS_END(); +} From 6de6e15ce7d7198db3fdf8848a070b081890d4d7 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 19 Dec 2017 09:02:21 -0800 Subject: [PATCH 26/34] Move RPL border router from example to os/services --- Makefile.include | 3 ++ arch/platform/cooja/contiki-cooja-main.c | 4 ++ examples/rpl-border-router/Makefile | 10 ++-- examples/rpl-border-router/border-router.c | 2 - examples/rpl-border-router/project-conf.h | 46 +++++++++++++++++++ .../{common => webserver}/httpd-simple.c | 0 .../{common => webserver}/httpd-simple.h | 0 .../{common => webserver}/webserver.c | 0 os/contiki-main.c | 6 +++ .../embedded/Makefile.embedded | 0 .../rpl-border-router/embedded/README.md | 0 .../embedded/border-router-embedded.c | 2 +- .../rpl-border-router/embedded/slip-bridge.c | 0 .../rpl-border-router/native/Makefile.native | 0 .../rpl-border-router/native/README.md | 0 .../native/border-router-cmds.c | 0 .../native/border-router-cmds.h | 0 .../native/border-router-mac.c | 0 .../native/border-router-native.c | 2 +- .../rpl-border-router/native/border-router.h | 0 .../rpl-border-router/native/module-macros.h | 0 .../rpl-border-router/native/slip-config.c | 0 .../rpl-border-router/native/slip-dev.c | 0 .../rpl-border-router/native/tun-bridge.c | 0 .../rpl-border-router/rpl-border-router.c | 10 +++- .../rpl-border-router/rpl-border-router.h | 1 + .../sky/slip-bridge-putchar.c | 0 27 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 examples/rpl-border-router/project-conf.h rename examples/rpl-border-router/{common => webserver}/httpd-simple.c (100%) rename examples/rpl-border-router/{common => webserver}/httpd-simple.h (100%) rename examples/rpl-border-router/{common => webserver}/webserver.c (100%) rename {examples => os/services}/rpl-border-router/embedded/Makefile.embedded (100%) rename {examples => os/services}/rpl-border-router/embedded/README.md (100%) rename {examples => os/services}/rpl-border-router/embedded/border-router-embedded.c (99%) rename {examples => os/services}/rpl-border-router/embedded/slip-bridge.c (100%) rename {examples => os/services}/rpl-border-router/native/Makefile.native (100%) rename {examples => os/services}/rpl-border-router/native/README.md (100%) rename {examples => os/services}/rpl-border-router/native/border-router-cmds.c (100%) rename {examples => os/services}/rpl-border-router/native/border-router-cmds.h (100%) rename {examples => os/services}/rpl-border-router/native/border-router-mac.c (100%) rename {examples => os/services}/rpl-border-router/native/border-router-native.c (99%) rename {examples => os/services}/rpl-border-router/native/border-router.h (100%) rename {examples => os/services}/rpl-border-router/native/module-macros.h (100%) rename {examples => os/services}/rpl-border-router/native/slip-config.c (100%) rename {examples => os/services}/rpl-border-router/native/slip-dev.c (100%) rename {examples => os/services}/rpl-border-router/native/tun-bridge.c (100%) rename examples/rpl-border-router/common/border-router-common.c => os/services/rpl-border-router/rpl-border-router.c (88%) rename examples/rpl-border-router/common/border-router-common.h => os/services/rpl-border-router/rpl-border-router.h (98%) rename {examples => os/services}/rpl-border-router/sky/slip-bridge-putchar.c (100%) diff --git a/Makefile.include b/Makefile.include index b1344c18f..0c6cc679f 100644 --- a/Makefile.include +++ b/Makefile.include @@ -170,6 +170,9 @@ CONTIKI_SOURCEFILES += $(MODULES_SOURCES) # Include module-specific makefiles MODULES_INCLUDES = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/Makefile.${notdir $(d)}}} include $(MODULES_INCLUDES) +# Iterate once more: include the modules added from the previous include. +# Only works with one level of nested module inclusion. +include $(MODULES_INCLUDES) # C-include module-specific macros using -imacros MODULES_IMACROS = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/module-macros.h}} diff --git a/arch/platform/cooja/contiki-cooja-main.c b/arch/platform/cooja/contiki-cooja-main.c index d418e7039..53c8eb7d8 100644 --- a/arch/platform/cooja/contiki-cooja-main.c +++ b/arch/platform/cooja/contiki-cooja-main.c @@ -61,6 +61,7 @@ #include "dev/vib-sensor.h" #include "sys/node-id.h" +#include "services/rpl-border-router/rpl-border-router.h" #if BUILD_WITH_ORCHESTRA #include "orchestra.h" #endif /* BUILD_WITH_ORCHESTRA */ @@ -240,6 +241,9 @@ contiki_init() /* Start serial process */ serial_line_init(); +#if BUILD_WITH_RPL_BORDER_ROUTER + rpl_border_router_init(); +#endif /* BUILD_WITH_RPL_BORDER_ROUTER */ #if BUILD_WITH_ORCHESTRA orchestra_init(); #endif /* BUILD_WITH_ORCHESTRA */ diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index 3c2aae020..d8b14d5bd 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -2,12 +2,12 @@ CONTIKI_PROJECT = border-router all: $(CONTIKI_PROJECT) CONTIKI = ../.. +# Include RPL BR module +MODULES += os/services/rpl-border-router +# Include webserver module +MODULES_REL += webserver +# Include optional target-specific module include $(CONTIKI)/Makefile.identify-target - -ifneq ($(TARGET),native) - MODULES_REL += embedded -endif MODULES_REL += $(TARGET) -MODULES_REL += common include $(CONTIKI)/Makefile.include diff --git a/examples/rpl-border-router/border-router.c b/examples/rpl-border-router/border-router.c index 668b1d6dd..416d18093 100644 --- a/examples/rpl-border-router/border-router.c +++ b/examples/rpl-border-router/border-router.c @@ -46,8 +46,6 @@ PROCESS_THREAD(contiki_ng_br, ev, data) { PROCESS_BEGIN(); - PROCESS_NAME(border_router_process); - process_start(&border_router_process, NULL); #if BORDER_ROUTER_CONF_WEBSERVER PROCESS_NAME(webserver_nogui_process); process_start(&webserver_nogui_process, NULL); diff --git a/examples/rpl-border-router/project-conf.h b/examples/rpl-border-router/project-conf.h new file mode 100644 index 000000000..a2ffcc950 --- /dev/null +++ b/examples/rpl-border-router/project-conf.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ + +#ifndef WEBSERVER_CONF_CFS_CONNS +#define WEBSERVER_CONF_CFS_CONNS 2 +#endif + +#ifndef BORDER_ROUTER_CONF_WEBSERVER +#define BORDER_ROUTER_CONF_WEBSERVER 1 +#endif + +#if BORDER_ROUTER_CONF_WEBSERVER +#define UIP_CONF_TCP 1 +#endif + +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/rpl-border-router/common/httpd-simple.c b/examples/rpl-border-router/webserver/httpd-simple.c similarity index 100% rename from examples/rpl-border-router/common/httpd-simple.c rename to examples/rpl-border-router/webserver/httpd-simple.c diff --git a/examples/rpl-border-router/common/httpd-simple.h b/examples/rpl-border-router/webserver/httpd-simple.h similarity index 100% rename from examples/rpl-border-router/common/httpd-simple.h rename to examples/rpl-border-router/webserver/httpd-simple.h diff --git a/examples/rpl-border-router/common/webserver.c b/examples/rpl-border-router/webserver/webserver.c similarity index 100% rename from examples/rpl-border-router/common/webserver.c rename to examples/rpl-border-router/webserver/webserver.c diff --git a/os/contiki-main.c b/os/contiki-main.c index 62638c8a7..234b759ee 100644 --- a/os/contiki-main.c +++ b/os/contiki-main.c @@ -47,6 +47,7 @@ #include "sys/stack-check.h" #include "dev/watchdog.h" +#include "services/rpl-border-router/rpl-border-router.h" #include "services/orchestra/orchestra.h" #include "services/shell/serial-shell.h" @@ -110,6 +111,11 @@ main(void) platform_init_stage_three(); +#if BUILD_WITH_RPL_BORDER_ROUTER + rpl_border_router_init(); + LOG_DBG("With RPL Border Router\n"); +#endif /* BUILD_WITH_RPL_BORDER_ROUTER */ + #if BUILD_WITH_ORCHESTRA orchestra_init(); LOG_DBG("With Orchestra\n"); diff --git a/examples/rpl-border-router/embedded/Makefile.embedded b/os/services/rpl-border-router/embedded/Makefile.embedded similarity index 100% rename from examples/rpl-border-router/embedded/Makefile.embedded rename to os/services/rpl-border-router/embedded/Makefile.embedded diff --git a/examples/rpl-border-router/embedded/README.md b/os/services/rpl-border-router/embedded/README.md similarity index 100% rename from examples/rpl-border-router/embedded/README.md rename to os/services/rpl-border-router/embedded/README.md diff --git a/examples/rpl-border-router/embedded/border-router-embedded.c b/os/services/rpl-border-router/embedded/border-router-embedded.c similarity index 99% rename from examples/rpl-border-router/embedded/border-router-embedded.c rename to os/services/rpl-border-router/embedded/border-router-embedded.c index d1d8cdafc..8ec4bd49c 100644 --- a/examples/rpl-border-router/embedded/border-router-embedded.c +++ b/os/services/rpl-border-router/embedded/border-router-embedded.c @@ -39,7 +39,7 @@ #include "rpl.h" #include "dev/button-sensor.h" #include "dev/slip.h" -#include "border-router-common.h" +#include "rpl-border-router.h" /*---------------------------------------------------------------------------*/ /* Log configuration */ diff --git a/examples/rpl-border-router/embedded/slip-bridge.c b/os/services/rpl-border-router/embedded/slip-bridge.c similarity index 100% rename from examples/rpl-border-router/embedded/slip-bridge.c rename to os/services/rpl-border-router/embedded/slip-bridge.c diff --git a/examples/rpl-border-router/native/Makefile.native b/os/services/rpl-border-router/native/Makefile.native similarity index 100% rename from examples/rpl-border-router/native/Makefile.native rename to os/services/rpl-border-router/native/Makefile.native diff --git a/examples/rpl-border-router/native/README.md b/os/services/rpl-border-router/native/README.md similarity index 100% rename from examples/rpl-border-router/native/README.md rename to os/services/rpl-border-router/native/README.md diff --git a/examples/rpl-border-router/native/border-router-cmds.c b/os/services/rpl-border-router/native/border-router-cmds.c similarity index 100% rename from examples/rpl-border-router/native/border-router-cmds.c rename to os/services/rpl-border-router/native/border-router-cmds.c diff --git a/examples/rpl-border-router/native/border-router-cmds.h b/os/services/rpl-border-router/native/border-router-cmds.h similarity index 100% rename from examples/rpl-border-router/native/border-router-cmds.h rename to os/services/rpl-border-router/native/border-router-cmds.h diff --git a/examples/rpl-border-router/native/border-router-mac.c b/os/services/rpl-border-router/native/border-router-mac.c similarity index 100% rename from examples/rpl-border-router/native/border-router-mac.c rename to os/services/rpl-border-router/native/border-router-mac.c diff --git a/examples/rpl-border-router/native/border-router-native.c b/os/services/rpl-border-router/native/border-router-native.c similarity index 99% rename from examples/rpl-border-router/native/border-router-native.c rename to os/services/rpl-border-router/native/border-router-native.c index fd5e3cde7..07bd322c6 100644 --- a/examples/rpl-border-router/native/border-router-native.c +++ b/os/services/rpl-border-router/native/border-router-native.c @@ -41,7 +41,7 @@ #include "contiki.h" #include "contiki-net.h" #include "rpl.h" -#include "border-router-common.h" +#include "rpl-border-router.h" #include "cmd.h" #include "border-router.h" #include "border-router-cmds.h" diff --git a/examples/rpl-border-router/native/border-router.h b/os/services/rpl-border-router/native/border-router.h similarity index 100% rename from examples/rpl-border-router/native/border-router.h rename to os/services/rpl-border-router/native/border-router.h diff --git a/examples/rpl-border-router/native/module-macros.h b/os/services/rpl-border-router/native/module-macros.h similarity index 100% rename from examples/rpl-border-router/native/module-macros.h rename to os/services/rpl-border-router/native/module-macros.h diff --git a/examples/rpl-border-router/native/slip-config.c b/os/services/rpl-border-router/native/slip-config.c similarity index 100% rename from examples/rpl-border-router/native/slip-config.c rename to os/services/rpl-border-router/native/slip-config.c diff --git a/examples/rpl-border-router/native/slip-dev.c b/os/services/rpl-border-router/native/slip-dev.c similarity index 100% rename from examples/rpl-border-router/native/slip-dev.c rename to os/services/rpl-border-router/native/slip-dev.c diff --git a/examples/rpl-border-router/native/tun-bridge.c b/os/services/rpl-border-router/native/tun-bridge.c similarity index 100% rename from examples/rpl-border-router/native/tun-bridge.c rename to os/services/rpl-border-router/native/tun-bridge.c diff --git a/examples/rpl-border-router/common/border-router-common.c b/os/services/rpl-border-router/rpl-border-router.c similarity index 88% rename from examples/rpl-border-router/common/border-router-common.c rename to os/services/rpl-border-router/rpl-border-router.c index ba3288777..59426d7f9 100644 --- a/examples/rpl-border-router/common/border-router-common.c +++ b/os/services/rpl-border-router/rpl-border-router.c @@ -31,7 +31,7 @@ */ #include "contiki.h" -#include "border-router-common.h" +#include "rpl-border-router.h" #include "rpl-dag-root.h" /* Log configuration */ @@ -67,3 +67,11 @@ set_prefix_64(uip_ipaddr_t *prefix_64) rpl_dag_root_init(prefix_64, NULL); rpl_dag_root_init_dag_immediately(); } +/*---------------------------------------------------------------------------*/ +void +rpl_border_router_init(void) +{ + PROCESS_NAME(border_router_process); + process_start(&border_router_process, NULL); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/rpl-border-router/common/border-router-common.h b/os/services/rpl-border-router/rpl-border-router.h similarity index 98% rename from examples/rpl-border-router/common/border-router-common.h rename to os/services/rpl-border-router/rpl-border-router.h index 25d58aab0..50d66ad05 100644 --- a/examples/rpl-border-router/common/border-router-common.h +++ b/os/services/rpl-border-router/rpl-border-router.h @@ -36,5 +36,6 @@ extern uint8_t prefix_set; +void rpl_border_router_init(void); void print_local_addresses(void); void set_prefix_64(uip_ipaddr_t *prefix_64); diff --git a/examples/rpl-border-router/sky/slip-bridge-putchar.c b/os/services/rpl-border-router/sky/slip-bridge-putchar.c similarity index 100% rename from examples/rpl-border-router/sky/slip-bridge-putchar.c rename to os/services/rpl-border-router/sky/slip-bridge-putchar.c From 91ca67d3936d230fca07b1c2560ac38fbad35b3e Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 19 Dec 2017 09:50:03 -0800 Subject: [PATCH 27/34] CI: minor printout fix --- .../Makefile.rpl-border-router | 10 ++++++ os/services/rpl-border-router/module-macros.h | 31 +++++++++++++++++++ tests/17-tun-rpl-br/06-native-coap.sh | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 os/services/rpl-border-router/Makefile.rpl-border-router create mode 100644 os/services/rpl-border-router/module-macros.h diff --git a/os/services/rpl-border-router/Makefile.rpl-border-router b/os/services/rpl-border-router/Makefile.rpl-border-router new file mode 100644 index 000000000..f1f28e096 --- /dev/null +++ b/os/services/rpl-border-router/Makefile.rpl-border-router @@ -0,0 +1,10 @@ +CFLAGS += -DBUILD_WITH_RPL_BORDER_ROUTER=1 + +include $(CONTIKI)/Makefile.identify-target + +# Include 'embedded' module for non-native platforms +ifneq ($(TARGET),native) + MODULES += os/services/rpl-border-router/embedded +endif +# Include optional target-specific module +MODULES += os/services/rpl-border-router/$(TARGET) diff --git a/os/services/rpl-border-router/module-macros.h b/os/services/rpl-border-router/module-macros.h new file mode 100644 index 000000000..2f2a8306c --- /dev/null +++ b/os/services/rpl-border-router/module-macros.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, RISE SICS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#define UIP_FALLBACK_INTERFACE rpl_interface diff --git a/tests/17-tun-rpl-br/06-native-coap.sh b/tests/17-tun-rpl-br/06-native-coap.sh index a42424ee4..453d76e2e 100755 --- a/tests/17-tun-rpl-br/06-native-coap.sh +++ b/tests/17-tun-rpl-br/06-native-coap.sh @@ -44,7 +44,7 @@ sleep 2 pgrep hello-world | sudo xargs kill -9 if [ $TESTCOUNT -eq $OKCOUNT ] ; then - printf "%-40s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" > $BASENAME.testlog; + printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" > $BASENAME.testlog; else echo "==== make.log ====" ; cat make.log; echo "==== make.err ====" ; cat make.err; From 7f1dd819ef5d457439528b4a29b570a7eb691cc0 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 22 Dec 2017 00:26:44 -0800 Subject: [PATCH 28/34] RPL BR: remove platform-specific code for sky. Add putchar with SLIP support to arch, like in other platforms --- arch/cpu/msp430/dev/uart0-putchar.c | 32 +++++++++- arch/cpu/msp430/dev/uart1-putchar.c | 32 +++++++++- arch/cpu/msp430/msp430-conf.h | 60 ++++++++++------- .../Makefile.rpl-border-router | 10 ++- os/services/rpl-border-router/module-macros.h | 3 +- .../sky/slip-bridge-putchar.c | 64 ------------------- 6 files changed, 105 insertions(+), 96 deletions(-) delete mode 100644 os/services/rpl-border-router/sky/slip-bridge-putchar.c diff --git a/arch/cpu/msp430/dev/uart0-putchar.c b/arch/cpu/msp430/dev/uart0-putchar.c index bf237695b..4c92f9160 100644 --- a/arch/cpu/msp430/dev/uart0-putchar.c +++ b/arch/cpu/msp430/dev/uart0-putchar.c @@ -1,9 +1,39 @@ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" #include "dev/uart0.h" -/* In case of IPv4: putchar() is defined by the SLIP driver */ +#include +/*---------------------------------------------------------------------------*/ +#define SLIP_END 0300 +#undef putchar +/*---------------------------------------------------------------------------*/ int putchar(int c) { +#if SLIP_ARCH_CONF_ENABLED + static char debug_frame = 0; + + if(!debug_frame) { /* Start of debug output */ + uart0_writeb(SLIP_END); + uart0_writeb('\r'); /* Type debug line == '\r' */ + debug_frame = 1; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ + + /* Need to also print '\n' because for example COOJA will not show + any output before line end */ uart0_writeb((char)c); + +#if SLIP_ARCH_CONF_ENABLED + /* + * Line buffered output, a newline marks the end of debug output and + * implicitly flushes debug output. + */ + if(c == '\n') { + uart0_writeb(SLIP_END); + debug_frame = 0; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ return c; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/dev/uart1-putchar.c b/arch/cpu/msp430/dev/uart1-putchar.c index 7623b435a..14146d9dc 100644 --- a/arch/cpu/msp430/dev/uart1-putchar.c +++ b/arch/cpu/msp430/dev/uart1-putchar.c @@ -1,9 +1,39 @@ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" #include "dev/uart1.h" -/* In case of IPv4: putchar() is defined by the SLIP driver */ +#include +/*---------------------------------------------------------------------------*/ +#define SLIP_END 0300 +#undef putchar +/*---------------------------------------------------------------------------*/ int putchar(int c) { +#if SLIP_ARCH_CONF_ENABLED + static char debug_frame = 0; + + if(!debug_frame) { /* Start of debug output */ + uart1_writeb(SLIP_END); + uart1_writeb('\r'); /* Type debug line == '\r' */ + debug_frame = 1; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ + + /* Need to also print '\n' because for example COOJA will not show + any output before line end */ uart1_writeb((char)c); + +#if SLIP_ARCH_CONF_ENABLED + /* + * Line buffered output, a newline marks the end of debug output and + * implicitly flushes debug output. + */ + if(c == '\n') { + uart1_writeb(SLIP_END); + debug_frame = 0; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ return c; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/msp430-conf.h b/arch/cpu/msp430/msp430-conf.h index ec4f49a55..f4f0da54c 100644 --- a/arch/cpu/msp430/msp430-conf.h +++ b/arch/cpu/msp430/msp430-conf.h @@ -1,30 +1,30 @@ /* * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ #ifndef MSP430_CONF_H_ @@ -42,6 +42,20 @@ #else #define MSP430_CPU_SPEED 2457600UL #endif + +#ifndef SLIP_ARCH_CONF_ENABLED +/* + * Determine whether we need SLIP + * This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT + * keep using SLIP + */ +#if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT) +#define SLIP_ARCH_CONF_ENABLED 1 +#else +#define SLIP_ARCH_CONF_ENABLED 0 +#endif +#endif + /*---------------------------------------------------------------------------*/ #endif /* MSP430_CONF_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/os/services/rpl-border-router/Makefile.rpl-border-router b/os/services/rpl-border-router/Makefile.rpl-border-router index f1f28e096..61ba5fa59 100644 --- a/os/services/rpl-border-router/Makefile.rpl-border-router +++ b/os/services/rpl-border-router/Makefile.rpl-border-router @@ -1,10 +1,8 @@ -CFLAGS += -DBUILD_WITH_RPL_BORDER_ROUTER=1 - include $(CONTIKI)/Makefile.identify-target -# Include 'embedded' module for non-native platforms -ifneq ($(TARGET),native) +# Include either native or embedded BR +ifeq ($(TARGET),native) + MODULES += os/services/rpl-border-router/native +else MODULES += os/services/rpl-border-router/embedded endif -# Include optional target-specific module -MODULES += os/services/rpl-border-router/$(TARGET) diff --git a/os/services/rpl-border-router/module-macros.h b/os/services/rpl-border-router/module-macros.h index 2f2a8306c..f3fad0b9b 100644 --- a/os/services/rpl-border-router/module-macros.h +++ b/os/services/rpl-border-router/module-macros.h @@ -28,4 +28,5 @@ * */ -#define UIP_FALLBACK_INTERFACE rpl_interface +#define BUILD_WITH_RPL_BORDER_ROUTER 1 +#define UIP_FALLBACK_INTERFACE rpl_interface diff --git a/os/services/rpl-border-router/sky/slip-bridge-putchar.c b/os/services/rpl-border-router/sky/slip-bridge-putchar.c deleted file mode 100644 index f7f501ba1..000000000 --- a/os/services/rpl-border-router/sky/slip-bridge-putchar.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/*---------------------------------------------------------------------------*/ -#include "contiki.h" -#include "dev/slip.h" - -#include -/*---------------------------------------------------------------------------*/ -#define SLIP_END 0300 -#undef putchar -/*---------------------------------------------------------------------------*/ -int -putchar(int c) -{ - static char debug_frame = 0; - - if(!debug_frame) { /* Start of debug output */ - slip_arch_writeb(SLIP_END); - slip_arch_writeb('\r'); /* Type debug line == '\r' */ - debug_frame = 1; - } - - /* Need to also print '\n' because for example COOJA will not show - any output before line end */ - slip_arch_writeb((char)c); - - /* - * Line buffered output, a newline marks the end of debug output and - * implicitly flushes debug output. - */ - if(c == '\n') { - slip_arch_writeb(SLIP_END); - debug_frame = 0; - } - return c; -} -/*---------------------------------------------------------------------------*/ From fa765e67b063ac2d31ff10e4258cd07e3953fdf8 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 22 Dec 2017 00:27:03 -0800 Subject: [PATCH 29/34] JN516x: fix SLIP configuration --- arch/platform/jn516x/jn516x-def.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/platform/jn516x/jn516x-def.h b/arch/platform/jn516x/jn516x-def.h index 357c255c0..4861d00b3 100644 --- a/arch/platform/jn516x/jn516x-def.h +++ b/arch/platform/jn516x/jn516x-def.h @@ -272,9 +272,14 @@ typedef uint32_t clock_time_t; /* Set this to zero only if we are using SLIP */ #ifndef SLIP_BRIDGE_CONF_NO_PUTCHAR -#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1 +#if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT) +#define SLIP_BRIDGE_CONF_NO_PUTCHAR 0 +#else +#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1 +#endif #endif /* SLIP_BRIDGE_CONF_NO_PUTCHAR */ + /* Extension of LED definitions from leds.h for various JN516x dev boards JN516x Dongle: LEDS_RED Red LED on dongle From f56822e968fbc804f848e2f72be8d6b8f59e8a44 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 16 Dec 2017 01:13:09 +0000 Subject: [PATCH 30/34] Include contiki.h to pull in possible configuration --- os/lib/list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/lib/list.c b/os/lib/list.c index 401da617e..ccd3865d8 100644 --- a/os/lib/list.c +++ b/os/lib/list.c @@ -44,7 +44,7 @@ * \addtogroup list * @{ */ - +#include "contiki.h" #include "lib/list.h" #define NULL 0 From b6aac6b008771bbee6ec0a4e211d445805313bff Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 16 Dec 2017 01:13:34 +0000 Subject: [PATCH 31/34] Don't define NULL internally --- os/lib/list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os/lib/list.c b/os/lib/list.c index ccd3865d8..111ef03c3 100644 --- a/os/lib/list.c +++ b/os/lib/list.c @@ -47,8 +47,8 @@ #include "contiki.h" #include "lib/list.h" -#define NULL 0 - +#include +/*---------------------------------------------------------------------------*/ struct list { struct list *next; }; From fe2c960756e40027d0154df55bf01197ea7af946 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 16 Dec 2017 01:14:54 +0000 Subject: [PATCH 32/34] Tidy-up codestyle --- os/lib/list.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/os/lib/list.c b/os/lib/list.c index 111ef03c3..605fe9c53 100644 --- a/os/lib/list.c +++ b/os/lib/list.c @@ -52,7 +52,6 @@ struct list { struct list *next; }; - /*---------------------------------------------------------------------------*/ /** * Initialize a list. @@ -118,13 +117,13 @@ void * list_tail(list_t list) { struct list *l; - + if(*list == NULL) { return NULL; } - + for(l = *list; l->next != NULL; l = l->next); - + return l; } /*---------------------------------------------------------------------------*/ @@ -148,7 +147,7 @@ list_add(list_t list, void *item) list_remove(list, item); ((struct list *)item)->next = NULL; - + l = list_tail(list); if(l == NULL) { @@ -164,8 +163,6 @@ list_add(list_t list, void *item) void list_push(list_t list, void *item) { - /* struct list *l;*/ - /* Make sure not to add the same element twice */ list_remove(list, item); @@ -186,7 +183,7 @@ void * list_chop(list_t list) { struct list *l, *r; - + if(*list == NULL) { return NULL; } @@ -195,12 +192,12 @@ list_chop(list_t list) *list = NULL; return l; } - + for(l = *list; l->next->next != NULL; l = l->next); r = l->next; l->next = NULL; - + return r; } /*---------------------------------------------------------------------------*/ @@ -240,20 +237,20 @@ void list_remove(list_t list, void *item) { struct list *l, *r; - + if(*list == NULL) { return; } - + r = NULL; for(l = *list; l != NULL; l = l->next) { if(l == item) { if(r == NULL) { - /* First on list */ - *list = l->next; + /* First on list */ + *list = l->next; } else { - /* Not first on list */ - r->next = l->next; + /* Not first on list */ + r->next = l->next; } l->next = NULL; return; @@ -324,7 +321,7 @@ list_insert(list_t list, void *previtem, void *newitem) void * list_item_next(void *item) { - return item == NULL? NULL: ((struct list *)item)->next; + return item == NULL ? NULL : ((struct list *)item)->next; } /*---------------------------------------------------------------------------*/ /** @} */ From bcd75789d524e3e618ac02ed99f55321ea78ea24 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 16 Dec 2017 01:15:25 +0000 Subject: [PATCH 33/34] Make sure we don't add the same item twice Fixes #254 --- os/lib/list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/lib/list.c b/os/lib/list.c index 605fe9c53..afa9df585 100644 --- a/os/lib/list.c +++ b/os/lib/list.c @@ -302,7 +302,7 @@ list_insert(list_t list, void *previtem, void *newitem) if(previtem == NULL) { list_push(list, newitem); } else { - + list_remove(list, newitem); ((struct list *)newitem)->next = ((struct list *)previtem)->next; ((struct list *)previtem)->next = newitem; } From 3aca0cf9f6dc97e9876b9ab299369d5239242bbb Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 16 Dec 2017 01:45:10 +0000 Subject: [PATCH 34/34] Add lists to the data structure unit tests --- .../test-data-structures.c | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/tests/07-simulation-base/code-data-structures/test-data-structures.c b/tests/07-simulation-base/code-data-structures/test-data-structures.c index e682e43da..dc4d8bb5b 100644 --- a/tests/07-simulation-base/code-data-structures/test-data-structures.c +++ b/tests/07-simulation-base/code-data-structures/test-data-structures.c @@ -30,6 +30,7 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" +#include "lib/list.h" #include "lib/stack.h" #include "lib/queue.h" #include "lib/circular-list.h" @@ -65,6 +66,141 @@ print_test_report(const unit_test_t *utp) } } /*---------------------------------------------------------------------------*/ +UNIT_TEST_REGISTER(test_list, "Singly-linked list"); +UNIT_TEST(test_list) +{ + demo_struct_t *head, *tail; + + LIST(lst); + + UNIT_TEST_BEGIN(); + + memset(elements, 0, sizeof(elements)); + list_init(lst); + + /* Starts from empty */ + UNIT_TEST_ASSERT(list_head(lst) == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 0); + + /* + * Add an item. Should be head and tail + * 0 --> NULL + */ + list_add(lst, &elements[0]); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[0]); + UNIT_TEST_ASSERT(elements[0].next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 1); + + /* + * Add an item. Should become the new tail + * 0 --> 1 --> NULL + */ + list_add(lst, &elements[1]); + head = list_head(lst); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[1]); + UNIT_TEST_ASSERT(head->next == tail); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 2); + + /* + * Add after existing head + * 0 --> 2 --> 1 --> NULL + */ + head = list_head(lst); + list_insert(lst, head, &elements[2]); + head = list_head(lst); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[1]); + UNIT_TEST_ASSERT(head->next == &elements[2]); + UNIT_TEST_ASSERT(elements[2].next == tail); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 3); + + /* + * Add after existing head + * 0 --> 2 --> 1 --> 3 --> NULL + */ + tail = list_tail(lst); + list_insert(lst, tail, &elements[3]); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[3]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 4); + + /* + * Re-add item 2 using list_add + * 0 --> 1 --> 3 --> 2 --> NULL + */ + list_add(lst, &elements[2]); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[2]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 4); + + /* + * Re-add item 3 using list_insert + * 0 --> 1 --> 2 --> 3 --> NULL + */ + tail = list_tail(lst); + list_insert(lst, tail, &elements[3]); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[3]); + UNIT_TEST_ASSERT(elements[2].next == tail); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 4); + + /* + * Remove the tail + * 0 --> 1 --> 2 --> NULL + */ + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_chop(lst) == tail); + head = list_head(lst); + tail = list_tail(lst); + UNIT_TEST_ASSERT(tail == &elements[2]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 3); + + /* + * Remove an item in the middle + * 0 --> 2 --> NULL + */ + head = list_head(lst); + list_remove(lst, head->next); + head = list_head(lst); + tail = list_tail(lst); + UNIT_TEST_ASSERT(head->next == tail); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[2]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 2); + + /* + * Remove the head + * 2 --> NULL + */ + list_remove(lst, list_head(lst)); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[2]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[2]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 1); + + /* Ends empty */ + list_remove(lst, list_tail(lst)); + UNIT_TEST_ASSERT(list_head(lst) == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 0); + + UNIT_TEST_END(); +} +/*---------------------------------------------------------------------------*/ UNIT_TEST_REGISTER(test_stack, "Stack Push/Pop"); UNIT_TEST(test_stack) { @@ -884,6 +1020,7 @@ PROCESS_THREAD(data_structure_test_process, ev, data) memset(elements, 0, sizeof(elements)); + UNIT_TEST_RUN(test_list); UNIT_TEST_RUN(test_stack); UNIT_TEST_RUN(test_queue); UNIT_TEST_RUN(test_csll);