diff --git a/cpu/atmega_common/include/cpu_conf.h b/cpu/atmega_common/include/cpu_conf.h index 639c6ab751..8cb9dd8560 100644 --- a/cpu/atmega_common/include/cpu_conf.h +++ b/cpu/atmega_common/include/cpu_conf.h @@ -31,7 +31,9 @@ extern "C" { #endif +#ifndef THREAD_EXTRA_STACKSIZE_PRINTF #define THREAD_EXTRA_STACKSIZE_PRINTF (128) +#endif /** * @name Kernel configuration diff --git a/drivers/at86rf2xx/at86rf2xx_netdev.c b/drivers/at86rf2xx/at86rf2xx_netdev.c index 661243f6cb..5765c55555 100644 --- a/drivers/at86rf2xx/at86rf2xx_netdev.c +++ b/drivers/at86rf2xx/at86rf2xx_netdev.c @@ -319,8 +319,23 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info) at86rf2xx_fb_stop(dev); #endif radio_info->rssi = RSSI_BASE_VAL + ed; - DEBUG("[at86rf2xx] LQI:%d high is good, RSSI:%d high is either good or" + DEBUG("[at86rf2xx] LQI:%d high is good, RSSI:%d high is either good or " "too much interference.\n", radio_info->lqi, radio_info->rssi); +#if AT86RF2XX_IS_PERIPH && IS_USED(MODULE_NETDEV_IEEE802154_RX_TIMESTAMP) + /* AT86RF2XX_IS_PERIPH means the MCU is ATmegaRFR2 that has symbol counter */ + { + uint32_t rx_sc; + rx_sc = at86rf2xx_get_sc(dev); + + /* convert counter value to ns */ + uint64_t res = SC_TO_NS * (uint64_t)rx_sc; + netdev_ieee802154_rx_info_set_timestamp(radio_info, res); + DEBUG("[at86rf2xx] CS: %" PRIu32 " timestamp: %" PRIu32 ".%09" PRIu32 " ", + rx_sc, (uint32_t)(radio_info->timestamp / NS_PER_SEC), + (uint32_t)(radio_info->timestamp % NS_PER_SEC)); + } +#endif + } else { at86rf2xx_fb_stop(dev); diff --git a/drivers/at86rf2xx/include/at86rf2xx_internal.h b/drivers/at86rf2xx/include/at86rf2xx_internal.h index ce9da53fb8..79381cc25b 100644 --- a/drivers/at86rf2xx/include/at86rf2xx_internal.h +++ b/drivers/at86rf2xx/include/at86rf2xx_internal.h @@ -30,6 +30,8 @@ #if AT86RF2XX_IS_PERIPH #include +#include "irq.h" +#include "time_units.h" #endif #include "at86rf2xx_registers.h" @@ -293,6 +295,46 @@ static inline uint8_t at86rf2xx_get_irq_flags(at86rf2xx_t *dev) } +#if AT86RF2XX_IS_PERIPH +/* + * Read a 32 bit register as described in section 10.3 of the datasheet: A read + * of the least significant byte causes the current value to be atomically + * captured in a temporary 32 bit registers. The remaining reads will access this + * register instead. Only a single 32 bit temporary register is used to provide + * means to atomically access them. Thus, interrupts must be disabled during the + * read sequence in order to prevent other threads (or ISRs) from updating the + * temporary 32 bit register before the reading sequence has completed. + */ +static inline uint32_t reg32_read(volatile uint8_t *reg_ll) +{ + le_uint32_t reg; + unsigned state = irq_disable(); + reg.u8[0] = reg_ll[0]; + reg.u8[1] = reg_ll[1]; + reg.u8[2] = reg_ll[2]; + reg.u8[3] = reg_ll[3]; + irq_restore(state); + return reg.u32; +} + +/** + * @brief Get the timestamp of the packet in symbol counter ticks + * + * @param[in] dev pointer to the device descriptor + * + * @return the symbol counter value + */ +static inline uint32_t at86rf2xx_get_sc(const at86rf2xx_t *dev) +{ + (void) dev; + return reg32_read(&SCCNTLL); +} + +/* Symbol counter frequency is 62500Hz. One symbol counter tick is 16us = 16000 ns*/ +#define SC_TO_NS (16000LU) + +#endif + #ifdef __cplusplus } #endif diff --git a/pkg/tensorflow-lite/Makefile b/pkg/tensorflow-lite/Makefile deleted file mode 100644 index ad0f220692..0000000000 --- a/pkg/tensorflow-lite/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -PKG_NAME=tensorflow-lite -PKG_URL=https://github.com/tensorflow/tensorflow -# 2.2.2 -PKG_VERSION=d745ff2a48cebf18e847e8b602a744e97e058946 -PKG_LICENSE=Apache2.0 - -include $(RIOTBASE)/pkg/pkg.mk - -TF_MODULES = tensorflow-lite-hello_world -TF_USEMODULE = $(filter $(TF_MODULES),$(USEMODULE)) - -.PHONY: tensorflow-lite tensorflow-lite-% - -CFLAGS += -Wno-pedantic -CFLAGS += -Wno-cast-align -CXXEXFLAGS += -Wno-maybe-uninitialized -CFLAGS += -DTF_LITE_STATIC_MEMORY -CFLAGS += -DTF_LITE_USE_GLOBAL_ROUND - -all: tensorflow-lite - -tensorflow-lite: $(TF_USEMODULE) - $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/tensorflow/lite/c -f $(CURDIR)/Makefile.$(PKG_NAME)-c - $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/tensorflow/lite/core/api -f $(CURDIR)/Makefile.$(PKG_NAME)-core - $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/tensorflow/lite/kernels -f $(CURDIR)/Makefile.$(PKG_NAME)-kernels - $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/tensorflow/lite/kernels/internal -f $(CURDIR)/Makefile.$(PKG_NAME)-kernels-internal - $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/tensorflow/lite/micro/kernels -f $(CURDIR)/Makefile.$(PKG_NAME)-micro-kernels - $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/tensorflow/lite/micro/memory_planner -f $(CURDIR)/Makefile.$(PKG_NAME)-memory - $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/tensorflow/lite/micro -f $(CURDIR)/Makefile.$(PKG_NAME) - -tensorflow-lite-%: - $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/tensorflow/lite/micro/examples/$* -f $(CURDIR)/Makefile.$(PKG_NAME)-$* diff --git a/pkg/tensorflow-lite/Makefile.dep b/pkg/tensorflow-lite/Makefile.dep deleted file mode 100644 index d0b0743284..0000000000 --- a/pkg/tensorflow-lite/Makefile.dep +++ /dev/null @@ -1,15 +0,0 @@ -USEMODULE += cpp11-compat - -USEPKG += flatbuffers -USEPKG += gemmlowp - -USEMODULE += tensorflow-lite -USEMODULE += tensorflow-lite-c -USEMODULE += tensorflow-lite-core -USEMODULE += tensorflow-lite-kernels -USEMODULE += tensorflow-lite-kernels-internal -USEMODULE += tensorflow-lite-memory -USEMODULE += tensorflow-lite-micro-kernels - -# Tensorflow Lite doesn't build on riscv because of missing math functions -FEATURES_BLACKLIST += arch_riscv diff --git a/pkg/tensorflow-lite/Makefile.include b/pkg/tensorflow-lite/Makefile.include deleted file mode 100644 index ae3f8bde6f..0000000000 --- a/pkg/tensorflow-lite/Makefile.include +++ /dev/null @@ -1,6 +0,0 @@ -INCLUDES += -I$(PKGDIRBASE)/tensorflow-lite - -ifneq (,$(filter cortex-m%,$(CPU_CORE))) - # LLVM/clang triggers a hard fault on Cortex-M - TOOLCHAINS_BLACKLIST += llvm -endif diff --git a/pkg/tensorflow-lite/Makefile.tensorflow-lite b/pkg/tensorflow-lite/Makefile.tensorflow-lite deleted file mode 100644 index 2840f1c005..0000000000 --- a/pkg/tensorflow-lite/Makefile.tensorflow-lite +++ /dev/null @@ -1,12 +0,0 @@ -MODULE = tensorflow-lite - -CXXEXFLAGS += -Wno-sign-compare -CXXEXFLAGS += -Wno-strict-aliasing -CXXEXFLAGS += -Wno-type-limits -CXXEXFLAGS += -Wno-unused-parameter -CXXEXFLAGS += -Wno-unused-variable - -SRCXXEXT = cc -SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT)) - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/tensorflow-lite/Makefile.tensorflow-lite-c b/pkg/tensorflow-lite/Makefile.tensorflow-lite-c deleted file mode 100644 index de5fe0583d..0000000000 --- a/pkg/tensorflow-lite/Makefile.tensorflow-lite-c +++ /dev/null @@ -1,9 +0,0 @@ -MODULE = tensorflow-lite-c - -CFLAGS += -Wno-strict-prototypes -CFLAGS += -Wno-old-style-definition - -NO_AUTO_SRC = 1 -SRC = common.c - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/tensorflow-lite/Makefile.tensorflow-lite-core b/pkg/tensorflow-lite/Makefile.tensorflow-lite-core deleted file mode 100644 index dba57992d3..0000000000 --- a/pkg/tensorflow-lite/Makefile.tensorflow-lite-core +++ /dev/null @@ -1,17 +0,0 @@ -MODULE = tensorflow-lite-core - -CXXEXFLAGS += -Wno-sign-compare -CXXEXFLAGS += -Wno-type-limits - -SRCXXEXT = cc -SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT)) - -NO_AUTO_SRC = 1 -SRCXX = \ - error_reporter.cc \ - flatbuffer_conversions.cc \ - op_resolver.cc \ - tensor_utils.cc \ - # - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/tensorflow-lite/Makefile.tensorflow-lite-hello_world b/pkg/tensorflow-lite/Makefile.tensorflow-lite-hello_world deleted file mode 100644 index 64ff48df87..0000000000 --- a/pkg/tensorflow-lite/Makefile.tensorflow-lite-hello_world +++ /dev/null @@ -1,17 +0,0 @@ -MODULE = tensorflow-lite-hello_world - -CXXEXFLAGS += -Wno-type-limits -CXXEXFLAGS += -Wno-unused-parameter - -SRCXXEXT = cc -SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT)) - -NO_AUTO_SRC = 1 -SRCXX = \ - constants.cc \ - main_functions.cc \ - output_handler.cc \ - sine_model_data.cc \ - # - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/tensorflow-lite/Makefile.tensorflow-lite-kernels b/pkg/tensorflow-lite/Makefile.tensorflow-lite-kernels deleted file mode 100644 index 23232bb345..0000000000 --- a/pkg/tensorflow-lite/Makefile.tensorflow-lite-kernels +++ /dev/null @@ -1,11 +0,0 @@ -MODULE = tensorflow-lite-kernels - -CXXEXFLAGS += -Wno-unused-function -CXXEXFLAGS += -Wno-unused-parameter - -SRCXXEXT = cc - -NO_AUTO_SRC = 1 -SRCXX = kernel_util.cc - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/tensorflow-lite/Makefile.tensorflow-lite-kernels-internal b/pkg/tensorflow-lite/Makefile.tensorflow-lite-kernels-internal deleted file mode 100644 index c9be42028d..0000000000 --- a/pkg/tensorflow-lite/Makefile.tensorflow-lite-kernels-internal +++ /dev/null @@ -1,11 +0,0 @@ -MODULE = tensorflow-lite-kernels-internal - -CXXEXFLAGS += -Wno-unused-function -CXXEXFLAGS += -Wno-unused-parameter - -SRCXXEXT = cc - -NO_AUTO_SRC = 1 -SRCXX = quantization_util.cc - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/tensorflow-lite/Makefile.tensorflow-lite-memory b/pkg/tensorflow-lite/Makefile.tensorflow-lite-memory deleted file mode 100644 index e454378167..0000000000 --- a/pkg/tensorflow-lite/Makefile.tensorflow-lite-memory +++ /dev/null @@ -1,9 +0,0 @@ -MODULE = tensorflow-lite-memory - -CXXEXFLAGS += -Wno-sign-compare -CXXEXFLAGS += -Wno-unused-parameter - -SRCXXEXT = cc -SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT)) - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/tensorflow-lite/Makefile.tensorflow-lite-micro-kernels b/pkg/tensorflow-lite/Makefile.tensorflow-lite-micro-kernels deleted file mode 100644 index ca5ea912e2..0000000000 --- a/pkg/tensorflow-lite/Makefile.tensorflow-lite-micro-kernels +++ /dev/null @@ -1,14 +0,0 @@ -MODULE = tensorflow-lite-micro-kernels - -CXXEXFLAGS += -Wno-strict-overflow -CXXEXFLAGS += -Wno-type-limits -CXXEXFLAGS += -Wno-unused-parameter - -ifeq (llvm,$(TOOLCHAIN)) - CXXEXFLAGS += -Wno-unused-const-variable -endif - -SRCXXEXT = cc -SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT)) - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/tensorflow-lite/doc.txt b/pkg/tensorflow-lite/doc.txt deleted file mode 100644 index 01b521a8b1..0000000000 --- a/pkg/tensorflow-lite/doc.txt +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @defgroup pkg_tensorflow-lite TensorFlow Lite - * @ingroup pkg - * @brief Provides a RIOT support for TensorFlow Lite AI library - * - * @deprecated Use @ref pkg_tflite-micro instead. Tensorflow-lite package is outdated - * and will be removed after 2022.07 release. - * - * @see https://www.tensorflow.org/lite/microcontrollers - */ diff --git a/pkg/tensorflow-lite/patches/0001-global-round.patch b/pkg/tensorflow-lite/patches/0001-global-round.patch deleted file mode 100644 index fa7f758816..0000000000 Binary files a/pkg/tensorflow-lite/patches/0001-global-round.patch and /dev/null differ diff --git a/sys/include/hashes/cmac.h b/sys/include/hashes/cmac.h deleted file mode 100644 index fbae5634f2..0000000000 --- a/sys/include/hashes/cmac.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2016 Fundación Inria Chile - * Copyright (C) 2022 Freie Universität Berlin - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @defgroup sys_hashes_cmac AES_CMAC - * @ingroup sys_hashes_keyed - * @brief Implementation of the AES CMAC hashing function - * @deprecated Will be removed after the 2023.01 release. Please use - * @ref sys_hashes_aes128_cmac instead. - - * @{ - * - * @file - * @brief AES_CMAC interface definition - * - * @author José Ignacio Alamos - * @author Martine S. Lenders - */ - -#ifndef HASHES_CMAC_H -#define HASHES_CMAC_H - -#include "hashes/aes128_cmac.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Length of AES_CMAC block in bytes - */ -#define CMAC_BLOCK_SIZE AES128_CMAC_BLOCK_SIZE - -/** - * @brief CMAC calculation context - */ -typedef aes128_cmac_context_t cmac_context_t; - -/** - * @brief Initialize CMAC message digest context - * - * @param[in] ctx Pointer to the CMAC context to initialize - * @param[in] key Key to be set - * @param[in] key_size Size of the key - * - * @return CIPHER_INIT_SUCCESS if the initialization was successful. - * CIPHER_ERR_INVALID_KEY_SIZE if the key size is not valid. - */ -static inline int cmac_init(cmac_context_t *ctx, - const uint8_t *key, uint8_t key_size) -{ - return aes128_cmac_init(ctx, key, key_size); -} - -/** - * @brief Update the CMAC context with a portion of the message being hashed - * - * @param[in] ctx Pointer to the CMAC context to update - * @param[in] data Input data - * @param[in] len Length of @p data - */ -static inline void cmac_update(cmac_context_t *ctx, - const void *data, size_t len) -{ - aes128_cmac_update(ctx, data, len); -} - -/** - * @brief Finalizes the CMAC message digest - * - * @param[in] ctx Pointer to the CMAC context - * @param[out] digest Result location - */ -static inline void cmac_final(cmac_context_t *ctx, void *digest) -{ - aes128_cmac_final(ctx, digest); -} - -#ifdef __cplusplus -} -#endif - -#endif /* HASHES_CMAC_H */ -/** @} */ diff --git a/sys/include/net/gnrc/netif/hdr.h b/sys/include/net/gnrc/netif/hdr.h index cb6489bf8f..bb13715ab6 100644 --- a/sys/include/net/gnrc/netif/hdr.h +++ b/sys/include/net/gnrc/netif/hdr.h @@ -29,6 +29,7 @@ #include "net/gnrc/pkt.h" #include "net/gnrc/pktbuf.h" #include "net/gnrc/netif.h" +#include "time_units.h" #ifdef __cplusplus extern "C" { diff --git a/sys/net/gnrc/netif/hdr/gnrc_netif_hdr_print.c b/sys/net/gnrc/netif/hdr/gnrc_netif_hdr_print.c index 64c72bff8b..1f254d3d4b 100644 --- a/sys/net/gnrc/netif/hdr/gnrc_netif_hdr_print.c +++ b/sys/net/gnrc/netif/hdr/gnrc_netif_hdr_print.c @@ -36,10 +36,14 @@ void gnrc_netif_hdr_print(gnrc_netif_hdr_t *hdr) if (hdr->flags & GNRC_NETIF_HDR_FLAGS_BROADCAST) { printf("BROADCAST "); } - if (hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST) { printf("MULTICAST "); } +#if IS_USED(MODULE_GNRC_NETIF_TIMESTAMP) + if (hdr->flags & GNRC_NETIF_HDR_FLAGS_TIMESTAMP) { + printf("TIMESTAMP "); + } +#endif puts(""); } else { diff --git a/tests/net/gnrc_netif_ieee802154/Makefile b/tests/net/gnrc_netif_ieee802154/Makefile index 1e48d6a9a7..6e8e0f3226 100644 --- a/tests/net/gnrc_netif_ieee802154/Makefile +++ b/tests/net/gnrc_netif_ieee802154/Makefile @@ -1,19 +1,34 @@ -BOARD_WHITELIST = native +BOARD_WHITELIST = native derfmega256 avr-rss2 atmega256rfr2-xpro nrf52840dongle include ../Makefile.net_common -TERMFLAGS ?= -z "0.0.0.0:17755,localhost:17754" +ifeq (native, $(BOARD)) + USEMODULE += socket_zep + TERMFLAGS ?= -z "0.0.0.0:17755,localhost:17754" + USEMODULE += netdev + # somehow this breaks the test + DISABLE_MODULE += test_utils_print_stack_usage +else + USEMODULE += shell + USEMODULE += shell_cmds_default + USEMODULE += ps + # use the default network interface for the board + USEMODULE += netdev_default + # shell command to send L2 packets with a simple string + USEMODULE += gnrc_txtsnd + # module to test rx timestamp + USEMODULE += gnrc_netif_timestamp +endif -USEMODULE += socket_zep -USEMODULE += auto_init_gnrc_netif -USEMODULE += netdev +# gnrc is a meta module including all required, basic gnrc networking modules USEMODULE += gnrc +# automatically initialize the network interface +USEMODULE += auto_init_gnrc_netif +# use GNRC IEEE 802.15.4 as link-layer protocol USEMODULE += gnrc_netif_ieee802154 +# the application dumps received packets to stdout USEMODULE += gnrc_pktdump -# somehow this breaks the test -DISABLE_MODULE += test_utils_print_stack_usage - TEST_ON_CI_WHITELIST += native include $(RIOTBASE)/Makefile.include diff --git a/tests/net/gnrc_netif_ieee802154/main.c b/tests/net/gnrc_netif_ieee802154/main.c index 957d01fb5f..c9f216bbb0 100644 --- a/tests/net/gnrc_netif_ieee802154/main.c +++ b/tests/net/gnrc_netif_ieee802154/main.c @@ -17,20 +17,36 @@ #include "net/gnrc/netif.h" #include "net/gnrc/pktdump.h" +#if IS_USED(MODULE_SHELL) +#include +#include + +#include "thread.h" +#include "shell.h" +#endif + int main(void) { +#if IS_USED(MODULE_SOCKET_ZEP) + /* This is a test for native with socket_zep */ char addr_str[GNRC_NETIF_L2ADDR_MAXLEN * 3]; gnrc_netif_t *netif = gnrc_netif_iter(NULL); printf("l2_addr: %s\n", gnrc_netif_addr_to_str(netif->l2addr, netif->l2addr_len, addr_str)); - +#endif gnrc_netreg_entry_t dump = GNRC_NETREG_ENTRY_INIT_PID( GNRC_NETREG_DEMUX_CTX_ALL, gnrc_pktdump_pid ); gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump); + +#if IS_USED(MODULE_SHELL) + /* this is manual test for real MCU using shell module */ + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); +#endif return 0; }