From 72e311b7908ec32ffd62e23cb2a23935b1f2849e Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 23 Feb 2018 15:39:48 -0500 Subject: [PATCH 1/4] fix CPX neopixel glitch: don't set neopixels when clock speed is wrong --- src/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.c b/src/utils.c index 9ec4d470..7a8c6133 100644 --- a/src/utils.c +++ b/src/utils.c @@ -148,10 +148,10 @@ void led_init() { // using APA102, set pins to outputs PINOP(BOARD_RGBLED_CLOCK_PIN, DIRSET); PINOP(BOARD_RGBLED_DATA_PIN, DIRSET); -#endif // This won't work for neopixel, because we're running at 1MHz or thereabouts... RGBLED_set_color(COLOR_LEAVE); +#endif } #if defined(BOARD_RGBLED_CLOCK_PIN) From 66346bcb1504697ebf3bb91c70cfeae5f7037135 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 13 Mar 2018 20:34:39 -0500 Subject: [PATCH 2/4] Fix for stack corruption occuring when the bootloader executes an applet. --- src/sam_ba_monitor.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/sam_ba_monitor.c b/src/sam_ba_monitor.c index 20e71796..2e7b2999 100644 --- a/src/sam_ba_monitor.c +++ b/src/sam_ba_monitor.c @@ -94,9 +94,7 @@ volatile uint32_t sp; void call_applet(uint32_t address) { uint32_t app_start_address; - __disable_irq(); - __DMB(); - + /* Save current Stack Pointer */ sp = __get_MSP(); /* Rebase the Stack Pointer */ @@ -106,7 +104,10 @@ void call_applet(uint32_t address) { app_start_address = *(uint32_t *)(address + 4); /* Jump to application Reset Handler in the application */ - asm("bx %0" ::"r"(app_start_address)); + asm("blx %0" ::"r"(app_start_address):"r0","r1","r2","r3","lr"); + + /* Rebase the Stack Pointer */ + __set_MSP(sp); } uint32_t current_number; @@ -193,10 +194,6 @@ void sam_ba_monitor_run(void) { sam_ba_putdata_term((uint8_t *)¤t_number, 4); } else if (command == 'G') { call_applet(current_number); - /* Rebase the Stack Pointer */ - __set_MSP(sp); - __DMB(); - __enable_irq(); if (b_sam_ba_interface_usart) { cdc_write_buf("\x06", 1); } From 8c98abd6b08504ff6b21149b0ee5935a9afde36d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 20 Mar 2018 13:19:37 -0400 Subject: [PATCH 3/4] Update metro_m4 to rev F pins. Save rev B in metro_m4_revb. --- boards/metro_m4/board_config.h | 18 ++++++++--------- boards/metro_m4_revb/board.mk | 2 ++ boards/metro_m4_revb/board_config.h | 31 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 boards/metro_m4_revb/board.mk create mode 100644 boards/metro_m4_revb/board_config.h diff --git a/boards/metro_m4/board_config.h b/boards/metro_m4/board_config.h index 4d7a90ee..9e0a3174 100644 --- a/boards/metro_m4/board_config.h +++ b/boards/metro_m4/board_config.h @@ -10,22 +10,22 @@ #define USB_VID 0x239A #define USB_PID 0x0021 -#define LED_PIN PIN_PA21 +#define LED_PIN PIN_PA16 #define LED_TX_PIN PIN_PA27 #define LED_RX_PIN PIN_PB06 -#define BOARD_NEOPIXEL_PIN PIN_PB17 +#define BOARD_NEOPIXEL_PIN PIN_PB22 #define BOARD_NEOPIXEL_COUNT 1 -#define BOOT_USART_MODULE SERCOM0 +#define BOOT_USART_MODULE SERCOM3 #define BOOT_USART_MASK APBAMASK -#define BOOT_USART_BUS_CLOCK_INDEX MCLK_APBAMASK_SERCOM0 -#define BOOT_USART_PAD_SETTINGS UART_RX_PAD3_TX_PAD2 +#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_PA10C_SERCOM0_PAD2 -#define BOOT_USART_PAD0 PINMUX_PA11C_SERCOM0_PAD3 -#define BOOT_GCLK_ID_CORE SERCOM0_GCLK_ID_CORE -#define BOOT_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW +#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 #endif diff --git a/boards/metro_m4_revb/board.mk b/boards/metro_m4_revb/board.mk new file mode 100644 index 00000000..c17f5fba --- /dev/null +++ b/boards/metro_m4_revb/board.mk @@ -0,0 +1,2 @@ +CHIP_FAMILY = samd51 +CHIP_VARIANT = SAMD51J19A diff --git a/boards/metro_m4_revb/board_config.h b/boards/metro_m4_revb/board_config.h new file mode 100644 index 00000000..9fc4e37a --- /dev/null +++ b/boards/metro_m4_revb/board_config.h @@ -0,0 +1,31 @@ +#ifndef BOARD_CONFIG_H +#define BOARD_CONFIG_H + +#define VENDOR_NAME "Adafruit Industries" +#define PRODUCT_NAME "Metro M4 Rev B" +#define VOLUME_LABEL "METROM4BOOT" +#define INDEX_URL "http://adafru.it/3505" +#define BOARD_ID "SAMD51J19A-Metro-v0" + +#define USB_VID 0x239A +#define USB_PID 0x0021 + +#define LED_PIN PIN_PA21 +#define LED_TX_PIN PIN_PA27 +#define LED_RX_PIN PIN_PB06 + +#define BOARD_NEOPIXEL_PIN PIN_PB17 +#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_PAD2 +#define BOOT_USART_PAD3 PINMUX_UNUSED +#define BOOT_USART_PAD2 PINMUX_UNUSED +#define BOOT_USART_PAD1 PINMUX_PA10C_SERCOM0_PAD2 +#define BOOT_USART_PAD0 PINMUX_PA11C_SERCOM0_PAD3 +#define BOOT_GCLK_ID_CORE SERCOM0_GCLK_ID_CORE +#define BOOT_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW + +#endif From bfc2ca5333ec4c536a9346997a26c2f2e3a466c6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 20 Mar 2018 14:06:22 -0400 Subject: [PATCH 4/4] Makefile did not end with a newline --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1640466b..12d48bbd 100644 --- a/Makefile +++ b/Makefile @@ -182,4 +182,4 @@ all-boards: drop: all-boards drop-pkg $(SUBMODULES): - git submodule update --init --recursive \ No newline at end of file + git submodule update --init --recursive