diff --git a/boards/common/adafruit-nrf52-bootloader/Makefile b/boards/common/adafruit-nrf52-bootloader/Makefile new file mode 100644 index 0000000000..55878b4bba --- /dev/null +++ b/boards/common/adafruit-nrf52-bootloader/Makefile @@ -0,0 +1,3 @@ +MODULE = boards_common_adafruit-nrf52-bootloader + +include $(RIOTBASE)/Makefile.base diff --git a/boards/common/adafruit-nrf52-bootloader/Makefile.dep b/boards/common/adafruit-nrf52-bootloader/Makefile.dep new file mode 100644 index 0000000000..b686eb3cc3 --- /dev/null +++ b/boards/common/adafruit-nrf52-bootloader/Makefile.dep @@ -0,0 +1,4 @@ +include $(RIOTBOARD)/common/nrf52/bootloader_nrfutil.dep.mk + +# make sure the bootloader module is used for reset to work +USEMODULE += boards_common_adafruit-nrf52-bootloader diff --git a/boards/common/adafruit-nrf52-bootloader/Makefile.include b/boards/common/adafruit-nrf52-bootloader/Makefile.include new file mode 100644 index 0000000000..93426bea1e --- /dev/null +++ b/boards/common/adafruit-nrf52-bootloader/Makefile.include @@ -0,0 +1,29 @@ +PROGRAMMER ?= uf2conv + +UF2CONV_FLAGS = -f 0xADA52840 + +ifeq (uf2conv,$(PROGRAMMER)) + + # Using uf2conv implies using the UF2 bootloader + # + # It has a static MBR at the first 4k, and a 38k UF2 Bootloader at + # the end, leaving 972k for the application. This overwrites any SoftDevice, + # but that's what the minimal working example does as well. + ROM_OFFSET = 0x1000 + ROM_LEN = 0xf3000 + + # Driver can take some time to get mounted + PREFLASH_DELAY ?= 3 + include $(RIOTMAKE)/tools/usb_board_reset.mk +endif + +PROGRAMMERS_SUPPORTED += uf2conv + +# HACK: replicate dependency resolution in Makefile.dep, only works +# if `USEMODULE` or `DEFAULT_MODULE` is set by the command line or in the +# application Makefile. +ifeq (,$(filter stdio_%,$(DISABLE_MODULE) $(USEMODULE))) + RIOT_TERMINAL ?= jlink +endif + +include $(RIOTBOARD)/common/nrf52/Makefile.include diff --git a/boards/feather-nrf52840/reset.c b/boards/common/adafruit-nrf52-bootloader/reset.c similarity index 88% rename from boards/feather-nrf52840/reset.c rename to boards/common/adafruit-nrf52-bootloader/reset.c index 68fe19fa41..e5e0ff2012 100644 --- a/boards/feather-nrf52840/reset.c +++ b/boards/common/adafruit-nrf52-bootloader/reset.c @@ -7,10 +7,10 @@ */ /** - * @ingroup boards_feather-nrf52840 + * @ingroup boards_common_adafruit-nrf52-bootloader * @{ * @file - * @brief Implementation for managing the nrfutil bootloader + * @brief Reset Logic for the Adafruit nRF52 Bootloader * * @author Alexandre Abadie * diff --git a/boards/feather-nrf52840-sense/Makefile b/boards/feather-nrf52840-sense/Makefile index f8fcbb53a0..618366c50d 100644 --- a/boards/feather-nrf52840-sense/Makefile +++ b/boards/feather-nrf52840-sense/Makefile @@ -1,3 +1,8 @@ MODULE = board +ifneq (,$(filter boards_common_adafruit-nrf52-bootloader,$(USEMODULE))) + # add the adafruit-nrf52-bootloader directory to the build + DIRS += $(RIOTBOARD)/common/adafruit-nrf52-bootloader +endif + include $(RIOTBASE)/Makefile.base diff --git a/boards/feather-nrf52840-sense/Makefile.dep b/boards/feather-nrf52840-sense/Makefile.dep index d9c149fcf9..50f8617a9a 100644 --- a/boards/feather-nrf52840-sense/Makefile.dep +++ b/boards/feather-nrf52840-sense/Makefile.dep @@ -9,6 +9,8 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += ws281x endif +# include common Adafruit nRF52 Bootloader dependencies +include $(RIOTBOARD)/common/adafruit-nrf52-bootloader/Makefile.dep + # include common nrf52 dependencies -include $(RIOTBOARD)/common/nrf52/bootloader_nrfutil.dep.mk include $(RIOTBOARD)/common/nrf52/Makefile.dep diff --git a/boards/feather-nrf52840-sense/Makefile.include b/boards/feather-nrf52840-sense/Makefile.include deleted file mode 120000 index a2ad50e198..0000000000 --- a/boards/feather-nrf52840-sense/Makefile.include +++ /dev/null @@ -1 +0,0 @@ -../feather-nrf52840/Makefile.include \ No newline at end of file diff --git a/boards/feather-nrf52840-sense/Makefile.include b/boards/feather-nrf52840-sense/Makefile.include new file mode 100644 index 0000000000..1289b03378 --- /dev/null +++ b/boards/feather-nrf52840-sense/Makefile.include @@ -0,0 +1,2 @@ +# Include the common definitions for the Adafruit nRF52 Bootloader +include $(RIOTBOARD)/common/adafruit-nrf52-bootloader/Makefile.include diff --git a/boards/feather-nrf52840-sense/reset.c b/boards/feather-nrf52840-sense/reset.c deleted file mode 120000 index fe94c2c228..0000000000 --- a/boards/feather-nrf52840-sense/reset.c +++ /dev/null @@ -1 +0,0 @@ -../feather-nrf52840/reset.c \ No newline at end of file diff --git a/boards/feather-nrf52840/Makefile b/boards/feather-nrf52840/Makefile index f8fcbb53a0..618366c50d 100644 --- a/boards/feather-nrf52840/Makefile +++ b/boards/feather-nrf52840/Makefile @@ -1,3 +1,8 @@ MODULE = board +ifneq (,$(filter boards_common_adafruit-nrf52-bootloader,$(USEMODULE))) + # add the adafruit-nrf52-bootloader directory to the build + DIRS += $(RIOTBOARD)/common/adafruit-nrf52-bootloader +endif + include $(RIOTBASE)/Makefile.base diff --git a/boards/feather-nrf52840/Makefile.dep b/boards/feather-nrf52840/Makefile.dep index 8bd26bc979..73f4ddaa4b 100644 --- a/boards/feather-nrf52840/Makefile.dep +++ b/boards/feather-nrf52840/Makefile.dep @@ -4,6 +4,8 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += ws281x endif +# include common Adafruit nRF52 Bootloader dependencies +include $(RIOTBOARD)/common/adafruit-nrf52-bootloader/Makefile.dep + # include common nrf52 dependencies -include $(RIOTBOARD)/common/nrf52/bootloader_nrfutil.dep.mk include $(RIOTBOARD)/common/nrf52/Makefile.dep diff --git a/boards/feather-nrf52840/Makefile.include b/boards/feather-nrf52840/Makefile.include index 93426bea1e..1289b03378 100644 --- a/boards/feather-nrf52840/Makefile.include +++ b/boards/feather-nrf52840/Makefile.include @@ -1,29 +1,2 @@ -PROGRAMMER ?= uf2conv - -UF2CONV_FLAGS = -f 0xADA52840 - -ifeq (uf2conv,$(PROGRAMMER)) - - # Using uf2conv implies using the UF2 bootloader - # - # It has a static MBR at the first 4k, and a 38k UF2 Bootloader at - # the end, leaving 972k for the application. This overwrites any SoftDevice, - # but that's what the minimal working example does as well. - ROM_OFFSET = 0x1000 - ROM_LEN = 0xf3000 - - # Driver can take some time to get mounted - PREFLASH_DELAY ?= 3 - include $(RIOTMAKE)/tools/usb_board_reset.mk -endif - -PROGRAMMERS_SUPPORTED += uf2conv - -# HACK: replicate dependency resolution in Makefile.dep, only works -# if `USEMODULE` or `DEFAULT_MODULE` is set by the command line or in the -# application Makefile. -ifeq (,$(filter stdio_%,$(DISABLE_MODULE) $(USEMODULE))) - RIOT_TERMINAL ?= jlink -endif - -include $(RIOTBOARD)/common/nrf52/Makefile.include +# Include the common definitions for the Adafruit nRF52 Bootloader +include $(RIOTBOARD)/common/adafruit-nrf52-bootloader/Makefile.include