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
This commit is contained in:
parent
95bf34ee9c
commit
c7f6d53773
3
boards/common/samd21-arduino-bootloader/Makefile
Normal file
3
boards/common/samd21-arduino-bootloader/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
MODULE = boards_common_samd21-arduino-bootloader
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
13
boards/common/samd21-arduino-bootloader/Makefile.dep
Normal file
13
boards/common/samd21-arduino-bootloader/Makefile.dep
Normal file
@ -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
|
||||||
31
boards/common/samd21-arduino-bootloader/Makefile.include
Normal file
31
boards/common/samd21-arduino-bootloader/Makefile.include
Normal file
@ -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
|
||||||
43
boards/common/samd21-arduino-bootloader/reset.c
Normal file
43
boards/common/samd21-arduino-bootloader/reset.c
Normal file
@ -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 <alexandre.abadie@inria.fr>
|
||||||
|
* @author Kees Bakker <kees@sodaq.com>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user