Skip to content

Upstreammerge 150304 #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fd50d90
fix makefile for easier programming
ladyada Oct 28, 2015
11fa3d3
pulse D13 LED during bootloader active
ladyada Oct 31, 2015
85d6c73
makefile now compiles from within Roaming/Arduino15 subfolder
ladyada Oct 31, 2015
e715bf3
add support for A6 (D8) and A7 (D9)
ladyada Nov 1, 2015
f851644
bootloader with different VID/PID
ladyada Nov 1, 2015
def75fa
adds bootloaders/feather
toddtreece Nov 17, 2015
9ad4e0d
reverts bootloaders/zero changes
toddtreece Nov 17, 2015
d5cda2b
Merge branch 'master' of github.com:arduino/ArduinoCore-samd
toddtreece Nov 17, 2015
e7579eb
adds new boards.txt
toddtreece Nov 18, 2015
22f47bb
Update platform.txt
ladyada Nov 24, 2015
bf20844
Merge branch 'master' of github.com:arduino/ArduinoCore-samd
ladyada Nov 24, 2015
5c7319f
make it so native USB is Serial
ladyada Jan 13, 2016
d8f4306
Serial5 not available anyhow
ladyada Jan 24, 2016
d95e053
Update Board for Feather M0
obsoleted Feb 10, 2016
c34dd05
Keep ARDUINO_SAMD_ZERO flag for compatilibity
obsoleted Feb 11, 2016
9d193cc
add metro m0 (testing)
ladyada Feb 14, 2016
440afc5
add USB CDC RX & TX LEDs with 10ms minimum on time, tested
ladyada Feb 14, 2016
616475a
fix random init() call, set debug output to Serial1
ladyada Feb 15, 2016
ae5e0b8
use Serial1 option for debug output (since USB port is taken)
ladyada Feb 15, 2016
e25840e
manually did https://github.com/arduino/ArduinoCore-samd/pull/88 and …
ladyada Feb 15, 2016
f41f197
Working demo with nice status change notifications
ladyada Feb 15, 2016
188d880
woot, that wasnt too bad - updated debug for Serial1, works nicely
ladyada Feb 15, 2016
21b53d1
Merge pull request #1 from obsoleted/board_featherm0
ladyada Feb 17, 2016
a2024c7
Merge branch 'master' of https://github.com/arduino/ArduinoCore-samd …
ladyada Mar 4, 2016
0303c16
merge with upstream, pulse LED & VID/PID change for bootloader
ladyada Mar 6, 2016
83834c3
feather bootloader files
ladyada Mar 6, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 52 additions & 71 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,77 +14,58 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

# Arduino/Genuino Zero (Prorgamming Port)
# ---------------------------------------
arduino_zero_edbg.name=Arduino/Genuino Zero (Programming Port)
arduino_zero_edbg.vid.0=0x03eb
arduino_zero_edbg.pid.0=0x2157

arduino_zero_edbg.upload.tool=openocd
arduino_zero_edbg.upload.protocol=sam-ba
arduino_zero_edbg.upload.maximum_size=262144
arduino_zero_edbg.upload.use_1200bps_touch=false
arduino_zero_edbg.upload.wait_for_upload_port=false
arduino_zero_edbg.upload.native_usb=false
arduino_zero_edbg.build.mcu=cortex-m0plus
arduino_zero_edbg.build.f_cpu=48000000L
arduino_zero_edbg.build.usb_product="Arduino Zero"
arduino_zero_edbg.build.usb_manufacturer="Arduino LLC"
arduino_zero_edbg.build.board=SAMD_ZERO
arduino_zero_edbg.build.core=arduino
arduino_zero_edbg.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
arduino_zero_edbg.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
arduino_zero_edbg.build.openocdscript=openocd_scripts/arduino_zero.cfg
arduino_zero_edbg.build.variant=arduino_zero
arduino_zero_edbg.build.variant_system_lib=
arduino_zero_edbg.build.vid=0x2341
arduino_zero_edbg.build.pid=0x804d
arduino_zero_edbg.bootloader.tool=openocd
arduino_zero_edbg.bootloader.file=zero/samd21_sam_ba.bin
adafruit_feather_m0.name=Adafruit Feather M0 (Native USB Port)
adafruit_feather_m0.vid.0=0x239A
adafruit_feather_m0.pid.0=0x800B
adafruit_feather_m0.vid.1=0x239A
adafruit_feather_m0.pid.1=0x000B
adafruit_feather_m0.upload.tool=bossac
adafruit_feather_m0.upload.protocol=sam-ba
adafruit_feather_m0.upload.maximum_size=262144
adafruit_feather_m0.upload.use_1200bps_touch=true
adafruit_feather_m0.upload.wait_for_upload_port=true
adafruit_feather_m0.upload.native_usb=true
adafruit_feather_m0.build.mcu=cortex-m0plus
adafruit_feather_m0.build.f_cpu=48000000L
adafruit_feather_m0.build.usb_product="Feather M0"
adafruit_feather_m0.build.usb_manufacturer="Adafruit"
adafruit_feather_m0.build.board=SAMD_FEATHER_M0
adafruit_feather_m0.build.core=arduino
adafruit_feather_m0.build.extra_flags=-DARDUINO_SAMD_ZERO -D__SAMD21G18A__ {build.usb_flags}
adafruit_feather_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
adafruit_feather_m0.build.openocdscript=openocd_scripts/arduino_zero.cfg
adafruit_feather_m0.build.variant=arduino_zero
adafruit_feather_m0.build.variant_system_lib=
adafruit_feather_m0.build.vid=0x239A
adafruit_feather_m0.build.pid=0x800B
adafruit_feather_m0.bootloader.tool=openocd
adafruit_feather_m0.bootloader.file=feather/samd21_sam_ba.bin

# Arduino/Genuino Zero (Native USB Port)
# ---------------------------------------
arduino_zero_native.name=Arduino/Genuino Zero (Native USB Port)
arduino_zero_native.vid.0=0x2341
arduino_zero_native.pid.0=0x804d
arduino_zero_native.vid.1=0x2341
arduino_zero_native.pid.1=0x004d

arduino_zero_native.vid.2=0x2341
arduino_zero_native.pid.2=0x824d
# If the board is a 2341:824d use 2341:824d for build and set other parameters as well
arduino_zero_native.vid.2.build.vid=0x2341
arduino_zero_native.vid.2.build.pid=0x824d
arduino_zero_native.vid.2.build.usb_product="Genuino Zero"
arduino_zero_native.vid.2.bootloader.file=zero/samd21_sam_ba_genuino.bin

arduino_zero_native.vid.3=0x2341
arduino_zero_native.pid.3=0x024d
# If the board is a 2341:024d use 2341:824d for build and set other parameters as well
arduino_zero_native.vid.3.build.vid=0x2341
arduino_zero_native.vid.3.build.pid=0x824d
arduino_zero_native.vid.3.build.usb_product="Genuino Zero"
arduino_zero_native.vid.3.bootloader.file=zero/samd21_sam_ba_genuino.bin

arduino_zero_native.upload.tool=bossac
arduino_zero_native.upload.protocol=sam-ba
arduino_zero_native.upload.maximum_size=262144
arduino_zero_native.upload.use_1200bps_touch=true
arduino_zero_native.upload.wait_for_upload_port=true
arduino_zero_native.upload.native_usb=true
arduino_zero_native.build.mcu=cortex-m0plus
arduino_zero_native.build.f_cpu=48000000L
arduino_zero_native.build.usb_product="Arduino Zero"
arduino_zero_native.build.usb_manufacturer="Arduino LLC"
arduino_zero_native.build.board=SAMD_ZERO
arduino_zero_native.build.core=arduino
arduino_zero_native.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
arduino_zero_native.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
arduino_zero_native.build.openocdscript=openocd_scripts/arduino_zero.cfg
arduino_zero_native.build.variant=arduino_zero
arduino_zero_native.build.variant_system_lib=
arduino_zero_native.build.vid=0x2341
arduino_zero_native.build.pid=0x804d
arduino_zero_native.bootloader.tool=openocd
arduino_zero_native.bootloader.file=zero/samd21_sam_ba.bin

adafruit_metro_m0.name=Adafruit Metro M0 (Native USB Port)
adafruit_metro_m0.vid.0=0x239A
adafruit_metro_m0.pid.0=0x8013
adafruit_metro_m0.vid.1=0x239A
adafruit_metro_m0.pid.1=0x0013
adafruit_metro_m0.upload.tool=bossac
adafruit_metro_m0.upload.protocol=sam-ba
adafruit_metro_m0.upload.maximum_size=262144
adafruit_metro_m0.upload.use_1200bps_touch=true
adafruit_metro_m0.upload.wait_for_upload_port=true
adafruit_metro_m0.upload.native_usb=true
adafruit_metro_m0.build.mcu=cortex-m0plus
adafruit_metro_m0.build.f_cpu=48000000L
adafruit_metro_m0.build.usb_product="Metro M0"
adafruit_metro_m0.build.usb_manufacturer="Adafruit"
adafruit_metro_m0.build.board=SAMD_ZERO
adafruit_metro_m0.build.core=arduino
adafruit_metro_m0.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
adafruit_metro_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
adafruit_metro_m0.build.openocdscript=openocd_scripts/arduino_zero.cfg
adafruit_metro_m0.build.variant=arduino_zero
adafruit_metro_m0.build.variant_system_lib=
adafruit_metro_m0.build.vid=0x239A
adafruit_metro_m0.build.pid=0x8013
adafruit_metro_m0.bootloader.tool=openocd
adafruit_metro_m0.bootloader.file=metro/samd21_sam_ba.bin
178 changes: 178 additions & 0 deletions bootloaders/feather/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Copyright (c) 2015 Atmel Corporation/Thibaut VIARD. All right reserved.
# Copyright (c) 2015 Arduino LLC. All right reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

# -----------------------------------------------------------------------------
# Paths
ifeq ($(OS),Windows_NT)

# Are we using mingw/msys/msys2/cygwin?
ifeq ($(TERM),xterm)
T=$(shell cygpath -u $(LOCALAPPDATA))
MODULE_PATH?=$(T)/Arduino15/packages/arduino
ARM_GCC_PATH?=$(MODULE_PATH)/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-
RM=rm
SEP=/
else
MODULE_PATH?=$(LOCALAPPDATA)/Arduino15/packages/arduino
ARM_GCC_PATH?=$(MODULE_PATH)/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-
RM=rm
SEP=\\
endif
else
UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S),Linux)
MODULE_PATH?=$(HOME)/.arduino15/packages/arduino
ARM_GCC_PATH?=$(MODULE_PATH)/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-
RM=rm
SEP=/
endif

ifeq ($(UNAME_S),Darwin)
MODULE_PATH?=$(HOME)/Library/Arduino15/packages/arduino/
ARM_GCC_PATH?=$(MODULE_PATH)/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-
RM=rm
SEP=/
endif
endif

BUILD_PATH=build

# -----------------------------------------------------------------------------
# Tools
CC=$(ARM_GCC_PATH)gcc
OBJCOPY=$(ARM_GCC_PATH)objcopy
NM=$(ARM_GCC_PATH)nm
SIZE=$(ARM_GCC_PATH)size

# -----------------------------------------------------------------------------
# Compiler options
CFLAGS=-mthumb -mcpu=cortex-m0plus -Wall -c -std=gnu99 -ffunction-sections -fdata-sections -nostdlib -nostartfiles --param max-inline-insns-single=500
ifdef DEBUG
CFLAGS+=-g3 -O1 -DDEBUG=1
else
CFLAGS+=-Os -DDEBUG=0
endif

CFLAGS_EXTRA?=-D__SAMD21G18A__ -DUSB_PID_HIGH=0x00 -DUSB_PID_LOW=0x0B -DUSB_VID_LOW=0x9A -DUSB_VID_HIGH=0x23
# Arduino Zero (PID == 0x004D)
# CFLAGS_EXTRA?=-D__SAMD21G18A__ -DUSB_PID_HIGH=0x00 -DUSB_PID_LOW=0x4D -DUSB_VID_LOW=0x41 -DUSB_VID_HIGH=0x23
# Genuino Zero (PID == 0x024D)
# CFLAGS_EXTRA?=-D__SAMD21G18A__ -DUSB_PID_HIGH=0x02 -DUSB_PID_LOW=0x4D -DUSB_VID_LOW=0x41 -DUSB_VID_HIGH=0x23
# Arduino MKR1000 (PID == 0x004E)
# CFLAGS_EXTRA?=-D__SAMD21G18A__ -DUSB_PID_HIGH=0x00 -DUSB_PID_LOW=0x4E -DUSB_VID_LOW=0x41 -DUSB_VID_HIGH=0x23
# Genuino MKR1000 (PID == 0x024E)
# CFLAGS_EXTRA?=-D__SAMD21G18A__ -DUSB_PID_HIGH=0x02 -DUSB_PID_LOW=0x4E -DUSB_VID_LOW=0x41 -DUSB_VID_HIGH=0x23

INCLUDES=-I"$(MODULE_PATH)/tools/CMSIS/4.0.0-atmel/CMSIS/Include/" -I"$(MODULE_PATH)/tools/CMSIS/4.0.0-atmel/Device/ATMEL/"

# -----------------------------------------------------------------------------
# Linker options
LDFLAGS=-mthumb -mcpu=cortex-m0plus -Wall -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all
LDFLAGS+=-Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols --specs=nano.specs --specs=nosys.specs

# -----------------------------------------------------------------------------
# Source files and objects
SOURCES= \
board_driver_led.c \
board_driver_serial.c \
board_driver_usb.c \
board_init.c \
board_startup.c \
main.c \
sam_ba_usb.c \
sam_ba_cdc.c \
sam_ba_monitor.c \
sam_ba_serial.c

OBJECTS=$(addprefix $(BUILD_PATH)/, $(SOURCES:.c=.o))
DEPS=$(addprefix $(BUILD_PATH)/, $(SOURCES:.c=.d))

NAME=samd21_sam_ba
ELF=$(NAME).elf
BIN=$(NAME).bin
HEX=$(NAME).hex

ifneq "test$(AVRSTUDIO_EXE_PATH)" "test"
AS_BUILD=copy_for_atmel_studio
AS_CLEAN=clean_for_atmel_studio
else
AS_BUILD=
AS_CLEAN=
endif


all: print_info $(SOURCES) $(BIN) $(HEX) $(AS_BUILD)

$(ELF): Makefile $(BUILD_PATH) $(OBJECTS)
@echo ----------------------------------------------------------
@echo Creating ELF binary
"$(CC)" -L. -L$(BUILD_PATH) $(LDFLAGS) -Os -Wl,--gc-sections -save-temps -Tbootloader_samd21x18.ld -Wl,-Map,"$(BUILD_PATH)/$(NAME).map" -o "$(BUILD_PATH)/$(ELF)" -Wl,--start-group $(OBJECTS) -lm -Wl,--end-group
"$(NM)" "$(BUILD_PATH)/$(ELF)" >"$(BUILD_PATH)/$(NAME)_symbols.txt"
"$(SIZE)" --format=sysv -t -x $(BUILD_PATH)/$(ELF)

$(BIN): $(ELF)
@echo ----------------------------------------------------------
@echo Creating flash binary
"$(OBJCOPY)" -O binary $(BUILD_PATH)/$< $@

$(HEX): $(ELF)
@echo ----------------------------------------------------------
@echo Creating flash binary
"$(OBJCOPY)" -O ihex $(BUILD_PATH)/$< $@

$(BUILD_PATH)/%.o: %.c
@echo ----------------------------------------------------------
@echo Compiling $< to $@
"$(CC)" $(CFLAGS) $(CFLAGS_EXTRA) $(INCLUDES) $< -o $@
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

$(BUILD_PATH):
@echo ----------------------------------------------------------
@echo Creating build folder
-mkdir $(BUILD_PATH)

print_info:
@echo ----------------------------------------------------------
@echo Compiling bootloader using
@echo BASE PATH = $(MODULE_PATH)
@echo GCC PATH = $(ARM_GCC_PATH)
# @echo OS = $(OS)
# @echo SHELL = $(SHELL)
# @echo TERM = $(TERM)
# "$(CC)" -v
# env

copy_for_atmel_studio: $(BIN) $(HEX)
@echo ----------------------------------------------------------
@echo Atmel Studio detected, copying ELF to project root for debug
cp $(BUILD_PATH)/$(ELF) .

clean_for_atmel_studio:
@echo ----------------------------------------------------------
@echo Atmel Studio detected, cleaning ELF from project root
-$(RM) ./$(ELF)

clean: $(AS_CLEAN)
@echo ----------------------------------------------------------
@echo Cleaning project
-$(RM) $(BIN)
-$(RM) $(HEX)
-$(RM) $(BUILD_PATH)/*.*
-rmdir $(BUILD_PATH)

.phony: print_info $(BUILD_PATH)
75 changes: 75 additions & 0 deletions bootloaders/feather/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Arduino Zero Bootloader

## 1- Prerequisites

The project build is based on Makefile system.
Makefile is present at project root and try to handle multi-platform cases.

Multi-plaform GCC is provided by ARM here: https://launchpad.net/gcc-arm-embedded/+download

Atmel Studio contains both make and ARM GCC toolchain. You don't need to install them in this specific use case.

### Windows

* Native command line
Make binary can be obtained here: http://gnuwin32.sourceforge.net/packages/make.htm

* Cygwin/MSys/MSys2/Babun/etc...
It is available natively in all distributions.

* Atmel Studio
An Atmel Studio **7** Makefile-based project is present at project root, just open samd21_sam_ba.atsln file in AS7.

### Linux

Make is usually available by default.

### OS X

Make is available through XCode package.


## 2- Selecting available SAM-BA interfaces

By default both USB and UART are made available, but this parameter can be modified in sam_ba_monitor.h, line 31:

Set the define SAM_BA_INTERFACE to
* SAM_BA_UART_ONLY for only UART interface
* SAM_BA_USBCDC_ONLY for only USB CDC interface
* SAM_BA_BOTH_INTERFACES for enabling both the interfaces

## 3- Behaviour

This bootloader implements the double-tap on Reset button.
By quickly pressing this button two times, the board will reset and stay in bootloader, waiting for communication on either USB or USART.

The USB port in use is the USB Native port, close to the Reset button.
The USART in use is the one available on pins D0/D1, labelled respectively RX/TX. Communication parameters are a baudrate at 115200, 8bits of data, no parity and 1 stop bit (8N1).

## 4- Description

**Pinmap**

The following pins are used by the program :
PA25 : input/output (USB DP)
PA24 : input/output (USB DM)
PA11 : input (USART RX)
PA10 : output (USART TX)

The application board shall avoid driving the PA25, PA24, PB23 and PB22 signals while the boot program is running (after a POR for example).

**Clock system**

CPU runs at 48MHz from Generic Clock Generator 0 on DFLL48M.

Generic Clock Generator 1 is using external 32kHz oscillator and is the source of DFLL48M.

USB and USART are using Generic Clock Generator 0 also.

**Memory Mapping**

Bootloader code will be located at 0x0 and executed before any applicative code.

Applications compiled to be executed along with the bootloader will start at 0x2000 (see linker script bootloader_samd21x18.ld).

Before jumping to the application, the bootloader changes the VTOR register to use the interrupt vectors of the application @0x2000.<- not required as application code is taking care of this.
Loading