-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
206 lines (173 loc) · 5.93 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
######################################
# target
######################################
export TARGET = IMBootloader
######################################
# building variables
######################################
# debug build?
export DEBUG = 1
# optimization
export OPT = -Og
######################################
# Git branch and hash
######################################
export BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
export HASH := $(shell git rev-parse HEAD)
export TAG := $(shell git tag --sort=committerdate | tail -1)
#######################################
# paths
#######################################
export COMMON_SRCS = \
Bootloader/Src/main.c \
Bootloader/Src/binary_update.c \
Bootloader/Src/communication.c \
Bootloader/Src/security.c \
Bootloader/Src/signature.c \
Bootloader/Src/board_info.c \
Bootloader/Adapters/Src/gpio_adapter.c \
Bootloader/Adapters/Src/flash_adapter.c \
Bootloader/Adapters/Src/hash_adapter.c \
Bootloader/Adapters/Src/security_adapter.c \
Bootloader/Adapters/Src/system_adapter.c \
Bootloader/Adapters/Src/system_clock_adapter.c \
Bootloader/Library/Src/software_info.c \
Bootloader/STM32/Src/usb_device.c \
Bootloader/STM32/Src/usbd_conf.c \
Bootloader/STM32/Src/usbd_desc.c \
Bootloader/STM32/Src/usbd_cdc_if.c \
Bootloader/Utility/Src/base64.c \
Bootloader/Utility/Src/crc/crc32_base.c \
Bootloader/Utility/Src/crc/crc32_variants/crc32_bzip2.c \
Bootloader/Utility/Src/json.c \
Bootloader/Utility/Src/utils.c \
Monocypher/src/monocypher.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c
export COMMON_INCS = \
-IBootloader/Inc \
-IBootloader/Adapters/Inc \
-IBootloader/Library/Inc \
-IBootloader/STM32/Inc \
-IBootloader/Utility/Inc \
-IBootloader/Utility/Inc/crc/ \
-IBootloader/Utility/Inc/crc/crc32_variants/ \
-IMonocypher/src \
-IDrivers/CMSIS/Include \
-IMiddlewares/ST/STM32_USB_Device_Library/Core/Inc \
-IMiddlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc \
-IExternalDevices/Winbond/Inc/
#######################################
# binaries
#######################################
export PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
export CC = $(GCC_PATH)/$(PREFIX)gcc
export AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
export CP = $(GCC_PATH)/$(PREFIX)objcopy
export SZ = $(GCC_PATH)/$(PREFIX)size
else
export CC = $(PREFIX)gcc
export AS = $(PREFIX)gcc -x assembler-with-cpp
export CP = $(PREFIX)objcopy
export SZ = $(PREFIX)size
endif
export HEX = $(CP) -O ihex
export BIN = $(CP) -O binary -S
#######################################
# Astyle
#######################################
.PHONY: check_format format
check_format:
$(call colorecho,'Checking formatting with astyle')
@Tools/astyle/check_code_style_all.sh
@git diff --check
format:
$(call colorecho,'Formatting with astyle')
@Tools/astyle/check_code_style_all.sh --fix
#######################################
# Cppcheck
#######################################
.PHONY: cppcheck misra
cppcheck:
$(call colorecho,'Checking code with cppcheck')
@cppcheck --error-exitcode=1 Bootloader -DSECURED
misra:
$(call colorecho,'Checking MISRA C:2012 with cppcheck')
@cppcheck cppcheck $(COMMON_INCS) Bootloader --force --addon=misra.py --inline-suppr --error-exitcode=1 \
-i Bootloader/Utility
#
# Bootloaders to build
#
TARGETS = \
stm32l4xx \
stm32h7xx \
stm32h7xx_ram \
stm32f7xx \
stm32f7xx_ram \
nucleo_h755zi \
matek_H7_slim \
matek_H7_slim_ram \
pixhawk4 \
pixhawk4_ram
all: $(TARGETS)
clean:
rm -f *.elf *.bin *.map # Remove any elf or bin files contained directly in the Bootloader directory
rm -rf build # Remove build directories
#
# Board specific targets.
#
BOARD =
nucleo_h755zi:
${MAKE} stm32h7xx BOARD=NUCLEO_H755ZI BOARD_FILE_NAME=$@
nucleo_h755zi_ram:
${MAKE} stm32h7xx_ram BOARD=NUCLEO_H755ZI BOARD_FILE_NAME=$@
matek_H7_slim:
${MAKE} stm32h7xx BOARD=MATEK_H743_SLIM BOARD_FILE_NAME=$@
matek_H7_slim_ram:
${MAKE} stm32h7xx_ram BOARD=MATEK_H743_SLIM BOARD_FILE_NAME=$@
pixhawk4:
${MAKE} stm32f7xx BOARD=PIXHAWK4 BOARD_FILE_NAME=$@
pixhawk4_ram:
${MAKE} stm32f7xx_ram BOARD=PIXHAWK4 BOARD_FILE_NAME=$@
test_cmock test_all test_clean:
${MAKE} -C Tests $@
#
# Microcontroller (MCU) specific targets.
#
stm32l4xx: $(MAKEFILE_LIST)
${MAKE} -f Makefile.stm32l4xx LDSCRIPT=STM32L4xx.ld FLASH=INTERNAL_FLASH MCU_FILE_NAME=$@
stm32h7xx: $(MAKEFILE_LIST)
${MAKE} -f Makefile.stm32h7xx LDSCRIPT=STM32H7xx.ld FLASH=INTERNAL_FLASH MCU_FILE_NAME=$@
stm32h7xx_ram: $(MAKEFILE_LIST)
${MAKE} -f Makefile.stm32h7xx LDSCRIPT=STM32H7xx_RAM.ld FLASH=INTERNAL_FLASH MCU_FILE_NAME=$@
stm32h7xx_ext: $(MAKEFILE_LIST)
${MAKE} -f Makefile.stm32h7xx LDSCRIPT=STM32H7xx.ld FLASH=EXTERNAL_FLASH MCU_FILE_NAME=$@
stm32f7xx: $(MAKEFILE_LIST)
${MAKE} -f Makefile.stm32f7xx LDSCRIPT=STM32F7xx.ld FLASH=INTERNAL_FLASH MCU_FILE_NAME=$@
stm32f7xx_ram: $(MAKEFILE_LIST)
${MAKE} -f Makefile.stm32f7xx LDSCRIPT=STM32F7xx_RAM.ld FLASH=INTERNAL_FLASH MCU_FILE_NAME=$@
#######################################
# Code coverage
#######################################
GCOV_EXTENSIONS=*.gc*
GCOVR_PATH=Tests/gcovr-report
LCOV_PATH=Tests/lcov-report
lcov-report: test_all
mkdir -p $(LCOV_PATH)
lcov --capture --directory . --output-file $(LCOV_PATH)/coverage.info
lcov --remove $(LCOV_PATH)/coverage.info '*/Tests/*' --output-file $(LCOV_PATH)/coverage.info
genhtml $(LCOV_PATH)/coverage.info --output-directory $(LCOV_PATH)
gcovr-report: test_all
mkdir -p $(GCOVR_PATH)
gcovr --exclude 'Tests' --root . --html --html-details --output $(GCOVR_PATH)/coverage.html
#######################################
# Dependancies
#######################################
deps:
sudo apt-get install lcov
pip3 install gcovr