Skip to content

Commit ff91855

Browse files
committed
nrf: Simplify the board makefiles
With the only difference between a SD and non-SD build is the linker file, there's no need to have two separate .mk per board files, just use a conditional.
1 parent 5509f39 commit ff91855

9 files changed

Lines changed: 55 additions & 89 deletions

File tree

ports/nrf/Makefile

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,14 @@ SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
1212

1313
# TODO: Verify that it is a valid target.
1414

15-
ifeq ($(SD), )
16-
# If the build directory is not given, make it reflect the board name.
17-
BUILD ?= build-$(BOARD)
18-
include ../../py/mkenv.mk
19-
include boards/$(BOARD)/mpconfigboard.mk
20-
-include mpconfigport.mk
21-
else
22-
# If the build directory is not given, make it reflect the board name.
23-
BUILD ?= build-$(BOARD)-$(SD_LOWER)
24-
include ../../py/mkenv.mk
25-
include boards/$(BOARD)/mpconfigboard_$(SD_LOWER).mk
26-
-include mpconfigport.mk
15+
# If the build directory is not given, make it reflect the board name
16+
BUILD ?= $(if $(SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD))
17+
18+
include ../../py/mkenv.mk
19+
include boards/$(BOARD)/mpconfigboard.mk
20+
-include mpconfigport.mk
2721

22+
ifneq ($(SD), )
2823
include drivers/bluetooth/bluetooth_common.mk
2924
endif
3025

ports/nrf/boards/feather52832/mpconfigboard.mk

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ else
1414
NRFUTIL = nrfutil
1515
endif
1616

17-
ifeq ($(SD), )
18-
INC += -Idrivers/bluetooth/s132_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/s132_$(MCU_VARIANT)_$(SOFTDEV_VERSION)_API/include
19-
INC += -Idrivers/bluetooth/s132_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/s132_$(MCU_VARIANT)_$(SOFTDEV_VERSION)_API/include/$(MCU_VARIANT)
20-
endif
21-
2217
CFLAGS += -DADAFRUIT_FEATHER52
2318

2419
check_defined = \

ports/nrf/boards/feather52832/mpconfigboard_s132.mk

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
1-
# This file is a placeholder to enable building with 'SD=s140' flag
2-
# The actual config data is stored in the file referenced below, regardless
3-
# of whether S140 is actively used or not.
4-
include boards/$(BOARD)/mpconfigboard.mk
1+
MCU_SERIES = m4
2+
MCU_VARIANT = nrf52
3+
MCU_SUB_VARIANT = nrf52840
4+
SOFTDEV_VERSION ?= 6.0.0
5+
6+
LD_FILE = boards/feather52840/bluefruit_nrf52840_s140_6.0.0.ld
7+
BOOTLOADER_FILENAME = boards/feather52840/bootloader/feather52840_bootloader_6.0.0_s140_single
8+
9+
NRF_DEFINES += -DNRF52840_XXAA
10+
11+
ifeq ($(OS),Windows_NT)
12+
NRFUTIL = ../../lib/nrfutil/binaries/win32/nrfutil.exe
13+
else
14+
NRFUTIL = nrfutil
15+
endif
16+
17+
CFLAGS += -DADAFRUIT_FEATHER52840
18+
19+
check_defined = \
20+
$(strip $(foreach 1,$1, \
21+
$(call __check_defined,$1,$(strip $(value 2)))))
22+
__check_defined = \
23+
$(if $(value $1),, \
24+
$(error Undefined make flag: $1$(if $2, ($2))))
25+
26+
.PHONY: dfu-gen dfu-flash boot-flash
27+
28+
dfu-gen:
29+
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip
30+
31+
dfu-flash:
32+
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
33+
$(NRFUTIL) --verbose dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200
34+
35+
boot-flash:
36+
nrfjprog --program $(BOOTLOADER_FILENAME).hex -f nrf52 --chiperase --reset

ports/nrf/boards/feather52840/mpconfigboard_s140.mk

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
MCU_SERIES = m4
22
MCU_VARIANT = nrf52
33
MCU_SUB_VARIANT = nrf52
4-
LD_FILE = boards/nrf52832_512k_64k.ld
4+
SOFTDEV_VERSION ?= 5.0.0
5+
6+
ifeq ($(SD),)
7+
LD_FILE = boards/nrf52832_512k_64k.ld
8+
else
9+
LD_FILE = boards/nrf52832_512k_64k_s132_$(SOFTDEV_VERSION).ld
10+
endif
511

612
NRF_DEFINES += -DNRF52832_XXAA

ports/nrf/boards/pca10040/mpconfigboard_s132.mk

Lines changed: 0 additions & 8 deletions
This file was deleted.

ports/nrf/boards/pca10056/mpconfigboard.mk

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ MCU_VARIANT = nrf52
33
MCU_SUB_VARIANT = nrf52840
44
SOFTDEV_VERSION ?= 6.0.0
55

6-
LD_FILE = boards/nrf52840_1M_256k.ld
6+
ifeq ($(SD),)
7+
LD_FILE = boards/nrf52840_1M_256k.ld
8+
else
9+
LD_FILE = boards/nrf52840_1M_256k_s140_$(SOFTDEV_VERSION).ld
10+
endif
711

812
NRF_DEFINES += -DNRF52840_XXAA
9-
10-
ifeq ($(SD), )
11-
INC += -Idrivers/bluetooth/s140_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/s140_$(MCU_SUB_VARIANT)_$(SOFTDEV_VERSION)_API/include
12-
INC += -Idrivers/bluetooth/s140_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/s140_$(MCU_SUB_VARIANT)_$(SOFTDEV_VERSION)_API/include/$(MCU_VARIANT)
13-
endif

ports/nrf/boards/pca10056/mpconfigboard_s140.mk

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)