-
Notifications
You must be signed in to change notification settings - Fork 4
/
bootloader.makefile
165 lines (128 loc) · 3.79 KB
/
bootloader.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Set Project Name
PROJECT_NAME := bootloader
# Set the serial port number for downloading the firmware
DOWNLOAD_PORT := COM3
COMPILE_OS = $(shell uname -o)
LINUX_OS = GNU/Linux
ifeq ($(COMPILE_OS),$(LINUX_OS))
COMPILE_PREFIX = /opt/tc32/bin/tc32
else
COMPILE_PREFIX = C:/TelinkSDK/opt/tc32/bin/tc32
endif
AS = $(COMPILE_PREFIX)-elf-as
CC = $(COMPILE_PREFIX)-elf-gcc
LD = $(COMPILE_PREFIX)-elf-ld
NM = $(COMPILE_PREFIX)-elf-nm
OBJCOPY = $(COMPILE_PREFIX)-elf-objcopy
OBJDUMP = $(COMPILE_PREFIX)-elf-objdump
ARCH = $(COMPILE_PREFIX)-elf-ar
SIZE = $(COMPILE_PREFIX)-elf-size
LIBS := -ldrivers_8258
MCU_TYPE = -DMCU_CORE_8258=1
BOOT_FLAG = -DMCU_CORE_8258 -DMCU_STARTUP_8258
SDK_PATH := ./tl_zigbee_sdk
SRC_PATH := ./src
OUT_PATH := ./out
MAKE_INCLUDES := ./make
TOOLS_PATH := ./tools
BIN_PATH := ./bin
TL_Check = $(TOOLS_PATH)/tl_check_fw.py
INCLUDE_PATHS := \
-I$(SDK_PATH)/platform \
-I$(SDK_PATH)/proj/common \
-I$(SDK_PATH)/proj \
-I$(SRC_PATH)/common \
-I$(SRC_PATH)/bootloader \
-I$(SRC_PATH)/include/boards
#-I$(SDK_PATH)/zigbee/common/includes \
#-I$(SRC_PATH)/include
LS_FLAGS := $(SDK_PATH)/platform/boot/8258/boot_8258.link
GCC_FLAGS := \
-ffunction-sections \
-fdata-sections \
-Wall \
-O2 \
-fpack-struct \
-fshort-enums \
-finline-small-functions \
-std=gnu99 \
-fshort-wchar \
-fms-extensions
GCC_FLAGS += \
$(DEVICE_TYPE) \
$(MCU_TYPE) \
-D__PROJECT_TL_BOOT_LOADER__=1
OBJ_SRCS :=
S_SRCS :=
ASM_SRCS :=
C_SRCS :=
S_UPPER_SRCS :=
O_SRCS :=
FLASH_IMAGE :=
ELFS :=
OBJS :=
LST :=
SIZEDUMMY :=
RM := rm -rf
# All of the sources participating in the build are defined here
-include $(MAKE_INCLUDES)/proj.mk
-include $(MAKE_INCLUDES)/platformS.mk
-include $(MAKE_INCLUDES)/div_mod.mk
-include $(MAKE_INCLUDES)/platform.mk
-include $(MAKE_INCLUDES)/bootloader.mk
# Add inputs and outputs from these tool invocations to the build variables
LST_FILE := $(OUT_PATH)/$(PROJECT_NAME).lst
BIN_FILE := $(OUT_PATH)/$(PROJECT_NAME).bin
ELF_FILE := $(OUT_PATH)/$(PROJECT_NAME).elf
MARKER_BIN := $(BIN_PATH)/marker.bin
SIZEDUMMY += \
sizedummy \
# All Target
bootloader: pre-build main-build
bootloader-flash: $(BIN_FILE)
@python3 $(TOOLS_PATH)/TlsrPgm.py -p$(DOWNLOAD_PORT) -z11 -a 100 -s -m we 0 $(BIN_FILE)
@python3 $(TOOLS_PATH)/TlsrPgm.py -p$(DOWNLOAD_PORT) -z11 -a 100 -s -m we 0x7ff0 $(MARKER_BIN)
# Main-build Target
main-build: clean $(ELF_FILE) secondary-outputs
# Tool invocations
$(ELF_FILE): $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: TC32 C Linker'
@$(LD) --gc-sections -L $(SDK_PATH)/platform/lib -T $(LS_FLAGS) -o "$(ELF_FILE)" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
$(LST_FILE): $(ELF_FILE)
@echo 'Invoking: TC32 Create Extended Listing'
$(OBJDUMP) -x -D -l -S $(ELF_FILE) > $(LST_FILE)
@echo 'Finished building: $@'
@echo ' '
$(BIN_FILE): $(ELF_FILE)
@echo 'Create Flash image (binary format)'
@$(OBJCOPY) -v -O binary $(ELF_FILE) $(BIN_FILE)
@python3 $(TL_Check) $(BIN_FILE)
@cp $(BIN_FILE) $(BIN_PATH)/$(PROJECT_NAME).bin
@echo 'Finished building: $@'
@echo ' '
sizedummy: $(ELF_FILE)
@echo 'Invoking: Print Size'
@$(SIZE) -t $(ELF_FILE)
@echo 'Finished building: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(FLASH_IMAGE) $(ELFS) $(OBJS) $(SIZEDUMMY) $(LST_FILE) $(ELF_FILE)
-@echo ' '
bootloader-clean:
-$(RM) $(FLASH_IMAGE) $(ELFS) $(SIZEDUMMY) $(LST_FILE) $(ELF_FILE) $(BIN_FILE)
-$(RM) -R $(OUT_PATH)/$(SRC_PATH)/*.o
-$(RM) -R $(OUT_PATH)/$(SRC_PATH)/common/*.o
-@echo ' '
pre-build:
mkdir -p $(foreach s,$(OUT_DIR),$(OUT_PATH)$(s))
-@echo ' '
post-build:
-"$(TOOLS_PATH)/tl_check_fw.sh" $(OUT_PATH)/$(PROJECT_NAME) tc32
-@echo ' '
secondary-outputs: $(BIN_FILE) $(LST_FILE) $(FLASH_IMAGE) $(SIZEDUMMY)
.PHONY: bootloader clean dependents pre-build
.SECONDARY: main-build pre-build post-build