From 0952960b91ea3a105f08eaf5dd53bd139b3210f5 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 10 Nov 2017 17:00:23 +0100 Subject: [PATCH 01/18] Removing multi-threading support --- arch/cpu/arm/common/sys/mtarch.c | 281 --------------------------- arch/cpu/arm/common/sys/mtarch.h | 119 ------------ arch/cpu/cc2538/startup-gcc.c | 6 +- arch/cpu/cc26xx-cc13xx/mtarch.h | 48 ----- arch/cpu/msp430/Makefile.msp430 | 7 - arch/cpu/msp430/mtarch.c | 177 ----------------- arch/cpu/msp430/mtarch.h | 51 ----- arch/cpu/native/Makefile.native | 2 +- arch/cpu/native/mtarch.c | 181 ----------------- arch/cpu/native/mtarch.h | 42 ---- arch/cpu/nrf52832/mtarch.h | 48 ----- arch/platform/jn516x/Makefile.jn516x | 2 +- arch/platform/jn516x/dev/mtarch.c | 72 ------- arch/platform/jn516x/dev/mtarch.h | 44 ----- os/sys/mt.c | 109 ----------- os/sys/mt.h | 256 ------------------------ tools/sky/check-size | 1 - 17 files changed, 4 insertions(+), 1442 deletions(-) delete mode 100644 arch/cpu/arm/common/sys/mtarch.c delete mode 100644 arch/cpu/arm/common/sys/mtarch.h delete mode 100644 arch/cpu/cc26xx-cc13xx/mtarch.h delete mode 100644 arch/cpu/msp430/mtarch.c delete mode 100644 arch/cpu/msp430/mtarch.h delete mode 100644 arch/cpu/native/mtarch.c delete mode 100644 arch/cpu/native/mtarch.h delete mode 100644 arch/cpu/nrf52832/mtarch.h delete mode 100644 arch/platform/jn516x/dev/mtarch.c delete mode 100644 arch/platform/jn516x/dev/mtarch.h delete mode 100644 os/sys/mt.c delete mode 100644 os/sys/mt.h diff --git a/arch/cpu/arm/common/sys/mtarch.c b/arch/cpu/arm/common/sys/mtarch.c deleted file mode 100644 index 6bf011411..000000000 --- a/arch/cpu/arm/common/sys/mtarch.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2016, Benoît Thébaudeau - * 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 copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. - */ -/** - * \addtogroup arm-cm-mtarch - * @{ - * - * \file - * Implmentation of the ARM Cortex-M support for Contiki multi-threading. - */ -#include CMSIS_DEV_HDR -#include "sys/mt.h" - -#include - -#define EXC_RETURN_PROCESS_THREAD_BASIC_FRAME 0xfffffffd - -/* Check whether EXC_RETURN[3:0] in LR indicates a preempted process thread. */ -#if __ARM_ARCH == 7 -#define PREEMPTED_PROCESS_THREAD() \ - "and r0, lr, #0xf\n\t" \ - "cmp r0, #0xd\n\t" -#elif __ARM_ARCH == 6 -#define PREEMPTED_PROCESS_THREAD() \ - "mov r0, lr\n\t" \ - "movs r1, #0xf\n\t" \ - "and r0, r1\n\t" \ - "cmp r0, #0xd\n\t" -#else -#error Unsupported ARM architecture -#endif -/*----------------------------------------------------------------------------*/ -/** - * \brief SVCall system handler - * - * This exception handler executes the action requested by the corresponding - * \c svc instruction, which is a task switch from the main Contiki thread to an - * mt thread or the other way around. - */ -__attribute__ ((__naked__)) -void -svcall_handler(void) -{ - /* - * Decide whether to switch to the main thread or to a process thread, - * depending on the type of the thread preempted by SVCall. - */ - __asm__ (PREEMPTED_PROCESS_THREAD() -#if __ARM_ARCH == 7 - "it eq\n\t" -#endif - "beq switch_to_main_thread\n\t" - - /* - * - Retrieve from the main stack the PSP passed to SVCall through R0. Note - * that it cannot be retrieved directly from R0 on exception entry because - * this register may have been overwritten by other exceptions on SVCall - * entry. - * - Save the main thread context to the main stack. - * - Restore the process thread context from the process stack. - * - Return to Thread mode, resuming the process thread. - */ -#if __ARM_ARCH == 7 - "ldr r0, [sp]\n\t" - "push {r4-r11, lr}\n\t" - "add r1, r0, #9 * 4\n\t" - "msr psp, r1\n\t" - "ldmia r0, {r4-r11, pc}"); -#elif __ARM_ARCH == 6 - "mov r0, r8\n\t" - "mov r1, r9\n\t" - "mov r2, r10\n\t" - "mov r3, r11\n\t" - "push {r0-r7, lr}\n\t" - "ldr r0, [sp, #9 * 4]\n\t" - "ldmia r0!, {r4-r7}\n\t" - "mov r8, r4\n\t" - "mov r9, r5\n\t" - "mov r10, r6\n\t" - "mov r11, r7\n\t" - "ldmia r0!, {r3-r7}\n\t" - "msr psp, r0\n\t" - "bx r3"); -#endif -} -/*----------------------------------------------------------------------------*/ -/** - * \brief PendSV system handler - * - * This exception handler executes following a call to mtarch_pstart() from - * another exception handler. It performs a task switch to the main Contiki - * thread if it is not already running. - */ -__attribute__ ((__naked__)) -void -pendsv_handler(void) -{ - /* - * Return without doing anything if PendSV has not preempted a process thread. - * This can occur either because PendSV has preempted the main thread, in - * which case there is nothing to do, or because mtarch_pstart() has been - * called from an exception handler without having called mt_init() first, in - * which case PendSV may have preempted an exception handler and nothing must - * be done because mt is not active. - */ - __asm__ ( PREEMPTED_PROCESS_THREAD() -#if __ARM_ARCH == 7 - "it ne\n\t" - "bxne lr\n" -#elif __ARM_ARCH == 6 - "beq switch_to_main_thread\n\t" - "bx lr\n" -#endif - - /* - * - Save the process thread context to the process stack. - * - Place into the main stack the updated PSP that SVCall must return through - * R0. - * - Restore the main thread context from the main stack. - * - Return to Thread mode, resuming the main thread. - */ - "switch_to_main_thread:\n\t" - "mrs r0, psp\n\t" -#if __ARM_ARCH == 7 - "stmdb r0!, {r4-r11, lr}\n\t" - "str r0, [sp, #9 * 4]\n\t" - "pop {r4-r11, pc}"); -#elif __ARM_ARCH == 6 - "mov r3, lr\n\t" - "sub r0, #5 * 4\n\t" - "stmia r0!, {r3-r7}\n\t" - "mov r4, r8\n\t" - "mov r5, r9\n\t" - "sub r0, #9 * 4\n\t" - "mov r6, r10\n\t" - "mov r7, r11\n\t" - "stmia r0!, {r4-r7}\n\t" - "pop {r4-r7}\n\t" - "sub r0, #4 * 4\n\t" - "mov r8, r4\n\t" - "mov r9, r5\n\t" - "str r0, [sp, #5 * 4]\n\t" - "mov r10, r6\n\t" - "mov r11, r7\n\t" - "pop {r4-r7, pc}"); -#endif -} -/*----------------------------------------------------------------------------*/ -void -mtarch_init(void) -{ - SCB->CCR = (SCB->CCR -#ifdef SCB_CCR_NONBASETHRDENA_Msk - /* - * Make sure that any attempt to enter Thread mode with exceptions - * active faults. - * - * Only SVCall and PendSV are allowed to forcibly enter Thread - * mode, and they are configured with the same, lowest exception - * priority, so no other exceptions may be active. - */ - & ~SCB_CCR_NONBASETHRDENA_Msk -#endif - /* - * Force 8-byte stack pointer alignment on exception entry in order - * to be able to use AAPCS-conforming functions as exception - * handlers. - */ - ) | SCB_CCR_STKALIGN_Msk; - - /* - * Configure SVCall and PendSV with the same, lowest exception priority. - * - * This makes sure that they cannot preempt each other, and that the processor - * executes them after having handled all other exceptions. If both are - * pending at the same time, then SVCall takes precedence because of its lower - * exception number. In addition, the associated exception handlers do not - * have to check whether they are returning to Thread mode, because they - * cannot preempt any other exception. - */ - NVIC_SetPriority(SVCall_IRQn, (1 << __NVIC_PRIO_BITS) - 1); - NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1); - - /* - * Force the preceding configurations to take effect before further - * operations. - */ - __DSB(); - __ISB(); -} -/*----------------------------------------------------------------------------*/ -void -mtarch_start(struct mtarch_thread *thread, - void (*function)(void *data), void *data) -{ - struct mtarch_thread_context *context = &thread->start_stack.context; - - /* - * Initialize the thread context with the appropriate values to call - * function() with data and to make function() return to mt_exit() without - * having to call it explicitly. - */ - context->exc_return = EXC_RETURN_PROCESS_THREAD_BASIC_FRAME; - context->r0 = (uint32_t)data; - context->lr = (uint32_t)mt_exit; - context->pc = (uint32_t)function; - context->xpsr = xPSR_T_Msk; - thread->psp = (uint32_t)context; -} -/*----------------------------------------------------------------------------*/ -void -mtarch_exec(struct mtarch_thread *thread) -{ - /* Pass the PSP to SVCall, and get the updated PSP as its return value. */ - register uint32_t psp __asm__ ("r0") = thread->psp; - __asm__ volatile ("svc #0" - : "+r" (psp) - :: "memory"); - thread->psp = psp; -} -/*----------------------------------------------------------------------------*/ -__attribute__ ((__naked__)) -void -mtarch_yield(void) -{ - /* Invoke SVCall. */ - __asm__ ("svc #0\n\t" - "bx lr"); -} -/*----------------------------------------------------------------------------*/ -void -mtarch_stop(struct mtarch_thread *thread) -{ -} -/*----------------------------------------------------------------------------*/ -void -mtarch_pstart(void) -{ - /* Trigger PendSV. */ - SCB->ICSR = SCB_ICSR_PENDSVSET_Msk; -} -/*----------------------------------------------------------------------------*/ -void -mtarch_pstop(void) -{ -} -/*----------------------------------------------------------------------------*/ -void -mtarch_remove(void) -{ -} -/*----------------------------------------------------------------------------*/ - -/** @} */ diff --git a/arch/cpu/arm/common/sys/mtarch.h b/arch/cpu/arm/common/sys/mtarch.h deleted file mode 100644 index d483e6e3f..000000000 --- a/arch/cpu/arm/common/sys/mtarch.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2016, Benoît Thébaudeau - * 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 copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. - */ -/** - * \addtogroup arm - * @{ - * - * \defgroup arm-cm-mtarch ARM Cortex-M support for Contiki multi-threading - * - * All the Cortex-M devices supported by CMSIS-CORE are supported. - * - * An exception handler can decide to make the main Contiki thread preempt any - * running mt thread by calling mtarch_pstart() (e.g. to perform urgent - * operations that have been triggered by some event or that had been - * scheduled). If the running thread is already the main Contiki thread, then - * nothing happens. The corresponding task switch takes place when leaving - * Handler mode. The main Contiki thread then resumes after the call to - * mt_exec() that yielded to the preempted mt thread. - * @{ - * - * \file - * Header file for the ARM Cortex-M support for Contiki multi-threading. - */ -#ifndef MTARCH_H_ -#define MTARCH_H_ - -#include "contiki.h" -#include "sys/cc.h" - -#include - -#ifndef MTARCH_CONF_STACKSIZE -/** Thread stack size configuration, expressed as a number of 32-bit words. */ -#define MTARCH_CONF_STACKSIZE 256 -#endif -/** Actual stack size, with minimum size and alignment requirements enforced. */ -#define MTARCH_STACKSIZE ((MAX(MTARCH_CONF_STACKSIZE, \ - sizeof(struct mtarch_thread_context) / \ - sizeof(uint32_t)) + 1) & ~1) - -/** - * Structure of a saved thread context. - * - * xpsr..r0 are managed by the processor (except in mtarch_start()), - * while the other register values are handled by the software. - */ -struct mtarch_thread_context { -#if __ARM_ARCH == 7 - uint32_t r4; - uint32_t r5; - uint32_t r6; - uint32_t r7; -#endif - uint32_t r8; - uint32_t r9; - uint32_t r10; - uint32_t r11; - uint32_t exc_return; -#if __ARM_ARCH == 6 - uint32_t r4; - uint32_t r5; - uint32_t r6; - uint32_t r7; -#endif - uint32_t r0; - uint32_t r1; - uint32_t r2; - uint32_t r3; - uint32_t r12; - uint32_t lr; - uint32_t pc; - uint32_t xpsr; -}; - -struct mtarch_thread { - uint32_t psp; - union { - struct { - uint32_t free[MTARCH_STACKSIZE - - sizeof(struct mtarch_thread_context) / sizeof(uint32_t)]; - struct mtarch_thread_context context; - } start_stack; - uint32_t stack[MTARCH_STACKSIZE]; - } CC_ALIGN(8); -}; - -#endif /* MTARCH_H_ */ - -/** - * @} - * @} - */ diff --git a/arch/cpu/cc2538/startup-gcc.c b/arch/cpu/cc2538/startup-gcc.c index 547764ec3..bde8d1488 100644 --- a/arch/cpu/cc2538/startup-gcc.c +++ b/arch/cpu/cc2538/startup-gcc.c @@ -52,8 +52,6 @@ void nmi_handler(void); void default_handler(void); /* System Handler and ISR prototypes implemented elsewhere */ -void svcall_handler(void); /* See mtarch.c */ -void pendsv_handler(void); /* See mtarch.c */ void clock_isr(void); /* SysTick Handler */ void gpio_port_a_isr(void); void gpio_port_b_isr(void); @@ -121,10 +119,10 @@ void(*const vectors[])(void) = 0, /* 8 Reserved */ 0, /* 9 Reserved */ 0, /* 10 Reserved */ - svcall_handler, /* 11 SVCall handler */ + default_handler, /* 11 SVCall handler */ default_handler, /* 12 Debug monitor handler */ 0, /* 13 Reserved */ - pendsv_handler, /* 14 The PendSV handler */ + default_handler, /* 14 The PendSV handler */ clock_isr, /* 15 The SysTick handler */ gpio_port_a_isr, /* 16 GPIO Port A */ gpio_port_b_isr, /* 17 GPIO Port B */ diff --git a/arch/cpu/cc26xx-cc13xx/mtarch.h b/arch/cpu/cc26xx-cc13xx/mtarch.h deleted file mode 100644 index 4f696669d..000000000 --- a/arch/cpu/cc26xx-cc13xx/mtarch.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2010, Loughborough University - 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. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - * - */ -/* - * \file - * Stub header file for multi-threading. It doesn't do anything, it - * just exists so that mt.c can compile cleanly. - * - * This is based on the original mtarch.h for z80 by Takahide Matsutsuka - * - * \author - * George Oikonomou - - */ -#ifndef __MTARCH_H__ -#define __MTARCH_H__ - -struct mtarch_thread { - unsigned char *sp; -}; - -#endif /* __MTARCH_H__ */ diff --git a/arch/cpu/msp430/Makefile.msp430 b/arch/cpu/msp430/Makefile.msp430 index 6f9e1e29c..97ea7f3f2 100644 --- a/arch/cpu/msp430/Makefile.msp430 +++ b/arch/cpu/msp430/Makefile.msp430 @@ -40,13 +40,6 @@ MSP430 = msp430.c flash.c clock.c leds.c leds-arch.c \ watchdog.c lpm.c rtimer-arch.c UIPDRIVERS = slip.c crc16.c -ifndef CPU_HAS_MSP430X -# include mtarch.c only in the non-large memory model case, because -# the current implementation assumes 16-bit addresses (function pointers -# stored as "unsigned short"). -MSP430 += mtarch.c -endif - CONTIKI_TARGET_SOURCEFILES += $(MSP430) \ $(SYSAPPS) \ $(UIPDRIVERS) diff --git a/arch/cpu/msp430/mtarch.c b/arch/cpu/msp430/mtarch.c deleted file mode 100644 index 0ecd5d9c0..000000000 --- a/arch/cpu/msp430/mtarch.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2005, 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. - * - * This file is part of the Contiki operating system. - * - */ - -#include -#include "sys/mt.h" - -#ifdef __IAR_SYSTEMS_ICC__ -#define __asm__ asm -#endif - -static unsigned short *sptmp; -static struct mtarch_thread *running; - -/*--------------------------------------------------------------------------*/ -void -mtarch_init(void) -{ - -} -/*--------------------------------------------------------------------------*/ -static void -mtarch_wrapper(void) -{ - /* Call thread function with argument */ - ((void (*)(void *))running->function)((void*)running->data); -} -/*--------------------------------------------------------------------------*/ -void -mtarch_start(struct mtarch_thread *t, - void (*function)(void *), void *data) -{ - int i; - - for(i = 0; i < MTARCH_STACKSIZE; ++i) { - t->stack[i] = i; - } - - t->sp = &t->stack[MTARCH_STACKSIZE - 1]; - - *t->sp = (unsigned short)mt_exit; - --t->sp; - - *t->sp = (unsigned short)mtarch_wrapper; - --t->sp; - - /* Space for registers. */ - t->sp -= 11; - - /* Store function and argument (used in mtarch_wrapper) */ - t->data = data; - t->function = function; -} -/*--------------------------------------------------------------------------*/ - -static void -sw(void) -{ - - sptmp = running->sp; - - __asm__("push r4"); - __asm__("push r5"); - __asm__("push r6"); - __asm__("push r7"); - __asm__("push r8"); - __asm__("push r9"); - __asm__("push r10"); - __asm__("push r11"); - __asm__("push r12"); - __asm__("push r13"); - __asm__("push r14"); - __asm__("push r15"); - -#ifdef __IAR_SYSTEMS_ICC__ -/* use IAR intrinsic functions */ - running->sp = (unsigned short *) __get_SP_register(); - __set_SP_register((unsigned short) sptmp); -#else - __asm__("mov.w r1,%0" : "=r" (running->sp)); - __asm__("mov.w %0,r1" : : "m" (sptmp)); -#endif - - __asm__("pop r15"); - __asm__("pop r14"); - __asm__("pop r13"); - __asm__("pop r12"); - __asm__("pop r11"); - __asm__("pop r10"); - __asm__("pop r9"); - __asm__("pop r8"); - __asm__("pop r7"); - __asm__("pop r6"); - __asm__("pop r5"); - __asm__("pop r4"); -} -/*--------------------------------------------------------------------------*/ -void -mtarch_exec(struct mtarch_thread *t) -{ - running = t; - sw(); - running = NULL; -} -/*--------------------------------------------------------------------------*/ -void -mtarch_remove(void) -{ - -} -/*--------------------------------------------------------------------------*/ -void -mtarch_yield(void) -{ - sw(); -} -/*--------------------------------------------------------------------------*/ -void -mtarch_pstop(void) -{ - -} -/*--------------------------------------------------------------------------*/ -void -mtarch_pstart(void) -{ - -} -/*--------------------------------------------------------------------------*/ -void -mtarch_stop(struct mtarch_thread *thread) -{ - -} -/*--------------------------------------------------------------------------*/ -int -mtarch_stack_usage(struct mt_thread *t) -{ - int i; - - for(i = 0; i < MTARCH_STACKSIZE; ++i) { - if(t->thread.stack[i] != (unsigned short)i) { - return MTARCH_STACKSIZE - i; - } - } - - return MTARCH_STACKSIZE; -} -/*--------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/mtarch.h b/arch/cpu/msp430/mtarch.h deleted file mode 100644 index f321bd176..000000000 --- a/arch/cpu/msp430/mtarch.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2005, 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. - * - * This file is part of the Contiki operating system. - */ -#ifndef MTARCH_H_ -#define MTARCH_H_ - -#include "contiki.h" - -#ifndef MTARCH_STACKSIZE -#define MTARCH_STACKSIZE 128 -#endif /* MTARCH_STACKSIZE */ - -struct mtarch_thread { - unsigned short stack[MTARCH_STACKSIZE]; - unsigned short *sp; - void *data; - void (* function)(void *); -}; - -struct mt_thread; - -int mtarch_stack_usage(struct mt_thread *t); - -#endif /* MTARCH_H_ */ diff --git a/arch/cpu/native/Makefile.native b/arch/cpu/native/Makefile.native index ba473a3d3..90a784e34 100644 --- a/arch/cpu/native/Makefile.native +++ b/arch/cpu/native/Makefile.native @@ -1,6 +1,6 @@ CONTIKI_CPU_DIRS = . net dev -CONTIKI_SOURCEFILES += mtarch.c rtimer-arch.c watchdog.c eeprom.c +CONTIKI_SOURCEFILES += rtimer-arch.c watchdog.c eeprom.c ### Compiler definitions CC ?= gcc diff --git a/arch/cpu/native/mtarch.c b/arch/cpu/native/mtarch.c deleted file mode 100644 index 397891efb..000000000 --- a/arch/cpu/native/mtarch.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2007, 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. - * - * This file is part of the Contiki operating system. - * - * Author: Oliver Schmidt - * - * - */ - -#include "sys/mt.h" - -#ifndef MTARCH_STACKSIZE -#define MTARCH_STACKSIZE 4096 -#endif /* MTARCH_STACKSIZE */ - -#if defined(_WIN32) || defined(__CYGWIN__) - -#define WIN32_LEAN_AND_MEAN -#include - -static void *main_fiber; - -#elif defined(__linux) - -#include -#include -#include - -struct mtarch_t { - char stack[MTARCH_STACKSIZE]; - ucontext_t context; -}; - -static ucontext_t main_context; -static ucontext_t *running_context; -#elif defined(__APPLE) -/* No support for OS-X at the moment as swapcontext, etc are deprecated */ - -#endif /* _WIN32 || __CYGWIN__ || __linux */ - -/*--------------------------------------------------------------------------*/ -void -mtarch_init(void) -{ -#if defined(_WIN32) || defined(__CYGWIN__) - - main_fiber = ConvertThreadToFiber(NULL); - -#endif /* _WIN32 || __CYGWIN__ */ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_remove(void) -{ -#if defined(_WIN32) || defined(__CYGWIN__) - - ConvertFiberToThread(); - -#endif /* _WIN32 || __CYGWIN__ */ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_start(struct mtarch_thread *thread, - void (* function)(void *data), - void *data) -{ -#if defined(_WIN32) || defined(__CYGWIN__) - - thread->mt_thread = CreateFiber(0, (LPFIBER_START_ROUTINE)function, data); - -#elif defined(__linux) - - thread->mt_thread = malloc(sizeof(struct mtarch_t)); - - getcontext(&((struct mtarch_t *)thread->mt_thread)->context); - - ((struct mtarch_t *)thread->mt_thread)->context.uc_link = NULL; - ((struct mtarch_t *)thread->mt_thread)->context.uc_stack.ss_sp = - ((struct mtarch_t *)thread->mt_thread)->stack; - ((struct mtarch_t *)thread->mt_thread)->context.uc_stack.ss_size = - sizeof(((struct mtarch_t *)thread->mt_thread)->stack); - - /* Some notes: - - If a CPU needs stronger alignment for the stack than malloc() - guarantees (like i.e. IA64) then makecontext() is supposed to - add that alignment internally. - - According to POSIX the arguments to function() are of type int - and there are in fact 64-bit implementations which support only - 32 bits per argument meaning that a pointer argument has to be - splitted into two arguments. - - Most implementations interpret context.uc_stack.ss_sp on entry - as the lowest stack address even if the CPU stack actually grows - downwards. Although this means that ss_sp does NOT represent the - CPU stack pointer this behaviour makes perfectly sense as it is - the only way to stay independent from the CPU architecture. But - Solaris prior to release 10 interprets ss_sp as highest stack - address thus requiring special handling. */ - makecontext(&((struct mtarch_t *)thread->mt_thread)->context, - (void (*)(void))function, 1, data); - -#endif /* _WIN32 || __CYGWIN__ || __linux */ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_yield(void) -{ -#if defined(_WIN32) || defined(__CYGWIN__) - - SwitchToFiber(main_fiber); - -#elif defined(__linux) - - swapcontext(running_context, &main_context); - -#endif /* _WIN32 || __CYGWIN__ || __linux */ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_exec(struct mtarch_thread *thread) -{ -#if defined(_WIN32) || defined(__CYGWIN__) - - SwitchToFiber(thread->mt_thread); - -#elif defined(__linux) - running_context = &((struct mtarch_t *)thread->mt_thread)->context; - swapcontext(&main_context, running_context); - running_context = NULL; - -#endif /* _WIN32 || __CYGWIN__ || __linux */ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_stop(struct mtarch_thread *thread) -{ -#if defined(_WIN32) || defined(__CYGWIN__) - - DeleteFiber(thread->mt_thread); - -#elif defined(linux) || defined(__linux) - free(thread->mt_thread); - -#endif /* _WIN32 || __CYGWIN__ || __linux */ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_pstart(void) -{ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_pstop(void) -{ -} -/*--------------------------------------------------------------------------*/ diff --git a/arch/cpu/native/mtarch.h b/arch/cpu/native/mtarch.h deleted file mode 100644 index d006c1360..000000000 --- a/arch/cpu/native/mtarch.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2007, 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. - * - * This file is part of the Contiki operating system. - * - * Author: Oliver Schmidt - * - */ - -#ifndef MTARCH_H_ -#define MTARCH_H_ - -struct mtarch_thread { - void *mt_thread; -}; - -#endif /* MTARCH_H_ */ diff --git a/arch/cpu/nrf52832/mtarch.h b/arch/cpu/nrf52832/mtarch.h deleted file mode 100644 index 4f696669d..000000000 --- a/arch/cpu/nrf52832/mtarch.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2010, Loughborough University - 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. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - * - */ -/* - * \file - * Stub header file for multi-threading. It doesn't do anything, it - * just exists so that mt.c can compile cleanly. - * - * This is based on the original mtarch.h for z80 by Takahide Matsutsuka - * - * \author - * George Oikonomou - - */ -#ifndef __MTARCH_H__ -#define __MTARCH_H__ - -struct mtarch_thread { - unsigned char *sp; -}; - -#endif /* __MTARCH_H__ */ diff --git a/arch/platform/jn516x/Makefile.jn516x b/arch/platform/jn516x/Makefile.jn516x index bf1560e31..8664f9f0a 100644 --- a/arch/platform/jn516x/Makefile.jn516x +++ b/arch/platform/jn516x/Makefile.jn516x @@ -82,7 +82,7 @@ OBJDUMP:=$(CROSS_COMPILE)-objdump ARCH = jn516x-ccm-star.c exceptions.c rtimer-arch.c rtimer-arch-slow.c \ slip_uart0.c clock.c micromac-radio.c \ - mtarch.c node-id.c watchdog.c slip.c sprintf.c + node-id.c watchdog.c slip.c sprintf.c # Default uart0 for printf and slip TARGET_WITH_UART0 ?= 1 TARGET_WITH_UART1 ?= 0 diff --git a/arch/platform/jn516x/dev/mtarch.c b/arch/platform/jn516x/dev/mtarch.c deleted file mode 100644 index c3c81457e..000000000 --- a/arch/platform/jn516x/dev/mtarch.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2008 - * Telecooperation Office (TecO), Universitaet Karlsruhe (TH), Germany. - * 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 Universitaet Karlsruhe (TH) 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 COPYRIGHT HOLDERS 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 COPYRIGHT - * OWNER 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. - * - * Author(s): Philipp Scholl - */ - -/* Copied from Philipp Scholl's (BSD) Contiki port to Jennic */ - -#include "mtarch.h" - -void -mtarch_init(void) -{ -} -void -mtarch_remove(void) -{ -} -void -mtarch_start(struct mtarch_thread *thread, - void (*function)(void *data), - void *data) -{ -} -void -mtarch_yield(void) -{ -} -void -mtarch_exec(struct mtarch_thread *thread) -{ -} -void -mtarch_stop(struct mtarch_thread *thread) -{ -} -void -mtarch_pstart(void) -{ -} -void -mtarch_pstop(void) -{ -} diff --git a/arch/platform/jn516x/dev/mtarch.h b/arch/platform/jn516x/dev/mtarch.h deleted file mode 100644 index 3c6292f1d..000000000 --- a/arch/platform/jn516x/dev/mtarch.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2008 - * Telecooperation Office (TecO), Universitaet Karlsruhe (TH), Germany. - * 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 Universitaet Karlsruhe (TH) 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 COPYRIGHT HOLDERS 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 COPYRIGHT - * OWNER 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. - * - * Author(s): Philipp Scholl - */ - -/* Copied from Philipp Scholl's (BSD) Contiki port to Jennic */ - -#ifndef __MTARCH_H__ -#define __MTARCH_H__ - -struct mtarch_thread { - void *mt_thread; -}; - -#endif /* __MTARCH_H__ */ diff --git a/os/sys/mt.c b/os/sys/mt.c deleted file mode 100644 index d5bc10398..000000000 --- a/os/sys/mt.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2006, 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. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - */ - -/** - * \file - * Implementation of the archtecture agnostic parts of the preemptive - * multithreading library for Contiki. - * - * \author - * Adam Dunkels - * - */ - -#include "contiki.h" -#include "sys/mt.h" -#include "sys/cc.h" - -static struct mt_thread *current; - -/*--------------------------------------------------------------------------*/ -void -mt_init(void) -{ - mtarch_init(); -} -/*--------------------------------------------------------------------------*/ -void -mt_remove(void) -{ - mtarch_remove(); -} -/*--------------------------------------------------------------------------*/ -void -mt_start(struct mt_thread *thread, void (* function)(void *), void *data) -{ - /* Call the architecture dependant function to set up the processor - stack with the correct parameters. */ - mtarch_start(&thread->thread, function, data); - - thread->state = MT_STATE_STARTED; -} -/*--------------------------------------------------------------------------*/ -void -mt_exec(struct mt_thread *thread) -{ - if(thread->state == MT_STATE_STARTED) { - current = thread; - /* Switch context to the thread. The function call will not return - until the the thread has yielded, or is preempted. */ - mtarch_exec(&thread->thread); - } -} -/*--------------------------------------------------------------------------*/ -void -mt_yield(void) -{ - mtarch_pstop(); - /* This function is called from the running thread, and we call the - switch function in order to switch the thread to the main Contiki - program instead. For us, the switch function will not return - until the next time we are scheduled to run. */ - mtarch_yield(); -} -/*--------------------------------------------------------------------------*/ -void -mt_exit(void) -{ - mtarch_pstop(); - current->state = MT_STATE_EXITED; - mtarch_yield(); -} -/*--------------------------------------------------------------------------*/ -void -mt_stop(struct mt_thread *thread) -{ - mtarch_stop(&thread->thread); -} -/*--------------------------------------------------------------------------*/ diff --git a/os/sys/mt.h b/os/sys/mt.h deleted file mode 100644 index abe04d12e..000000000 --- a/os/sys/mt.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (c) 2004, 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. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - */ - -/** \addtogroup threads - * @{ - */ - -/** - * \defgroup mt Multi-threading library - * - * The event driven Contiki kernel does not provide multi-threading - * by itself - instead, preemptive multi-threading is implemented - * as a library that optionally can be linked with applications. This - * library consists of two parts: a platform independent part, which is - * the same for all platforms on which Contiki runs, and a platform - * specific part, which must be implemented specifically for the - * platform that the multi-threading library should run. - * @{ - * - * The Contiki multi-threading library requires some architecture - * specific support for setting up and switching stacks. This support - * requires four stack manipulation functions to be implemented: - * mtarch_start(), which sets up the stack frame for a new thread, - * mtarch_exec(), which switches in the stack of a thread, - * mtarch_yield(), which restores the kernel stack from a thread's - * stack and mtarch_stop(), which cleans up the stack of a thread. - * Additionally, two functions for controlling the preemption - * (if any) must be implemented: mtarch_pstart() and mtarch_pstop(). - * If no preemption is used, these functions can be implemented as - * empty functions. Finally, the function mtarch_init() is called by - * mt_init(), and can be used for initialization of timer interrupts, - * or any other mechanisms required for correct operation of the - * architecture specific support functions while mtarch_remove() is - * called by mt_remove() to clean up those resources. - * - */ - -/** - * \file - * Header file for the preemptive multitasking library for Contiki. - * \author - * Adam Dunkels - * - */ -#ifndef MT_H_ -#define MT_H_ - -#include "contiki.h" - -#define MT_STATE_STARTED 1 -#define MT_STATE_EXITED 2 - -/** - * An opaque structure that is used for holding the state of a thread. - * - * The structure should be defined in the "mtarch.h" file. This - * structure typically holds the entire stack for the thread. - */ -struct mtarch_thread; - -/** - * Initialize the architecture specific support functions for the - * multi-thread library. - * - * This function is implemented by the architecture specific functions - * for the multi-thread library and is called by the mt_init() - * function as part of the initialization of the library. The - * mtarch_init() function can be used for, e.g., starting preemption - * timers or other architecture specific mechanisms required for the - * operation of the library. - */ -void mtarch_init(void); - -/** - * Uninstall library and clean up. - * - */ -void mtarch_remove(void); - -/** - * Setup the stack frame for a thread that is being started. - * - * This function is called by the mt_start() function in order to set - * up the architecture specific stack of the thread to be started. - * - * \param thread A pointer to a struct mtarch_thread for the thread to - * be started. - * - * \param function A pointer to the function that the thread will - * start executing the first time it is scheduled to run. - * - * \param data A pointer to the argument that the function should be - * passed. - */ -void mtarch_start(struct mtarch_thread *thread, - void (* function)(void *data), - void *data); - -/** - * Start executing a thread. - * - * This function is called from mt_exec() and the purpose of the - * function is to start execution of the thread. The function should - * switch in the stack of the thread, and does not return until the - * thread has explicitly yielded (using mt_yield()) or until it is - * preempted. - * - * \param thread A pointer to a struct mtarch_thread for the thread to - * be executed. - * - */ -void mtarch_exec(struct mtarch_thread *thread); - -/** - * Yield the processor. - * - * This function is called by the mt_yield() function, which is called - * from the running thread in order to give up the processor. - * - */ -void mtarch_yield(void); - -/** - * Clean up the stack of a thread. - * - * This function is called by the mt_stop() function in order to clean - * up the architecture specific stack of the thread to be stopped. - * - * \note If the stack is wholly contained in struct mtarch_thread this - * function may very well be empty. - * - * \param thread A pointer to a struct mtarch_thread for the thread to - * be stopped. - * - */ -void mtarch_stop(struct mtarch_thread *thread); - -void mtarch_pstart(void); -void mtarch_pstop(void); - -/** @} */ - - -#include "mtarch.h" - -struct mt_thread { - int state; - struct mtarch_thread thread; -}; - -/** - * Initializes the multithreading library. - * - */ -void mt_init(void); - -/** - * Uninstalls library and cleans up. - * - */ -void mt_remove(void); - - -/** - * Starts a multithreading thread. - * - * \param thread Pointer to an mt_thread struct that must have been - * previously allocated by the caller. - * - * \param function A pointer to the entry function of the thread that is - * to be set up. - * - * \param data A pointer that will be passed to the entry function. - * - */ -void mt_start(struct mt_thread *thread, void (* function)(void *), void *data); - -/** - * Execute parts of a thread. - * - * This function is called by a Contiki process and runs a - * thread. The function does not return until the thread has yielded, - * or is preempted. - * - * \note The thread library must first be initialized with the mt_init() - * function. - * - * \param thread A pointer to a struct mt_thread block that must be - * allocated by the caller. - * - */ -void mt_exec(struct mt_thread *thread); - -/** - * Voluntarily give up the processor. - * - * This function is called by a running thread in order to give up - * control of the CPU. - * - */ -void mt_yield(void); - -/** - * Exit a thread. - * - * This function is called from within an executing thread in order to - * exit the thread. The function never returns. - * - */ -void mt_exit(void); - -/** - * Stop a thread. - * - * This function is called by a Contiki process in order to clean up a - * thread. The struct mt_thread block may then be discarded by the caller. - * - * \param thread A pointer to a struct mt_thread block that must be - * allocated by the caller. - * - */ -void mt_stop(struct mt_thread *thread); - -/** @} */ -#endif /* MT_H_ */ diff --git a/tools/sky/check-size b/tools/sky/check-size index fc0bb9429..99a8c6257 100755 --- a/tools/sky/check-size +++ b/tools/sky/check-size @@ -9,7 +9,6 @@ @sky = ( "battery-sensor", "button-sensor", "cfs-xmem", "clock", "contiki-sky-main", "ds2411", "flash", "msp430", - "mtarch", "i2c", "leds-arch", "light", "radio-sensor", "sht11", "simple-cc2420-arch", "simple-cc2420", "spi", "slip", "uart1", "watchdog", "xmem", "rtimer-arch" ); From 7f8ff9d9af824d1968185421909fd82aca212426 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 4 Nov 2017 17:55:31 +0100 Subject: [PATCH 02/18] Simulation script for tests with random rearrangement: use a random generator that lets us control the seed. Set the seed to the Cooja simulation seed. --- tests/14-rpl-lite/07-rpl-random-rearrangement.csc | 5 +++-- tests/15-rpl-classic/07-rpl-random-rearrangement.csc | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/14-rpl-lite/07-rpl-random-rearrangement.csc b/tests/14-rpl-lite/07-rpl-random-rearrangement.csc index cdb62c420..16ba26e20 100644 --- a/tests/14-rpl-lite/07-rpl-random-rearrangement.csc +++ b/tests/14-rpl-lite/07-rpl-random-rearrangement.csc @@ -544,7 +544,7 @@ make receiver-node.cooja TARGET=cooja } function getRandom(min, max) { - return Math.random() * (max - min) + min; + return r.nextFloat() * (max - min) + min; } // From: http://bost.ocks.org/mike/shuffle/ @@ -555,7 +555,7 @@ function shuffle(array) { while (m) { // Pick a remaining element… - i = Math.floor(Math.random() * m--); + i = Math.floor(r.nextFloat() * m--); // And swap it with the current element. t = array[m]; @@ -571,6 +571,7 @@ GENERATE_MSG(1200000, 'randomize-nodes'); GENERATE_MSG(2400000, 'randomize-nodes'); GENERATE_MSG(3600000, 'randomize-nodes'); +var r = new java.util.Random(sim.getRandomSeed()); var numForwarders = 20; var forwardIDStart = 4; packetsReceived = []; diff --git a/tests/15-rpl-classic/07-rpl-random-rearrangement.csc b/tests/15-rpl-classic/07-rpl-random-rearrangement.csc index cdb62c420..16ba26e20 100644 --- a/tests/15-rpl-classic/07-rpl-random-rearrangement.csc +++ b/tests/15-rpl-classic/07-rpl-random-rearrangement.csc @@ -544,7 +544,7 @@ make receiver-node.cooja TARGET=cooja } function getRandom(min, max) { - return Math.random() * (max - min) + min; + return r.nextFloat() * (max - min) + min; } // From: http://bost.ocks.org/mike/shuffle/ @@ -555,7 +555,7 @@ function shuffle(array) { while (m) { // Pick a remaining element… - i = Math.floor(Math.random() * m--); + i = Math.floor(r.nextFloat() * m--); // And swap it with the current element. t = array[m]; @@ -571,6 +571,7 @@ GENERATE_MSG(1200000, 'randomize-nodes'); GENERATE_MSG(2400000, 'randomize-nodes'); GENERATE_MSG(3600000, 'randomize-nodes'); +var r = new java.util.Random(sim.getRandomSeed()); var numForwarders = 20; var forwardIDStart = 4; packetsReceived = []; From 22cc45c79736d6a880953019ebc4dc04b9bb63e3 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 5 Nov 2017 21:47:13 +0100 Subject: [PATCH 03/18] Added ability to run arbitrary .sh scripts as test --- tests/Makefile.script-test | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/Makefile.script-test diff --git a/tests/Makefile.script-test b/tests/Makefile.script-test new file mode 100644 index 000000000..fff52f0b4 --- /dev/null +++ b/tests/Makefile.script-test @@ -0,0 +1,30 @@ +TESTS=$(wildcard ??-*.sh) +TESTLOGS=$(patsubst %.sh,%.testlog,$(TESTS)) +FAILLOGS=$(patsubst %.sh,%.faillog,$(TESTS)) + +CONTIKI=../.. + +tests: $(TESTLOGS) + +report: clean tests + @echo | grep -s -e '' - $(TESTLOGS) $(FAILLOGS) > $@ || true + +summary: report +ifeq ($(TESTS),) + @echo No tests > $@ +else + @egrep -e ' OK| FAIL' $< > $@ + @ls -1 ??-*.faillog > /dev/null 2>&1; [ $$? = 0 ] && tail -v ??-*.log ??-*.faillog >> $@ || true +endif + +all: cooja clean tests + +%.testlog: %.sh cooja + @bash $(TESTS) "$(CONTIKI)" + +clean: + @rm -f $(TESTLOGS) $(FAILLOGS) report summary + +cooja: $(CONTIKI)/tools/cooja/dist/cooja.jar +$(CONTIKI)/tools/cooja/dist/cooja.jar: + (cd $(CONTIKI)/tools/cooja; ant jar) From 853a0a9c56e74419dc219c7cda96a2300eab004b Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 5 Nov 2017 21:47:39 +0100 Subject: [PATCH 04/18] Added basic border router test, platform cooja, testing ping --- .travis.yml | 4 + .../01-border-router-cooja.csc | 252 ++++++++++++++++++ .../01-border-router-cooja.sh | 9 + tests/17-rpl-border-router/Makefile | 1 + .../test-border-router.sh | 58 ++++ tests/Makefile.script-test | 2 +- 6 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 tests/17-rpl-border-router/01-border-router-cooja.csc create mode 100755 tests/17-rpl-border-router/01-border-router-cooja.sh create mode 100644 tests/17-rpl-border-router/Makefile create mode 100755 tests/17-rpl-border-router/test-border-router.sh diff --git a/.travis.yml b/.travis.yml index 16fb5abd3..ca80acc05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ # See https://github.com/travis-ci/travis-ci/issues/6928#issuecomment-264227708 group: deprecated +before_install: + - sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 + notifications: email: false language: c #NOTE: this will set CC=gcc which might cause trouble @@ -106,3 +109,4 @@ env: - BUILD_TYPE='base' BUILD_CATEGORY='sim' - BUILD_TYPE='ieee802154' BUILD_CATEGORY='sim' - BUILD_TYPE='6tisch' BUILD_CATEGORY='sim' + - BUILD_TYPE='rpl-border-router' BUILD_CATEGORY='sim' diff --git a/tests/17-rpl-border-router/01-border-router-cooja.csc b/tests/17-rpl-border-router/01-border-router-cooja.csc new file mode 100644 index 000000000..a010d5ef2 --- /dev/null +++ b/tests/17-rpl-border-router/01-border-router-cooja.csc @@ -0,0 +1,252 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/collect-view + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype295 + Cooja Mote Type #1 + [CONTIKI_DIR]/examples/rpl-border-router/border-router.c + make TARGET=cooja clean +make border-router.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype686 + Cooja Mote Type #2 + [CONTIKI_DIR]/examples/hello-world/hello-world.c + make TARGET=cooja clean +make hello-world.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 54.36775767371176 + 24.409055040864118 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype295 + + + + org.contikios.cooja.interfaces.Position + 83.54989222799365 + 52.63050856506214 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype686 + + + + org.contikios.cooja.interfaces.Position + 108.91767775240822 + 78.59778809170032 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 3 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype686 + + + + org.contikios.cooja.interfaces.Position + 139.91021061864723 + 98.34190023350419 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 4 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype686 + + + + org.contikios.cooja.plugins.SimControl + 280 + 1 + 160 + 400 + 0 + + + org.contikios.cooja.plugins.Visualizer + + true + org.contikios.cooja.plugins.skins.UDGMVisualizerSkin + org.contikios.cooja.plugins.skins.IDVisualizerSkin + 1.9798610460263038 0.0 0.0 1.9798610460263038 -61.112037797038525 -1.2848438586294648 + + 400 + 4 + 400 + 1 + 1 + + + org.contikios.cooja.plugins.LogListener + + ID:4 + + + + 1404 + 2 + 240 + 400 + 160 + + + org.contikios.cooja.plugins.TimeLine + + 0 + 1 + 2 + 3 + + + + 500.0 + + 1804 + 6 + 166 + 0 + 753 + + + org.contikios.cooja.plugins.Notes + + Enter notes here + true + + 1124 + 5 + 160 + 680 + 0 + + + org.contikios.cooja.serialsocket.SerialSocketServer + 0 + + 60001 + true + + 362 + 3 + 116 + 13 + 414 + + + org.contikios.cooja.plugins.ScriptRunner + + + true + + 600 + 0 + 700 + 1037 + 40 + + diff --git a/tests/17-rpl-border-router/01-border-router-cooja.sh b/tests/17-rpl-border-router/01-border-router-cooja.sh new file mode 100755 index 000000000..f19b386e9 --- /dev/null +++ b/tests/17-rpl-border-router/01-border-router-cooja.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Contiki directory +CONTIKI=$1 + +# Simulation file +BASENAME=01-border-router-cooja + +bash test-border-router.sh $CONTIKI $BASENAME diff --git a/tests/17-rpl-border-router/Makefile b/tests/17-rpl-border-router/Makefile new file mode 100644 index 000000000..c46e5271d --- /dev/null +++ b/tests/17-rpl-border-router/Makefile @@ -0,0 +1 @@ +include ../Makefile.script-test diff --git a/tests/17-rpl-border-router/test-border-router.sh b/tests/17-rpl-border-router/test-border-router.sh new file mode 100755 index 000000000..c99c01117 --- /dev/null +++ b/tests/17-rpl-border-router/test-border-router.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Contiki directory +CONTIKI=$1 + +# Simulation file +BASENAME=$2 + +# Start simulation +echo "Starting Cooja simulation $BASENAME.csc" +java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > /dev/null & +JPID=$! +sleep 20 + +# Connect to the simlation +echo "Starting tunslip6" +make -C $CONTIKI/tools tunslip6 +make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=zoul > tunslip.log 2> tunslip.err & +MPID=$! +echo "Waiting for network formation" +sleep 5 + +# Do ping +echo "Pinging" +ping6 fd00::204:4:4:4 -c 5 | tee $BASENAME.log +# Fetch ping6 status code (not $? because this is piped) +STATUS=${PIPESTATUS[0]} + +echo "Closing simulation and tunslip6" +sleep 2 +kill -9 $JPID +kill -9 $MPID + +if [ $STATUS -eq 0 ] ; then + mv $BASENAME.log $BASENAME.testlog + echo " OK" +else + mv $BASENAME.log $BASENAME.faillog + + echo "" + echo "---- COOJA.log" + cat COOJA.log + + echo "" + echo "---- tunslip.log" + cat tunslip.log + + echo "" + echo "---- tunslip.err" + cat tunslip.err + + echo " FAIL ಠ_ಠ" | tee -a $BASENAME.faillog; +fi + +# We do not want Make to stop -> Return 0 +# The Makefile will check if a log contains FAIL at the end + +exit 0 diff --git a/tests/Makefile.script-test b/tests/Makefile.script-test index fff52f0b4..c39ce383c 100644 --- a/tests/Makefile.script-test +++ b/tests/Makefile.script-test @@ -20,7 +20,7 @@ endif all: cooja clean tests %.testlog: %.sh cooja - @bash $(TESTS) "$(CONTIKI)" + @bash "$(basename $@).sh" "$(CONTIKI)" clean: @rm -f $(TESTLOGS) $(FAILLOGS) report summary From 44e33a8da3137261032d26e3a345b3b75960c13e Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 10 Nov 2017 21:28:00 +0100 Subject: [PATCH 05/18] Added CI test: border router with TSCH --- .../02-border-router-cooja-tsch.csc | 252 ++++++++++++++++++ .../02-border-router-cooja-tsch.sh | 9 + 2 files changed, 261 insertions(+) create mode 100644 tests/17-rpl-border-router/02-border-router-cooja-tsch.csc create mode 100755 tests/17-rpl-border-router/02-border-router-cooja-tsch.sh diff --git a/tests/17-rpl-border-router/02-border-router-cooja-tsch.csc b/tests/17-rpl-border-router/02-border-router-cooja-tsch.csc new file mode 100644 index 000000000..011da9df3 --- /dev/null +++ b/tests/17-rpl-border-router/02-border-router-cooja-tsch.csc @@ -0,0 +1,252 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/collect-view + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype295 + Cooja Mote Type #1 + [CONTIKI_DIR]/examples/rpl-border-router/border-router.c + make TARGET=cooja clean +make border-router.cooja TARGET=cooja MAKE_MAC=MAKE_MAC_TSCH + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype686 + Cooja Mote Type #2 + [CONTIKI_DIR]/examples/hello-world/hello-world.c + make TARGET=cooja clean +make hello-world.cooja TARGET=cooja MAKE_MAC=MAKE_MAC_TSCH + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 54.36775767371176 + 24.409055040864118 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype295 + + + + org.contikios.cooja.interfaces.Position + 83.54989222799365 + 52.63050856506214 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype686 + + + + org.contikios.cooja.interfaces.Position + 108.91767775240822 + 78.59778809170032 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 3 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype686 + + + + org.contikios.cooja.interfaces.Position + 139.91021061864723 + 98.34190023350419 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 4 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype686 + + + + org.contikios.cooja.plugins.SimControl + 280 + 1 + 160 + 400 + 0 + + + org.contikios.cooja.plugins.Visualizer + + true + org.contikios.cooja.plugins.skins.UDGMVisualizerSkin + org.contikios.cooja.plugins.skins.IDVisualizerSkin + 1.9798610460263038 0.0 0.0 1.9798610460263038 -61.112037797038525 -1.2848438586294648 + + 400 + 4 + 400 + 1 + 1 + + + org.contikios.cooja.plugins.LogListener + + ID:4 + + + + 1404 + 2 + 240 + 400 + 160 + + + org.contikios.cooja.plugins.TimeLine + + 0 + 1 + 2 + 3 + + + + 500.0 + + 1804 + 6 + 166 + 0 + 753 + + + org.contikios.cooja.plugins.Notes + + Enter notes here + true + + 1124 + 5 + 160 + 680 + 0 + + + org.contikios.cooja.serialsocket.SerialSocketServer + 0 + + 60001 + true + + 362 + 3 + 116 + 13 + 414 + + + org.contikios.cooja.plugins.ScriptRunner + + + true + + 600 + 0 + 700 + 1037 + 40 + + diff --git a/tests/17-rpl-border-router/02-border-router-cooja-tsch.sh b/tests/17-rpl-border-router/02-border-router-cooja-tsch.sh new file mode 100755 index 000000000..02ec6e294 --- /dev/null +++ b/tests/17-rpl-border-router/02-border-router-cooja-tsch.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Contiki directory +CONTIKI=$1 + +# Simulation file +BASENAME=02-border-router-cooja-tsch + +bash border-router.sh $CONTIKI $BASENAME From 7c1c901028cb3f496387a2054f507482376f13d9 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 10 Nov 2017 21:32:46 +0100 Subject: [PATCH 06/18] Added CI test: border router on Sky motes --- .../01-border-router-cooja.sh | 2 +- .../02-border-router-cooja-tsch.sh | 2 +- .../03-border-router-sky.csc | 236 ++++++++++++++++++ .../03-border-router-sky.sh | 9 + .../test-border-router.sh | 5 +- 5 files changed, 251 insertions(+), 3 deletions(-) create mode 100644 tests/17-rpl-border-router/03-border-router-sky.csc create mode 100755 tests/17-rpl-border-router/03-border-router-sky.sh diff --git a/tests/17-rpl-border-router/01-border-router-cooja.sh b/tests/17-rpl-border-router/01-border-router-cooja.sh index f19b386e9..6a781583d 100755 --- a/tests/17-rpl-border-router/01-border-router-cooja.sh +++ b/tests/17-rpl-border-router/01-border-router-cooja.sh @@ -6,4 +6,4 @@ CONTIKI=$1 # Simulation file BASENAME=01-border-router-cooja -bash test-border-router.sh $CONTIKI $BASENAME +bash test-border-router.sh $CONTIKI $BASENAME fd00::204:4:4:4 diff --git a/tests/17-rpl-border-router/02-border-router-cooja-tsch.sh b/tests/17-rpl-border-router/02-border-router-cooja-tsch.sh index 02ec6e294..b91a8d5c7 100755 --- a/tests/17-rpl-border-router/02-border-router-cooja-tsch.sh +++ b/tests/17-rpl-border-router/02-border-router-cooja-tsch.sh @@ -6,4 +6,4 @@ CONTIKI=$1 # Simulation file BASENAME=02-border-router-cooja-tsch -bash border-router.sh $CONTIKI $BASENAME +bash test-border-router.sh $CONTIKI $BASENAME fd00::204:4:4:4 diff --git a/tests/17-rpl-border-router/03-border-router-sky.csc b/tests/17-rpl-border-router/03-border-router-sky.csc new file mode 100644 index 000000000..d707dde17 --- /dev/null +++ b/tests/17-rpl-border-router/03-border-router-sky.csc @@ -0,0 +1,236 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/collect-view + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.mspmote.SkyMoteType + sky1 + Sky Mote Type #sky1 + [CONTIKI_DIR]/examples/rpl-border-router/border-router.c + make clean TARGET=sky +make border-router.sky TARGET=sky + [CONTIKI_DIR]/examples/rpl-border-router/border-router.sky + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.interfaces.IPAddress + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + org.contikios.cooja.mspmote.interfaces.MspClock + org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.mspmote.interfaces.SkyButton + org.contikios.cooja.mspmote.interfaces.SkyFlash + org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem + org.contikios.cooja.mspmote.interfaces.Msp802154Radio + org.contikios.cooja.mspmote.interfaces.MspSerial + org.contikios.cooja.mspmote.interfaces.SkyLED + org.contikios.cooja.mspmote.interfaces.MspDebugOutput + org.contikios.cooja.mspmote.interfaces.SkyTemperature + + + org.contikios.cooja.mspmote.SkyMoteType + sky2 + Sky Mote Type #sky2 + [CONTIKI_DIR]/examples/hello-world/hello-world.c + make clean TARGET=sky +make hello-world.sky TARGET=sky + [CONTIKI_DIR]/examples/hello-world/hello-world.sky + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.interfaces.IPAddress + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + org.contikios.cooja.mspmote.interfaces.MspClock + org.contikios.cooja.mspmote.interfaces.MspMoteID + org.contikios.cooja.mspmote.interfaces.SkyButton + org.contikios.cooja.mspmote.interfaces.SkyFlash + org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem + org.contikios.cooja.mspmote.interfaces.Msp802154Radio + org.contikios.cooja.mspmote.interfaces.MspSerial + org.contikios.cooja.mspmote.interfaces.SkyLED + org.contikios.cooja.mspmote.interfaces.MspDebugOutput + org.contikios.cooja.mspmote.interfaces.SkyTemperature + + + + + org.contikios.cooja.interfaces.Position + -24.750327773354453 + 17.688901393447438 + 0.0 + + + org.contikios.cooja.mspmote.interfaces.MspClock + 1.0 + + + org.contikios.cooja.mspmote.interfaces.MspMoteID + 1 + + sky1 + + + + + org.contikios.cooja.interfaces.Position + 1.091493067677618 + 40.943504236660225 + 0.0 + + + org.contikios.cooja.mspmote.interfaces.MspClock + 1.0 + + + org.contikios.cooja.mspmote.interfaces.MspMoteID + 2 + + sky2 + + + + + org.contikios.cooja.interfaces.Position + 22.647678967805337 + 61.6365018442491 + 0.0 + + + org.contikios.cooja.mspmote.interfaces.MspClock + 1.0 + + + org.contikios.cooja.mspmote.interfaces.MspMoteID + 3 + + sky2 + + + + + org.contikios.cooja.interfaces.Position + 44.02005813888037 + 93.02398317771755 + 0.0 + + + org.contikios.cooja.mspmote.interfaces.MspClock + 1.0 + + + org.contikios.cooja.mspmote.interfaces.MspMoteID + 4 + + sky2 + + + + org.contikios.cooja.plugins.SimControl + 280 + 1 + 160 + 400 + 0 + + + org.contikios.cooja.plugins.Visualizer + + true + org.contikios.cooja.plugins.skins.IDVisualizerSkin + org.contikios.cooja.plugins.skins.UDGMVisualizerSkin + 2.3610941331949244 0.0 0.0 2.3610941331949244 119.38219749746548 -4.52452305190821 + + 400 + 3 + 400 + 1 + 1 + + + org.contikios.cooja.plugins.LogListener + + + + + + 1404 + 6 + 240 + 400 + 160 + + + org.contikios.cooja.plugins.TimeLine + + 0 + 1 + 2 + 3 + + + + 500.0 + + 1804 + 5 + 166 + 0 + 742 + + + org.contikios.cooja.plugins.Notes + + Enter notes here + true + + 1124 + 4 + 160 + 680 + 0 + + + org.contikios.cooja.serialsocket.SerialSocketServer + 0 + + 60001 + true + + 362 + 2 + 116 + 30 + 403 + + + org.contikios.cooja.plugins.ScriptRunner + + + true + + 600 + 0 + 700 + 850 + 13 + + + diff --git a/tests/17-rpl-border-router/03-border-router-sky.sh b/tests/17-rpl-border-router/03-border-router-sky.sh new file mode 100755 index 000000000..798e0242b --- /dev/null +++ b/tests/17-rpl-border-router/03-border-router-sky.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Contiki directory +CONTIKI=$1 + +# Simulation file +BASENAME=03-border-router-sky + +bash test-border-router.sh $CONTIKI $BASENAME fd00::0212:7404:0004:0404 diff --git a/tests/17-rpl-border-router/test-border-router.sh b/tests/17-rpl-border-router/test-border-router.sh index c99c01117..ab1ef55bd 100755 --- a/tests/17-rpl-border-router/test-border-router.sh +++ b/tests/17-rpl-border-router/test-border-router.sh @@ -6,6 +6,9 @@ CONTIKI=$1 # Simulation file BASENAME=$2 +# Destination IPv6 +IPADDR=$3 + # Start simulation echo "Starting Cooja simulation $BASENAME.csc" java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > /dev/null & @@ -22,7 +25,7 @@ sleep 5 # Do ping echo "Pinging" -ping6 fd00::204:4:4:4 -c 5 | tee $BASENAME.log +ping6 $IPADDR -c 5 | tee $BASENAME.log # Fetch ping6 status code (not $? because this is piped) STATUS=${PIPESTATUS[0]} From 6cf4d62e90f4b7248d14112d3296ca3bd108ec89 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 10 Nov 2017 22:57:32 +0100 Subject: [PATCH 07/18] Added CI test: native node ping --- .travis.yml | 1 + tests/18-native-networking/01-native-ping.sh | 47 ++++++++++++++++++++ tests/18-native-networking/Makefile | 1 + 3 files changed, 49 insertions(+) create mode 100755 tests/18-native-networking/01-native-ping.sh create mode 100644 tests/18-native-networking/Makefile diff --git a/.travis.yml b/.travis.yml index ca80acc05..d4060c893 100644 --- a/.travis.yml +++ b/.travis.yml @@ -110,3 +110,4 @@ env: - BUILD_TYPE='ieee802154' BUILD_CATEGORY='sim' - BUILD_TYPE='6tisch' BUILD_CATEGORY='sim' - BUILD_TYPE='rpl-border-router' BUILD_CATEGORY='sim' + - BUILD_TYPE='native-networking' BUILD_CATEGORY='sim' diff --git a/tests/18-native-networking/01-native-ping.sh b/tests/18-native-networking/01-native-ping.sh new file mode 100755 index 000000000..46efbf1df --- /dev/null +++ b/tests/18-native-networking/01-native-ping.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Contiki directory +CONTIKI=$1 +# Test basename +BASENAME=01-native-ping + +IPADDR=fd00::302:304:506:708 + +# Starting Contiki-NG native node +echo "Starting native node" +make -C $CONTIKI/examples/hello-world +sudo $CONTIKI/examples/hello-world/hello-world.native > node.log 2> node.err & +CPID=$! +sleep 2 + +# Do ping +echo "Pinging" +ping6 $IPADDR -c 5 | tee $BASENAME.log +# Fetch ping6 status code (not $? because this is piped) +STATUS=${PIPESTATUS[0]} + +echo "Closing native node" +sleep 2 +sudo kill -9 $CPID + +if [ $STATUS -eq 0 ] ; then + mv $BASENAME.log $BASENAME.testlog + echo " OK" +else + mv $BASENAME.log $BASENAME.faillog + + echo "" + echo "---- node.log" + cat node.log + + echo "" + echo "---- node.err" + cat node.err + + echo " FAIL ಠ_ಠ" | tee -a $BASENAME.faillog; +fi + +# We do not want Make to stop -> Return 0 +# The Makefile will check if a log contains FAIL at the end + +exit 0 diff --git a/tests/18-native-networking/Makefile b/tests/18-native-networking/Makefile new file mode 100644 index 000000000..c46e5271d --- /dev/null +++ b/tests/18-native-networking/Makefile @@ -0,0 +1 @@ +include ../Makefile.script-test From 295a0c6d6360e0f714e7fc2bc6c5d1ffbdfdc5cc Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 11 Nov 2017 15:05:27 +0100 Subject: [PATCH 08/18] CI: simplify script tests --- .../test-border-router.sh | 37 +++++++++---------- tests/18-native-networking/01-native-ping.sh | 7 ++-- tests/Makefile.script-test | 11 ++---- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/tests/17-rpl-border-router/test-border-router.sh b/tests/17-rpl-border-router/test-border-router.sh index ab1ef55bd..260f9a4f9 100755 --- a/tests/17-rpl-border-router/test-border-router.sh +++ b/tests/17-rpl-border-router/test-border-router.sh @@ -11,48 +11,45 @@ IPADDR=$3 # Start simulation echo "Starting Cooja simulation $BASENAME.csc" -java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > /dev/null & +java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > $BASENAME.coojalog & JPID=$! sleep 20 # Connect to the simlation echo "Starting tunslip6" make -C $CONTIKI/tools tunslip6 -make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=zoul > tunslip.log 2> tunslip.err & +make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=zoul >> $BASENAME.tunsliplog 2>&1 & MPID=$! echo "Waiting for network formation" sleep 5 # Do ping echo "Pinging" -ping6 $IPADDR -c 5 | tee $BASENAME.log +ping6 $IPADDR -c 5 | tee $BASENAME.scriptlog # Fetch ping6 status code (not $? because this is piped) STATUS=${PIPESTATUS[0]} echo "Closing simulation and tunslip6" -sleep 2 +sleep 1 kill -9 $JPID kill -9 $MPID +sleep 1 +rm COOJA.testlog +rm COOJA.log if [ $STATUS -eq 0 ] ; then - mv $BASENAME.log $BASENAME.testlog - echo " OK" + echo "$BASENAME: TEST OK" | tee $BASENAME.testlog; else - mv $BASENAME.log $BASENAME.faillog + # Verbose output when using CI + if [ "$CI" = "true" ]; then + echo "==== $BASENAME.coojalog ====" ; cat $BASENAME.coojalog; + echo "==== $BASENAME.tunsliplog ====" ; cat $BASENAME.tunsliplog; + echo "==== $BASENAME.scriptlog ====" ; cat $BASENAME.scriptlog; + else + echo "==== Check $BASENAME.coojalog, $BASENAME.tunsliplog, and $BASENAME.scriptlog for details ===="; + fi; - echo "" - echo "---- COOJA.log" - cat COOJA.log - - echo "" - echo "---- tunslip.log" - cat tunslip.log - - echo "" - echo "---- tunslip.err" - cat tunslip.err - - echo " FAIL ಠ_ಠ" | tee -a $BASENAME.faillog; + echo "$BASENAME: TEST FAIL ಠ_ಠ" | tee $BASENAME.testlog; fi # We do not want Make to stop -> Return 0 diff --git a/tests/18-native-networking/01-native-ping.sh b/tests/18-native-networking/01-native-ping.sh index 46efbf1df..144554499 100755 --- a/tests/18-native-networking/01-native-ping.sh +++ b/tests/18-native-networking/01-native-ping.sh @@ -25,8 +25,8 @@ sleep 2 sudo kill -9 $CPID if [ $STATUS -eq 0 ] ; then - mv $BASENAME.log $BASENAME.testlog - echo " OK" + cp $BASENAME.log $BASENAME.testlog + echo "$BASENAME: TEST OK" | tee -a $BASENAME.testlog; else mv $BASENAME.log $BASENAME.faillog @@ -38,7 +38,8 @@ else echo "---- node.err" cat node.err - echo " FAIL ಠ_ಠ" | tee -a $BASENAME.faillog; + cp $BASENAME.log $BASENAME.faillog + echo "$BASENAME: TEST FAIL ಠ_ಠ" | tee -a $BASENAME.testlog; fi # We do not want Make to stop -> Return 0 diff --git a/tests/Makefile.script-test b/tests/Makefile.script-test index c39ce383c..a14523fe4 100644 --- a/tests/Makefile.script-test +++ b/tests/Makefile.script-test @@ -1,20 +1,15 @@ TESTS=$(wildcard ??-*.sh) TESTLOGS=$(patsubst %.sh,%.testlog,$(TESTS)) -FAILLOGS=$(patsubst %.sh,%.faillog,$(TESTS)) CONTIKI=../.. tests: $(TESTLOGS) -report: clean tests - @echo | grep -s -e '' - $(TESTLOGS) $(FAILLOGS) > $@ || true - -summary: report +summary: clean tests ifeq ($(TESTS),) @echo No tests > $@ else - @egrep -e ' OK| FAIL' $< > $@ - @ls -1 ??-*.faillog > /dev/null 2>&1; [ $$? = 0 ] && tail -v ??-*.log ??-*.faillog >> $@ || true + @cat $(TESTLOGS) > $@ endif all: cooja clean tests @@ -23,7 +18,7 @@ all: cooja clean tests @bash "$(basename $@).sh" "$(CONTIKI)" clean: - @rm -f $(TESTLOGS) $(FAILLOGS) report summary + @rm -f *.*log report summary cooja: $(CONTIKI)/tools/cooja/dist/cooja.jar $(CONTIKI)/tools/cooja/dist/cooja.jar: From 071f54207834d75a715eee4eb21b5a46f989ceb4 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 11 Nov 2017 14:48:20 +0100 Subject: [PATCH 09/18] uIP6: check MTU, check and update TTL even in the case of routing header forwarding --- os/net/ipv6/uip6.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/os/net/ipv6/uip6.c b/os/net/ipv6/uip6.c index b0cab3ebd..9a9f62e2e 100644 --- a/os/net/ipv6/uip6.c +++ b/os/net/ipv6/uip6.c @@ -1358,6 +1358,31 @@ uip_process(uint8_t flag) if(UIP_ROUTING_BUF->seg_left > 0) { #if UIP_CONF_IPV6_RPL && RPL_WITH_NON_STORING if(rpl_ext_header_srh_update()) { + + /* With routing header, the detination address is us and will + * be swapped later to the next hop. Because of this, the MTU + * and TTL were not checked and updated yet. Do this now. */ + + /* Check MTU */ + if(uip_len > UIP_LINK_MTU) { + uip_icmp6_error_output(ICMP6_PACKET_TOO_BIG, 0, UIP_LINK_MTU); + UIP_STAT(++uip_stat.ip.drop); + goto send; + } + /* Check Hop Limit */ + if(UIP_IP_BUF->ttl <= 1) { + uip_icmp6_error_output(ICMP6_TIME_EXCEEDED, + ICMP6_TIME_EXCEED_TRANSIT, 0); + UIP_STAT(++uip_stat.ip.drop); + goto send; + } + UIP_IP_BUF->ttl = UIP_IP_BUF->ttl - 1; + + LOG_INFO("Forwarding packet to "); + LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); + LOG_INFO_("\n"); + UIP_STAT(++uip_stat.ip.forwarded); + goto send; /* Proceed to forwarding */ } #endif /* UIP_CONF_IPV6_RPL && RPL_WITH_NON_STORING */ From 45ef10ff640542624fd56391c6058954eacd559b Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 14 Nov 2017 10:00:15 +0100 Subject: [PATCH 10/18] CI script tests: homogenize logs --- tests/17-rpl-border-router/test-border-router.sh | 4 ++-- tests/18-native-networking/01-native-ping.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/17-rpl-border-router/test-border-router.sh b/tests/17-rpl-border-router/test-border-router.sh index 260f9a4f9..db399ca70 100755 --- a/tests/17-rpl-border-router/test-border-router.sh +++ b/tests/17-rpl-border-router/test-border-router.sh @@ -38,7 +38,7 @@ rm COOJA.testlog rm COOJA.log if [ $STATUS -eq 0 ] ; then - echo "$BASENAME: TEST OK" | tee $BASENAME.testlog; + printf "%-32s TEST OK\n" "$BASENAME" | tee $BASENAME.testlog; else # Verbose output when using CI if [ "$CI" = "true" ]; then @@ -49,7 +49,7 @@ else echo "==== Check $BASENAME.coojalog, $BASENAME.tunsliplog, and $BASENAME.scriptlog for details ===="; fi; - echo "$BASENAME: TEST FAIL ಠ_ಠ" | tee $BASENAME.testlog; + printf "%-32s TEST FAIL\n" "$BASENAME" | tee $BASENAME.testlog; fi # We do not want Make to stop -> Return 0 diff --git a/tests/18-native-networking/01-native-ping.sh b/tests/18-native-networking/01-native-ping.sh index 144554499..c6acb733c 100755 --- a/tests/18-native-networking/01-native-ping.sh +++ b/tests/18-native-networking/01-native-ping.sh @@ -26,7 +26,7 @@ sudo kill -9 $CPID if [ $STATUS -eq 0 ] ; then cp $BASENAME.log $BASENAME.testlog - echo "$BASENAME: TEST OK" | tee -a $BASENAME.testlog; + printf "%-32s TEST OK\n" "$BASENAME" | tee -a $BASENAME.testlog; else mv $BASENAME.log $BASENAME.faillog @@ -39,7 +39,7 @@ else cat node.err cp $BASENAME.log $BASENAME.faillog - echo "$BASENAME: TEST FAIL ಠ_ಠ" | tee -a $BASENAME.testlog; + printf "%-32s TEST FAIL\n" "$BASENAME" | tee -a $BASENAME.testlog; fi # We do not want Make to stop -> Return 0 From 640fbd33b59a90ef444087fd02f620ce60939908 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 14 Nov 2017 10:00:37 +0100 Subject: [PATCH 11/18] CI script tests: order tests explicitly --- tests/Makefile.script-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.script-test b/tests/Makefile.script-test index a14523fe4..26d60737f 100644 --- a/tests/Makefile.script-test +++ b/tests/Makefile.script-test @@ -1,5 +1,5 @@ TESTS=$(wildcard ??-*.sh) -TESTLOGS=$(patsubst %.sh,%.testlog,$(TESTS)) +TESTLOGS=$(sort $(patsubst %.sh,%.testlog,$(TESTS))) CONTIKI=../.. From 164f228e91dcf64394bfb6eb59d4047bc9eb49c5 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 11 Nov 2017 14:48:44 +0100 Subject: [PATCH 12/18] Added CI test for traceroute --- .../04-border-router-traceroute.csc | 252 ++++++++++++++++++ .../04-border-router-traceroute.sh | 61 +++++ 2 files changed, 313 insertions(+) create mode 100644 tests/17-rpl-border-router/04-border-router-traceroute.csc create mode 100755 tests/17-rpl-border-router/04-border-router-traceroute.sh diff --git a/tests/17-rpl-border-router/04-border-router-traceroute.csc b/tests/17-rpl-border-router/04-border-router-traceroute.csc new file mode 100644 index 000000000..a010d5ef2 --- /dev/null +++ b/tests/17-rpl-border-router/04-border-router-traceroute.csc @@ -0,0 +1,252 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/collect-view + [APPS_DIR]/powertracker + + My simulation + 1.0 + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype295 + Cooja Mote Type #1 + [CONTIKI_DIR]/examples/rpl-border-router/border-router.c + make TARGET=cooja clean +make border-router.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype686 + Cooja Mote Type #2 + [CONTIKI_DIR]/examples/hello-world/hello-world.c + make TARGET=cooja clean +make hello-world.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 54.36775767371176 + 24.409055040864118 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype295 + + + + org.contikios.cooja.interfaces.Position + 83.54989222799365 + 52.63050856506214 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype686 + + + + org.contikios.cooja.interfaces.Position + 108.91767775240822 + 78.59778809170032 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 3 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype686 + + + + org.contikios.cooja.interfaces.Position + 139.91021061864723 + 98.34190023350419 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 4 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype686 + + + + org.contikios.cooja.plugins.SimControl + 280 + 1 + 160 + 400 + 0 + + + org.contikios.cooja.plugins.Visualizer + + true + org.contikios.cooja.plugins.skins.UDGMVisualizerSkin + org.contikios.cooja.plugins.skins.IDVisualizerSkin + 1.9798610460263038 0.0 0.0 1.9798610460263038 -61.112037797038525 -1.2848438586294648 + + 400 + 4 + 400 + 1 + 1 + + + org.contikios.cooja.plugins.LogListener + + ID:4 + + + + 1404 + 2 + 240 + 400 + 160 + + + org.contikios.cooja.plugins.TimeLine + + 0 + 1 + 2 + 3 + + + + 500.0 + + 1804 + 6 + 166 + 0 + 753 + + + org.contikios.cooja.plugins.Notes + + Enter notes here + true + + 1124 + 5 + 160 + 680 + 0 + + + org.contikios.cooja.serialsocket.SerialSocketServer + 0 + + 60001 + true + + 362 + 3 + 116 + 13 + 414 + + + org.contikios.cooja.plugins.ScriptRunner + + + true + + 600 + 0 + 700 + 1037 + 40 + + diff --git a/tests/17-rpl-border-router/04-border-router-traceroute.sh b/tests/17-rpl-border-router/04-border-router-traceroute.sh new file mode 100755 index 000000000..96278e7d5 --- /dev/null +++ b/tests/17-rpl-border-router/04-border-router-traceroute.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Contiki directory +CONTIKI=$1 + +# Simulation file +BASENAME=04-border-router-traceroute + +# Destination IPv6 +IPADDR=fd00::204:4:4:4 +# The expected hop count +TARGETHOPS=4 + +# Start simulation +echo "Starting Cooja simulation $BASENAME.csc" +java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > $BASENAME.coojalog & +JPID=$! +sleep 20 + +# Connect to the simlation +echo "Starting tunslip6" +make -C $CONTIKI/tools tunslip6 +make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=zoul >> $BASENAME.tunsliplog 2>&1 & +MPID=$! +echo "Waiting for network formation" +sleep 5 + +# Do ping +echo "Running Traceroute" +traceroute6 $IPADDR -m 5 | tee $BASENAME.scriptlog +# Fetch traceroute6 status code (not $? because this is piped) +STATUS=${PIPESTATUS[0]} +HOPS=`wc $BASENAME.scriptlog -l | cut -f 1 -d ' '` + +echo "Closing simulation and tunslip6" +sleep 1 +kill -9 $JPID +kill -9 $MPID +sleep 1 +rm COOJA.testlog +rm COOJA.log + +if [ $STATUS -eq 0 ] && [ $HOPS -eq $TARGETHOPS ] ; then + printf "%-32s TEST OK\n" "$BASENAME" | tee $BASENAME.testlog; +else + # Verbose output when using CI + if [ "$CI" = "true" ]; then + echo "==== $BASENAME.coojalog ====" ; cat $BASENAME.coojalog; + echo "==== $BASENAME.tunsliplog ====" ; cat $BASENAME.tunsliplog; + echo "==== $BASENAME.scriptlog ====" ; cat $BASENAME.scriptlog; + else + echo "==== Check $BASENAME.coojalog, $BASENAME.tunsliplog, and $BASENAME.scriptlog for details ===="; + fi; + + printf "%-32s TEST FAIL\n" "$BASENAME" | tee $BASENAME.testlog; +fi + +# We do not want Make to stop -> Return 0 +# The Makefile will check if a log contains FAIL at the end + +exit 0 From 0bd107b0a00c13653c705f9e8ac83068b90ae183 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 12 Nov 2017 14:07:47 +0100 Subject: [PATCH 13/18] uIP6 forwarding: clearer log messages --- os/net/ipv6/uip6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os/net/ipv6/uip6.c b/os/net/ipv6/uip6.c index 9a9f62e2e..60233ee19 100644 --- a/os/net/ipv6/uip6.c +++ b/os/net/ipv6/uip6.c @@ -1224,7 +1224,7 @@ uip_process(uint8_t flag) } UIP_IP_BUF->ttl = UIP_IP_BUF->ttl - 1; - LOG_INFO("Forwarding packet to "); + LOG_INFO("Forwarding packet towards "); LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); LOG_INFO_("\n"); UIP_STAT(++uip_stat.ip.forwarded); @@ -1378,7 +1378,7 @@ uip_process(uint8_t flag) } UIP_IP_BUF->ttl = UIP_IP_BUF->ttl - 1; - LOG_INFO("Forwarding packet to "); + LOG_INFO("Forwarding packet to next hop "); LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); LOG_INFO_("\n"); UIP_STAT(++uip_stat.ip.forwarded); From 7b26ead9de23ae33b18d1493d086413d824b8a47 Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Wed, 15 Nov 2017 12:17:44 +0000 Subject: [PATCH 14/18] add deep sleep tracking for CC2538 --- arch/cpu/cc2538/lpm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/cpu/cc2538/lpm.c b/arch/cpu/cc2538/lpm.c index 9e21fe4dc..7892ff204 100644 --- a/arch/cpu/cc2538/lpm.c +++ b/arch/cpu/cc2538/lpm.c @@ -212,10 +212,14 @@ lpm_exit() /* Restore system clock to the 32 MHz XOSC */ select_32_mhz_xosc(); + if((REG(SYS_CTRL_PMCTL) & SYS_CTRL_PMCTL_PM3) == SYS_CTRL_PMCTL_PM1) { + ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); + } else { + ENERGEST_SWITCH(ENERGEST_TYPE_DEEP_LPM, ENERGEST_TYPE_CPU); + } + /* Restore PMCTL to PM0 for next pass */ REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM0; - - ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); } /*---------------------------------------------------------------------------*/ void @@ -286,8 +290,6 @@ lpm_enter() REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM1; } - ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM); - /* Remember the current time so we can keep stats when we wake up */ if(LPM_CONF_STATS) { sleep_enter_time = RTIMER_NOW(); @@ -310,9 +312,13 @@ lpm_enter() REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM0; - ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); } else { /* All clear. Assert WFI and drop to PM1/2. This is now un-interruptible */ + if((REG(SYS_CTRL_PMCTL) & SYS_CTRL_PMCTL_PM3) == SYS_CTRL_PMCTL_PM1) { + ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM); + } else { + ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_DEEP_LPM); + } assert_wfi(); } From 02c065db696dbb4ec6cf020171dfa3d46b3b8362 Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Wed, 15 Nov 2017 12:17:53 +0000 Subject: [PATCH 15/18] add deep sleep tracking for CC26xx --- arch/cpu/cc26xx-cc13xx/lpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/cpu/cc26xx-cc13xx/lpm.c b/arch/cpu/cc26xx-cc13xx/lpm.c index 48ded636e..a5e746f24 100644 --- a/arch/cpu/cc26xx-cc13xx/lpm.c +++ b/arch/cpu/cc26xx-cc13xx/lpm.c @@ -185,7 +185,7 @@ wake_up(void) { lpm_registered_module_t *module; - ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); + ENERGEST_SWITCH(ENERGEST_TYPE_DEEP_LPM, ENERGEST_TYPE_CPU); /* Sync so that we get the latest values before adjusting recharge settings */ ti_lib_sys_ctrl_aon_sync(); @@ -485,7 +485,7 @@ deep_sleep(void) ti_lib_pwr_ctrl_source_set(PWRCTRL_PWRSRC_ULDO); } - ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM); + ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_DEEP_LPM); /* Sync the AON interface to ensure all writes have gone through. */ ti_lib_sys_ctrl_aon_sync(); From a211cb6e31ae4c971d0f06d87135bc4f27263e76 Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Wed, 15 Nov 2017 14:54:32 +0000 Subject: [PATCH 16/18] Allow to set a different number of MAC retransmissions for different classes of packets --- os/net/ipv6/sicslowpan.c | 11 +++++++ os/net/ipv6/uip.h | 19 ++++++++++++ os/net/ipv6/uip6.c | 28 ++++++++++++++++-- os/net/ipv6/uipopt.h | 29 +++++++++++++++++++ os/net/mac/csma/csma-output.c | 14 +++++++-- os/net/mac/tsch/tsch-queue.c | 6 ++-- os/net/mac/tsch/tsch-queue.h | 4 ++- os/net/mac/tsch/tsch.c | 15 ++++++++-- os/net/packetbuf.h | 3 ++ .../test-flush-nbr-queue.c | 6 ++-- 10 files changed, 121 insertions(+), 14 deletions(-) diff --git a/os/net/ipv6/sicslowpan.c b/os/net/ipv6/sicslowpan.c index 2f239f77e..492dfe444 100644 --- a/os/net/ipv6/sicslowpan.c +++ b/os/net/ipv6/sicslowpan.c @@ -1504,6 +1504,17 @@ output(const linkaddr_t *localdest) set_packet_attrs(); } +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + { + uint8_t traffic_class = (UIP_IP_BUF->vtc << 4) | (UIP_IP_BUF->tcflow >> 4); + if(traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_BIT) { + uint8_t max_mac_transmissions = traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_MASK; + /* propagate the MAC transmission limit to lower layers */ + packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, max_mac_transmissions); + } + } +#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */ + /* * The destination address will be tagged to each outbound * packet. If the argument localdest is NULL, we are sending a diff --git a/os/net/ipv6/uip.h b/os/net/ipv6/uip.h index 809f4b4bc..69888445e 100755 --- a/os/net/ipv6/uip.h +++ b/os/net/ipv6/uip.h @@ -820,6 +820,18 @@ CCIF void uip_send(const void *data, int len); */ #define uip_mss() (uip_conn->mss) +/** + * Set the maximal number of MAC transmissions. + * + * \hideinitializer + */ +#if UIP_WITH_VARIABLE_RETRANSMISSIONS +#define uip_set_max_mac_transmissions(conn, value) ((conn)->max_mac_transmissions = (value)) +#else +#define uip_set_max_mac_transmissions(conn, value) +#endif + + /** * Set up a new UDP connection. * @@ -883,6 +895,7 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport); */ #define uip_udp_send(len) uip_send((char *)uip_appdata, len) + /** @} */ /* uIP convenience and converting functions. */ @@ -1352,6 +1365,9 @@ struct uip_conn { uint8_t timer; /**< The retransmission timer. */ uint8_t nrtx; /**< The number of retransmissions for the last segment sent. */ +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + uint8_t max_mac_transmissions; /**< Number of max MAC-layer transmissions. */ +#endif uip_tcp_appstate_t appstate; /** The application state. */ }; @@ -1389,6 +1405,9 @@ struct uip_udp_conn { uint16_t lport; /**< The local port number in network byte order. */ uint16_t rport; /**< The remote port number in network byte order. */ uint8_t ttl; /**< Default time-to-live. */ +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + uint8_t max_mac_transmissions; /**< Number of max MAC-layer transmissions. */ +#endif /** The application state. */ uip_udp_appstate_t appstate; diff --git a/os/net/ipv6/uip6.c b/os/net/ipv6/uip6.c index b0cab3ebd..d3df05b7f 100644 --- a/os/net/ipv6/uip6.c +++ b/os/net/ipv6/uip6.c @@ -508,6 +508,9 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport) conn->rto = UIP_RTO; conn->sa = 0; conn->sv = 16; /* Initial value of the RTT variance. */ +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + conn->max_mac_transmissions = UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED; +#endif conn->lport = uip_htons(lastport); conn->rport = rport; uip_ipaddr_copy(&conn->ripaddr, ripaddr); @@ -581,6 +584,9 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport) uip_ipaddr_copy(&conn->ripaddr, ripaddr); } conn->ttl = uip_ds6_if.cur_hop_limit; +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + conn->max_mac_transmissions = UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED; +#endif return conn; } @@ -1545,6 +1551,16 @@ uip_process(uint8_t flag) UIP_IP_BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8); UIP_IP_BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff); + UIP_IP_BUF->vtc = 0x60; + UIP_IP_BUF->tcflow = 0x00; +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + if(uip_udp_conn->max_mac_transmissions != UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) { + /* Encapsulate the MAC transmission limit in the Traffic Class field */ + UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4); + UIP_IP_BUF->tcflow = uip_udp_conn->max_mac_transmissions << 4; + } +#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */ + UIP_IP_BUF->ttl = uip_udp_conn->ttl; UIP_IP_BUF->proto = UIP_PROTO_UDP; @@ -2249,6 +2265,16 @@ uip_process(uint8_t flag) UIP_TCP_BUF->srcport = uip_connr->lport; UIP_TCP_BUF->destport = uip_connr->rport; + UIP_IP_BUF->vtc = 0x60; + UIP_IP_BUF->tcflow = 0x00; +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + if(uip_connr->max_mac_transmissions != UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) { + /* Encapsulate the MAC transmission limit in the Traffic Class field */ + UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4); + UIP_IP_BUF->tcflow = uip_connr->max_mac_transmissions << 4; + } +#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */ + uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &uip_connr->ripaddr); uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr); LOG_INFO("Sending TCP packet to "); @@ -2284,8 +2310,6 @@ uip_process(uint8_t flag) #if UIP_UDP ip_send_nolen: #endif - UIP_IP_BUF->vtc = 0x60; - UIP_IP_BUF->tcflow = 0x00; UIP_IP_BUF->flow = 0x00; send: LOG_INFO("Sending packet with length %d (%d)\n", uip_len, diff --git a/os/net/ipv6/uipopt.h b/os/net/ipv6/uipopt.h index 84b7fd023..d668133a8 100644 --- a/os/net/ipv6/uipopt.h +++ b/os/net/ipv6/uipopt.h @@ -518,6 +518,35 @@ void uip_log(char *msg); #define UIP_DEFAULT_PREFIX_LEN 64 +/** + * Enables selection of maximal MAC-layer transmission count at application layer + */ +#ifdef UIP_CONF_WITH_VARIABLE_RETRANSMISSIONS +#define UIP_WITH_VARIABLE_RETRANSMISSIONS UIP_CONF_WITH_VARIABLE_RETRANSMISSIONS +#else +#define UIP_WITH_VARIABLE_RETRANSMISSIONS 0 +#endif + +/** + * This is the default value of MAC-layer transmissons for uIPv6 + * + * It means that the limit is selected by the MAC protocol instead of uIPv6. + */ +#define UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED 0 + +/** + * The MAC-layer transmissons limit is encapslated in "Traffic Class" field + * + * In Contiki, if the Traffic Class field in the IPv6 header has this bit set, + * the low-order bits are used as the MAC-layer transmissons limit. + */ +#define UIP_TC_MAC_TRANSMISSION_COUNTER_BIT 0x40 + +/** + * The bits in the "Traffic Class" field that describe the MAC transmission limit + */ +#define UIP_TC_MAC_TRANSMISSION_COUNTER_MASK 0x3F + /** @} */ /*------------------------------------------------------------------------------*/ diff --git a/os/net/mac/csma/csma-output.c b/os/net/mac/csma/csma-output.c index 167d4374c..532b4ae7a 100644 --- a/os/net/mac/csma/csma-output.c +++ b/os/net/mac/csma/csma-output.c @@ -85,9 +85,9 @@ /* macMaxFrameRetries: Maximum number of re-transmissions attampts. Range 0--7 */ #ifdef CSMA_CONF_MAX_FRAME_RETRIES -#define CSMA_MAX_MAX_FRAME_RETRIES CSMA_CONF_MAX_FRAME_RETRIES +#define CSMA_MAX_FRAME_RETRIES CSMA_MAX_FRAME_RETRIES #else -#define CSMA_MAX_MAX_FRAME_RETRIES 7 +#define CSMA_MAX_FRAME_RETRIES 7 #endif /* Packet metadata */ @@ -506,7 +506,15 @@ csma_output_packet(mac_callback_t sent, void *ptr) if(q->buf != NULL) { struct qbuf_metadata *metadata = (struct qbuf_metadata *)q->ptr; /* Neighbor and packet successfully allocated */ - metadata->max_transmissions = CSMA_MAX_MAX_FRAME_RETRIES + 1; +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + metadata->max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS); + if(metadata->max_transmissions == 0) { + /* If not set by the application, use the default CSMA value */ + metadata->max_transmissions = CSMA_MAX_FRAME_RETRIES + 1; + } +#else + metadata->max_transmissions = CSMA_MAX_FRAME_RETRIES + 1; +#endif metadata->sent = sent; metadata->cptr = ptr; list_add(n->packet_queue, q); diff --git a/os/net/mac/tsch/tsch-queue.c b/os/net/mac/tsch/tsch-queue.c index 388953a60..7aee0d66a 100644 --- a/os/net/mac/tsch/tsch-queue.c +++ b/os/net/mac/tsch/tsch-queue.c @@ -230,7 +230,8 @@ tsch_queue_remove_nbr(struct tsch_neighbor *n) /*---------------------------------------------------------------------------*/ /* Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) */ struct tsch_packet * -tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr) +tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions, + mac_callback_t sent, void *ptr) { struct tsch_neighbor *n = NULL; int16_t put_index = -1; @@ -252,6 +253,7 @@ tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr) p->ptr = ptr; p->ret = MAC_TX_DEFERRED; p->transmissions = 0; + p->max_transmissions = max_transmissions; /* Add to ringbuf (actual add committed through atomic operation) */ n->tx_array[put_index] = p; ringbufindex_put(&n->tx_ringbuf); @@ -342,7 +344,7 @@ tsch_queue_packet_sent(struct tsch_neighbor *n, struct tsch_packet *p, } } else { /* Failed transmission */ - if(p->transmissions >= TSCH_MAC_MAX_FRAME_RETRIES + 1) { + if(p->transmissions >= p->max_transmissions) { /* Drop packet */ tsch_queue_remove_packet_from_queue(n); in_queue = 0; diff --git a/os/net/mac/tsch/tsch-queue.h b/os/net/mac/tsch/tsch-queue.h index 037461e7d..0d77a6105 100644 --- a/os/net/mac/tsch/tsch-queue.h +++ b/os/net/mac/tsch/tsch-queue.h @@ -135,6 +135,7 @@ struct tsch_packet { mac_callback_t sent; /* callback for this packet */ void *ptr; /* MAC callback parameter */ uint8_t transmissions; /* #transmissions performed for this packet */ + uint8_t max_transmissions; /* maximal number of Tx before dropping the packet */ uint8_t ret; /* status -- MAC return code */ uint8_t header_len; /* length of header and header IEs (needed for link-layer security) */ uint8_t tsch_sync_ie_offset; /* Offset within the frame used for quick update of EB ASN and join priority */ @@ -176,7 +177,8 @@ struct tsch_neighbor *tsch_queue_get_time_source(void); /* Update TSCH time source */ int tsch_queue_update_time_source(const linkaddr_t *new_addr); /* Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) */ -struct tsch_packet *tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr); +struct tsch_packet *tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions, + mac_callback_t sent, void *ptr); /* Returns the number of packets currently in any TSCH queue */ int tsch_queue_global_packet_count(void); /* Returns the number of packets currently a given neighbor queue */ diff --git a/os/net/mac/tsch/tsch.c b/os/net/mac/tsch/tsch.c index 017f6542c..bbaed827a 100644 --- a/os/net/mac/tsch/tsch.c +++ b/os/net/mac/tsch/tsch.c @@ -832,8 +832,8 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data) /* Prepare the EB packet and schedule it to be sent */ if(tsch_packet_create_eb(&hdr_len, &tsch_sync_ie_offset) > 0) { struct tsch_packet *p; - /* Enqueue EB packet */ - if(!(p = tsch_queue_add_packet(&tsch_eb_address, NULL, NULL))) { + /* Enqueue EB packet, for a single transmission only */ + if(!(p = tsch_queue_add_packet(&tsch_eb_address, 1, NULL, NULL))) { LOG_ERR("! could not enqueue EB packet\n"); } else { LOG_INFO("TSCH: enqueue EB packet %u %u\n", @@ -958,6 +958,7 @@ send_packet(mac_callback_t sent, void *ptr) int ret = MAC_TX_DEFERRED; int hdr_len = 0; const linkaddr_t *addr = packetbuf_addr(PACKETBUF_ADDR_RECEIVER); + uint8_t max_transmissions = 0; if(!tsch_is_associated) { if(!tsch_is_initialized) { @@ -1006,13 +1007,21 @@ send_packet(mac_callback_t sent, void *ptr) packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr); #endif +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS); +#endif + if(max_transmissions == 0) { + /* If not set by the application, use the default TSCH value */ + max_transmissions = TSCH_MAC_MAX_FRAME_RETRIES + 1; + } + if((hdr_len = NETSTACK_FRAMER.create()) < 0) { LOG_ERR("! can't send packet due to framer error\n"); ret = MAC_TX_ERR; } else { struct tsch_packet *p; /* Enqueue packet */ - p = tsch_queue_add_packet(addr, sent, ptr); + p = tsch_queue_add_packet(addr, max_transmissions, sent, ptr); if(p == NULL) { LOG_ERR("! can't send packet to "); LOG_ERR_LLADDR(addr); diff --git a/os/net/packetbuf.h b/os/net/packetbuf.h index c16a3f8f1..706fe51d6 100644 --- a/os/net/packetbuf.h +++ b/os/net/packetbuf.h @@ -217,6 +217,9 @@ enum { PACKETBUF_ATTR_LINK_QUALITY, PACKETBUF_ATTR_RSSI, PACKETBUF_ATTR_TIMESTAMP, +#if UIP_WITH_VARIABLE_RETRANSMISSIONS + PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, +#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */ PACKETBUF_ATTR_MAC_SEQNO, PACKETBUF_ATTR_MAC_ACK, PACKETBUF_ATTR_MAC_METADATA, diff --git a/tests/13-ieee802154/code-flush-nbr-queue/test-flush-nbr-queue.c b/tests/13-ieee802154/code-flush-nbr-queue/test-flush-nbr-queue.c index 9045f77e4..d8be606ac 100644 --- a/tests/13-ieee802154/code-flush-nbr-queue/test-flush-nbr-queue.c +++ b/tests/13-ieee802154/code-flush-nbr-queue/test-flush-nbr-queue.c @@ -58,7 +58,7 @@ UNIT_TEST(test) UNIT_TEST_BEGIN(); - packet = tsch_queue_add_packet(TEST_PEER_ADDR, NULL, NULL); + packet = tsch_queue_add_packet(TEST_PEER_ADDR, 1, NULL, NULL); UNIT_TEST_ASSERT(packet != NULL); nbr = tsch_queue_get_nbr(TEST_PEER_ADDR); @@ -68,14 +68,14 @@ UNIT_TEST(test) * QUEUEBUF_CONF_NUM is set with 1; so another addition should fail due to * lack of memory. */ - packet = tsch_queue_add_packet(TEST_PEER_ADDR, NULL, NULL); + packet = tsch_queue_add_packet(TEST_PEER_ADDR, 1, NULL, NULL); UNIT_TEST_ASSERT(packet == NULL); /* tsch_queue_flush_nbr_queue() is called inside of tsch_queue_reset(). */ tsch_queue_reset(); /* After flushing the nbr queue, we should be able to add a new packet */ - packet = tsch_queue_add_packet(TEST_PEER_ADDR, NULL, NULL); + packet = tsch_queue_add_packet(TEST_PEER_ADDR, 1, NULL, NULL); UNIT_TEST_ASSERT(packet != NULL); UNIT_TEST_END(); From 6f15a2aa65b0776e90d2ec24a556b16c782a4ba5 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 17 Nov 2017 07:56:01 -0800 Subject: [PATCH 17/18] CI script tests: minor fixes --- tests/18-native-networking/01-native-ping.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/18-native-networking/01-native-ping.sh b/tests/18-native-networking/01-native-ping.sh index c6acb733c..fa7fe49e7 100755 --- a/tests/18-native-networking/01-native-ping.sh +++ b/tests/18-native-networking/01-native-ping.sh @@ -22,7 +22,7 @@ STATUS=${PIPESTATUS[0]} echo "Closing native node" sleep 2 -sudo kill -9 $CPID +pgrep hello-world | sudo xargs kill -9 if [ $STATUS -eq 0 ] ; then cp $BASENAME.log $BASENAME.testlog @@ -42,7 +42,9 @@ else printf "%-32s TEST FAIL\n" "$BASENAME" | tee -a $BASENAME.testlog; fi +rm node.log +rm node.err + # We do not want Make to stop -> Return 0 # The Makefile will check if a log contains FAIL at the end - exit 0 From 8f7b8cd23e5587581ed86fbdb03dd5a31f0fe916 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 17 Nov 2017 08:24:10 -0800 Subject: [PATCH 18/18] Removing unused Cooja MT functions --- arch/platform/cooja/sys/cooja_mt.c | 20 ------- arch/platform/cooja/sys/cooja_mt.h | 77 -------------------------- arch/platform/cooja/sys/cooja_mtarch.c | 33 +---------- arch/platform/cooja/sys/cooja_mtarch.h | 3 - 4 files changed, 1 insertion(+), 132 deletions(-) diff --git a/arch/platform/cooja/sys/cooja_mt.c b/arch/platform/cooja/sys/cooja_mt.c index 3ccc5c169..ca0d79303 100644 --- a/arch/platform/cooja/sys/cooja_mt.c +++ b/arch/platform/cooja/sys/cooja_mt.c @@ -46,18 +46,6 @@ static struct cooja_mt_thread *current; -/*--------------------------------------------------------------------------*/ -void -cooja_mt_init(void) -{ - cooja_mtarch_init(); -} -/*--------------------------------------------------------------------------*/ -void -cooja_mt_remove(void) -{ - cooja_mtarch_remove(); -} /*--------------------------------------------------------------------------*/ void cooja_mt_start(struct cooja_mt_thread *thread, void (* function)(void *), void *data) @@ -82,14 +70,6 @@ cooja_mt_exec(struct cooja_mt_thread *thread) } /*--------------------------------------------------------------------------*/ void -cooja_mt_exit(void) -{ - current->state = MT_STATE_EXITED; - current = NULL; - cooja_mtarch_yield(); -} -/*--------------------------------------------------------------------------*/ -void cooja_mt_yield(void) { current->state = MT_STATE_READY; diff --git a/arch/platform/cooja/sys/cooja_mt.h b/arch/platform/cooja/sys/cooja_mt.h index 4707b1fff..f9138c6dd 100644 --- a/arch/platform/cooja/sys/cooja_mt.h +++ b/arch/platform/cooja/sys/cooja_mt.h @@ -49,25 +49,6 @@ */ struct cooja_mtarch_thread; -/** - * Initialize the architecture specific support functions for the - * multi-thread library. - * - * This function is implemented by the architecture specific functions - * for the multi-thread library and is called by the mt_init() - * function as part of the initialization of the library. The - * mtarch_init() function can be used for, e.g., starting preemtion - * timers or other architecture specific mechanisms required for the - * operation of the library. - */ -void cooja_mtarch_init(void); - -/** - * Uninstall library and clean up. - * - */ -void cooja_mtarch_remove(void); - /** * Setup the stack frame for a thread that is being started. * @@ -128,19 +109,6 @@ struct cooja_mt_thread { */ #define MT_OK 1 -/** - * Initializes the multithreading library. - * - */ -void cooja_mt_init(void); - -/** - * Uninstalls library and cleans up. - * - */ -void cooja_mt_remove(void); - - /** * Starts a multithreading thread. * @@ -201,51 +169,6 @@ void cooja_mt_exec(struct cooja_mt_thread *thread); */ void cooja_mt_yield(void); -/** - * Post an event to another process. - * - * This function is called by a running thread and will emit a signal - * to another Contiki process. This will cause the currently executing - * thread to yield. - * - * \param p The process receiving the signal, or PROCESS_BROADCAST - * for a broadcast event. - * - * \param ev The event to be posted. - * - * \param data A pointer to a message that is to be delivered together - * with the signal. - * - */ -/*void mt_post(struct process *p, process_event_t ev, process_data_t data);*/ - -/** - * Block and wait for an event to occur. - * - * This function can be called by a running thread in order to block - * and wait for an event. The function returns when an event has - * occured. The event number and the associated data are placed in the - * variables pointed to by the function arguments. - * - * \param ev A pointer to a process_event_t variable. The variable - * will be filled with the number event that woke the thread. - * - * \param data A pointer to a process_data_t variable. The variable - * will be filled with the data associated with the event that woke - * the thread. - * - */ -/*void mt_wait(process_event_t *ev, process_data_t *data);*/ - -/** - * Exit a thread. - * - * This function is called from within an executing thread in order to - * exit the thread. The function never returns. - * - */ -void cooja_mt_exit(void); - /** @} */ /** @} */ #endif /* MT_H_ */ diff --git a/arch/platform/cooja/sys/cooja_mtarch.c b/arch/platform/cooja/sys/cooja_mtarch.c index 8d73ad088..4a1f78360 100644 --- a/arch/platform/cooja/sys/cooja_mtarch.c +++ b/arch/platform/cooja/sys/cooja_mtarch.c @@ -72,11 +72,7 @@ struct frame { unsigned long retaddr2; unsigned long data; }; -/*--------------------------------------------------------------------------*/ -void -cooja_mtarch_init(void) -{ -} + /*--------------------------------------------------------------------------*/ void cooja_mtarch_start(struct cooja_mtarch_thread *t, @@ -187,35 +183,8 @@ cooja_mtarch_exec(struct cooja_mtarch_thread *t) } /*--------------------------------------------------------------------------*/ void -cooja_mtarch_remove(void) -{ -} -/*--------------------------------------------------------------------------*/ -void cooja_mtarch_yield(void) { cooja_sw(); } /*--------------------------------------------------------------------------*/ -void -cooja_mtarch_pstop(void) -{ -} -/*--------------------------------------------------------------------------*/ -void -cooja_mtarch_pstart(void) -{ -} -/*--------------------------------------------------------------------------*/ -int -cooja_mtarch_stack_usage(struct cooja_mt_thread *t) -{ - int i; - for(i = 0; i < COOJA_MTARCH_STACKSIZE; ++i) { - if(t->thread.stack[i] != i) { - return COOJA_MTARCH_STACKSIZE - i; - } - } - return -1; -} -/*--------------------------------------------------------------------------*/ diff --git a/arch/platform/cooja/sys/cooja_mtarch.h b/arch/platform/cooja/sys/cooja_mtarch.h index 084962e81..2a16c0ae4 100644 --- a/arch/platform/cooja/sys/cooja_mtarch.h +++ b/arch/platform/cooja/sys/cooja_mtarch.h @@ -46,7 +46,4 @@ struct cooja_mtarch_thread { struct cooja_mt_thread; -int cooja_mtarch_stack_usage(struct cooja_mt_thread *t); - #endif /* COOJA_MTARCH_H_ */ -