From cc58384b40355bcadd8e1d2e8e65f9da92ebc7b8 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 4 Dec 2015 10:15:22 +0100 Subject: [PATCH] jn516x: remove temporary adjustements for compilation in a 802.15.4e-free Contiki --- core/net/mac/tsch/tsch-slot-operation.c | 5 +- core/net/mac/tsch/tsch.c | 5 + platform/jn516x/Makefile.jn516x | 4 +- platform/jn516x/contiki-conf.h | 4 + platform/jn516x/dev/micromac-radio.c | 66 -------- platform/jn516x/lib/ringbufindex.c | 149 ------------------ platform/jn516x/lib/ringbufindex.h | 72 --------- .../22-compile-nxp-ports/Makefile | 1 + 8 files changed, 14 insertions(+), 292 deletions(-) delete mode 100644 platform/jn516x/lib/ringbufindex.c delete mode 100644 platform/jn516x/lib/ringbufindex.h diff --git a/core/net/mac/tsch/tsch-slot-operation.c b/core/net/mac/tsch/tsch-slot-operation.c index 3607ba2fb..3174787c2 100644 --- a/core/net/mac/tsch/tsch-slot-operation.c +++ b/core/net/mac/tsch/tsch-slot-operation.c @@ -808,9 +808,8 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t)) } else { TSCH_LOG_ADD(tsch_log_message, snprintf(log->message, sizeof(log->message), - "!not for us %x:%x:%x:%x", - destination_address.u8[4], destination_address.u8[5], - destination_address.u8[6], destination_address.u8[7]); + "!not for us %x:%x", + destination_address.u8[LINKADDR_SIZE - 2], destination_address.u8[LINKADDR_SIZE - 1]); ); } diff --git a/core/net/mac/tsch/tsch.c b/core/net/mac/tsch/tsch.c index 5aadf09af..1d9701e42 100644 --- a/core/net/mac/tsch/tsch.c +++ b/core/net/mac/tsch/tsch.c @@ -122,10 +122,15 @@ static const uint16_t tsch_default_timing_us[tsch_ts_elements_count] = { /* TSCH timeslot timing (in rtimer ticks) */ rtimer_clock_t tsch_timing[tsch_ts_elements_count]; +#if LINKADDR_SIZE == 8 /* 802.15.4 broadcast MAC address */ const linkaddr_t tsch_broadcast_address = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; /* Address used for the EB virtual neighbor queue */ const linkaddr_t tsch_eb_address = { { 0, 0, 0, 0, 0, 0, 0, 0 } }; +#else /* LINKADDR_SIZE == 8 */ +const linkaddr_t tsch_broadcast_address = { { 0xff, 0xff } }; +const linkaddr_t tsch_eb_address = { { 0, 0 } }; +#endif /* LINKADDR_SIZE == 8 */ /* Is TSCH started? */ int tsch_is_started = 0; diff --git a/platform/jn516x/Makefile.jn516x b/platform/jn516x/Makefile.jn516x index c7d0353d5..412a1cbd4 100644 --- a/platform/jn516x/Makefile.jn516x +++ b/platform/jn516x/Makefile.jn516x @@ -82,7 +82,7 @@ OBJDUMP:=$(CROSS_COMPILE)-objdump ARCH = 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 log.c ringbufindex.c slip.c sprintf.c + mtarch.c node-id.c watchdog.c log.c slip.c sprintf.c # Default uart0 for printf and slip TARGET_WITH_UART0 ?= 1 TARGET_WITH_UART1 ?= 0 @@ -145,7 +145,7 @@ CLEAN += *.jn516x.bin MODULES += core/net \ core/net/mac \ - core/net/mac/contikimac \ + core/net/mac/contikimac core/net/mac/tsch \ core/net/llsec core/net/llsec/noncoresec CONTIKI_TARGET_SOURCEFILES += $(ARCH) diff --git a/platform/jn516x/contiki-conf.h b/platform/jn516x/contiki-conf.h index 41135c187..a1e74b251 100644 --- a/platform/jn516x/contiki-conf.h +++ b/platform/jn516x/contiki-conf.h @@ -59,6 +59,10 @@ #define NETSTACK_CONF_FRAMER framer_802154 #endif /* NETSTACK_CONF_FRAMER */ +/* IEEE802.15.4 frame version */ +#undef FRAME802154_CONF_VERSION +#define FRAME802154_CONF_VERSION FRAME802154_IEEE802154E_2012 + #define PACKETBUF_CONF_ATTRS_INLINE 1 #ifndef IEEE802154_CONF_PANID diff --git a/platform/jn516x/dev/micromac-radio.c b/platform/jn516x/dev/micromac-radio.c index 556019e5c..e2d087aa2 100644 --- a/platform/jn516x/dev/micromac-radio.c +++ b/platform/jn516x/dev/micromac-radio.c @@ -206,72 +206,6 @@ PROCESS(micromac_radio_process, "micromac_radio_driver"); #define RADIO_RX_MODE_POLL_MODE (1 << 2) #endif /* RADIO_RX_MODE_POLL_MODE */ -#ifndef FRAME802154_IEEE802154E_2012 -/* We define here the missing few features this driver needs from IEEE802.15.4e */ -#define FRAME802154_IEEE802154E_2012 (0x02) -/*----------------------------------------------------------------------------*/ -uint16_t -frame802154_get_pan_id() -{ - return IEEE802154_PANID; -} -/*----------------------------------------------------------------------------*/ -static void -frame802154_has_panid(frame802154_fcf_t *fcf, int *has_src_pan_id, int *has_dest_pan_id) -{ - int src_pan_id = 0; - int dest_pan_id = 0; - - if(fcf == NULL) { - return; - } - if(fcf->frame_version == FRAME802154_IEEE802154E_2012) { - if(!fcf->panid_compression) { - /* Compressed PAN ID == no PAN ID at all */ - if(fcf->dest_addr_mode == fcf->dest_addr_mode) { - /* No address or both addresses: include destination PAN ID */ - dest_pan_id = 1; - } else if(fcf->dest_addr_mode) { - /* Only dest address, include dest PAN ID */ - dest_pan_id = 1; - } else if(fcf->src_addr_mode) { - /* Only src address, include src PAN ID */ - src_pan_id = 1; - } - } - if(fcf->dest_addr_mode == 0 && fcf->dest_addr_mode == 1) { - /* No address included, include dest PAN ID conditionally */ - if(!fcf->panid_compression) { - dest_pan_id = 1; - /* Remove the following rule the day rows 2 and 3 from table 2a are fixed: */ - } - } - if(fcf->dest_addr_mode == 0 && fcf->dest_addr_mode == 0) { - /* Not meaningful, we include a PAN ID iff the compress flag is set, but - * this is what the standard currently stipulates */ - dest_pan_id = fcf->panid_compression; - } - } else - /* No PAN ID in ACK */ - if(fcf->frame_type != FRAME802154_ACKFRAME) { - if(!fcf->panid_compression && fcf->src_addr_mode & 3) { - /* If compressed, don't inclue source PAN ID */ - src_pan_id = 1; - } - if(fcf->dest_addr_mode & 3) { - dest_pan_id = 1; - } - } - - if(has_src_pan_id != NULL) { - *has_src_pan_id = src_pan_id; - } - if(has_dest_pan_id != NULL) { - *has_dest_pan_id = dest_pan_id; - } -} -#endif /* FRAME802154_IEEE802154E_2012 */ - /*---------------------------------------------------------------------------*/ static rtimer_clock_t get_packet_timestamp(void) diff --git a/platform/jn516x/lib/ringbufindex.c b/platform/jn516x/lib/ringbufindex.c deleted file mode 100644 index 0b2149ff7..000000000 --- a/platform/jn516x/lib/ringbufindex.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2015, SICS Swedish ICT. - * 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. - * - */ - -/** - * \file - * ringbufindex library. Implements basic support for ring buffers - * of any type, as opposed to the core/lib/ringbuf module which - * is only for byte arrays. Simply returns index in the ringbuf - * rather than actual elements. The ringbuf size must be power of two. - * Like the original ringbuf, this module implements atomic put and get. - * \author - * Simon Duquennoy - * based on Contiki's core/lib/ringbuf library by Adam Dunkels - */ - -#include -#include "lib/ringbufindex.h" - -/* Initialize a ring buffer. The size must be a power of two */ -void -ringbufindex_init(struct ringbufindex *r, uint8_t size) -{ - r->mask = size - 1; - r->put_ptr = 0; - r->get_ptr = 0; -} -/* Put one element to the ring buffer */ -int -ringbufindex_put(struct ringbufindex *r) -{ - /* Check if buffer is full. If it is full, return 0 to indicate that - the element was not inserted. - - XXX: there is a potential risk for a race condition here, because - the ->get_ptr field may be written concurrently by the - ringbufindex_get() function. To avoid this, access to ->get_ptr must - be atomic. We use an uint8_t type, which makes access atomic on - most platforms, but C does not guarantee this. - */ - if(((r->put_ptr - r->get_ptr) & r->mask) == r->mask) { - return 0; - } - r->put_ptr = (r->put_ptr + 1) & r->mask; - return 1; -} -/* Check if there is space to put an element. - * Return the index where the next element is to be added */ -int -ringbufindex_peek_put(const struct ringbufindex *r) -{ - /* Check if there are bytes in the buffer. If so, we return the - first one. If there are no bytes left, we return -1. - */ - if(((r->put_ptr - r->get_ptr) & r->mask) == r->mask) { - return -1; - } - return (r->put_ptr + 1) & r->mask; -} -/* Remove the first element and return its index */ -int -ringbufindex_get(struct ringbufindex *r) -{ - int get_ptr; - - /* Check if there are bytes in the buffer. If so, we return the - first one and increase the pointer. If there are no bytes left, we - return -1. - - XXX: there is a potential risk for a race condition here, because - the ->put_ptr field may be written concurrently by the - ringbufindex_put() function. To avoid this, access to ->get_ptr must - be atomic. We use an uint8_t type, which makes access atomic on - most platforms, but C does not guarantee this. - */ - if(((r->put_ptr - r->get_ptr) & r->mask) > 0) { - get_ptr = r->get_ptr; - r->get_ptr = (r->get_ptr + 1) & r->mask; - return get_ptr; - } else { - return -1; - } -} -/* Return the index of the first element - * (which will be removed if calling ringbufindex_peek) */ -int -ringbufindex_peek_get(const struct ringbufindex *r) -{ - /* Check if there are bytes in the buffer. If so, we return the - first one. If there are no bytes left, we return -1. - */ - if(((r->put_ptr - r->get_ptr) & r->mask) > 0) { - return (r->get_ptr + 1) & r->mask; - } else { - return -1; - } -} -/* Return the ring buffer size */ -int -ringbufindex_size(const struct ringbufindex *r) -{ - return r->mask + 1; -} -/* Return the number of elements currently in the ring buffer */ -int -ringbufindex_elements(const struct ringbufindex *r) -{ - return (r->put_ptr - r->get_ptr) & r->mask; -} -/* Is the ring buffer full? */ -int -ringbufindex_full(const struct ringbufindex *r) -{ - return ((r->put_ptr - r->get_ptr) & r->mask) == r->mask; -} -/* Is the ring buffer empty? */ -int -ringbufindex_empty(const struct ringbufindex *r) -{ - return ringbufindex_elements(r) == 0; -} diff --git a/platform/jn516x/lib/ringbufindex.h b/platform/jn516x/lib/ringbufindex.h deleted file mode 100644 index c39f99d18..000000000 --- a/platform/jn516x/lib/ringbufindex.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2015, SICS Swedish ICT. - * 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. - * - */ - -/** - * \file - * Header file for the ringbufindex library - * \author - * Simon Duquennoy - */ - -#ifndef __RINGBUFINDEX_H__ -#define __RINGBUFINDEX_H__ - -#include "contiki-conf.h" - -struct ringbufindex { - uint8_t mask; - /* These must be 8-bit quantities to avoid race conditions. */ - uint8_t put_ptr, get_ptr; -}; - -/* Initialize a ring buffer. The size must be a power of two */ -void ringbufindex_init(struct ringbufindex *r, uint8_t size); -/* Put one element to the ring buffer */ -int ringbufindex_put(struct ringbufindex *r); -/* Check if there is space to put an element. - * Return the index where the next element is to be added */ -int ringbufindex_peek_put(const struct ringbufindex *r); -/* Remove the first element and return its index */ -int ringbufindex_get(struct ringbufindex *r); -/* Return the index of the first element - * (which will be removed if calling ringbufindex_peek) */ -int ringbufindex_peek_get(const struct ringbufindex *r); -/* Return the ring buffer size */ -int ringbufindex_size(const struct ringbufindex *r); -/* Return the number of elements currently in the ring buffer */ -int ringbufindex_elements(const struct ringbufindex *r); -/* Is the ring buffer full? */ -int ringbufindex_full(const struct ringbufindex *r); -/* Is the ring buffer empty? */ -int ringbufindex_empty(const struct ringbufindex *r); - -#endif /* __RINGBUFINDEX_H__ */ diff --git a/regression-tests/22-compile-nxp-ports/Makefile b/regression-tests/22-compile-nxp-ports/Makefile index 681df7ca7..b2c529d28 100644 --- a/regression-tests/22-compile-nxp-ports/Makefile +++ b/regression-tests/22-compile-nxp-ports/Makefile @@ -3,6 +3,7 @@ TOOLSDIR=../../tools # build jn516x examples, covering IPv6, RPL, CoAP, Rime, Nullrdc, Contikimac EXAMPLES = \ +hello-world/jn516x \ jn516x/dr1175-sensors/jn516x \ jn516x/rime/jn516x \ jn516x/rpl/border-router/jn516x \