-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
93 lines (73 loc) · 2.6 KB
/
Makefile
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2020 Daniel Thompson
BOARD ?= pinetime
CROSS_COMPILE := arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
CFLAGS += \
-mcpu=cortex-m4 -mthumb -g3 -Os \
-ffunction-sections \
-fdata-sections \
-DNRF52832_XXAA \
-Ilib/CMSIS/CMSIS/Core/Include \
-Ilib/nrfx \
-Ilib/nrfx/drivers/include \
-Ilib/nrfx/mdk \
-Ilib/nrfx/hal \
-Isrc/boards/$(BOARD) -Isrc
LDFLAGS += $(CFLAGS) -Wl,-Map=$(OBJDIR)/reloader.map -Lsrc -Llib/nrfx/mdk -T$(LDSCRIPT)
APP = $(OBJDIR)/reloader.zip
OBJS = main.o \
blit.o \
flash.o \
spi.o \
spinor.o \
st7789.o \
wdt.o \
nrfx_nvmc.o \
gcc_startup_nrf52.o \
system_nrf52.o
OBJDIR = build-$(BOARD)
OBJS := $(OBJS:%.o=$(OBJDIR)/%.o)
all: $(APP)
$(OBJDIR)/reloader.elf: LDSCRIPT = nrf52832_xxaa.ld
$(OBJDIR)/reloader.elf: $(OBJDIR) $(OBJS) $(LDFILE)
$(CROSS_COMPILE)gcc $(LDFLAGS) $(OBJS) -o $@
$(OBJDIR)/reloader.hex: $(OBJDIR)/reloader.elf
$(CROSS_COMPILE)objcopy -O ihex $< $@
$(OBJDIR)/reloader.zip : $(OBJDIR)/reloader.hex
python3 -m nordicsemi dfu genpkg --dev-type 0x0052 --application $< $@
ifeq ($(BOARD),pinetime)
all : $(OBJDIR)/reloader-mcuboot.zip $(OBJDIR)/reloader-factory.zip
endif
$(OBJDIR)/reloader-mcuboot.elf: LDSCRIPT = nrf52832_xxaa_mcuboot.ld
$(OBJDIR)/reloader-mcuboot.elf: $(OBJDIR) $(OBJS) $(LDFILE)
$(CROSS_COMPILE)gcc $(LDFLAGS) $(OBJS) -o $@
$(OBJDIR)/reloader-mcuboot.bin: $(OBJDIR)/reloader-mcuboot.elf
$(CROSS_COMPILE)objcopy -O binary $< $@.tmp
lib/mcuboot/scripts/imgtool.py create \
--align 4 --version 1.0.0 \
--header-size 32 --slot-size 475136 --pad-header $@.tmp $@
$(RM) $@.tmp
$(OBJDIR)/reloader-mcuboot.zip : $(OBJDIR)/reloader-mcuboot.bin
python3 -m nordicsemi dfu genpkg --dev-type 0x0052 --application $< $@
FACTORY_OBJS = $(subst flash.o,factoryflash.o,$(OBJS))
$(OBJDIR)/reloader-factory.elf: LDSCRIPT = nrf52832_xxaa.ld
$(OBJDIR)/reloader-factory.elf: $(OBJDIR) $(FACTORY_OBJS) $(LDFILE)
$(CROSS_COMPILE)gcc $(LDFLAGS) $(FACTORY_OBJS) -o $@
$(OBJDIR)/reloader-factory.hex: $(OBJDIR)/reloader-factory.elf
$(CROSS_COMPILE)objcopy -O ihex $< $@
$(OBJDIR)/reloader-factory.zip : $(OBJDIR)/reloader-factory.hex
python3 -m nordicsemi dfu genpkg --dev-type 0x0052 --application $< $@
VPATH = src:lib/nrfx/drivers/src:lib/nrfx/mdk
$(OBJDIR) :
mkdir -p $@
$(OBJDIR)/%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/factoryflash.o : flash.c
$(CC) $(CFLAGS) -DFACTORY -c $< -o $@
$(OBJDIR)/%.o : %.S
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: clean
clean:
$(RM) -r $(OBJDIR)
$(OBJS) factoryflash.o : $(wildcard src/boards/$(BOARD)/*.h)