From fedca810cda440156ece7e8a9048d3381a8f8beb Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sun, 4 Jul 2021 22:52:09 +0200 Subject: [PATCH] riotboot: factor out common Makefile parts --- bootloaders/riotboot/Makefile | 30 +--------------------------- bootloaders/riotboot_common.mk | 29 +++++++++++++++++++++++++++ bootloaders/riotboot_dfu/Makefile | 28 +------------------------- bootloaders/riotboot_serial/Makefile | 12 ++++------- 4 files changed, 35 insertions(+), 64 deletions(-) create mode 100644 bootloaders/riotboot_common.mk diff --git a/bootloaders/riotboot/Makefile b/bootloaders/riotboot/Makefile index bc19fbe7e0..4800be4f9e 100644 --- a/bootloaders/riotboot/Makefile +++ b/bootloaders/riotboot/Makefile @@ -1,35 +1,7 @@ # Default RIOT bootloader APPLICATION = riotboot -# Default testing board -BOARD ?= samr21-xpro - -# Select the boards with riotboot feature -FEATURES_REQUIRED += riotboot - -# Set RIOTBOOT_BUILD to indicate a riotboot application build -RIOTBOOT_BUILD = 1 -# Provide a define to detect if building the bootloader -CFLAGS += -DRIOTBOOT - -# Disable unused modules -CFLAGS += -DNDEBUG -DLOG_LEVEL=LOG_NONE -DISABLE_MODULE += core_init core_msg core_panic -DISABLE_MODULE += auto_init auto_init_% -DISABLE_MODULE += pm_layered - -# avoid using stdio -USEMODULE += stdio_null - # Include riotboot flash partition functionality USEMODULE += riotboot_slot -# RIOT codebase -RIOTBASE ?= $(CURDIR)/../../ - -include $(RIOTBASE)/Makefile.include - -# limit riotboot bootloader size -# TODO: Manage to set this variable for boards which already embed a -# bootloader, currently it will be overwritten -ROM_LEN := $(RIOTBOOT_LEN) +include ../riotboot_common.mk diff --git a/bootloaders/riotboot_common.mk b/bootloaders/riotboot_common.mk new file mode 100644 index 0000000000..de4975f943 --- /dev/null +++ b/bootloaders/riotboot_common.mk @@ -0,0 +1,29 @@ +# Default testing board +BOARD ?= samr21-xpro + +# Select the boards with riotboot feature +FEATURES_REQUIRED += riotboot + +# Set RIOTBOOT_BUILD to indicate a riotboot application build +RIOTBOOT_BUILD = 1 +# Provide a define to detect if building the bootloader +CFLAGS += -DRIOTBOOT + +# Disable unused modules +CFLAGS += -DNDEBUG -DLOG_LEVEL=LOG_NONE +DISABLE_MODULE += core_init core_msg core_panic +DISABLE_MODULE += auto_init auto_init_% +DISABLE_MODULE += pm_layered + +# avoid using stdio +USEMODULE += stdio_null + +# RIOT codebase +RIOTBASE ?= $(CURDIR)/../.. + +include $(RIOTBASE)/Makefile.include + +# limit riotboot bootloader size +# TODO: Manage to set this variable for boards which already embed a +# bootloader, currently it will be overwritten +ROM_LEN := $(RIOTBOOT_LEN) diff --git a/bootloaders/riotboot_dfu/Makefile b/bootloaders/riotboot_dfu/Makefile index 0c14a71cf4..86995d3119 100644 --- a/bootloaders/riotboot_dfu/Makefile +++ b/bootloaders/riotboot_dfu/Makefile @@ -1,33 +1,12 @@ # Default RIOT bootloader APPLICATION = riotboot_dfu -# Default testing board -BOARD ?= samr21-xpro - -# Select the boards with riotboot feature -FEATURES_REQUIRED += riotboot - -# Set RIOTBOOT_BUILD to indicate a riotboot application build -RIOTBOOT_BUILD = 1 -# Provide a define to detect if building the bootloader -CFLAGS += -DRIOTBOOT - -# Disable unused modules -CFLAGS += -DNDEBUG -DLOG_LEVEL=LOG_NONE -DISABLE_MODULE += core_init core_msg core_panic -DISABLE_MODULE += auto_init auto_init_% - -# avoid using stdio -USEMODULE += stdio_null # Add RIOTBOOT USB DFU integration USEMODULE += riotboot_usb_dfu # Use xtimer for scheduled reboot USEMODULE += xtimer -# RIOT codebase -RIOTBASE ?= $(CURDIR)/../../ - # USB device vendor and product ID # pid.codes test VID/PID, not globally unique @@ -36,9 +15,4 @@ RIOTBASE ?= $(CURDIR)/../../ USB_VID ?= 1209 USB_PID ?= 7D02 -include $(RIOTBASE)/Makefile.include - -# limit riotboot bootloader size -# TODO: Manage to set this variable for boards which already embed a -# bootloader, currently it will be overwritten -ROM_LEN := $(RIOTBOOT_LEN) +include ../riotboot_common.mk diff --git a/bootloaders/riotboot_serial/Makefile b/bootloaders/riotboot_serial/Makefile index 1bd20aa81f..fdf226bfec 100644 --- a/bootloaders/riotboot_serial/Makefile +++ b/bootloaders/riotboot_serial/Makefile @@ -1,14 +1,10 @@ # Default RIOT bootloader APPLICATION = riotboot_serial +# Include riotboot flash partition functionality +# USEMODULE += riotboot_slot + # Include serial bootloader functionality USEMODULE += riotboot_serial -# RIOT codebase -RIOTBASE ?= $(CURDIR)/../../ - -include $(RIOTBASE)/Makefile.include - -# limit riotboot bootloader size -RIOTBOOT_SERIAL_LEN ?= $(RIOTBOOT_LEN) -ROM_LEN := $(RIOTBOOT_SERIAL_LEN) +include ../riotboot_common.mk