From accbfbd0d148a382b6ac68bc2aa2c320db113503 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 26 Sep 2019 08:10:13 +0200 Subject: [PATCH 01/17] tools/bossa: add and configure preflash-delay when required --- makefiles/tools/bossa.inc.mk | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/makefiles/tools/bossa.inc.mk b/makefiles/tools/bossa.inc.mk index 66974215b644..bec1a77a9e95 100644 --- a/makefiles/tools/bossa.inc.mk +++ b/makefiles/tools/bossa.inc.mk @@ -14,10 +14,19 @@ ifneq (,$(BOSSA_ARDUINO_PREFLASH)) PREFLASHER ?= stty PREFFLAGS ?= $(STTY_FLAG) $(PROG_DEV) raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255 - FLASHDEPS += preflash + ifneq (,$(PREFLASH_DELAY)) + FLASHDEPS += preflash-delay + else + FLASHDEPS += preflash + endif + RESETFFLASG ?= $(STTY_FLAG) $(PORT) raw ispeed 600 ospeed 600 cs8 -cstopb ignpar eol 255 eof 255 + RESET ?= $(PREFLASHER) $(RESETFFLASG) endif +preflash-delay: preflash + sleep $(PREFLASH_DELAY) + # if we go with the default (BOSSA shipped with RIOT), we download and build # the tool if not already done ifeq ($(RIOTTOOLS)/bossa-$(BOSSA_VERSION)/bossac,$(FLASHER)) From 643187c1e46ad3e42bc7c88462b127b6f8c681bb Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 12 Feb 2020 15:16:10 +0100 Subject: [PATCH 02/17] sys: add usb_board_reset module --- sys/include/usb_board_reset.h | 56 +++++++++++++++++++++++ sys/usb_board_reset/Makefile | 1 + sys/usb_board_reset/usb_board_reset.c | 66 +++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 sys/include/usb_board_reset.h create mode 100644 sys/usb_board_reset/Makefile create mode 100644 sys/usb_board_reset/usb_board_reset.c diff --git a/sys/include/usb_board_reset.h b/sys/include/usb_board_reset.h new file mode 100644 index 000000000000..8aa6c655de82 --- /dev/null +++ b/sys/include/usb_board_reset.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2020 Inria + * + * 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_usb_board_reset Board reset via USB CDC ACM + * @ingroup sys + * @brief Trigger a board reset via USB CDC ACM + * + * @{ + * + * @file + * @author Alexandre Abadie + */ + +#ifndef USB_BOARD_RESET_H +#define USB_BOARD_RESET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "usb/usbus/cdc/acm.h" + +/** + * @brief USB coding callback used to trigger the board reset + * + * @param[in] cdcacm Pointer to the cdcacm device + * @param[in] baud Baudrate used by the client. Only 1200 baud is taken into account + * @param[in] bits Number of bit mode used by the client + * @param[in] parity Parity mode used by the client + * @param[in] stop Stop bit mode used by the client + * + * @return Always return 0 + */ +int usb_board_reset_coding_cb(usbus_cdcacm_device_t *cdcacm, + uint32_t baud, uint8_t bits, + uint8_t parity, uint8_t stop); + +/** + * @brief Trigger a simple reset, back to the application + */ +void usb_board_reset_in_application(void); + +#ifdef __cplusplus +} +#endif + +#endif /* USB_BOARD_RESET_H */ +/** @} */ diff --git a/sys/usb_board_reset/Makefile b/sys/usb_board_reset/Makefile new file mode 100644 index 000000000000..48422e909a47 --- /dev/null +++ b/sys/usb_board_reset/Makefile @@ -0,0 +1 @@ +include $(RIOTBASE)/Makefile.base diff --git a/sys/usb_board_reset/usb_board_reset.c b/sys/usb_board_reset/usb_board_reset.c new file mode 100644 index 000000000000..04aa426d3d59 --- /dev/null +++ b/sys/usb_board_reset/usb_board_reset.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2020 Inria + * + * 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. + */ + +/** + * @ingroup sys + * @{ + * @file + * + * @author Alexandre Abadie + * @} + */ + +#define USB_H_USER_IS_RIOT_INTERNAL + +#include "log.h" + +#include "usb/usbus/cdc/acm.h" +#include "usb_board_reset.h" + +#include "periph/pm.h" + +#ifndef RESET_IN_BOOTLOADER_TRIGGER_BAUDRATE +#define RESET_IN_BOOTLOADER_TRIGGER_BAUDRATE (1200U) +#endif + +#ifndef RESET_IN_APPLICATION_TRIGGER_BAUDRATE +#define RESET_IN_APPLICATION_TRIGGER_BAUDRATE (600U) +#endif + +void usb_board_reset_in_bootloader(void); + +int usb_board_reset_coding_cb(usbus_cdcacm_device_t *cdcacm, + uint32_t baud, uint8_t bits, + uint8_t parity, uint8_t stop) +{ + (void)cdcacm; + (void)bits; + (void)parity; + (void)stop; + switch (baud) { + case RESET_IN_BOOTLOADER_TRIGGER_BAUDRATE: + LOG_DEBUG("[cdc-acm-stdio] reset in bootloader"); + usb_board_reset_in_bootloader(); + break; + case RESET_IN_APPLICATION_TRIGGER_BAUDRATE: + LOG_DEBUG("[cdc-acm-stdio] reset in application"); + usb_board_reset_in_application(); + break; + default: + (void)baud; + break; + } + + return 0; +} + +void usb_board_reset_in_application(void) +{ + pm_reboot(); + while (1) {} +} From 95bf34ee9cb3fa9a787867cd2afd396b4b5144a6 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 20 Sep 2019 08:21:31 +0200 Subject: [PATCH 03/17] makefiles: sys/cdc-acm-stdio: provide a reset in bootloader hook --- sys/usb/usbus/cdc/acm/cdc_acm_stdio.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c b/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c index f6b192e2a3c0..a14dc1a07367 100644 --- a/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c +++ b/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c @@ -23,6 +23,7 @@ #include +#include "log.h" #include "isrpipe.h" #include "usb/usbus.h" @@ -32,6 +33,10 @@ #include "vfs.h" #endif +#ifdef MODULE_USB_BOARD_RESET +#include "usb_board_reset.h" +#endif + static usbus_cdcacm_device_t cdcacm; static uint8_t _cdc_tx_buf_mem[USBUS_CDC_ACM_STDIO_BUF_SIZE]; static uint8_t _cdc_rx_buf_mem[USBUS_CDC_ACM_STDIO_BUF_SIZE]; @@ -78,4 +83,7 @@ void usb_cdc_acm_stdio_init(usbus_t *usbus) { usbus_cdc_acm_init(usbus, &cdcacm, _cdc_acm_rx_pipe, NULL, _cdc_tx_buf_mem, sizeof(_cdc_tx_buf_mem)); +#ifdef MODULE_USB_BOARD_RESET + usbus_cdc_acm_set_coding_cb(&cdcacm, usb_board_reset_coding_cb); +#endif } From c7f6d53773c4fcb0265a8d06020102ba276efba2 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 30 Sep 2019 17:16:00 +0200 Subject: [PATCH 04/17] boards/samd21-arduino-bootloader: add common board module This module implements the 2 functions called when requesting a board 'reset in application' and 'board reset in bootloader' actions. This module will also configure the behaviour of bossa flasher and has a dependency on USBUS CDC ACM module for providing STDIO over USB --- .../common/samd21-arduino-bootloader/Makefile | 3 ++ .../samd21-arduino-bootloader/Makefile.dep | 13 ++++++ .../Makefile.include | 31 +++++++++++++ .../common/samd21-arduino-bootloader/reset.c | 43 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 boards/common/samd21-arduino-bootloader/Makefile create mode 100644 boards/common/samd21-arduino-bootloader/Makefile.dep create mode 100644 boards/common/samd21-arduino-bootloader/Makefile.include create mode 100644 boards/common/samd21-arduino-bootloader/reset.c diff --git a/boards/common/samd21-arduino-bootloader/Makefile b/boards/common/samd21-arduino-bootloader/Makefile new file mode 100644 index 000000000000..7b62d525441b --- /dev/null +++ b/boards/common/samd21-arduino-bootloader/Makefile @@ -0,0 +1,3 @@ +MODULE = boards_common_samd21-arduino-bootloader + +include $(RIOTBASE)/Makefile.base diff --git a/boards/common/samd21-arduino-bootloader/Makefile.dep b/boards/common/samd21-arduino-bootloader/Makefile.dep new file mode 100644 index 000000000000..13b725807345 --- /dev/null +++ b/boards/common/samd21-arduino-bootloader/Makefile.dep @@ -0,0 +1,13 @@ +# Provide stdio over USB by default +# This is a temporary solution until management of stdio is correctly +# handled by the build system +DEFAULT_MODULE += stdio_cdc_acm + +# Default auto-initialization of usbus for stdio other USB +USEMODULE += auto_init_usbus + +# This boards requires support for Arduino bootloader. +USEMODULE += usb_board_reset +USEMODULE += boards_common_samd21-arduino-bootloader + +FEATURES_REQUIRED += bootloader_arduino diff --git a/boards/common/samd21-arduino-bootloader/Makefile.include b/boards/common/samd21-arduino-bootloader/Makefile.include new file mode 100644 index 000000000000..cbc6d0fba034 --- /dev/null +++ b/boards/common/samd21-arduino-bootloader/Makefile.include @@ -0,0 +1,31 @@ +# setup the flash tool used +# Bossa is the default programmer +PROGRAMMER ?= bossa + +ifeq ($(PROGRAMMER),bossa) + # by default, we use BOSSA to flash this board and take into account the + # preinstalled Arduino bootloader. ROM_OFFSET skips the space taken by + # such bootloader. + ROM_OFFSET ?= 0x2000 + BOSSA_ARDUINO_PREFLASH = yes + PREFLASH_DELAY = 1 + + ifneq (,$(filter reset flash flash-only, $(MAKECMDGOALS))) + # By default, add 2 seconds delay before opening terminal: this is required + # when opening the terminal right after flashing. In this case, the stdio + # over USB needs some time after reset before being ready. + TERM_DELAY ?= 2 + TERMDEPS += term-delay + endif + + include $(RIOTMAKE)/tools/bossa.inc.mk +endif + +term-delay: + sleep $(TERM_DELAY) + +TESTRUNNER_CONNECT_DELAY ?= $(TERM_DELAY) +$(call target-export-variables,test,TESTRUNNER_CONNECT_DELAY) + +# Add the samd21-arduino-bootloader directory to the build +DIRS += $(RIOTBOARD)/common/samd21-arduino-bootloader diff --git a/boards/common/samd21-arduino-bootloader/reset.c b/boards/common/samd21-arduino-bootloader/reset.c new file mode 100644 index 000000000000..ced63c795360 --- /dev/null +++ b/boards/common/samd21-arduino-bootloader/reset.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2019 Inria + * 2019 Kees Bakker, SODAQ + * + * 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. + */ + +/** + * @ingroup boards_common + * @{ + * @file + * @brief Board common implementations for managing an Arduino bootloader + * + * @author Alexandre Abadie + * @author Kees Bakker + * + * @} + */ + +#define USB_H_USER_IS_RIOT_INTERNAL + +#include "usb_board_reset.h" + + +#define SAMD21_DOUBLE_TAP_ADDR (0x20007FFCUL) +#define SAMD21_DOUBLE_TAP_MAGIC_NUMBER (0x07738135UL) + +void usb_board_reset_in_bootloader(void) +{ + /* The Arduino bootloader checks for a magic number in SRAM to remain in + bootloader mode. + See + https://github.com/arduino/ArduinoCore-samd/blob/master/bootloaders/zero/board_definitions_arduino_mkr1000.h#L38 + and + https://github.com/arduino/ArduinoCore-samd/blob/master/bootloaders/zero/main.c#L94 + for implementation details. */ + uint32_t *reset_addr = (uint32_t *)SAMD21_DOUBLE_TAP_ADDR; + *reset_addr = (uint32_t)SAMD21_DOUBLE_TAP_MAGIC_NUMBER; + + usb_board_reset_in_application(); +} From a2c20666f0130064648e8e252064217b24ea6a37 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 26 Sep 2019 08:13:50 +0200 Subject: [PATCH 05/17] boards/arduino-mkr: use bootloader_arduino feature --- boards/common/arduino-mkr/Makefile.dep | 3 +++ boards/common/arduino-mkr/Makefile.features | 1 + boards/common/arduino-mkr/Makefile.include | 9 +++------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/boards/common/arduino-mkr/Makefile.dep b/boards/common/arduino-mkr/Makefile.dep index 5472bf8b8d8f..c15f2eaf268c 100644 --- a/boards/common/arduino-mkr/Makefile.dep +++ b/boards/common/arduino-mkr/Makefile.dep @@ -1,3 +1,6 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio endif + +# setup the samd21 arduino bootloader related dependencies +include $(RIOTBOARD)/common/samd21-arduino-bootloader/Makefile.dep diff --git a/boards/common/arduino-mkr/Makefile.features b/boards/common/arduino-mkr/Makefile.features index e4bdf6f2ac6a..08c79c508cd5 100644 --- a/boards/common/arduino-mkr/Makefile.features +++ b/boards/common/arduino-mkr/Makefile.features @@ -16,3 +16,4 @@ FEATURES_PROVIDED += periph_usbdev # Various other features (if any) FEATURES_PROVIDED += arduino FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += bootloader_arduino diff --git a/boards/common/arduino-mkr/Makefile.include b/boards/common/arduino-mkr/Makefile.include index 6bebf8f75a7c..c7485c968484 100644 --- a/boards/common/arduino-mkr/Makefile.include +++ b/boards/common/arduino-mkr/Makefile.include @@ -9,12 +9,9 @@ ifeq ($(PROGRAMMER),jlink) # in case J-Link is attached to SWD pins, use a plain CPU memory model JLINK_DEVICE = $(MKR_JLINK_DEVICE) include $(RIOTMAKE)/tools/jlink.inc.mk -else - # by default, we use BOSSA to flash this board and take into account the - # preinstalled Arduino bootloader. ROM_OFFSET skips the space taken by - # such bootloader. - ROM_OFFSET ?= 0x2000 - include $(RIOTMAKE)/tools/bossa.inc.mk endif +# Include all definitions for flashing with bossa over USB +include $(RIOTBOARD)/common/samd21-arduino-bootloader/Makefile.include + INCLUDES += -I$(RIOTBOARD)/common/arduino-mkr/include From 8632978ae16e000500188395bdac7704b957538f Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 26 Sep 2019 08:19:00 +0200 Subject: [PATCH 06/17] boards/arduino-mkrfox1200: update doc about flash and stdio --- boards/arduino-mkrfox1200/doc.txt | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/boards/arduino-mkrfox1200/doc.txt b/boards/arduino-mkrfox1200/doc.txt index 27eb93777941..72bdbe63bbc7 100644 --- a/boards/arduino-mkrfox1200/doc.txt +++ b/boards/arduino-mkrfox1200/doc.txt @@ -16,19 +16,22 @@ powered by an Atmel SAMD21 microcontroller. ### Flash the board -1. Put the board in bootloader mode by double tapping the reset button.
- When the board is in bootloader mode, the user led (green) oscillates - smoothly. - - -2. Use `BOARD=arduino-mkrfox1200` with the `make` command.
- Example with `hello-world` application: +Use `BOARD=arduino-mkrfox1200` with the `make` command.
+Example with `hello-world` application: ``` make BOARD=arduino-mkrfox1200 -C examples/hello-world flash ``` +@note If the application crashes, automatic reflashing via USB, as explained + above won't be possible. In this case, the board must be set in + bootloader mode by double tapping the reset button before running the + flash command. + ### Accessing STDIO via UART -To access the STDIO of RIOT, a FTDI to USB converter needs to be plugged to -the RX/TX pins on the board. +STDIO of RIOT is directly available over the USB port. + +The `TERM_DELAY` environment variable can be used to add a delay (in second) +before opening the serial terminal. The default value is 2s which should be +enough in most of the situation. */ From edd4f690a83f3ac09ee7694613e70620134fc8e2 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 30 Sep 2019 17:17:24 +0200 Subject: [PATCH 07/17] boards/feather-m0: use bootloader_arduino feature This provides automatic reflash/reset and stdio over USB for this board --- boards/feather-m0/Makefile.dep | 3 +++ boards/feather-m0/Makefile.features | 3 +++ boards/feather-m0/Makefile.include | 10 ++-------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/boards/feather-m0/Makefile.dep b/boards/feather-m0/Makefile.dep index 5472bf8b8d8f..c15f2eaf268c 100644 --- a/boards/feather-m0/Makefile.dep +++ b/boards/feather-m0/Makefile.dep @@ -1,3 +1,6 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio endif + +# setup the samd21 arduino bootloader related dependencies +include $(RIOTBOARD)/common/samd21-arduino-bootloader/Makefile.dep diff --git a/boards/feather-m0/Makefile.features b/boards/feather-m0/Makefile.features index 254a910c8304..e1044fadd8f6 100644 --- a/boards/feather-m0/Makefile.features +++ b/boards/feather-m0/Makefile.features @@ -11,3 +11,6 @@ FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev + +# Put other features for this board (in alphabetical order) +FEATURES_PROVIDED += bootloader_arduino diff --git a/boards/feather-m0/Makefile.include b/boards/feather-m0/Makefile.include index 3e5872289075..4a1da523b4c4 100644 --- a/boards/feather-m0/Makefile.include +++ b/boards/feather-m0/Makefile.include @@ -9,13 +9,7 @@ ifeq ($(PROGRAMMER),jlink) # in case J-Link is attached to SWD pins, use a plain CPU memory model JLINK_DEVICE = atsamd21 include $(RIOTMAKE)/tools/jlink.inc.mk -else - # by default, we use BOSSA to flash this board to take into account the - # pre-flashed Arduino bootloader. ROM_OFFSET skips the space taken by - # such bootloader. - ROM_OFFSET ?= 0x2000 - include $(RIOTMAKE)/tools/bossa.inc.mk endif -# setup the boards dependencies -include $(RIOTBOARD)/feather-m0/Makefile.dep +# Include all definitions for flashing with bossa over USB +include $(RIOTBOARD)/common/samd21-arduino-bootloader/Makefile.include From 1ffb78fa6edb74dead071f751dc670be136c31af Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 1 Oct 2019 12:09:04 +0200 Subject: [PATCH 08/17] boards/feather-m0: update doc about flash and stdio --- boards/feather-m0/doc.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/boards/feather-m0/doc.txt b/boards/feather-m0/doc.txt index 471954ce9ac9..5ecc3898fa92 100644 --- a/boards/feather-m0/doc.txt +++ b/boards/feather-m0/doc.txt @@ -41,18 +41,22 @@ printf("Bat: %dV\n", vbat); ### Flash the board -1. Put the board in bootloader mode by double tapping the reset button.
- When the board is in bootloader mode, the user led (red) oscillates smoothly. - - -2. Use `BOARD=feather-m0` with the `make` command.
- Example with `hello-world` application: +Use `BOARD=feather-m0` with the `make` command.
+Example with `hello-world` application: ``` make BOARD=feather-m0 -C examples/hello-world flash ``` +@note If the application crashes, automatic reflashing via USB, as explained + above won't be possible. In this case, the board must be set in + bootloader mode by double tapping the reset button before running the + flash command. + ### Accessing STDIO via UART -To access the STDIO of RIOT, a FTDI to USB converted needs to be plugged to -the RX/TX pins on the board. +STDIO of RIOT is directly available over the USB port. + +The `TERM_DELAY` environment variable can be used to add a delay (in second) +before opening the serial terminal. The default value is 2s which should be +enough in most of the situation. */ From 8e2c6c3cce4bd86c3ad643c534da375b0cea43ae Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 1 Oct 2019 12:09:14 +0200 Subject: [PATCH 09/17] boards/sodaq-*: update doc about flash and stdio --- boards/sodaq-autonomo/doc.txt | 21 +++++++++++++++------ boards/sodaq-explorer/doc.txt | 20 +++++++++++--------- boards/sodaq-one/doc.txt | 20 +++++++++++--------- boards/sodaq-sara-aff/doc.txt | 20 +++++++++++--------- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/boards/sodaq-autonomo/doc.txt b/boards/sodaq-autonomo/doc.txt index 0872e1f9ccd5..1cc144d26810 100644 --- a/boards/sodaq-autonomo/doc.txt +++ b/boards/sodaq-autonomo/doc.txt @@ -93,16 +93,25 @@ Besides the SAMD21 the board has the following features: ## Flashing the device -1. Put the board in bootloader mode by double tapping the reset button.
- When the board is in bootloader mode, the user led (green) oscillates - smoothly. - -2. Use `BOARD=sodaq-autonomo` with the `make` command.
- Example with `hello-world` application: +Use `BOARD=sodaq-autonomo` with the `make` command.
+Example with `hello-world` application: ``` make BOARD=sodaq-autonomo -C examples/hello-world flash ``` +@note If the application crashes, automatic reflashing via USB, as explained + above won't be possible. In this case, the board must be set in + bootloader mode by double tapping the reset button before running the + flash command. + +## Accessing STDIO via UART + +STDIO of RIOT is directly available over the USB port. + +The `TERM_DELAY` environment variable can be used to add a delay (in second) +before opening the serial terminal. The default value is 2s which should be +enough in most of the situation. + ## Supported Toolchains To build software for the autonomo board we strongly recommend the usage of diff --git a/boards/sodaq-explorer/doc.txt b/boards/sodaq-explorer/doc.txt index 4ee636e5320e..6e311d92c0e7 100644 --- a/boards/sodaq-explorer/doc.txt +++ b/boards/sodaq-explorer/doc.txt @@ -10,20 +10,22 @@ General information about this board can be found on the ### Flash the board -1. Put the board in bootloader mode by double tapping the reset button.
- When the board is in bootloader mode, the user led (blue) oscillates - smoothly. - - -2. Use `BOARD=sodaq-explorer` with the `make` command.
- Example with `hello-world` application: +Use `BOARD=sodaq-explorer` with the `make` command.
+Example with `hello-world` application: ``` make BOARD=sodaq-explorer -C examples/hello-world flash ``` +@note If the application crashes, automatic reflashing via USB, as explained + above won't be possible. In this case, the board must be set in + bootloader mode by double tapping the reset button before running the + flash command. + ### Accessing STDIO via UART -To access the STDIO of RIOT, a FTDI to USB converter needs to be plugged to -the RX/TX pins on the board. +STDIO of RIOT is directly available over the USB port. +The `TERM_DELAY` environment variable can be used to add a delay (in second) +before opening the serial terminal. The default value is 2s which should be +enough in most of the situation. */ diff --git a/boards/sodaq-one/doc.txt b/boards/sodaq-one/doc.txt index 43a4eb037583..332f3d71c277 100644 --- a/boards/sodaq-one/doc.txt +++ b/boards/sodaq-one/doc.txt @@ -10,20 +10,22 @@ * * ### Flash the board * - * 1. Put the board in bootloader mode by double tapping the reset button.
- * When the board is in bootloader mode, the user led (blue) oscillates - * smoothly. - * - * - * 2. Use `BOARD=sodaq-one` with the `make` command.
- * Example with `hello-world` application: + * Use `BOARD=sodaq-one` with the `make` command.
+ * Example with `hello-world` application: * ``` * make BOARD=sodaq-one -C examples/hello-world flash * ``` * + * @note If the application crashes, automatic reflashing via USB, as explained + * above won't be possible. In this case, the board must be set in + * bootloader mode by double tapping the reset button before running the + * flash command. + * * ### Accessing STDIO via UART * - * To access the STDIO of RIOT, a FTDI to USB converter needs to be plugged to - * the RX/TX pins on the board. + * STDIO of RIOT is directly available over the USB port. * + * The `TERM_DELAY` environment variable can be used to add a delay (in second) + * before opening the serial terminal. The default value is 2s which should be + * enough in most of the situation. */ diff --git a/boards/sodaq-sara-aff/doc.txt b/boards/sodaq-sara-aff/doc.txt index fcad988c6f26..b4daf900b01e 100644 --- a/boards/sodaq-sara-aff/doc.txt +++ b/boards/sodaq-sara-aff/doc.txt @@ -12,20 +12,22 @@ * * ### Flash the board * - * 1. Put the board in bootloader mode by double tapping the reset button.
- * When the board is in bootloader mode, the user led (blue) oscillates - * smoothly. - * - * - * 2. Use `BOARD=sodaq-sara-aff` with the `make` command.
- * Example with `hello-world` application: + * Use `BOARD=sodaq-sara-aff` with the `make` command.
+ * Example with `hello-world` application: * ``` * make BOARD=sodaq-sara-aff -C examples/hello-world flash * ``` * + * @note If the application crashes, automatic reflashing via USB, as explained + * above won't be possible. In this case, the board must be set in + * bootloader mode by double tapping the reset button before running the + * flash command. + * * ### Accessing STDIO via UART * - * To access the STDIO of RIOT, a FTDI to USB converter needs to be plugged to - * the RX/TX pins on the board. + * STDIO of RIOT is directly available over the USB port. * + * The `TERM_DELAY` environment variable can be used to add a delay (in second) + * before opening the serial terminal. The default value is 2s which should be + * enough in most of the situation. */ From eb20cfe9cad0edc71d574a79debc7517f025f207 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 12 Oct 2019 23:29:58 +0200 Subject: [PATCH 10/17] Makefile.dep: blacklist bootloader_arduino feature when required - bootloader_arduino cannot be used if stdio_cdc_acm is not used - stdio_cdc_acm is disabled when other stdio modules are already used --- Makefile.dep | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Makefile.dep b/Makefile.dep index 0ded69d32c67..21f5d2f2ef2d 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -492,6 +492,17 @@ ifneq (,$(filter stdio_cdc_acm stdio_null stdio_uart slipdev_stdio,$(USEMODULE)) DISABLE_MODULE += stdio_rtt endif +ifneq (,$(filter stdio_rtt stdio_null stdio_uart slipdev_stdio,$(USEMODULE))) + # stdio_cdc_acm cannot be used when another STDIO is loaded + DISABLE_MODULE += stdio_cdc_acm +endif + +ifeq (,$(filter stdio_cdc_acm,$(USEMODULE))) + # The arduino bootloader feature cannot be used if the stdio_cdc_acm module + # is not used + FEATURES_BLACKLIST += bootloader_arduino +endif + ifneq (,$(filter isrpipe,$(USEMODULE))) USEMODULE += tsrb endif From 13420609773e78f44b674c9d539d22d90ef2408d Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 17 Oct 2019 21:29:48 +0200 Subject: [PATCH 11/17] boards/arduino-mkrwan1300: update doc about flash and stdio --- boards/arduino-mkrwan1300/doc.txt | 70 +++++++++++++++---------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/boards/arduino-mkrwan1300/doc.txt b/boards/arduino-mkrwan1300/doc.txt index 9e56cedbb25c..e9cc8b5047d3 100644 --- a/boards/arduino-mkrwan1300/doc.txt +++ b/boards/arduino-mkrwan1300/doc.txt @@ -1,37 +1,37 @@ /** - * @defgroup boards_arduino-mkrwan1300 Arduino MKR WAN 1300 - * @ingroup boards - * @brief Support for the Arduino MKR WAN 1300 board. - * - * ### General information - * - * The [Arduino MKR WAN 1300](https://store.arduino.cc/mkr-wan-1300) board is - * a learning and development board that provides LoRa connectivity and is - * powered by an Atmel SAMD21 microcontroller. - * - * ### Pinout - * - * Arduino MKR WAN 1300 pinout - * - * ### Flash the board - * - * 1. Put the board in bootloader mode by double tapping the reset button.
- * When the board is in bootloader mode, the user led (amber) oscillates - * smoothly. - * - * - * 2. Use `BOARD=arduino-mkrwan1300` with the `make` command.
- * Example with `hello-world` application: - * ``` - * make BOARD=arduino-mkrwan1300 -C examples/hello-world flash - * ``` - * - * @warning Unplug the board from the anti-static protective foam before - * starting to use it otherwise it may not work as expected. - * - * ### Accessing STDIO via UART - * - * To access the STDIO of RIOT, a FTDI to USB converted needs to be plugged to - * the RX/TX pins on the board. +@defgroup boards_arduino-mkrwan1300 Arduino MKR WAN 1300 +@ingroup boards +@brief Support for the Arduino MKR WAN 1300 board. + +### General information + +The [Arduino MKR WAN 1300](https://store.arduino.cc/mkr-wan-1300) board is +a learning and development board that provides LoRa connectivity and is +powered by an Atmel SAMD21 microcontroller. + +### Pinout + +Arduino MKR WAN 1300 pinout + +### Flash the board + +Use `BOARD=arduino-mkrgsm1400` with the `make` command.
+Example with `hello-world` application: +``` + make BOARD=arduino-mkrgsm1400 -C examples/hello-world flash +``` + +@note If the application crashes, automatic reflashing via USB, as explained + above won't be possible. In this case, the board must be set in + bootloader mode by double tapping the reset button before running the + flash command. + +### Accessing STDIO via UART + +STDIO of RIOT is directly available over the USB port. + +The `TERM_DELAY` environment variable can be used to add a delay (in second) +before opening the serial terminal. The default value is 2s which should be +enough in most of the situation. */ \ No newline at end of file From f5a17a90fbf9cc8573759040fb88c500a11a716f Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 22 Oct 2019 19:01:53 +0200 Subject: [PATCH 12/17] boards/sodaq-*: use bootloader_arduino feature --- boards/common/sodaq/Makefile.dep | 3 +++ boards/common/sodaq/Makefile.features | 1 + boards/common/sodaq/Makefile.include | 7 ++----- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/boards/common/sodaq/Makefile.dep b/boards/common/sodaq/Makefile.dep index 5472bf8b8d8f..c15f2eaf268c 100644 --- a/boards/common/sodaq/Makefile.dep +++ b/boards/common/sodaq/Makefile.dep @@ -1,3 +1,6 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio endif + +# setup the samd21 arduino bootloader related dependencies +include $(RIOTBOARD)/common/samd21-arduino-bootloader/Makefile.dep diff --git a/boards/common/sodaq/Makefile.features b/boards/common/sodaq/Makefile.features index c9ffe71f9281..4cc1f1a62088 100644 --- a/boards/common/sodaq/Makefile.features +++ b/boards/common/sodaq/Makefile.features @@ -12,3 +12,4 @@ FEATURES_PROVIDED += periph_usbdev # Various other features (if any) FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += bootloader_arduino diff --git a/boards/common/sodaq/Makefile.include b/boards/common/sodaq/Makefile.include index 8db3929a94a3..116cd8b3e4ca 100644 --- a/boards/common/sodaq/Makefile.include +++ b/boards/common/sodaq/Makefile.include @@ -7,8 +7,5 @@ include $(RIOTMAKE)/tools/serial.inc.mk # Add board common includes INCLUDES += -I$(RIOTBOARD)/common/sodaq/include -# setup the flash tool used -# we use BOSSA to flash this board since there's an Arduino bootloader -# preflashed on it. ROM_OFFSET skips the space taken by such bootloader. -ROM_OFFSET ?= 0x2000 -include $(RIOTMAKE)/tools/bossa.inc.mk +# Include all definitions for flashing with bossa over USB +include $(RIOTBOARD)/common/samd21-arduino-bootloader/Makefile.include From a91c4bf7e6b996d76087f3edb9d5d1860634a430 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 19 Dec 2019 15:00:42 +0100 Subject: [PATCH 13/17] dist/testrunner: add optional delay before opening serial This option is null by default but is useful when used with boards exposing their stdio over USB --- dist/pythonlibs/testrunner/spawn.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dist/pythonlibs/testrunner/spawn.py b/dist/pythonlibs/testrunner/spawn.py index 606114175822..032618a24479 100644 --- a/dist/pythonlibs/testrunner/spawn.py +++ b/dist/pythonlibs/testrunner/spawn.py @@ -28,6 +28,10 @@ # default value (0, no delay) MAKE_RESET_DELAY = int(os.environ.get('TESTRUNNER_RESET_DELAY') or 0) +# Setting an empty 'TESTRUNNER_CONNECT_DELAY' environment variable use the +# default value (0) +MAKE_TERM_CONNECT_DELAY = int(os.environ.get('TESTRUNNER_CONNECT_DELAY') or 0) + # Allow customizing test interactive settings with environment variables TEST_INTERACTIVE_RETRIES = int(os.environ.get('TEST_INTERACTIVE_RETRIES') or 5) TEST_INTERACTIVE_DELAY = int(os.environ.get('TEST_INTERACTIVE_DELAY') or 1) @@ -66,6 +70,10 @@ def setup_child(timeout=10, spawnclass=pexpect.spawnu, env=None, logfile=None): # before `cleanterm`. _reset_board(env) + # on platforms exposing UART over USB, wait a little before connecting to + # the serial terminal. This gives time for stdio to be ready. + time.sleep(MAKE_TERM_CONNECT_DELAY) + child = spawnclass("make cleanterm", env=env, timeout=timeout, codec_errors='replace', echo=False) From 0e511a689279623c7e9731e9fc1c6eb8da6efdbd Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 18 Jan 2020 07:26:42 +0100 Subject: [PATCH 14/17] tests/bench_xtimer: update low memory boards list Samd21 based boards using the Arduino bootloader and stdio over usb by default doesn't have enough RAM to run the test in its default configuration (1000 timers) --- tests/bench_xtimer/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/bench_xtimer/Makefile b/tests/bench_xtimer/Makefile index d06a3b2a34a9..3ff38afa0838 100644 --- a/tests/bench_xtimer/Makefile +++ b/tests/bench_xtimer/Makefile @@ -7,6 +7,10 @@ USEMODULE += xtimer LOW_MEMORY_BOARDS += \ airfy-beacon \ arduino-mega2560 \ + arduino-mkr1000 \ + arduino-mkrfox1200 \ + arduino-mkrwan1300 \ + arduino-mkrzero \ atmega1284p \ b-l072z-lrwan1 \ blackpill \ @@ -20,6 +24,7 @@ LOW_MEMORY_BOARDS += \ cc2650stk \ chronos \ derfmega128 \ + feather-m0 \ hifive1 \ hifive1b \ i-nucleo-lrwan1 \ @@ -45,6 +50,10 @@ LOW_MEMORY_BOARDS += \ opencm904 \ saml10-xpro \ saml11-xpro \ + sodaq-autonomo \ + sodaq-explorer \ + sodaq-one \ + sodaq-sara-aff \ spark-core \ stm32f0discovery \ stm32l0538-disco \ From 182cb8735b2b83ce93f2ad16cc1eeab883b94fac Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 20 Jan 2020 16:30:11 +0100 Subject: [PATCH 15/17] sys: periph_uart is required for arduino --- sys/Makefile.dep | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/Makefile.dep b/sys/Makefile.dep index bf6e335a99a3..6f3d534a9f36 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -1,6 +1,7 @@ ifneq (,$(filter arduino,$(USEMODULE))) FEATURES_OPTIONAL += periph_i2c FEATURES_OPTIONAL += periph_spi + FEATURES_REQUIRED += periph_uart endif ifneq (,$(filter eepreg,$(USEMODULE))) From 4145c196b7a8ecada506150dbe35b248d005db30 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 11 Mar 2020 11:45:42 +0100 Subject: [PATCH 16/17] tests/ssp: blacklist bootloader_arduino feature --- tests/ssp/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/ssp/Makefile b/tests/ssp/Makefile index aaeb93306736..eb11ad187106 100644 --- a/tests/ssp/Makefile +++ b/tests/ssp/Makefile @@ -2,6 +2,10 @@ include ../Makefile.tests_common USEMODULE += ssp +# This test intentionally crashes the firmware and when using a board with a +# preflashed bootloader, it cannot be reflashed automatically afterwards. +FEATURES_BLACKLIST += bootloader_arduino + include $(RIOTBASE)/Makefile.include ifneq (,$(shell $(CC) --help=warnings | grep '\-Wstringop-overflow=')) From 012567e0a86af03fab1ce1f73c8aefb2b957a625 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 17 Mar 2020 16:44:48 +0100 Subject: [PATCH 17/17] tests/unittests: blacklist bootloader_arduino feature --- tests/unittests/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unittests/Makefile b/tests/unittests/Makefile index d1a1d93dddf6..ea6fe6db21f4 100644 --- a/tests/unittests/Makefile +++ b/tests/unittests/Makefile @@ -13,6 +13,12 @@ endif DISABLE_MODULE += auto_init +# boards using arduino bootloader require auto_init to +# automatically initialize stdio over USB. Without this, the bootloader +# management feature cannot be used (auto reset and auto reboot in bootloader +# mode) +FEATURES_BLACKLIST += bootloader_arduino + # Pull in `Makefile.include`s from the test suites: -include $(UNIT_TESTS:%=$(RIOTBASE)/tests/unittests/%/Makefile.include)