1-
21# STM32 ARM Core and platform.
32# ------------------------------
43#
@@ -21,25 +20,36 @@ compiler.warning_flags.more=-Wall
2120compiler.warning_flags.all=-Wall -Wextra
2221
2322compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
24- compiler.c.cmd=arm-none-eabi-gcc
25- compiler.c.flags=-mthumb -c {build.flags.optimize} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD {compiler.stm.extra_include}
26- compiler.c.elf.cmd=arm-none-eabi-gcc
27- compiler.c.elf.flags=-mthumb {build.flags.optimize} {build.flags.ldspecs} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
23+
2824compiler.S.cmd=arm-none-eabi-gcc
29- compiler.S.flags=-mthumb -c -x assembler-with-cpp {compiler.stm.extra_include}
25+ compiler.c.cmd=arm-none-eabi-gcc
3026compiler.cpp.cmd=arm-none-eabi-g++
31- compiler.cpp.flags=-mthumb -c {build.flags.optimize} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD {compiler.stm.extra_include}
3227compiler.ar.cmd=arm-none-eabi-gcc-ar
33- compiler.ar.flags=rcs
28+ compiler.c.elf.cmd=arm-none-eabi-gcc
3429compiler.objcopy.cmd=arm-none-eabi-objcopy
30+ compiler.elf2hex.cmd=arm-none-eabi-objcopy
31+
32+ compiler.extra_flags=-mcpu={build.mcu} -DF_CPU={build.f_cpu} -mthumb @{build.opt.path}
33+
34+ compiler.S.flags={compiler.extra_flags} -c -x assembler-with-cpp {compiler.stm.extra_include}
35+
36+ compiler.c.flags={compiler.extra_flags} -c {build.flags.optimize} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD {compiler.stm.extra_include}
37+
38+ compiler.cpp.flags={compiler.extra_flags} -c {build.flags.optimize} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD {compiler.stm.extra_include}
39+
40+ compiler.ar.flags=rcs
41+
42+ compiler.c.elf.flags=-mcpu={build.mcu} -mthumb {build.flags.optimize} {build.flags.ldspecs} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
43+
3544compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
45+
3646compiler.elf2hex.flags=-O binary
37- compiler.elf2hex.cmd=arm-none-eabi-objcopy
47+
3848compiler.ldflags={build.flags.ldspecs}
3949compiler.size.cmd=arm-none-eabi-size
4050compiler.define=-DARDUINO=
4151
42- # this can be overriden in boards.txt
52+ # These can be overriden in boards.txt
4353build.extra_flags=
4454build.ldscript=ldscript.ld
4555
@@ -61,32 +71,39 @@ build.usb_flags=-DUSBCON -DUSBD_VID={build.vid} -DUSBD_PID={build.pid} '-DUSB_MA
6171# numeric vendor ID if available or by board's specific value.
6272build.usb_manufacturer="Unknown"
6373
64- #
6574# Defaults config
66- #
6775build.xSerial=
6876build.enable_usb=
6977build.flags.optimize=
7078build.flags.ldspecs=
7179
80+ # Pre and post build hooks
81+ build.opt.name=build_opt.h
82+ build.opt.sourcepath={build.source.path}/{build.opt.name}
83+ build.opt.path={build.path}/sketch/{build.opt.name}
84+
85+ # Create empty {build.opt} if not exists in the sketch dir
86+ recipe.hooks.prebuild.1.pattern.windows=cmd /c "if not exist {build.opt.sourcepath} mkdir {build.path}/sketch & type NUL > {build.opt.path}"
87+ recipe.hooks.prebuild.1.pattern.linux=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})"
88+ recipe.hooks.prebuild.1.pattern.macosx=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})"
89+
7290# compile patterns
7391# ---------------------
7492
7593## Compile c files
76- recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} - D{build.series} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
94+ recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -D{build.series} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
7795
7896## Compile c++ files
79- recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} - D{build.series} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
97+ recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -D{build.series} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
8098
8199## Compile S files
82- recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} - D{build.series} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
100+ recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -D{build.series} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
83101
84102## Create archives
85103recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
86104
87105## Combine gc-sections, archives, and objects
88- recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group {object_files} {compiler.arm.cmsis.ldflags} -Wl,--whole-archive "{archive_file_path}" -Wl,--no-whole-archive -lc -Wl,--end-group -lm -lgcc -lstdc++ --specs=nano.specs
89-
106+ recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} {compiler.ldflags} {compiler.arm.cmsis.ldflags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group {object_files} -Wl,--whole-archive "{archive_file_path}" -Wl,--no-whole-archive -lc -Wl,--end-group -lm -lgcc -lstdc++ --specs=nano.specs
90107
91108## Create output (.bin file)
92109recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
@@ -105,7 +122,7 @@ recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
105122# Uploader tool
106123# -------------------
107124
108- #Upload to board via mass storage
125+ # Upload to board via mass storage
109126tools.massStorageCopy.cmd=massStorageCopy
110127tools.massStorageCopy.cmd.windows=massStorageCopy.bat
111128tools.massStorageCopy.cmd.macosx=massStorageCopyMacOsX
@@ -117,7 +134,7 @@ tools.massStorageCopy.upload.params.verbose=
117134tools.massStorageCopy.upload.params.quiet=
118135tools.massStorageCopy.upload.pattern="{path}/{cmd}" {upload.verbose} -I "{build.path}/{build.project_name}.bin" -O "{node}"
119136
120- # stlink upload
137+ # ST-Link upload
121138tools.stlink_upload.cmd=stlink_upload
122139tools.stlink_upload.cmd.windows=stlink_upload.bat
123140tools.stlink_upload.path.windows={runtime.hardware.path}/tools/win
0 commit comments