forked from kaidyth/nrf52_bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (53 loc) · 1.64 KB
/
Copy pathMakefile
File metadata and controls
67 lines (53 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
BOARD ?=
BOARD_LIST := $(sort $(subst /,,$(subst boards/,,$(dir $(wildcard boards/*/)))))
rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
default: check-env
ifneq ($(filter $(BOARD),$(BOARD_LIST)),)
$(MAKE) merge -C boards/$(BOARD)/s140
else
$(error Run `make` with a board specified: ($(BOARD_LIST)))
endif
all: check-env $(BOARD_LIST)
$(BOARD_LIST):
$(MAKE) -C boards/$@/s140
flash: default
$(MAKE) flash -C boards/$(BOARD)/s140
clean_build: clean
$(MAKE) -C boards/$(BOARD)/s140 dfu_package
clean_flash: clean_build
$(MAKE) -C boards/$(BOARD)/s140 erase flash
usb_flash: check_port default
$(MAKE) -C boards/$(BOARD)/s140 usb_flash
check_port:
ifndef PORT
$(error PORT must be defined to perform usb serial flashing)
endif
clean: check-env patch
ifneq ($(filter $(BOARD),$(BOARD_LIST)),)
@cd boards/$(BOARD)/s140 && $(MAKE) clean
@rm -rf $(BOARD).hex
@rm -f $(BOARD)_s140.zip
@rm -f debug_$(BOARD)_s140.zip
else
@for board in $(BOARD_LIST); do \
cd boards/$$board/s140 && $(MAKE) clean; \
cd ../../..; \
done
@rm -f *.hex
@rm -f *.zip
endif
.PHONY: check-env
check-env: dfu_public_key.c
ifndef NORDIC_SDK_PATH
$(error NORDIC_SDK_PATH is not defined.)
endif
private.pem:
echo y | nrfutil keys generate ./private.pem
dfu_public_key.c: private.pem
nrfutil keys display --key pk --format code private.pem --out_file dfu_public_key.c
patch:
@for file in $(subst ./sdk/,,$(call rwildcard,./sdk/,*.c)); do \
if patch -p0 -s -f --dry-run --reject-file /dev/null $(NORDIC_SDK_PATH)/$${file} ./sdk/$${file}; then \
patch --forward --unified $(NORDIC_SDK_PATH)/$${file} ./sdk/$${file}; \
fi \
done;