forked from wirepas/wm-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile_bootloader.mk
62 lines (45 loc) · 1.45 KB
/
makefile_bootloader.mk
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
include makefile_common.mk
.DEFAULT_GOAL := all
unprotected ?= false
# Get the right bootloader binary
BOOTLOADER_SRC := $(BUILDPREFIX_BOOTLOADER)bootloader.a
# Bootloader build variables
BL_BUILDPREFIX := $(BUILDPREFIX_BOOTLOADER)
# Linker for the bootloader
LDSCRIPT := mcu/$(MCU)/linker/gcc_bl_$(MCU)$(MCU_SUB)$(MCU_MEM_VAR).ld
BOOTLOADER_ELF := $(BL_BUILDPREFIX)bootloader.elf
# Include bootloader makefile
-include bootloader/makefile
OBJS_ = $(SRCS:.c=.o)
OBJS = $(addprefix $(BL_BUILDPREFIX), $(OBJS_))
# Files to be cleaned
CLEAN := $(OBJS) $(BOOTLOADER_ELF) $(BOOTLOADER_HEX)
$(BOOTLOADER_SRC): FORCE
# Get the right firmware from the image folder
$(MKDIR) $(@D)
@$(FMW_SEL) --firmware_path=$(IMAGE_PATH)\
--firmware_type="wp_bootloader"\
--version=3\
--output_path=$(@D)\
--output_name="bootloader"\
--unlocked=$(unprotected)\
--mcu=$(MCU)\
--mcu_sub=$(MCU_SUB)$(MCU_MEM_VAR)
$(BL_BUILDPREFIX)%.o : %.c
$(MKDIR) $(@D)
$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
$(BOOTLOADER_ELF): $(OBJS) $(BOOTLOADER_SRC)
$(MKDIR) $(@D)
@ # Linking with the provided lib $(BOOTLOADER_SRC)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(BOOTLOADER_SRC)\
-Wl,-Map=$(BL_BUILDPREFIX)bootloader.map \
-Wl,-T,$(LDSCRIPT) $(LIBS)
$(BOOTLOADER_HEX): $(BOOTLOADER_ELF)
$(MKDIR) $(@D)
$(OBJCOPY) $(BOOTLOADER_ELF) -O ihex $@
.PHONY: all
all: $(BOOTLOADER_HEX)
clean:
$(RM) -rf $(CLEAN)
# Special ruel to force other rule to run every time
FORCE: