Skip to content

Commit

Permalink
Merge pull request #49 from adafruit/upstream-merge-2019-04
Browse files Browse the repository at this point in the history
Merge from microsoft/uf2-samdx1; fuse repair
  • Loading branch information
dhalbert authored Apr 15, 2019
2 parents 5193a1a + a2fa250 commit b9e9e70
Show file tree
Hide file tree
Showing 29 changed files with 1,283 additions and 36 deletions.
25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ 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 -Wl,--warn-unresolved-symbols \
-Wl,--warn-section-align \
-save-temps -nostartfiles \
--specs=nano.specs --specs=nosys.specs
BUILD_PATH=build/$(BOARD)
Expand All @@ -64,6 +64,8 @@ COMMON_SRC = \
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) \
Expand Down Expand Up @@ -100,6 +102,27 @@ burn: all

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 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

wait:
sleep 5

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ to temporarily turn off the protection. In gdb the command is:

* `make` and an Unix environment
* `node`.js in path (optional)
* `arm-none-eabi-gcc` in the path (the one coming with Yotta will do just fine)
* `arm-none-eabi-gcc` in the path (the one coming with Yotta will do just fine). You can get the latest version from ARM: https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
* `openocd` - you can use the one coming with Arduino (after your install the M0 board support)

Atmel Studio is not supported.
Expand Down
2 changes: 2 additions & 0 deletions boards/CC03/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHIP_FAMILY = samd21
CHIP_VARIANT = SAMD21G18A
16 changes: 16 additions & 0 deletions boards/CC03/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define VENDOR_NAME "XinaBox Limited"
#define PRODUCT_NAME "CC03"
#define VOLUME_LABEL "CC03"
#define INDEX_URL "https://xinabox.cc/products/cc03"

#define BOARD_ID "SAMD21G18A-CC03-v0"

//#define USB_VID 0x2341
//#define USB_PID 0x024D

#define LED_PIN PIN_PA07

#endif
2 changes: 2 additions & 0 deletions boards/CS11/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHIP_FAMILY = samd21
CHIP_VARIANT = SAMD21G18A
16 changes: 16 additions & 0 deletions boards/CS11/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define VENDOR_NAME "XinaBox Limited"
#define PRODUCT_NAME "CS11"
#define VOLUME_LABEL "CS11"
#define INDEX_URL "https://xinabox.cc/products/cc11"

#define BOARD_ID "SAMD21G18A-CS11-v0"

//#define USB_VID 0x2341
//#define USB_PID 0x024D

#define LED_PIN PIN_PA08

#endif
2 changes: 2 additions & 0 deletions boards/arcade_badge/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHIP_FAMILY = samd51
CHIP_VARIANT = SAMD51J19A
110 changes: 110 additions & 0 deletions boards/arcade_badge/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define VENDOR_NAME "Adafruit Industries"
#define PRODUCT_NAME "Arcade D51"
#define VOLUME_LABEL "ARCADE-D5"
#define INDEX_URL "http://adafru.it/"
#define BOARD_ID "SAMD51J19A-Arcade-D51"

#define USB_VID 0x239A
#define USB_PID 0x002B

#define LED_PIN PIN_PA23

#define BOARD_NEOPIXEL_PIN PIN_PA15
#define BOARD_NEOPIXEL_COUNT 5

#define BOARD_SCREEN 1

#define BOOT_USART_MODULE SERCOM3
#define BOOT_USART_MASK APBAMASK
#define BOOT_USART_BUS_CLOCK_INDEX MCLK_APBBMASK_SERCOM3
#define BOOT_USART_PAD_SETTINGS UART_RX_PAD1_TX_PAD0
#define BOOT_USART_PAD3 PINMUX_UNUSED
#define BOOT_USART_PAD2 PINMUX_UNUSED
#define BOOT_USART_PAD1 PINMUX_PA22C_SERCOM3_PAD0
#define BOOT_USART_PAD0 PINMUX_PA23C_SERCOM3_PAD1
#define BOOT_GCLK_ID_CORE SERCOM3_GCLK_ID_CORE
#define BOOT_GCLK_ID_SLOW SERCOM3_GCLK_ID_SLOW


#define HAS_CONFIG_DATA 1

// This configuration data should be edited at https://microsoft.github.io/uf2/patcher/
// Just drop this file there.
// Alternatively, it can be also binary edited there after the bootloader is compiled.

#ifdef DEFINE_CONFIG_DATA
const uint32_t config_data[] = {
/* CF2 START */
513675505, 539130489, // magic
60, 100, // used entries, total entries
1, 0x2e, // PIN_ACCELEROMETER_INT = PB14
2, 0xd, // PIN_ACCELEROMETER_SCL = PIN_SCL
3, 0xc, // PIN_ACCELEROMETER_SDA = PIN_SDA
4, 0x3ef, // PIN_BTN_A = P_1007
5, 0x3ee, // PIN_BTN_B = P_1006
13, 0x17, // PIN_LED = PIN_D13
18, 0x36, // PIN_MISO = PB22
19, 0x37, // PIN_MOSI = PB23
20, 0xf, // PIN_NEOPIXEL = PA15
21, 0x11, // PIN_RX = PA17
23, 0x11, // PIN_SCK = PA17
24, 0xd, // PIN_SCL = PA13
25, 0xc, // PIN_SDA = PA12
28, 0x10, // PIN_TX = PA16
32, 0x2d, // PIN_DISPLAY_SCK = PB13
34, 0x2c, // PIN_DISPLAY_MOSI = PB12
35, 0x27, // PIN_DISPLAY_CS = PB07
36, 0x25, // PIN_DISPLAY_DC = PB05
37, 0xa0, // DISPLAY_WIDTH = 160
38, 0x80, // DISPLAY_HEIGHT = 128
39, 0x80, // DISPLAY_CFG0 = 0x80
40, 0x12c2d, // DISPLAY_CFG1 = 0x12c2d
41, 0x18, // DISPLAY_CFG2 = 0x18
43, 0x1, // PIN_DISPLAY_RST = PA01
44, 0x0, // PIN_DISPLAY_BL = PA00
47, 0x3e8, // PIN_BTN_LEFT = P_1000
48, 0x3eb, // PIN_BTN_RIGHT = P_1003
49, 0x3e9, // PIN_BTN_UP = P_1001
50, 0x3ea, // PIN_BTN_DOWN = P_1002
51, 0x3ec, // PIN_BTN_MENU = P_1004
59, 0x200, // SPEAKER_VOLUME = 512
60, 0x10, // PIN_JACK_TX = PIN_D5
65, 0x2, // PIN_JACK_SND = PIN_A0
69, 0x3ed, // PIN_BTN_SOFT_RESET = P_1005
70, 0x32, // ACCELEROMETER_TYPE = LIS3DH
71, 0x20, // PIN_BTNMX_LATCH = PB00
72, 0x3f, // PIN_BTNMX_CLOCK = PB31
73, 0x3e, // PIN_BTNMX_DATA = PB30
100, 0x2, // PIN_A0 = PA02
101, 0x5, // PIN_A1 = PA05
102, 0x28, // PIN_A2 = PB08
103, 0x29, // PIN_A3 = PB09
104, 0x4, // PIN_A4 = PA04
105, 0x6, // PIN_A5 = PA06
152, 0x23, // PIN_D2 = PB03
153, 0x22, // PIN_D3 = PB02
154, 0xe, // PIN_D4 = PA14
155, 0x10, // PIN_D5 = PA16
156, 0x12, // PIN_D6 = PA18
159, 0x13, // PIN_D9 = PA19
160, 0x14, // PIN_D10 = PA20
161, 0x15, // PIN_D11 = PA21
162, 0x16, // PIN_D12 = PA22
163, 0x17, // PIN_D13 = PA23
200, 0x5, // NUM_NEOPIXELS = 5
204, 0x80000, // FLASH_BYTES = 0x80000
205, 0x30000, // RAM_BYTES = 0x30000
208, 0x18591ab9, // BOOTLOADER_BOARD_ID = 0x18591ab9
209, 0x55114460, // UF2_FAMILY = ATSAMD51
210, 0x20, // PINS_PORT_SIZE = PA_32
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* CF2 END */
};
#endif

#endif
2 changes: 2 additions & 0 deletions boards/arcade_feather_m4/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHIP_FAMILY = samd51
CHIP_VARIANT = SAMD51J19A
106 changes: 106 additions & 0 deletions boards/arcade_feather_m4/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define VENDOR_NAME "Adafruit Industries"
#define PRODUCT_NAME "Feather Arcade D51"
#define VOLUME_LABEL "ARCADE-D5"
#define INDEX_URL "https://arcade.makecode.com/"
#define BOARD_ID "SAMD51J19A-Feather-Arcade-D51"


#define USB_VID 0x239A
#define USB_PID 0x0022

#define LED_PIN PIN_PA23

#define BOARD_NEOPIXEL_PIN PIN_PB03
#define BOARD_NEOPIXEL_COUNT 1

#define BOOT_USART_MODULE SERCOM0
#define BOOT_USART_MASK APBAMASK
#define BOOT_USART_BUS_CLOCK_INDEX MCLK_APBAMASK_SERCOM0
#define BOOT_USART_PAD_SETTINGS UART_RX_PAD3_TX_PAD0
#define BOOT_USART_PAD3 PINMUX_PA07D_SERCOM0_PAD3
#define BOOT_USART_PAD2 PINMUX_UNUSED
#define BOOT_USART_PAD1 PINMUX_UNUSED
#define BOOT_USART_PAD0 PINMUX_PA04D_SERCOM0_PAD0
#define BOOT_GCLK_ID_CORE SERCOM0_GCLK_ID_CORE
#define BOOT_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW

#define HAS_CONFIG_DATA 1
#define BOARD_SCREEN 1


// This configuration data should be edited at https://microsoft.github.io/uf2/patcher/
// Just drop this file there.
// Alternatively, it can be also binary edited there after the bootloader is compiled.

#ifdef DEFINE_CONFIG_DATA
const uint32_t config_data[] = {
/* CF2 START */
513675505, 539130489, // magic
53, 100, // used entries, total entries
4, 0xd, // PIN_BTN_A = PIN_SCL
5, 0x12, // PIN_BTN_B = PIN_D6
13, 0x17, // PIN_LED = PIN_D13
18, 0x36, // PIN_MISO = PB22
19, 0x37, // PIN_MOSI = PB23
20, 0x23, // PIN_NEOPIXEL = PB03
21, 0x31, // PIN_RX = PB17
23, 0x11, // PIN_SCK = PA17
24, 0xd, // PIN_SCL = PA13
25, 0xc, // PIN_SDA = PA12
26, 0xe, // PIN_SPEAKER_AMP = PIN_D4
28, 0x30, // PIN_TX = PB16
32, 0x11, // PIN_DISPLAY_SCK = PIN_SCK
33, 0x36, // PIN_DISPLAY_MISO = PIN_MISO
34, 0x37, // PIN_DISPLAY_MOSI = PIN_MOSI
35, 0x28, // PIN_DISPLAY_CS = PIN_A2
36, 0x29, // PIN_DISPLAY_DC = PIN_A3
37, 0xa0, // DISPLAY_WIDTH = 160
38, 0x80, // DISPLAY_HEIGHT = 128
39, 0x90, // DISPLAY_CFG0 = 0x90
40, 0xe14ff, // DISPLAY_CFG1 = 0xe14ff
41, 0x18, // DISPLAY_CFG2 = 0x18
43, 0x4, // PIN_DISPLAY_RST = PIN_A4
44, 0x6, // PIN_DISPLAY_BL = PIN_A5
47, 0x15, // PIN_BTN_LEFT = PIN_D11
48, 0x13, // PIN_BTN_RIGHT = PIN_D9
49, 0x14, // PIN_BTN_UP = PIN_D10
50, 0x16, // PIN_BTN_DOWN = PIN_D12
51, 0xc, // PIN_BTN_MENU = PIN_SDA
59, 0x200, // SPEAKER_VOLUME = 512
60, 0x30, // PIN_JACK_TX = PIN_D1
100, 0x2, // PIN_A0 = PA02
101, 0x5, // PIN_A1 = PA05
102, 0x28, // PIN_A2 = PB08
103, 0x29, // PIN_A3 = PB09
104, 0x4, // PIN_A4 = PA04
105, 0x6, // PIN_A5 = PA06
150, 0x31, // PIN_D0 = PB17
151, 0x30, // PIN_D1 = PB16
154, 0xe, // PIN_D4 = PA14
155, 0x10, // PIN_D5 = PA16
156, 0x12, // PIN_D6 = PA18
159, 0x13, // PIN_D9 = PA19
160, 0x14, // PIN_D10 = PA20
161, 0x15, // PIN_D11 = PA21
162, 0x16, // PIN_D12 = PA22
163, 0x17, // PIN_D13 = PA23
200, 0x1, // NUM_NEOPIXELS = 1
204, 0x80000, // FLASH_BYTES = 0x80000
205, 0x30000, // RAM_BYTES = 0x30000
208, 0x2b9e3d05, // BOOTLOADER_BOARD_ID = 0x2b9e3d05
209, 0x55114460, // UF2_FAMILY = ATSAMD51
210, 0x20, // PINS_PORT_SIZE = PA_32
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* CF2 END */
};
#endif

#endif



7 changes: 7 additions & 0 deletions boards/arcade_itsybitsy_m4/altkeys.cf2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PIN_BTN_A = PIN_D10
PIN_BTN_B = PIN_D11
PIN_BTN_LEFT = PIN_SDA
PIN_BTN_UP = PIN_D7
PIN_BTN_RIGHT = PIN_SCL
PIN_BTN_DOWN = PIN_D9
PIN_BTN_MENU = PIN_D12
2 changes: 2 additions & 0 deletions boards/arcade_itsybitsy_m4/altscreen.cf2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DISPLAY_CFG0 = 0x01000080
DISPLAY_CFG1 = 0x00000603
2 changes: 2 additions & 0 deletions boards/arcade_itsybitsy_m4/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHIP_FAMILY = samd51
CHIP_VARIANT = SAMD51G19A
Loading

0 comments on commit b9e9e70

Please sign in to comment.