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
)-x86_64-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
)
52 arm_sdk_install
: arm_sdk_download
$(SDK_INSTALL_MARKER
)
54 $(SDK_INSTALL_MARKER
):
55 ifneq ($(OSFAMILY
), windows
)
56 # binary only release so just extract it
57 $(V1
) tar -C
$(TOOLS_DIR
) -xjf
"$(DL_DIR)/$(ARM_SDK_FILE)"
59 $(V1
) unzip
-q
-d
$(ARM_SDK_DIR
) "$(DL_DIR)/$(ARM_SDK_FILE)"
62 .PHONY
: arm_sdk_download
63 arm_sdk_download
: |
$(DL_DIR
)
64 arm_sdk_download
: $(DL_DIR
)/$(ARM_SDK_FILE
)
65 $(DL_DIR
)/$(ARM_SDK_FILE
):
66 # download the source only if it's newer than what we already have
67 $(V1
) curl
-L
-k
-o
"$(DL_DIR)/$(ARM_SDK_FILE)" -z
"$(DL_DIR)/$(ARM_SDK_FILE)" "$(ARM_SDK_URL)"
70 ## arm_sdk_clean : Uninstall Arm SDK
73 $(V1
) [ ! -d
"$(ARM_SDK_DIR)" ] ||
$(RM
) -r
$(ARM_SDK_DIR
)
74 $(V1
) [ ! -d
"$(DL_DIR)" ] ||
$(RM
) -r
$(DL_DIR
)
76 .PHONY
: openocd_win_install
78 openocd_win_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
79 openocd_win_install
: OPENOCD_URL
:= git
://git.code.sf.net
/p
/openocd
/code
80 openocd_win_install
: OPENOCD_REV
:= cf1418e9a85013bbf8dbcc2d2e9985695993d9f4
81 openocd_win_install
: OPENOCD_OPTIONS
:=
83 ifeq ($(OPENOCD_FTDI
), yes
)
84 openocd_win_install
: OPENOCD_OPTIONS
:= $(OPENOCD_OPTIONS
) --enable-ft2232_ftd2xx
--with-ftd2xx-win32-zipdir
=$(FTD2XX_DIR
)
87 openocd_win_install
: openocd_win_clean libusb_win_install ftd2xx_install
89 @echo
" DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
90 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
91 $(V1
) mkdir
-p
"$(OPENOCD_BUILD_DIR)"
92 $(V1
) git clone
--no-checkout
$(OPENOCD_URL
) "$(DL_DIR)/openocd-build"
94 cd
$(OPENOCD_BUILD_DIR
) ; \
95 git checkout
-q
$(OPENOCD_REV
) ; \
99 @echo
" PATCH $(OPENOCD_BUILD_DIR)"
101 cd
$(OPENOCD_BUILD_DIR
) ; \
102 git apply
< $(ROOT_DIR
)/flight
/Project
/OpenOCD
/0003-freertos-cm4f-fpu-support.patch
; \
103 git apply
< $(ROOT_DIR
)/flight
/Project
/OpenOCD
/0004-st-icdi-disable.patch
; \
107 @echo
" BUILD $(OPENOCD_WIN_DIR)"
108 $(V1
) mkdir
-p
"$(OPENOCD_WIN_DIR)"
110 cd
$(OPENOCD_BUILD_DIR
) ; \
112 .
/configure
--enable-maintainer-mode
--prefix="$(OPENOCD_WIN_DIR)" \
113 --build
=i686-pc-linux-gnu
--host
=i586-mingw32msvc \
114 CPPFLAGS
=-I
$(LIBUSB_WIN_DIR
)/include \
115 LDFLAGS
=-L
$(LIBUSB_WIN_DIR
)/lib
/gcc \
123 # delete the extracted source when we're done
124 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
126 .PHONY
: openocd_win_clean
128 @echo
" CLEAN $(OPENOCD_WIN_DIR)"
129 $(V1
) [ ! -d
"$(OPENOCD_WIN_DIR)" ] ||
$(RM
) -r
"$(OPENOCD_WIN_DIR)"
131 # Set up openocd tools
132 OPENOCD_DIR
:= $(TOOLS_DIR
)/openocd
133 OPENOCD_WIN_DIR
:= $(TOOLS_DIR
)/openocd_win
134 OPENOCD_BUILD_DIR
:= $(DL_DIR
)/openocd-build
136 .PHONY
: openocd_install
138 openocd_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
139 openocd_install
: OPENOCD_URL
:= git
://git.code.sf.net
/p
/openocd
/code
140 openocd_install
: OPENOCD_TAG
:= v0.9
.0
141 openocd_install
: OPENOCD_OPTIONS
:= --enable-maintainer-mode
--prefix="$(OPENOCD_DIR)" --enable-buspirate
--enable-stlink
143 ifeq ($(OPENOCD_FTDI
), yes
)
144 openocd_install
: OPENOCD_OPTIONS
:= $(OPENOCD_OPTIONS
) --enable-ftdi
147 ifeq ($(UNAME
), Darwin
)
148 openocd_install
: OPENOCD_OPTIONS
:= $(OPENOCD_OPTIONS
) --disable-option-checking
151 openocd_install
: openocd_clean
152 # download the source
153 @echo
" DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_TAG)"
154 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
155 $(V1
) mkdir
-p
"$(OPENOCD_BUILD_DIR)"
156 $(V1
) git clone
--no-checkout
$(OPENOCD_URL
) "$(OPENOCD_BUILD_DIR)"
158 cd
$(OPENOCD_BUILD_DIR
) ; \
159 git checkout
-q
tags/$(OPENOCD_TAG
) ; \
163 @echo
" BUILD $(OPENOCD_DIR)"
164 $(V1
) mkdir
-p
"$(OPENOCD_DIR)"
166 cd
$(OPENOCD_BUILD_DIR
) ; \
168 .
/configure
$(OPENOCD_OPTIONS
) ; \
173 # delete the extracted source when we're done
174 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
176 .PHONY
: openocd_clean
178 @echo
" CLEAN $(OPENOCD_DIR)"
179 $(V1
) [ ! -d
"$(OPENOCD_DIR)" ] ||
$(RM
) -r
"$(OPENOCD_DIR)"
181 STM32FLASH_DIR
:= $(TOOLS_DIR
)/stm32flash
183 .PHONY
: stm32flash_install
184 stm32flash_install
: STM32FLASH_URL
:= http
://stm32flash.googlecode.com
/svn
/trunk
185 stm32flash_install
: STM32FLASH_REV
:= 61
186 stm32flash_install
: stm32flash_clean
187 # download the source
188 @echo
" DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)"
189 $(V1
) svn
export -q
-r
"$(STM32FLASH_REV)" "$(STM32FLASH_URL)" "$(STM32FLASH_DIR)"
192 @echo
" BUILD $(STM32FLASH_DIR)"
193 $(V1
) $(MAKE
) --silent
-C
$(STM32FLASH_DIR
) all
195 .PHONY
: stm32flash_clean
197 @echo
" CLEAN $(STM32FLASH_DIR)"
198 $(V1
) [ ! -d
"$(STM32FLASH_DIR)" ] ||
$(RM
) -r
"$(STM32FLASH_DIR)"
200 # Set up uncrustify tools
201 UNCRUSTIFY_DIR
:= $(TOOLS_DIR
)/uncrustify-0.61
202 UNCRUSTIFY_BUILD_DIR
:= $(DL_DIR
)/uncrustify
204 .PHONY
: uncrustify_install
205 uncrustify_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
206 uncrustify_install
: UNCRUSTIFY_URL
:= http
://downloads.sourceforge.net
/project
/uncrustify
/uncrustify
/uncrustify-0.61
/uncrustify-0.61.
tar.gz
207 uncrustify_install
: UNCRUSTIFY_FILE
:= uncrustify-0.61.
tar.gz
208 uncrustify_install
: UNCRUSTIFY_OPTIONS
:= prefix=$(UNCRUSTIFY_DIR
)
209 uncrustify_install
: uncrustify_clean
210 ifneq ($(OSFAMILY
), windows
)
211 @echo
" DOWNLOAD $(UNCRUSTIFY_URL)"
212 $(V1
) curl
-L
-k
-o
"$(DL_DIR)/$(UNCRUSTIFY_FILE)" "$(UNCRUSTIFY_URL)"
215 @echo
" EXTRACT $(UNCRUSTIFY_FILE)"
216 $(V1
) tar -C
$(TOOLS_DIR
) -xf
"$(DL_DIR)/$(UNCRUSTIFY_FILE)"
218 @echo
" BUILD $(UNCRUSTIFY_DIR)"
220 cd
$(UNCRUSTIFY_DIR
) ; \
221 .
/configure
--prefix="$(UNCRUSTIFY_DIR)" ; \
225 # delete the extracted source when we're done
226 $(V1
) [ ! -d
"$(UNCRUSTIFY_BUILD_DIR)" ] ||
$(RM
) -r
"$(UNCRUSTIFY_BUILD_DIR)"
228 .PHONY
: uncrustify_clean
230 @echo
" CLEAN $(UNCRUSTIFY_DIR)"
231 $(V1
) [ ! -d
"$(UNCRUSTIFY_DIR)" ] ||
$(RM
) -r
"$(UNCRUSTIFY_DIR)"
232 @echo
" CLEAN $(UNCRUSTIFY_BUILD_DIR)"
233 $(V1
) [ ! -d
"$(UNCRUSTIFY_BUILD_DIR)" ] ||
$(RM
) -r
"$(UNCRUSTIFY_BUILD_DIR)"
236 zip_install
: ZIP_URL
:= http
://pkgs.fedoraproject.org
/repo
/pkgs
/zip
/zip30.
tar.gz
/7b74551e63f8ee6aab6fbc86676c0d37
/zip30.
tar.gz
238 zip_install
: ZIP_FILE
:= $(notdir $(ZIP_URL
))
240 ZIP_DIR
= $(TOOLS_DIR
)/zip30
242 # order-only prereq on directory existance:
243 zip_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
244 zip_install
: zip_clean
245 $(V1
) curl
-L
-k
-o
"$(DL_DIR)/$(ZIP_FILE)" "$(ZIP_URL)"
246 $(V1
) tar --force-local
-C
$(TOOLS_DIR
) -xzf
"$(DL_DIR)/$(ZIP_FILE)"
247 ifneq ($(OSFAMILY
), windows
)
248 $(V1
) cd
"$(ZIP_DIR)" && $(MAKE
) -f unix
/Makefile generic_gcc
250 $(V1
) cd
"$(ZIP_DIR)" && $(MAKE
) -f win32
/makefile.gcc
255 $(V1
) [ ! -d
"$(ZIP_DIR)" ] ||
$(RM
) -rf
$(ZIP_DIR
)
257 ##############################
259 # Set up paths to tools
261 ##############################
263 ifeq ($(shell [ -d
"$(ARM_SDK_DIR)" ] && echo
"exists"), exists
)
264 ARM_SDK_PREFIX
:= $(ARM_SDK_DIR
)/bin
/arm-none-eabi-
265 else ifeq (,$(filter %_install
test% clean% %-print checks help
, $(MAKECMDGOALS
)))
266 GCC_VERSION
= $(shell arm-none-eabi-gcc
-dumpversion
)
267 ifeq ($(GCC_VERSION
),)
268 $(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
)
269 else ifneq ($(GCC_VERSION
), $(GCC_REQUIRED_VERSION
))
270 $(error
**ERROR
** your arm-none-eabi-gcc is
'$(GCC_VERSION)', but
'$(GCC_REQUIRED_VERSION)' is expected. Override with
'GCC_REQUIRED_VERSION' in make
/local.mk or run
'make arm_sdk_install' to
install the right version automatically in the tools folder of this repo
)
273 # ARM tookchain is in the path, and the version is what's required.
274 ARM_SDK_PREFIX ?
= arm-none-eabi-
277 ifeq ($(shell [ -d
"$(ZIP_DIR)" ] && echo
"exists"), exists
)
278 export ZIPBIN
:= $(ZIP_DIR
)/zip
283 ifeq ($(shell [ -d
"$(OPENOCD_DIR)" ] && echo
"exists"), exists
)
284 OPENOCD
:= $(OPENOCD_DIR
)/bin
/openocd
286 # not installed, hope it's in the path...
290 ifeq ($(shell [ -d
"$(UNCRUSTIFY_DIR)" ] && echo
"exists"), exists
)
291 UNCRUSTIFY
:= $(UNCRUSTIFY_DIR
)/bin
/uncrustify
293 # not installed, hope it's in the path...
294 UNCRUSTIFY ?
= uncrustify
298 DUMP_SYMBOLS_TOOL
:= $(TOOLS_DIR
)/breakpad
/$(OSFAMILY
)-$(ARCHFAMILY
)/dump_syms
299 BREAKPAD_URL
:= http
://dronin.tracer.nz
/tools
/breakpad.zip
300 BREAKPAD_DL_FILE
:= $(DL_DIR
)/$(notdir $(BREAKPAD_URL
))
301 BREAKPAD_DIR
:= $(TOOLS_DIR
)/breakpad
303 .PHONY
: breakpad_install
304 breakpad_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
305 breakpad_install
: breakpad_clean
306 @echo
" DOWNLOAD $(BREAKPAD_URL)"
307 $(V1
) $(V1
) curl
-L
-k
-z
"$(BREAKPAD_DL_FILE)" -o
"$(BREAKPAD_DL_FILE)" "$(BREAKPAD_URL)"
308 @echo
" EXTRACT $(notdir $(BREAKPAD_DL_FILE))"
309 $(V1
) mkdir
-p
"$(BREAKPAD_DIR)"
310 $(V1
) unzip
-q
-d
$(BREAKPAD_DIR
) "$(BREAKPAD_DL_FILE)"
311 ifeq ($(OSFAMILY
), windows
)
312 $(V1
) ln
-s
"$(TOOLS_DIR)/breakpad/$(OSFAMILY)-i686" "$(TOOLS_DIR)/breakpad/$(OSFAMILY)-x86_64"
315 .PHONY
: breakpad_clean
317 @echo
" CLEAN $(BREAKPAD_DIR)"
318 $(V1
) [ ! -d
"$(BREAKPAD_DIR)" ] ||
$(RM
) -rf
$(BREAKPAD_DIR
)
319 @echo
" CLEAN $(BREAKPAD_DL_FILE)"
320 $(V1
) $(RM
) -f
$(BREAKPAD_DL_FILE
)