From 9121680204c9b8a1caf12995a35ebaa8d2306838 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 21 Feb 2022 15:13:29 +0100 Subject: [PATCH 1/2] cpu/sam0_common: decode model number --- cpu/sam0_common/sam0_info.mk | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cpu/sam0_common/sam0_info.mk diff --git a/cpu/sam0_common/sam0_info.mk b/cpu/sam0_common/sam0_info.mk new file mode 100644 index 0000000000..7113168db3 --- /dev/null +++ b/cpu/sam0_common/sam0_info.mk @@ -0,0 +1,14 @@ +# Extract SAM0 infos from CPU_MODEL +# Example for saml21e15b +# - SAM0_FAMILY: l +# - SAM0_SERIES: 21 +# - SAM0_PINCNT: e (32 Pins) +# - SAM0_DENSITY: 15 (32k Flash) +# - SAM0_VARIANT: b (release stepping) + +SAM0_INFO := $(shell echo $(CPU_MODEL) | sed -E -e 's/^sam(d|e|l|r)([0-9][0-9])([a-z])([0-9][0-9])(.)?/\1 \2 \3 \4 \5/') +SAM0_FAMILY := $(word 1, $(SAM0_INFO)) +SAM0_SERIES := $(word 2, $(SAM0_INFO)) +SAM0_PINCNT := $(word 3, $(SAM0_INFO)) +SAM0_DENSITY := $(word 4, $(SAM0_INFO)) +SAM0_VARIANT := $(word 5, $(SAM0_INFO)) From c44cf1423e0b8dfb8f00c7a530e4ca6105f729d0 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 21 Feb 2022 15:14:35 +0100 Subject: [PATCH 2/2] cpu/saml21: derive low power SRAM length from model number --- cpu/saml21/Makefile.include | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cpu/saml21/Makefile.include b/cpu/saml21/Makefile.include index 1bd1b002dd..97493cfa5d 100644 --- a/cpu/saml21/Makefile.include +++ b/cpu/saml21/Makefile.include @@ -1,3 +1,5 @@ +include $(RIOTCPU)/sam0_common/sam0_info.mk + ifneq (,$(filter saml21%a,$(CPU_MODEL))) CFLAGS += -DCPU_SAML21A endif @@ -13,9 +15,15 @@ endif CFLAGS += -DCPU_COMMON_SAML21 -ifneq (,$(filter saml21j18b saml21j18a samr30g18a samr34j18b,$(CPU_MODEL))) - BACKUP_RAM_ADDR = 0x30000000 - BACKUP_RAM_LEN = 0x2000 +BACKUP_RAM_ADDR = 0x30000000 +ifeq (18, $(SAM0_DENSITY)) + BACKUP_RAM_LEN = 0x2000 # 8k +else ifeq (17, $(SAM0_DENSITY)) + BACKUP_RAM_LEN = 0x2000 # 8k +else ifeq (16, $(SAM0_DENSITY)) + BACKUP_RAM_LEN = 0x1000 # 4k +else ifeq (15, $(SAM0_DENSITY)) + BACKUP_RAM_LEN = 0x800 # 2k endif include $(RIOTCPU)/sam0_common/Makefile.include