1 ###############################################################
5 # NOTE: These are not tied to the default goals
6 # and must be invoked manually
8 # ARM SDK Version: 10.3-2021.10
10 ###############################################################
12 ##############################
14 # Check that environmental variables are sane
16 ##############################
18 # Set up ARM (STM32) SDK
19 ARM_SDK_DIR ?
= $(TOOLS_DIR
)/gcc-arm-none-eabi-10.3
-2021.10
20 # Checked below, Should match the output of $(shell arm-none-eabi-gcc -dumpversion)
21 GCC_REQUIRED_VERSION ?
= 10.3.1
23 .PHONY
: arm_sdk_version
26 $(V1
) $(ARM_SDK_PREFIX
)gcc
--version
28 ## arm_sdk_install : Install Arm SDK
29 .PHONY
: arm_sdk_install
31 ARM_SDK_URL_BASE
:= https
://developer.arm.com
/-/media
/Files
/downloads
/gnu-rm
/10.3-2021.10/gcc-arm-none-eabi-10.3
-2021.10
32 # source: https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
33 ifeq ($(OSFAMILY
), linux
)
34 ARM_SDK_URL
:= $(ARM_SDK_URL_BASE
)-$(shell uname
-m
)-linux.
tar.bz2
37 ifeq ($(OSFAMILY
), macosx
)
38 ARM_SDK_URL
:= $(ARM_SDK_URL_BASE
)-mac.
tar.bz2
41 ifeq ($(OSFAMILY
), windows
)
42 ARM_SDK_URL
:= $(ARM_SDK_URL_BASE
)-win32.zip
45 ARM_SDK_FILE
:= $(notdir $(ARM_SDK_URL
))
47 SDK_INSTALL_MARKER
:= $(ARM_SDK_DIR
)/bin
/arm-none-eabi-gcc-
$(GCC_REQUIRED_VERSION
)
49 # order-only prereq on directory existance:
50 arm_sdk_install
: |
$(TOOLS_DIR
)
51 arm_sdk_install
: arm_sdk_download
$(SDK_INSTALL_MARKER
)
53 $(SDK_INSTALL_MARKER
):
54 ifneq ($(OSFAMILY
), windows
)
55 # binary only release so just extract it
56 $(V1
) tar -C
$(TOOLS_DIR
) -xjf
"$(DL_DIR)/$(ARM_SDK_FILE)"
58 $(V1
) unzip
-q
-d
$(ARM_SDK_DIR
) "$(DL_DIR)/$(ARM_SDK_FILE)"
61 .PHONY
: arm_sdk_download
62 arm_sdk_download
: |
$(DL_DIR
)
63 arm_sdk_download
: $(DL_DIR
)/$(ARM_SDK_FILE
)
64 $(DL_DIR
)/$(ARM_SDK_FILE
):
65 # download the source only if it's newer than what we already have
66 $(V1
) curl
-L
-k
-o
"$@" $(if
$(wildcard $@
), -z
"$@",) "$(ARM_SDK_URL)"
68 ## arm_sdk_clean : Uninstall Arm SDK
71 $(V1
) [ ! -d
"$(ARM_SDK_DIR)" ] ||
$(RM
) -r
$(ARM_SDK_DIR
)
72 $(V1
) [ ! -d
"$(DL_DIR)" ] ||
$(RM
) -r
$(DL_DIR
)
74 .PHONY
: openocd_win_install
76 openocd_win_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
77 openocd_win_install
: OPENOCD_URL
:= git
://git.code.sf.net
/p
/openocd
/code
78 openocd_win_install
: OPENOCD_REV
:= cf1418e9a85013bbf8dbcc2d2e9985695993d9f4
79 openocd_win_install
: OPENOCD_OPTIONS
:=
81 ifeq ($(OPENOCD_FTDI
), yes
)
82 openocd_win_install
: OPENOCD_OPTIONS
:= $(OPENOCD_OPTIONS
) --enable-ft2232_ftd2xx
--with-ftd2xx-win32-zipdir
=$(FTD2XX_DIR
)
85 openocd_win_install
: openocd_win_clean libusb_win_install ftd2xx_install
87 @echo
" DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
88 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
89 $(V1
) mkdir
-p
"$(OPENOCD_BUILD_DIR)"
90 $(V1
) git clone
--no-checkout
$(OPENOCD_URL
) "$(DL_DIR)/openocd-build"
92 cd
$(OPENOCD_BUILD_DIR
) ; \
93 git checkout
-q
$(OPENOCD_REV
) ; \
97 @echo
" PATCH $(OPENOCD_BUILD_DIR)"
99 cd
$(OPENOCD_BUILD_DIR
) ; \
100 git apply
< $(ROOT_DIR
)/flight
/Project
/OpenOCD
/0003-freertos-cm4f-fpu-support.patch
; \
101 git apply
< $(ROOT_DIR
)/flight
/Project
/OpenOCD
/0004-st-icdi-disable.patch
; \
105 @echo
" BUILD $(OPENOCD_WIN_DIR)"
106 $(V1
) mkdir
-p
"$(OPENOCD_WIN_DIR)"
108 cd
$(OPENOCD_BUILD_DIR
) ; \
110 .
/configure
--enable-maintainer-mode
--prefix="$(OPENOCD_WIN_DIR)" \
111 --build
=i686-pc-linux-gnu
--host
=i586-mingw32msvc \
112 CPPFLAGS
=-I
$(LIBUSB_WIN_DIR
)/include \
113 LDFLAGS
=-L
$(LIBUSB_WIN_DIR
)/lib
/gcc \
121 # delete the extracted source when we're done
122 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
124 .PHONY
: openocd_win_clean
126 @echo
" CLEAN $(OPENOCD_WIN_DIR)"
127 $(V1
) [ ! -d
"$(OPENOCD_WIN_DIR)" ] ||
$(RM
) -r
"$(OPENOCD_WIN_DIR)"
129 # Set up openocd tools
130 OPENOCD_DIR
:= $(TOOLS_DIR
)/openocd
131 OPENOCD_WIN_DIR
:= $(TOOLS_DIR
)/openocd_win
132 OPENOCD_BUILD_DIR
:= $(DL_DIR
)/openocd-build
134 .PHONY
: openocd_install
136 openocd_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
137 openocd_install
: OPENOCD_URL
:= git
://git.code.sf.net
/p
/openocd
/code
138 openocd_install
: OPENOCD_TAG
:= v0.9
.0
139 openocd_install
: OPENOCD_OPTIONS
:= --enable-maintainer-mode
--prefix="$(OPENOCD_DIR)" --enable-buspirate
--enable-stlink
141 ifeq ($(OPENOCD_FTDI
), yes
)
142 openocd_install
: OPENOCD_OPTIONS
:= $(OPENOCD_OPTIONS
) --enable-ftdi
145 ifeq ($(UNAME
), Darwin
)
146 openocd_install
: OPENOCD_OPTIONS
:= $(OPENOCD_OPTIONS
) --disable-option-checking
149 openocd_install
: openocd_clean
150 # download the source
151 @echo
" DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_TAG)"
152 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
153 $(V1
) mkdir
-p
"$(OPENOCD_BUILD_DIR)"
154 $(V1
) git clone
--no-checkout
$(OPENOCD_URL
) "$(OPENOCD_BUILD_DIR)"
156 cd
$(OPENOCD_BUILD_DIR
) ; \
157 git checkout
-q
tags/$(OPENOCD_TAG
) ; \
161 @echo
" BUILD $(OPENOCD_DIR)"
162 $(V1
) mkdir
-p
"$(OPENOCD_DIR)"
164 cd
$(OPENOCD_BUILD_DIR
) ; \
166 .
/configure
$(OPENOCD_OPTIONS
) ; \
171 # delete the extracted source when we're done
172 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
174 .PHONY
: openocd_clean
176 @echo
" CLEAN $(OPENOCD_DIR)"
177 $(V1
) [ ! -d
"$(OPENOCD_DIR)" ] ||
$(RM
) -r
"$(OPENOCD_DIR)"
179 STM32FLASH_DIR
:= $(TOOLS_DIR
)/stm32flash
181 .PHONY
: stm32flash_install
182 stm32flash_install
: STM32FLASH_URL
:= http
://stm32flash.googlecode.com
/svn
/trunk
183 stm32flash_install
: STM32FLASH_REV
:= 61
184 stm32flash_install
: stm32flash_clean
185 # download the source
186 @echo
" DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)"
187 $(V1
) svn
export -q
-r
"$(STM32FLASH_REV)" "$(STM32FLASH_URL)" "$(STM32FLASH_DIR)"
190 @echo
" BUILD $(STM32FLASH_DIR)"
191 $(V1
) $(MAKE
) --silent
-C
$(STM32FLASH_DIR
) all
193 .PHONY
: stm32flash_clean
195 @echo
" CLEAN $(STM32FLASH_DIR)"
196 $(V1
) [ ! -d
"$(STM32FLASH_DIR)" ] ||
$(RM
) -r
"$(STM32FLASH_DIR)"
198 # Set up uncrustify tools
199 UNCRUSTIFY_DIR
:= $(TOOLS_DIR
)/uncrustify-0.61
200 UNCRUSTIFY_BUILD_DIR
:= $(DL_DIR
)/uncrustify
202 .PHONY
: uncrustify_install
203 uncrustify_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
204 uncrustify_install
: UNCRUSTIFY_URL
:= http
://downloads.sourceforge.net
/project
/uncrustify
/uncrustify
/uncrustify-0.61
/uncrustify-0.61.
tar.gz
205 uncrustify_install
: UNCRUSTIFY_FILE
:= uncrustify-0.61.
tar.gz
206 uncrustify_install
: UNCRUSTIFY_OPTIONS
:= prefix=$(UNCRUSTIFY_DIR
)
207 uncrustify_install
: uncrustify_clean
208 ifneq ($(OSFAMILY
), windows
)
209 @echo
" DOWNLOAD $(UNCRUSTIFY_URL)"
210 $(V1
) curl
-L
-k
-o
"$(DL_DIR)/$(UNCRUSTIFY_FILE)" "$(UNCRUSTIFY_URL)"
213 @echo
" EXTRACT $(UNCRUSTIFY_FILE)"
214 $(V1
) tar -C
$(TOOLS_DIR
) -xf
"$(DL_DIR)/$(UNCRUSTIFY_FILE)"
216 @echo
" BUILD $(UNCRUSTIFY_DIR)"
218 cd
$(UNCRUSTIFY_DIR
) ; \
219 .
/configure
--prefix="$(UNCRUSTIFY_DIR)" ; \
223 # delete the extracted source when we're done
224 $(V1
) [ ! -d
"$(UNCRUSTIFY_BUILD_DIR)" ] ||
$(RM
) -r
"$(UNCRUSTIFY_BUILD_DIR)"
226 .PHONY
: uncrustify_clean
228 @echo
" CLEAN $(UNCRUSTIFY_DIR)"
229 $(V1
) [ ! -d
"$(UNCRUSTIFY_DIR)" ] ||
$(RM
) -r
"$(UNCRUSTIFY_DIR)"
230 @echo
" CLEAN $(UNCRUSTIFY_BUILD_DIR)"
231 $(V1
) [ ! -d
"$(UNCRUSTIFY_BUILD_DIR)" ] ||
$(RM
) -r
"$(UNCRUSTIFY_BUILD_DIR)"
234 zip_install
: ZIP_URL
:= http
://pkgs.fedoraproject.org
/repo
/pkgs
/zip
/zip30.
tar.gz
/7b74551e63f8ee6aab6fbc86676c0d37
/zip30.
tar.gz
236 zip_install
: ZIP_FILE
:= $(notdir $(ZIP_URL
))
238 ZIP_DIR
= $(TOOLS_DIR
)/zip30
240 # order-only prereq on directory existance:
241 zip_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
242 zip_install
: zip_clean
243 $(V1
) curl
-L
-k
-o
"$(DL_DIR)/$(ZIP_FILE)" "$(ZIP_URL)"
244 $(V1
) tar --force-local
-C
$(TOOLS_DIR
) -xzf
"$(DL_DIR)/$(ZIP_FILE)"
245 ifneq ($(OSFAMILY
), windows
)
246 $(V1
) cd
"$(ZIP_DIR)" && $(MAKE
) -f unix
/Makefile generic_gcc
248 $(V1
) cd
"$(ZIP_DIR)" && $(MAKE
) -f win32
/makefile.gcc
253 $(V1
) [ ! -d
"$(ZIP_DIR)" ] ||
$(RM
) -rf
$(ZIP_DIR
)
255 ##############################
257 # Set up paths to tools
259 ##############################
261 ifeq ($(shell [ -d
"$(ARM_SDK_DIR)" ] && echo
"exists"), exists
)
262 ARM_SDK_PREFIX
:= $(ARM_SDK_DIR
)/bin
/arm-none-eabi-
263 else ifeq (,$(filter %_install
test% clean% %-print checks help configs
, $(MAKECMDGOALS
)))
264 GCC_VERSION
= $(shell arm-none-eabi-gcc
-dumpversion
)
265 ifeq ($(GCC_VERSION
),)
266 $(error
**ERROR
** arm-none-eabi-gcc not in the PATH. Run
'make arm_sdk_install' to
install automatically in the tools folder of this repo
)
267 else ifneq ($(GCC_VERSION
), $(GCC_REQUIRED_VERSION
))
268 $(error
**ERROR
** your arm-none-eabi-gcc is
'$(GCC_VERSION)', but
'$(GCC_REQUIRED_VERSION)' is expected. Override with
'GCC_REQUIRED_VERSION' in mk
/local.mk or run
'make arm_sdk_install' to
install the right version automatically in the tools folder of this repo
)
271 # ARM toolchain is in the path, and the version is what's required.
272 ARM_SDK_PREFIX ?
= arm-none-eabi-
275 ifeq ($(shell [ -d
"$(ZIP_DIR)" ] && echo
"exists"), exists
)
276 export ZIPBIN
:= $(ZIP_DIR
)/zip
281 ifeq ($(shell [ -d
"$(OPENOCD_DIR)" ] && echo
"exists"), exists
)
282 OPENOCD
:= $(OPENOCD_DIR
)/bin
/openocd
284 # not installed, hope it's in the path...
288 ifeq ($(shell [ -d
"$(UNCRUSTIFY_DIR)" ] && echo
"exists"), exists
)
289 UNCRUSTIFY
:= $(UNCRUSTIFY_DIR
)/bin
/uncrustify
291 # not installed, hope it's in the path...
292 UNCRUSTIFY ?
= uncrustify
296 DUMP_SYMBOLS_TOOL
:= $(TOOLS_DIR
)/breakpad
/$(OSFAMILY
)-$(ARCHFAMILY
)/dump_syms
297 BREAKPAD_URL
:= http
://dronin.tracer.nz
/tools
/breakpad.zip
298 BREAKPAD_DL_FILE
:= $(DL_DIR
)/$(notdir $(BREAKPAD_URL
))
299 BREAKPAD_DIR
:= $(TOOLS_DIR
)/breakpad
301 .PHONY
: breakpad_install
302 breakpad_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
303 breakpad_install
: breakpad_clean
304 @echo
" DOWNLOAD $(BREAKPAD_URL)"
305 $(V1
) $(V1
) curl
-L
-k
-z
"$(BREAKPAD_DL_FILE)" -o
"$(BREAKPAD_DL_FILE)" "$(BREAKPAD_URL)"
306 @echo
" EXTRACT $(notdir $(BREAKPAD_DL_FILE))"
307 $(V1
) mkdir
-p
"$(BREAKPAD_DIR)"
308 $(V1
) unzip
-q
-d
$(BREAKPAD_DIR
) "$(BREAKPAD_DL_FILE)"
309 ifeq ($(OSFAMILY
), windows
)
310 $(V1
) ln
-s
"$(TOOLS_DIR)/breakpad/$(OSFAMILY)-i686" "$(TOOLS_DIR)/breakpad/$(OSFAMILY)-x86_64"
313 .PHONY
: breakpad_clean
315 @echo
" CLEAN $(BREAKPAD_DIR)"
316 $(V1
) [ ! -d
"$(BREAKPAD_DIR)" ] ||
$(RM
) -rf
$(BREAKPAD_DIR
)
317 @echo
" CLEAN $(BREAKPAD_DL_FILE)"
318 $(V1
) $(RM
) -f
$(BREAKPAD_DL_FILE
)