This repository has been archived by the owner on Sep 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e9d69e
commit ac1184e
Showing
4,560 changed files
with
2,439,301 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
BasedOnStyle: LLVM | ||
IndentWidth: 4 | ||
UseTab: Never | ||
ColumnLimit: 100 | ||
SortIncludes: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target extended-remote localhost:3333 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "lib/uf2"] | ||
path = lib/uf2 | ||
url = https://github.com/Microsoft/uf2.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
language: node_js | ||
sudo: false | ||
node_js: | ||
- "5.7.0" | ||
notifications: | ||
email: | ||
- [email protected] | ||
addons: | ||
apt: | ||
packages: | ||
- libc6-i386 | ||
|
||
node_js: | ||
- "6" | ||
|
||
cache: | ||
directories: | ||
- $HOME/gcc-arm-none-eabi-6-2017-q1-update | ||
|
||
install: | ||
- export GCC_DIR=$HOME/gcc-arm-none-eabi-6-2017-q1-update | ||
- export GCC_ARCHIVE=$HOME/gcc-arm-none-eabi-6-2017-q1-update-linux.tar.bz2 | ||
- export GCC_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/6_1-2017q1/gcc-arm-none-eabi-6-2017-q1-update-linux.tar.bz2?product=GNU%20ARM%20Embedded%20Toolchain,64-bit,,Linux,6-2017-q1-update | ||
- if [ ! -e $GCC_DIR/bin/arm-none-eabi-g++ ]; then wget $GCC_URL -O $GCC_ARCHIVE; tar xfj $GCC_ARCHIVE -C $HOME; fi | ||
- export PATH=$PATH:$GCC_DIR/bin | ||
|
||
script: | ||
- make all-boards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "C++ Attach", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${workspaceRoot}/uf2-bootloader.elf", | ||
"cwd": "${workspaceRoot}", | ||
"logging": { | ||
"moduleLoad": true, | ||
"trace": true, | ||
"exceptions": true, | ||
"programOutput": true, | ||
"engineLogging": true, | ||
"traceResponse": true | ||
}, | ||
"targetArchitecture": "arm", | ||
"stopAtEntry": true, | ||
"customLaunchSetupCommands": [ | ||
{ | ||
"text": "cd ${workspaceRoot}", | ||
"description": "attach", | ||
"ignoreFailures": false | ||
}, | ||
{ | ||
"text": "file ${workspaceRoot}/uf2-bootloader.elf", | ||
"description": "attach", | ||
"ignoreFailures": false | ||
}, | ||
{ | ||
"text": "target extended-remote localhost:3333", | ||
"description": "attach", | ||
"ignoreFailures": false | ||
} | ||
], | ||
"linux": { | ||
"MIMode": "gdb" | ||
}, | ||
"osx": { | ||
"miDebuggerPath": "/usr/local/bin/arm-none-eabi-gdb", | ||
"MIMode": "gdb" | ||
}, | ||
"windows": { | ||
"MIMode": "gdb" | ||
}, | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"files.associations": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "0.1.0", | ||
"command": "make", | ||
"isShellCommand": true, | ||
"args": [], | ||
"showOutput": "always" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Microsoft | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
Third Party Programs: The software may include third party programs that | ||
Microsoft, not the third party, licenses to you under this agreement. | ||
Notices, if any, for the third party programs are included for your | ||
information only. | ||
|
||
|
||
|
||
Otherwise, where noted: | ||
|
||
/* ---------------------------------------------------------------------------- | ||
* SAM Software Package License | ||
* ---------------------------------------------------------------------------- | ||
* Copyright (c) 2011-2014, Atmel Corporation | ||
* | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following condition is met: | ||
* | ||
* Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the disclaimer below. | ||
* | ||
* Atmel's name may not be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR | ||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE | ||
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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 contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
BOARD=dragoninjector | ||
-include Makefile.user | ||
include boards/$(BOARD)/board.mk | ||
CC=arm-none-eabi-gcc | ||
ifeq ($(CHIP_FAMILY), samd21) | ||
COMMON_FLAGS = -mthumb -mcpu=cortex-m0plus -Os -g -DSAMD21 | ||
endif | ||
ifeq ($(CHIP_FAMILY), samd51) | ||
COMMON_FLAGS = -mthumb -mcpu=cortex-m4 -O2 -g -DSAMD51 | ||
endif | ||
WFLAGS = \ | ||
-Werror -Wall -Wstrict-prototypes \ | ||
-Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 \ | ||
-ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 \ | ||
-Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch \ | ||
-Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wno-undef \ | ||
-Wbad-function-cast -Wwrite-strings -Waggregate-return \ | ||
-Wformat -Wmissing-format-attribute \ | ||
-Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs \ | ||
-Wlong-long -Wunreachable-code -Wcast-align \ | ||
-Wno-missing-braces -Wno-overflow -Wno-shadow -Wno-attributes -Wno-packed -Wno-pointer-sign | ||
CFLAGS = $(COMMON_FLAGS) \ | ||
-x c -c -pipe -nostdlib \ | ||
--param max-inline-insns-single=500 \ | ||
-fno-strict-aliasing -fdata-sections -ffunction-sections \ | ||
-D__$(CHIP_VARIANT)__ \ | ||
$(WFLAGS) | ||
|
||
UF2_VERSION_BASE = $(shell git describe --dirty --always --tags) | ||
|
||
ifeq ($(CHIP_FAMILY), samd21) | ||
LINKER_SCRIPT=scripts/samd21j18a.ld | ||
BOOTLOADER_SIZE=8192 | ||
SELF_LINKER_SCRIPT=scripts/samd21j18a_self.ld | ||
endif | ||
|
||
ifeq ($(CHIP_FAMILY), samd51) | ||
LINKER_SCRIPT=scripts/samd51j19a.ld | ||
BOOTLOADER_SIZE=16384 | ||
SELF_LINKER_SCRIPT=scripts/samd51j19a_self.ld | ||
endif | ||
|
||
LDFLAGS= $(COMMON_FLAGS) \ | ||
-Wall -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common \ | ||
-Wl,--warn-section-align \ | ||
-save-temps -nostartfiles \ | ||
--specs=nano.specs --specs=nosys.specs | ||
BUILD_PATH=build/$(BOARD) | ||
INCLUDES = -I. -I./inc -I./inc/preprocessor | ||
INCLUDES += -I./boards/$(BOARD) -Ilib/cmsis/CMSIS/Include -Ilib/usb_msc | ||
INCLUDES += -I$(BUILD_PATH) | ||
|
||
|
||
ifeq ($(CHIP_FAMILY), samd21) | ||
INCLUDES += -Ilib/samd21/samd21a/include/ | ||
endif | ||
|
||
ifeq ($(CHIP_FAMILY), samd51) | ||
ifeq ($(findstring SAME54,$(CHIP_VARIANT)),SAME54) | ||
INCLUDES += -Ilib/same54/include/ | ||
else | ||
INCLUDES += -Ilib/samd51/include/ | ||
endif | ||
endif | ||
|
||
COMMON_SRC = \ | ||
src/flash_$(CHIP_FAMILY).c \ | ||
src/init_$(CHIP_FAMILY).c \ | ||
src/startup_$(CHIP_FAMILY).c \ | ||
src/usart_sam_ba.c \ | ||
src/screen.c \ | ||
src/images.c \ | ||
src/utils.c | ||
|
||
SOURCES = $(COMMON_SRC) \ | ||
src/cdc_enumerate.c \ | ||
src/fat.c \ | ||
src/main.c \ | ||
src/msc.c \ | ||
src/sam_ba_monitor.c \ | ||
src/uart_driver.c \ | ||
src/hid.c \ | ||
|
||
SELF_SOURCES = $(COMMON_SRC) \ | ||
src/selfmain.c | ||
|
||
OBJECTS = $(patsubst src/%.c,$(BUILD_PATH)/%.o,$(SOURCES)) | ||
SELF_OBJECTS = $(patsubst src/%.c,$(BUILD_PATH)/%.o,$(SELF_SOURCES)) $(BUILD_PATH)/selfdata.o | ||
|
||
NAME=$(DI_BOOTLOADER_VERSION) | ||
EXECUTABLE=$(BUILD_PATH)/$(NAME).bin | ||
SELF_EXECUTABLE=$(BUILD_PATH)/Update_$(NAME).uf2 | ||
SELF_EXECUTABLE_INO=$(BUILD_PATH)/Update_$(NAME).ino | ||
|
||
SUBMODULES = lib/uf2/README.md | ||
|
||
all: $(SUBMODULES) dirs $(EXECUTABLE) $(SELF_EXECUTABLE) | ||
|
||
r: run | ||
b: burn | ||
l: logs | ||
|
||
burn: all | ||
node scripts/dbgtool.js fuses | ||
node scripts/dbgtool.js $(BUILD_PATH)/$(NAME).bin | ||
|
||
run: burn wait logs | ||
|
||
# This currently only works on macOS with a BMP debugger attached. | ||
# It's meant to flash the bootloader in a loop. | ||
BMP = $(shell ls -1 /dev/cu.usbmodem* | head -1) | ||
BMP_ARGS = --nx -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "target extended-remote $(BMP)" -ex "mon tpwr enable" -ex "mon swdp_scan" -ex "attach 1" | ||
GDB = arm-none-eabi-gdb | ||
|
||
bmp-flash: $(BUILD_PATH)/$(NAME).bin | ||
@test "X$(BMP)" != "X" | ||
$(GDB) $(BMP_ARGS) -ex "load" -ex "quit" $(BUILD_PATH)/$(NAME).elf | tee build/flash.log | ||
@grep -q "Transfer rate" build/flash.log | ||
|
||
bmp-flashone: | ||
while : ; do $(MAKE) bmp-flash && exit 0 ; sleep 1 ; done | ||
afplay /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/Error.aiff | ||
|
||
bmp-loop: | ||
while : ; do $(MAKE) bmp-flashone ; sleep 5 ; done | ||
|
||
bmp-gdb: $(BUILD_PATH)/$(NAME).bin | ||
$(GDB) $(BMP_ARGS) $(BUILD_PATH)/$(NAME).elf | ||
|
||
$(BUILD_PATH)/flash.jlink: $(BUILD_PATH)/$(NAME).bin | ||
echo " \n\ | ||
r \n\ | ||
h \n\ | ||
loadbin \"$(BUILD_PATH)/$(NAME).bin\", 0x0 \n\ | ||
verifybin \"$(BUILD_PATH)/$(NAME).bin\", 0x0 \n\ | ||
r \n\ | ||
qc \n\ | ||
" > $(BUILD_PATH)/flash.jlink | ||
|
||
jlink-flash: $(BUILD_PATH)/$(NAME).bin $(BUILD_PATH)/flash.jlink | ||
jlinkexe -if swd -device AT$(CHIP_VARIANT) -speed 4000 -CommanderScript $(BUILD_PATH)/flash.jlink | ||
|
||
wait: | ||
sleep 5 | ||
|
||
logs: | ||
node scripts/dbgtool.js $(BUILD_PATH)/$(NAME).map | ||
|
||
selflogs: | ||
node scripts/dbgtool.js $(BUILD_PATH)/Update_$(NAME).map | ||
|
||
dirs: | ||
@echo "Building $(BOARD)" | ||
-@mkdir -p $(BUILD_PATH) | ||
|
||
$(EXECUTABLE): $(OBJECTS) | ||
$(CC) -L$(BUILD_PATH) $(LDFLAGS) \ | ||
-T$(LINKER_SCRIPT) \ | ||
-Wl,-Map,$(BUILD_PATH)/$(NAME).map -o $(BUILD_PATH)/$(NAME).elf $(OBJECTS) | ||
arm-none-eabi-objcopy -O binary $(BUILD_PATH)/$(NAME).elf $@ | ||
@echo | ||
-@arm-none-eabi-size $(BUILD_PATH)/$(NAME).elf | awk '{ s=$$1+$$2; print } END { print ""; print "Space left: " ($(BOOTLOADER_SIZE)-s) }' | ||
@echo | ||
|
||
$(BUILD_PATH)/uf2_version.h: Makefile | ||
echo "#define UF2_VERSION_BASE \"$(UF2_VERSION_BASE)\""> $@ | ||
|
||
$(SELF_EXECUTABLE): $(SELF_OBJECTS) | ||
$(CC) -L$(BUILD_PATH) $(LDFLAGS) \ | ||
-T$(SELF_LINKER_SCRIPT) \ | ||
-Wl,-Map,$(BUILD_PATH)/Update_$(NAME).map -o $(BUILD_PATH)/Update_$(NAME).elf $(SELF_OBJECTS) | ||
arm-none-eabi-objcopy -O binary $(BUILD_PATH)/Update_$(NAME).elf $(BUILD_PATH)/Update_$(NAME).bin | ||
python2 lib/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -c -o $@ $(BUILD_PATH)/Update_$(NAME).bin | ||
|
||
$(BUILD_PATH)/%.o: src/%.c $(wildcard inc/*.h boards/*/*.h) $(BUILD_PATH)/uf2_version.h | ||
echo "$<" | ||
$(CC) $(CFLAGS) $(BLD_EXTA_FLAGS) $(INCLUDES) $< -o $@ | ||
|
||
$(BUILD_PATH)/%.o: $(BUILD_PATH)/%.c | ||
$(CC) $(CFLAGS) $(BLD_EXTA_FLAGS) $(INCLUDES) $< -o $@ | ||
|
||
$(BUILD_PATH)/selfdata.c: $(EXECUTABLE) scripts/gendata.py src/sketch.cpp | ||
python2 scripts/gendata.py $(BOOTLOADER_SIZE) $(EXECUTABLE) | ||
|
||
clean: | ||
rm -rf build | ||
|
||
gdb: | ||
arm-none-eabi-gdb $(BUILD_PATH)/$(NAME).elf | ||
|
||
tui: | ||
arm-none-eabi-gdb -tui $(BUILD_PATH)/$(NAME).elf | ||
|
||
%.asmdump: %.o | ||
arm-none-eabi-objdump -d $< > $@ | ||
|
||
applet0: $(BUILD_PATH)/flash.asmdump | ||
node scripts/genapplet.js $< flash_write | ||
|
||
applet1: $(BUILD_PATH)/utils.asmdump | ||
node scripts/genapplet.js $< resetIntoApp | ||
|
||
drop-board: all | ||
@echo "*** Copy files for $(BOARD)" | ||
mkdir -p build/drop | ||
rm -rf build/drop/$(BOARD) | ||
mkdir -p build/drop/$(BOARD) | ||
cp $(SELF_EXECUTABLE) build/drop/$(BOARD)/ | ||
cp $(EXECUTABLE) build/drop/$(BOARD)/ | ||
cp $(SELF_EXECUTABLE_INO) build/drop/$(BOARD)/ | ||
cp boards/$(BOARD)/board_config.h build/drop/$(BOARD)/ | ||
|
||
drop-pkg: | ||
mv build/drop build/uf2-samd21-$(UF2_VERSION_BASE) | ||
cp bin-README.md build/uf2-samd21-$(UF2_VERSION_BASE)/README.md | ||
cd build; 7z a uf2-samd21-$(UF2_VERSION_BASE).zip uf2-samd21-$(UF2_VERSION_BASE) | ||
rm -rf build/uf2-samd21-$(UF2_VERSION_BASE) | ||
|
||
all-boards: | ||
for f in `cd boards; ls` ; do "$(MAKE)" BOARD=$$f drop-board || break; done | ||
|
||
drop: all-boards drop-pkg | ||
|
||
$(SUBMODULES): | ||
git submodule update --init --recursive |
Oops, something went wrong.