From dc8aa6aecafbccc12c69c3c50b66b2af220ad423 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 18 Mar 2018 13:10:21 +0000 Subject: [PATCH 1/6] Fix link layer address retrieval from flash --- arch/platform/srf06-cc26xx/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/platform/srf06-cc26xx/platform.c b/arch/platform/srf06-cc26xx/platform.c index 4d2fca2fb..b0e5794e4 100644 --- a/arch/platform/srf06-cc26xx/platform.c +++ b/arch/platform/srf06-cc26xx/platform.c @@ -108,7 +108,7 @@ set_rf_params(void) { uint8_t ext_addr[8]; -#if MAKE_MAC == MAKE_MAC_BLE +#if MAC_CONF_WITH_BLE ble_eui64_addr_cpy_to((uint8_t *)&ext_addr); NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8); #else @@ -181,7 +181,7 @@ platform_init_stage_two() #endif /* Populate linkaddr_node_addr */ -#if MAKE_MAC == MAKE_MAC_BLE +#if MAC_CONF_WITH_BLE uint8_t ext_addr[8]; ble_eui64_addr_cpy_to((uint8_t *)&ext_addr); memcpy(&linkaddr_node_addr, &ext_addr[8 - LINKADDR_SIZE], LINKADDR_SIZE); From 5364f81f5ac95be0900d09af6d4f3493db072077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Tue, 30 Jan 2018 18:59:41 +0100 Subject: [PATCH 2/6] Add Vagrant support --- tools/vagrant/.gitignore | 1 + tools/vagrant/README.md | 1 + tools/vagrant/Vagrantfile | 48 ++++++++++++++++++++++++ tools/vagrant/bootstrap.sh | 76 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 tools/vagrant/.gitignore create mode 100644 tools/vagrant/README.md create mode 100644 tools/vagrant/Vagrantfile create mode 100755 tools/vagrant/bootstrap.sh diff --git a/tools/vagrant/.gitignore b/tools/vagrant/.gitignore new file mode 100644 index 000000000..8000dd9db --- /dev/null +++ b/tools/vagrant/.gitignore @@ -0,0 +1 @@ +.vagrant diff --git a/tools/vagrant/README.md b/tools/vagrant/README.md new file mode 100644 index 000000000..e64a0314e --- /dev/null +++ b/tools/vagrant/README.md @@ -0,0 +1 @@ +Instructions can be fonud at https://github.com/contiki-ng/contiki-ng/wiki/Vagrant diff --git a/tools/vagrant/Vagrantfile b/tools/vagrant/Vagrantfile new file mode 100644 index 000000000..a4e66ab21 --- /dev/null +++ b/tools/vagrant/Vagrantfile @@ -0,0 +1,48 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.box = "ubuntu/xenial64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # NOTE: This will enable public access to the opened port + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + config.vm.synced_folder "../../", "/home/vagrant/contiki-ng" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + # vb.memory = "1024" + # end + # + # View the documentation for the provider you are using for more + # information on available options. +end diff --git a/tools/vagrant/bootstrap.sh b/tools/vagrant/bootstrap.sh new file mode 100755 index 000000000..996ffb12e --- /dev/null +++ b/tools/vagrant/bootstrap.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# i386 binary support on x64 system +sudo dpkg --add-architecture i386 +sudo apt update +sudo apt install -y --no-install-recommends \ + libc6:i386 libstdc++6:i386 libncurses5:i386 libz1:i386 + +# Tools +sudo apt-get install -y --no-install-recommends \ + build-essential doxygen git wget unzip python-serial \ + default-jdk ant srecord python-pip iputils-tracepath uncrustify python-magic +sudo apt-get clean +sudo python2 -m pip install intelhex + +# Install ARM toolchain +wget https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 +tar xjf gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 -C /tmp/ +sudo cp -f -r /tmp/gcc-arm-none-eabi-5_2-2015q4/* /usr/local/ +rm -rf /tmp/gcc-arm-none-eabi-* gcc-arm-none-eabi-*-linux.tar.bz2 + +# Install msp430 toolchain +wget http://simonduq.github.io/resources/mspgcc-4.7.2-compiled.tar.bz2 +tar xjf mspgcc*.tar.bz2 -C /tmp/ +sudo cp -f -r /tmp/msp430/* /usr/local/ +rm -rf /tmp/msp430 mspgcc*.tar.bz2 + +# Install NXP toolchain (partial, with binaries excluded. Download from nxp.com) +wget http://simonduq.github.io/resources/ba-elf-gcc-4.7.4-part1.tar.bz2 +wget http://simonduq.github.io/resources/ba-elf-gcc-4.7.4-part2.tar.bz2 +wget http://simonduq.github.io/resources/jn516x-sdk-4163-1416.tar.bz2 +mkdir -p /tmp/jn516x-sdk /tmp/ba-elf-gcc +tar xjf jn516x-sdk-*.tar.bz2 -C /tmp/jn516x-sdk +tar xjf ba-elf-gcc-*part1.tar.bz2 -C /tmp/ba-elf-gcc +tar xjf ba-elf-gcc-*part2.tar.bz2 -C /tmp/ba-elf-gcc +sudo cp -f -r /tmp/jn516x-sdk /usr/ +sudo cp -f -r /tmp/ba-elf-gcc /usr/ +rm -rf jn516x*.bz2 ba-elf-gcc*.bz2 /tmp/ba-elf-gcc* /tmp/jn516x-sdk* + +echo 'export PATH="/usr/ba-elf-gcc/bin:${PATH}"' >> ${HOME}/.bashrc + +## Install nRF52 SDK +wget https://developer.nordicsemi.com/nRF5_IoT_SDK/nRF5_IoT_SDK_v0.9.x/nrf5_iot_sdk_3288530.zip +sudo mkdir -p /usr/nrf52-sdk +sudo unzip nrf5_iot_sdk_3288530.zip -d /usr/nrf52-sdk +rm nrf5_iot_sdk_3288530.zip + +echo "export NRF52_SDK_ROOT=/usr/nrf52-sdk" >> ${HOME}/.bashrc + +sudo usermod -aG dialout vagrant + +# Environment variables +echo "export JAVA_HOME=/usr/lib/jvm/default-java" >> ${HOME}/.bashrc +echo "export CONTIKI_NG=${HOME}/contiki-ng" >> ${HOME}/.bashrc +echo "export COOJA=${CONTIKI_NG}/tools/cooja" >> ${HOME}/.bashrc +echo "export PATH=${HOME}:${PATH}" >> ${HOME}/.bashrc +echo "export WORKDIR=${HOME}" >> ${HOME}/.bashrc +source ${HOME}/.bashrc + +# Create Cooja shortcut +echo "#!/bin/bash\nant -Dbasedir=${COOJA} -f ${COOJA}/build.xml run" > ${HOME}/cooja && chmod +x ${HOME}/cooja + +# Install coap-cli +sudo apt-get install -y npm +sudo apt-get clean +sudo npm install coap-cli -g +sudo ln -s /usr/bin/nodejs /usr/bin/node + +# Docker +curl -fsSL get.docker.com -o get-docker.sh +sudo sh get-docker.sh +sudo usermod -aG docker vagrant + +# Docker image "Contiker" alias +echo 'alias contiker="docker run --privileged --mount type=bind,source=$CONTIKI_NG,destination=/home/user/contiki-ng -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev/bus/usb:/dev/bus/usb -ti simonduq/contiki-ng"' >> /home/vagrant/.bashrc +source ${HOME}/.bashrc From 850e6fefb3f24a179254217cf95eeb54bafaa29d Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 19 Mar 2018 11:51:40 -0700 Subject: [PATCH 3/6] RPL-Lite: initialize rpl-neighbor module only once, in rpl.c --- os/net/routing/rpl-lite/rpl-dag.c | 1 - 1 file changed, 1 deletion(-) diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index 5074dd482..65365ac77 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -716,7 +716,6 @@ void rpl_dag_init(void) { memset(&curr_instance, 0, sizeof(curr_instance)); - rpl_neighbor_init(); } /*---------------------------------------------------------------------------*/ /** @} */ From fc053b15b9a1c40dd0522bcf7f32d5fbbb675c08 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 19 Mar 2018 12:05:06 -0700 Subject: [PATCH 4/6] Rename nbr_table_is_register to nbr_table_is_registered --- os/net/mac/tsch/sixtop/sixp-nbr.c | 2 +- os/net/nbr-table.c | 3 +-- os/net/nbr-table.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/os/net/mac/tsch/sixtop/sixp-nbr.c b/os/net/mac/tsch/sixtop/sixp-nbr.c index 8b5d979de..d736f3668 100644 --- a/os/net/mac/tsch/sixtop/sixp-nbr.c +++ b/os/net/mac/tsch/sixtop/sixp-nbr.c @@ -186,7 +186,7 @@ int sixp_nbr_init(void) { sixp_nbr_t *nbr, *next_nbr; - if(nbr_table_is_register(sixp_nbrs) == 0) { + if(nbr_table_is_registered(sixp_nbrs) == 0) { nbr_table_register(sixp_nbrs, NULL); } else { /* remove all the existing nbrs */ diff --git a/os/net/nbr-table.c b/os/net/nbr-table.c index f86e5954e..03db7b3ab 100644 --- a/os/net/nbr-table.c +++ b/os/net/nbr-table.c @@ -303,7 +303,7 @@ nbr_table_register(nbr_table_t *table, nbr_table_callback *callback) /*---------------------------------------------------------------------------*/ /* Test whether a specified table has been registered or not */ int -nbr_table_is_register(nbr_table_t *table) +nbr_table_is_registered(nbr_table_t *table) { if(table != NULL && all_tables[table->index] == table) { return 1; @@ -490,4 +490,3 @@ handle_periodic_timer(void *ptr) ctimer_reset(&periodic_timer); } #endif - diff --git a/os/net/nbr-table.h b/os/net/nbr-table.h index 430a10a8d..d7fad5267 100644 --- a/os/net/nbr-table.h +++ b/os/net/nbr-table.h @@ -92,7 +92,7 @@ typedef enum { /** \name Neighbor tables: register and loop through table elements */ /** @{ */ int nbr_table_register(nbr_table_t *table, nbr_table_callback *callback); -int nbr_table_is_register(nbr_table_t *table); +int nbr_table_is_registered(nbr_table_t *table); nbr_table_item_t *nbr_table_head(nbr_table_t *table); nbr_table_item_t *nbr_table_next(nbr_table_t *table, nbr_table_item_t *item); /** @} */ From baa02a76f2980556a6ad30c9424867baae0ef28a Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 19 Mar 2018 12:08:02 -0700 Subject: [PATCH 5/6] nbr_table_is_registered: prevent potential buffer overflow --- os/net/nbr-table.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/os/net/nbr-table.c b/os/net/nbr-table.c index 03db7b3ab..b72c6f868 100644 --- a/os/net/nbr-table.c +++ b/os/net/nbr-table.c @@ -305,7 +305,8 @@ nbr_table_register(nbr_table_t *table, nbr_table_callback *callback) int nbr_table_is_registered(nbr_table_t *table) { - if(table != NULL && all_tables[table->index] == table) { + if(table != NULL && table->index >= 0 && table->index < MAX_NUM_TABLES + && all_tables[table->index] == table) { return 1; } return 0; From eb62a7894c7e954ecaefd9f5e4c20c5425b3483c Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 19 Mar 2018 12:09:07 -0700 Subject: [PATCH 6/6] nbr_table_register: make sure not to register a given table twice --- os/net/nbr-table.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/os/net/nbr-table.c b/os/net/nbr-table.c index b72c6f868..77d3cb07d 100644 --- a/os/net/nbr-table.c +++ b/os/net/nbr-table.c @@ -290,6 +290,13 @@ nbr_table_register(nbr_table_t *table, nbr_table_callback *callback) ctimer_set(&periodic_timer, CLOCK_SECOND * 60, handle_periodic_timer, NULL); } #endif + + if(nbr_table_is_registered(table)) { + /* Table already registered, just update callback */ + table->callback = callback; + return 1; + } + if(num_tables < MAX_NUM_TABLES) { table->index = num_tables++; table->callback = callback;