Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/efm32: cleanup #13174

Merged
merged 10 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/ikea-tradfri/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CPU = efm32
CPU_FAM = efr32mg1p
CPU_MODEL = efr32mg1p132f256gm32

# Put defined MCU peripherals here (in alphabetical order)
Expand Down
1 change: 1 addition & 0 deletions boards/slstk3401a/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CPU = efm32
CPU_FAM = efm32pg1b
CPU_MODEL = efm32pg1b200f256gm48

# Put defined MCU peripherals here (in alphabetical order)
Expand Down
1 change: 1 addition & 0 deletions boards/slstk3402a/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CPU = efm32
CPU_FAM = efm32pg12b
CPU_MODEL = efm32pg12b500f1024gl125

# Put defined MCU peripherals here (in alphabetical order)
Expand Down
1 change: 1 addition & 0 deletions boards/sltb001a/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CPU = efm32
CPU_FAM = efr32mg1p
CPU_MODEL = efr32mg1p132f256gm48

# Put defined MCU peripherals here (in alphabetical order)
Expand Down
1 change: 1 addition & 0 deletions boards/slwstk6000b-slwrb4150a/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# HACK this should be deduced from the daughter board in 'common/slwstk6000b'
CPU_FAM = efr32mg1p
CPU_MODEL = efr32mg1p233f256gm48
include $(RIOTBOARD)/common/slwstk6000b/Makefile.features
1 change: 1 addition & 0 deletions boards/slwstk6000b-slwrb4162a/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# HACK this should be deduced from the daughter board in 'common/slwstk6000b'
CPU_FAM = efr32mg12p
CPU_MODEL = efr32mg12p332f1024gl125
include $(RIOTBOARD)/common/slwstk6000b/Makefile.features
1 change: 1 addition & 0 deletions boards/stk3600/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CPU = efm32
CPU_FAM = efm32lg
CPU_MODEL = efm32lg990f256

# Put defined MCU peripherals here (in alphabetical order)
Expand Down
1 change: 1 addition & 0 deletions boards/stk3700/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CPU = efm32
CPU_FAM = efm32gg
CPU_MODEL = efm32gg990f1024

# Put defined MCU peripherals here (in alphabetical order)
Expand Down
22 changes: 21 additions & 1 deletion cpu/efm32/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
MODULE = cpu

# add a list of subdirectories, that should also be build
DIRS = periph families/$(EFM32_FAMILY) $(RIOTCPU)/cortexm_common
DIRS += periph
DIRS += $(RIOTCPU)/cortexm_common

ifneq (,$(filter cpu_efm32gg,$(USEMODULE)))
DIRS += families/efm32gg
endif
ifneq (,$(filter cpu_efm32lg,$(USEMODULE)))
DIRS += families/efm32lg
endif
ifneq (,$(filter cpu_efm32pg1b,$(USEMODULE)))
DIRS += families/efm32pg1b
endif
ifneq (,$(filter cpu_efm32pg12b,$(USEMODULE)))
DIRS += families/efm32pg12b
endif
ifneq (,$(filter cpu_efr32mg1p,$(USEMODULE)))
DIRS += families/efr32mg1p
endif
ifneq (,$(filter cpu_efr32mg12p,$(USEMODULE)))
DIRS += families/efr32mg12p
endif

include $(RIOTBASE)/Makefile.base
8 changes: 8 additions & 0 deletions cpu/efm32/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ USEPKG += gecko_sdk

# include layered power management
USEMODULE += pm_layered

# CMSIS-DSP is needed for arm_math.h on Cortex-M0+ architectures
ifeq ($(CPU_ARCH),cortex-m0plus)
USEPKG += cmsis-dsp
endif

# include CPU family module
USEMODULE += cpu_$(CPU_FAM)
5 changes: 4 additions & 1 deletion cpu/efm32/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
include $(RIOTCPU)/efm32/efm32-info.mk
include $(RIOTCPU)/efm32/efm32-features.mk

CPU_ARCH = $(EFM32_ARCHITECTURE)

FEATURES_PROVIDED += arch_efm32
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_flashpage
Expand All @@ -9,7 +12,7 @@ FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_CONFLICT += periph_rtc:periph_rtt
FEATURES_CONFLICT_MSG += "On the EFM32, the RTC and RTT map to the same hardware peripheral."

ifeq (1,$(EFM32_TNRG))
ifeq (1,$(EFM32_TRNG))
FEATURES_PROVIDED += periph_hwrng
endif

Expand Down
25 changes: 9 additions & 16 deletions cpu/efm32/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
include $(RIOTCPU)/efm32/efm32-info.mk

CPU_ARCH = $(EFM32_ARCHITECTURE)
CPU_FAM = $(EFM32_FAMILY)
# HACK: here we would want to look into USEMODULE to include Makefile.include
# but since Makefile.dep is still resolved after Makefile.include we can't do
# something like `$(filter cpu_efm32%,$(USEMODULE))`. This is why we use
# `cpu_$(CPU_FAM)` for something that is MODULE related.
include $(RIOTCPU)/efm32/families/$(CPU_FAM)/Makefile.include

ifeq (,$(EFM32_HEADER))
$(error Header file for $(CPU_MODEL) is missing)
endif

# the size of riotboot on the EFM32 exceeds the default value
RIOTBOOT_LEN ?= 0x2000

# the em_device.h header requires a global define with the cpu model
CFLAGS += -D$(call uppercase_and_underscore,$(CPU_MODEL))

# CMSIS-DSP is needed for arm_math.h on Cortex-M0+ architectures
ifeq ($(CPU_ARCH),cortex-m0plus)
USEPKG += cmsis-dsp
endif

# include CPU family module
USEMODULE += cpu_$(EFM32_FAMILY)

# vectors.o is provided by 'cpu_$(EFM32_FAMILY)' and not by 'cpu'
VECTORS_O := $(BINDIR)/cpu_$(EFM32_FAMILY)/vectors.o

# include vendor device headers
INCLUDES += -I$(RIOTCPU)/efm32/families/$(EFM32_FAMILY)/include/vendor

# include cortexm_common
LINKER_SCRIPT = cortexm.ld

Expand Down
2 changes: 1 addition & 1 deletion cpu/efm32/efm32-features.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file provides defaults for additional EFM32-specific features. You
# should override them from the command line, or in your Makefile. Note that
# some features may not be applicable to all EFM32 boards or CPUs.
export EFM32_LEUART_ENABLED ?= 1
EFM32_LEUART_ENABLED ?= 1
40 changes: 20 additions & 20 deletions cpu/efm32/efm32-info.mk
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Find the header file that should exist if the CPU is supported.
EFM32_HEADER = $(wildcard $(RIOTCPU)/efm32/families/*/include/vendor/$(CPU_MODEL).h)
# Include family-specific CPU information. This file contains one line per
# CPU_MODEL that includes additional information, such as flash and memory
# sized and supported features. This does not respect the current
# NOTE: here we use $(CPU_FAM) to parse the directory since it is used only
# to load a 'database' or set a of `FEATURES`, where the file location cant
# be obtained from the CPU and CPU_MODEL
include $(RIOTCPU)/efm32/families/$(CPU_FAM)/efm32-info.mk

ifeq (,$(EFM32_HEADER))
$(error Header file for $(CPU_MODEL) is missing)
endif

# Lookup up CPU information using grep.
EFM32_INFO = $(shell grep $(CPU_MODEL) $(shell dirname $(EFM32_HEADER))/../../cpus.txt)
EFM32_INFO = $(EFM32_INFO_$(CPU_MODEL))

ifeq (,$(EFM32_INFO))
$(error Unable to read CPU information for $(CPU_MODEL))
$(error Family-specific information for $(CPU_MODEL) is missing)
endif

# Export variables to use in this build.
export EFM32_FAMILY = $(word 2, $(EFM32_INFO))
export EFM32_SERIES = $(word 3, $(EFM32_INFO))
export EFM32_ARCHITECTURE = $(word 4, $(EFM32_INFO))
# Parse the information into EFM32 specific variables. They are specific to the
# EFM32 CPU only, and should not be used outside this module.
EFM32_SERIES = $(word 1, $(EFM32_INFO))
EFM32_ARCHITECTURE = $(word 2, $(EFM32_INFO))

export EFM32_FLASH_START = $(word 5, $(EFM32_INFO))
export EFM32_FLASH_SIZE = $(word 6, $(EFM32_INFO))
export EFM32_SRAM_START = $(word 7, $(EFM32_INFO))
export EFM32_SRAM_SIZE = $(word 8, $(EFM32_INFO))
EFM32_FLASH_START = $(word 3, $(EFM32_INFO))
EFM32_FLASH_SIZE = $(word 4, $(EFM32_INFO))
EFM32_SRAM_START = $(word 5, $(EFM32_INFO))
EFM32_SRAM_SIZE = $(word 6, $(EFM32_INFO))

export EFM32_CRYPTO = $(word 9, $(EFM32_INFO))
export EFM32_TRNG = $(word 10, $(EFM32_INFO))
export EFM32_RADIO = $(word 11, $(EFM32_INFO))
EFM32_CRYPTO = $(word 7, $(EFM32_INFO))
EFM32_TRNG = $(word 8, $(EFM32_INFO))
EFM32_RADIO = $(word 9, $(EFM32_INFO))
10 changes: 10 additions & 0 deletions cpu/efm32/families/efm32gg/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Find the header file that should exist if the CPU is supported. Only headers
# for supported boards are included, but to support another CPU, it should be
# as easy as adding the header file only.
EFM32_HEADER = $(wildcard $(RIOTCPU)/efm32/families/efm32gg/include/vendor/$(CPU_MODEL).h)

# vectors.o is provided by 'cpu_$(CPU_FAM)' module and not by 'cpu'
VECTORS_O = $(BINDIR)/cpu_efm32gg/vectors.o

# include vendor device headers
INCLUDES += -I$(RIOTCPU)/efm32/families/efm32gg/include/vendor
50 changes: 0 additions & 50 deletions cpu/efm32/families/efm32gg/cpus.txt

This file was deleted.

47 changes: 47 additions & 0 deletions cpu/efm32/families/efm32gg/efm32-info.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is automatically generated, and should not be changed. There is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@basilfx I have a THUNDERBOARD EFM32GG12 here, for whose MCU there is no entry in this file. Is this file really created automatically and if so, how. Or does the entry have to be added manually?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is generated using https://github.com/basilfx/EFM2Riot. That script parses the Gecko SDK and generates the necessary files. I'll admit that it's a bit outdated now.

# probably little reason to edit this file anyway, since it should already
# contain all information for the EFM32GG family of CPUs.
Comment on lines +1 to +3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to add support to another member of the efm32 family and now I wonder what tool was used to generate that kind of file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to look here: https://github.com/basilfx/EFM2RIOT/tree/develop/dist

It should be reasonably up to date and contain all supported chips already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh that's nice.
@aabadie did something very similar for stm32.

I take we can't do that on the fly as Gecko SDK is required. But I don't like copying around folders either.

But we could just import that wholesale.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is necessary to do it on-the-fly. These families are quite stable (only new ones are added).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# Series - Architecture - Flash base - Flash size - SRAM base - SRAM size - Crypto? - TRNG? - Radio?
EFM32_INFO_efm32gg330f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg295f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg940f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg840f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg332f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg990f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg890f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg232f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg942f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg842f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg395f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg295f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg995f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg895f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg395f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg230f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg895f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg390f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg290f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg995f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg980f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg940f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg942f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg330f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg230f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg842f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg332f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg232f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg880f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg840f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg380f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg890f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg990f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg290f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg390f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg900f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg900f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg380f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg280f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg280f512 = 0 cortex-m3 0x00000000 0x00080000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg980f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
EFM32_INFO_efm32gg880f1024 = 0 cortex-m3 0x00000000 0x00100000 0x20000000 0x00020000 0 0 0
10 changes: 10 additions & 0 deletions cpu/efm32/families/efm32lg/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Find the header file that should exist if the CPU is supported. Only headers
# for supported boards are included, but to support another CPU, it should be
# as easy as adding the header file only.
EFM32_HEADER = $(wildcard $(RIOTCPU)/efm32/families/efm32lg/include/vendor/$(CPU_MODEL).h)

# vectors.o is provided by 'cpu_$(CPU_FAM)' module and not by 'cpu'
VECTORS_O = $(BINDIR)/cpu_efm32lg/vectors.o

# include vendor device headers
INCLUDES += -I$(RIOTCPU)/efm32/families/efm32lg/include/vendor
Loading