From 14d69e46be7b875fef534d70e619764df63f023d Mon Sep 17 00:00:00 2001 From: mndza Date: Tue, 27 Jun 2023 12:05:59 +0200 Subject: [PATCH] Update support for Cynthion boards - Rename LUNA to Cynthion - Add support for newer revisions (>=0.6) - Bootloader (saturn-v) default size is now 2K --- docs/reference/supported.rst | 2 +- .../boards/{luna_d11 => cynthion_d11}/board.h | 6 +++++ hw/bsp/samd11/boards/cynthion_d11/board.mk | 22 +++++++++++++++++++ .../samd11d14am_flash.ld | 2 +- hw/bsp/samd11/boards/luna_d11/board.mk | 11 ---------- hw/bsp/samd11/boards/samd11_xplained/board.h | 1 + hw/bsp/samd11/family.c | 2 +- .../boards/{luna_d21 => cynthion_d21}/board.h | 0 .../{luna_d21 => cynthion_d21}/board.mk | 6 +++++ .../samd21g18a_flash.ld | 2 +- 10 files changed, 39 insertions(+), 15 deletions(-) rename hw/bsp/samd11/boards/{luna_d11 => cynthion_d11}/board.h (87%) create mode 100644 hw/bsp/samd11/boards/cynthion_d11/board.mk rename hw/bsp/samd11/boards/{luna_d11 => cynthion_d11}/samd11d14am_flash.ld (97%) delete mode 100644 hw/bsp/samd11/boards/luna_d11/board.mk rename hw/bsp/samd21/boards/{luna_d21 => cynthion_d21}/board.h (100%) rename hw/bsp/samd21/boards/{luna_d21 => cynthion_d21}/board.mk (60%) rename hw/bsp/samd21/boards/{luna_d21 => cynthion_d21}/samd21g18a_flash.ld (97%) diff --git a/docs/reference/supported.rst b/docs/reference/supported.rst index a5d055893..aed64782c 100644 --- a/docs/reference/supported.rst +++ b/docs/reference/supported.rst @@ -175,7 +175,7 @@ SAMD11 & SAMD21 - `Adafruit Feather M0 Express `__ - `Adafruit ItsyBitsy M0 Express `__ - `Adafruit Metro M0 Express `__ -- `Great Scott Gadgets LUNA `__ +- `Great Scott Gadgets Cynthion `__ - `Microchip SAMD11 Xplained Pro `__ - `Microchip SAMD21 Xplained Pro `__ - `Seeeduino Xiao `__ diff --git a/hw/bsp/samd11/boards/luna_d11/board.h b/hw/bsp/samd11/boards/cynthion_d11/board.h similarity index 87% rename from hw/bsp/samd11/boards/luna_d11/board.h rename to hw/bsp/samd11/boards/cynthion_d11/board.h index 1bda92934..b13c8eeea 100644 --- a/hw/bsp/samd11/boards/luna_d11/board.h +++ b/hw/bsp/samd11/boards/cynthion_d11/board.h @@ -36,7 +36,13 @@ #define LED_STATE_ON 0 // Button +#if ((_BOARD_REVISION_MAJOR_ == 0) && (_BOARD_REVISION_MINOR_ < 6)) #define BUTTON_PIN PIN_PA16 // pin PB22 +#define BUTTON_PULL_MODE GPIO_PULL_UP +#else +#define BUTTON_PIN PIN_PA02 +#define BUTTON_PULL_MODE GPIO_PULL_OFF +#endif #define BUTTON_STATE_ACTIVE 0 #ifdef __cplusplus diff --git a/hw/bsp/samd11/boards/cynthion_d11/board.mk b/hw/bsp/samd11/boards/cynthion_d11/board.mk new file mode 100644 index 000000000..d36c91970 --- /dev/null +++ b/hw/bsp/samd11/boards/cynthion_d11/board.mk @@ -0,0 +1,22 @@ +BOARD_REVISION_MAJOR ?= 1 +BOARD_REVISION_MINOR ?= 0 + +CFLAGS += -D__SAMD11D14AM__ \ + -D_BOARD_REVISION_MAJOR_=$(BOARD_REVISION_MAJOR) \ + -D_BOARD_REVISION_MINOR_=$(BOARD_REVISION_MINOR) + +# All source paths should be relative to the top level. +LD_FILE = $(BOARD_PATH)/samd11d14am_flash.ld + +# Default bootloader size is now 2K, allow to specify other +ifeq ($(BOOTLOADER_SIZE), ) + BOOTLOADER_SIZE := 0x800 +endif +LDFLAGS += -Wl,--defsym=BOOTLOADER_SIZE=$(BOOTLOADER_SIZE) + +# For flash-jlink target +JLINK_DEVICE = ATSAMD11D14 + +# flash using dfu-util +flash: $(BUILD)/$(PROJECT).bin + dfu-util -a 0 -d 1d50:615c -D $< || dfu-util -a 0 -d 16d0:05a5 -D $< diff --git a/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld b/hw/bsp/samd11/boards/cynthion_d11/samd11d14am_flash.ld similarity index 97% rename from hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld rename to hw/bsp/samd11/boards/cynthion_d11/samd11d14am_flash.ld index cb633c195..f175e6504 100644 --- a/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld +++ b/hw/bsp/samd11/boards/cynthion_d11/samd11d14am_flash.ld @@ -35,7 +35,7 @@ SEARCH_DIR(.) /* Memory Spaces Definitions */ MEMORY { - rom (rx) : ORIGIN = 0x00000000 + 4K, LENGTH = 0x00004000 - 4K + rom (rx) : ORIGIN = 0x00000000 + BOOTLOADER_SIZE, LENGTH = 0x00004000 - BOOTLOADER_SIZE ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00001000 } diff --git a/hw/bsp/samd11/boards/luna_d11/board.mk b/hw/bsp/samd11/boards/luna_d11/board.mk deleted file mode 100644 index ad9cfb25d..000000000 --- a/hw/bsp/samd11/boards/luna_d11/board.mk +++ /dev/null @@ -1,11 +0,0 @@ -CFLAGS += -D__SAMD11D14AM__ - -# All source paths should be relative to the top level. -LD_FILE = $(BOARD_PATH)/samd11d14am_flash.ld - -# For flash-jlink target -JLINK_DEVICE = ATSAMD11D14 - -# flash using dfu-util -flash: $(BUILD)/$(PROJECT).bin - dfu-util -a 0 -d 1d50:615c -D $< || dfu-util -a 0 -d 16d0:05a5 -D $< diff --git a/hw/bsp/samd11/boards/samd11_xplained/board.h b/hw/bsp/samd11/boards/samd11_xplained/board.h index cfeac673c..2bbec4958 100644 --- a/hw/bsp/samd11/boards/samd11_xplained/board.h +++ b/hw/bsp/samd11/boards/samd11_xplained/board.h @@ -38,6 +38,7 @@ // Button #define BUTTON_PIN PIN_PA14 // pin PB22 #define BUTTON_STATE_ACTIVE 0 +#define BUTTON_PULL_MODE GPIO_PULL_UP #ifdef __cplusplus } diff --git a/hw/bsp/samd11/family.c b/hw/bsp/samd11/family.c index 8d9633971..e232761cc 100644 --- a/hw/bsp/samd11/family.c +++ b/hw/bsp/samd11/family.c @@ -78,7 +78,7 @@ void board_init(void) // Button init gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN); - gpio_set_pin_pull_mode(BUTTON_PIN, GPIO_PULL_UP); + gpio_set_pin_pull_mode(BUTTON_PIN, BUTTON_PULL_MODE); /* USB Clock init * The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock diff --git a/hw/bsp/samd21/boards/luna_d21/board.h b/hw/bsp/samd21/boards/cynthion_d21/board.h similarity index 100% rename from hw/bsp/samd21/boards/luna_d21/board.h rename to hw/bsp/samd21/boards/cynthion_d21/board.h diff --git a/hw/bsp/samd21/boards/luna_d21/board.mk b/hw/bsp/samd21/boards/cynthion_d21/board.mk similarity index 60% rename from hw/bsp/samd21/boards/luna_d21/board.mk rename to hw/bsp/samd21/boards/cynthion_d21/board.mk index 508a72b1f..52c9d60cb 100644 --- a/hw/bsp/samd21/boards/luna_d21/board.mk +++ b/hw/bsp/samd21/boards/cynthion_d21/board.mk @@ -2,6 +2,12 @@ CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY LD_FILE = $(BOARD_PATH)/samd21g18a_flash.ld +# Default bootloader size is now 2K, allow to specify other +ifeq ($(BOOTLOADER_SIZE), ) + BOOTLOADER_SIZE := 0x800 +endif +LDFLAGS += -Wl,--defsym=BOOTLOADER_SIZE=$(BOOTLOADER_SIZE) + # For flash-jlink target JLINK_DEVICE = ATSAMD21G18 diff --git a/hw/bsp/samd21/boards/luna_d21/samd21g18a_flash.ld b/hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld similarity index 97% rename from hw/bsp/samd21/boards/luna_d21/samd21g18a_flash.ld rename to hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld index 158593036..ecb6b8523 100644 --- a/hw/bsp/samd21/boards/luna_d21/samd21g18a_flash.ld +++ b/hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld @@ -35,7 +35,7 @@ SEARCH_DIR(.) /* Memory Spaces Definitions */ MEMORY { - rom (rx) : ORIGIN = 0x00000000 + 4K, LENGTH = 0x00040000 - 4K + rom (rx) : ORIGIN = 0x00000000 + BOOTLOADER_SIZE, LENGTH = 0x00040000 - BOOTLOADER_SIZE ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 }