Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test sh #21

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 35 additions & 27 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,33 @@
name=STM32 boards groups (Board to be selected from Tools submenu 'Board part number')
version=2.8.0-dev


# Define variables used multiple times in platform file
# --------------------
tool_suffix=
tool_suffix.windows=.exe

busybox=
busybox.windows={runtime.tools.STM32Tools.path}/win/busybox.exe

toolchain_dir={runtime.tools.xpack-arm-none-eabi-gcc-13.2.1-1.1.path}
openocd_dir={runtime.tools.xpack-openocd-0.12.0-2.path}

tools_bin_path.windows={runtime.tools.STM32Tools.path}/win
tools_bin_path.macosx={runtime.tools.STM32Tools.path}/macosx
tools_bin_path.linux={runtime.tools.STM32Tools.path}/linux

core_stm32_dir={build.core.path}/stm32
core_usb_dir={core_stm32_dir}/usb
hal_dir={build.system.path}/Drivers/{build.series}_HAL_Driver
cmsis_dir={runtime.tools.CMSIS-5.9.0.path}/CMSIS
cmsis_dev_dir={build.system.path}/Drivers/CMSIS/Device/ST/{build.series}
usbd_core_dir={build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core

# STM compile variables
# ----------------------
compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{build.core.path}/stm32" "-I{build.core.path}/stm32/LL" "-I{build.core.path}/stm32/usb" "-I{build.core.path}/stm32/OpenAMP" "-I{build.core.path}/stm32/usb/hid" "-I{build.core.path}/stm32/usb/cdc" "-I{build.system.path}/Drivers/{build.series}_HAL_Driver/Inc" "-I{build.system.path}/Drivers/{build.series}_HAL_Driver/Src" "-I{build.system.path}/{build.series}" "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core/Src" {build.virtio_extra_include}
compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{core_stm32_dir}" "-I{core_stm32_dir}/LL" "-I{core_usb_dir}" "-I{core_stm32_dir}/OpenAMP" "-I{core_usb_dir}/hid" "-I{core_usb_dir}/cdc" "-I{hal_dir}/Inc" "-I{hal_dir}/Src" "-I{build.system.path}/{build.series}" "-I{usbd_core_dir}/Inc" "-I{usbd_core_dir}/Src" {build.virtio_extra_include}
compiler.arm.cmsis.c.flags="-I{cmsis_dir}/Core/Include/" "-I{cmsis_dev_dir}/Include/" "-I{cmsis_dev_dir}/Source/Templates/gcc/" "-I{cmsis_dir}/DSP/Include" "-I{cmsis_dir}/DSP/PrivateInclude"

compiler.warning_flags=-w
compiler.warning_flags.none=-w
Expand All @@ -23,7 +47,7 @@ compiler.optimization_flags={build.flags.optimize} {build.flags.debug}
compiler.optimization_flags.release={build.flags.optimize} {build.flags.debug}
compiler.optimization_flags.debug=-Og -g

compiler.path={runtime.tools.xpack-arm-none-eabi-gcc-13.2.1-1.1.path}/bin/
compiler.path={toolchain_dir}/bin/

compiler.S.cmd=arm-none-eabi-gcc
compiler.c.cmd=arm-none-eabi-gcc
Expand Down Expand Up @@ -75,8 +99,6 @@ compiler.ar.extra_flags=
compiler.elf2bin.extra_flags=
compiler.elf2hex.extra_flags=

compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.9.0.path}/CMSIS/Core/Include/" "-I{build.system.path}/Drivers/CMSIS/Device/ST/{build.series}/Include/" "-I{build.system.path}/Drivers/CMSIS/Device/ST/{build.series}/Source/Templates/gcc/" "-I{runtime.tools.CMSIS-5.9.0.path}/CMSIS/DSP/Include" "-I{runtime.tools.CMSIS-5.9.0.path}/CMSIS/DSP/PrivateInclude"

# USB Flags
# ---------
build.usb_flags=-DUSBCON {build.usb_speed} -DUSBD_VID={build.vid} -DUSBD_PID={build.pid} -DHAL_PCD_MODULE_ENABLED
Expand Down Expand Up @@ -122,10 +144,8 @@ build.opt.path={build.path}/sketch/{build.opt.name}
extras.path={build.system.path}/extras

# Create {build.opt} if not exists in the output sketch dir and force include of SrcWrapper library
recipe.hooks.prebuild.1.pattern="{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{runtime.platform.path}"
recipe.hooks.prebuild.1.pattern.windows="{runtime.tools.STM32Tools.path}/win/busybox.exe" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{runtime.platform.path}"
recipe.hooks.postbuild.1.pattern="{extras.path}/postbuild.sh" "{build.path}" "{build.series}" "{runtime.platform.path}"
recipe.hooks.postbuild.1.pattern.windows="{runtime.tools.STM32Tools.path}/win/busybox.exe" sh "{extras.path}/postbuild.sh" "{build.path}" "{build.series}" "{runtime.platform.path}"
recipe.hooks.prebuild.1.pattern="{busybox}" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{runtime.platform.path}"
recipe.hooks.postbuild.1.pattern="{busybox}" sh "{extras.path}/postbuild.sh" "{build.path}" "{build.series}" "{runtime.platform.path}"

# compile patterns
# ---------------------
Expand All @@ -149,7 +169,7 @@ recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.f
recipe.objcopy.bin.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"

## Create output (.hex file)
recipe.objcopy.hex.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"

build.preferred_out_format=bin

Expand All @@ -170,25 +190,20 @@ recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
# Upload to board via mass storage
tools.massStorageCopy.cmd=massStorageCopy.sh
tools.massStorageCopy.cmd.windows=massStorageCopy.bat
tools.massStorageCopy.path={runtime.tools.STM32Tools.path}/win
tools.massStorageCopy.path.macosx={runtime.tools.STM32Tools.path}/macosx
tools.massStorageCopy.path.linux={runtime.tools.STM32Tools.path}/linux
tools.massStorageCopy.upload.params.verbose=
tools.massStorageCopy.upload.params.quiet=
tools.massStorageCopy.upload.pattern="{path}/{cmd}" {upload.verbose} -I "{build.path}/{build.project_name}.bin" -O "{node}"
tools.massStorageCopy.upload.pattern="{tools_bin_path}/{cmd}" {upload.verbose} -I "{build.path}/{build.project_name}.bin" -O "{node}"

# STM32CubeProgrammer upload
tools.stm32CubeProg.path={runtime.tools.STM32Tools.path}
tools.stm32CubeProg.busybox=
tools.stm32CubeProg.busybox.windows={path}/win/busybox.exe
tools.stm32CubeProg.cmd=stm32CubeProg.sh
tools.stm32CubeProg.upload.params.verbose=
tools.stm32CubeProg.upload.params.quiet=
tools.stm32CubeProg.upload.pattern="{busybox}" sh "{path}/{cmd}" {upload.protocol} "{build.path}/{build.project_name}.bin" {build.flash_offset} {upload.options}

# blackmagic upload for generic STM32
tools.bmp_upload.cmd=arm-none-eabi-gdb
tools.bmp_upload.path={runtime.tools.xpack-arm-none-eabi-gcc.path}/bin
tools.bmp_upload.path={toolchain_dir}/bin
tools.bmp_upload.upload.speed=230400
tools.bmp_upload.upload.params.verbose=-batch
tools.bmp_upload.upload.params.quiet=--batch-silent
Expand All @@ -198,26 +213,19 @@ tools.bmp_upload.upload.pattern.windows="{path}/{cmd}" -nx -b {upload.speed} {up
# HID flash 2.2 (HID bootloader v2.2 for STM32F1 and STM32F4 series)
tools.hid_upload.cmd=hid-flash
tools.hid_upload.cmd.windows=hid-flash.exe
tools.hid_upload.path={runtime.tools.STM32Tools.path}/win
tools.hid_upload.path.macosx={runtime.tools.STM32Tools.path}/macosx
tools.hid_upload.path.linux={runtime.tools.STM32Tools.path}/linux
tools.hid_upload.upload.params.verbose=-d
tools.hid_upload.upload.params.quiet=n
tools.hid_upload.upload.pattern="{path}/{cmd}" "{build.path}/{build.project_name}.bin" {serial.port.file}
tools.hid_upload.upload.pattern="{tools_bin_path}/{cmd}" "{build.path}/{build.project_name}.bin" {serial.port.file}

# Upload using Maple bootloader over DFU
tools.maple_upload.script=maple_upload.sh
tools.maple_upload.busybox=
tools.maple_upload.busybox.windows={path}/win/busybox.exe
tools.maple_upload.path={runtime.tools.STM32Tools.path}
tools.maple_upload.upload.params.verbose=-d
tools.maple_upload.upload.params.quiet=n
tools.maple_upload.upload.pattern="{busybox}" sh "{path}/{script}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"

# STM32MP1 self-contained shell script
tools.remoteproc_gen.path={runtime.tools.STM32Tools.path}
tools.remoteproc_gen.busybox=
tools.remoteproc_gen.busybox.windows={path}/win/busybox.exe
tools.remoteproc_gen.script=run_arduino_gen.sh
tools.remoteproc_gen.upload.params.verbose=
tools.remoteproc_gen.upload.params.quiet=
Expand All @@ -229,9 +237,9 @@ tools.remoteproc_gen.upload.pattern="{busybox}" sh "{path}/{script}" generate "{
# - this is alpha and may be subject to change without notice
debug.executable={build.path}/{build.project_name}.elf
debug.toolchain=gcc
debug.toolchain.path={compiler.path}
debug.toolchain.path={toolchain_dir.path}/bin
debug.toolchain.prefix=arm-none-eabi-
debug.server=openocd
debug.server.openocd.path={runtime.tools.xpack-openocd-0.12.0-2.path}/bin/openocd
debug.server.openocd.scripts_dir={runtime.tools.xpack-openocd-0.12.0-2.path}/openocd/scripts
debug.server.openocd.path={openocd_dir}/bin/openocd
debug.server.openocd.scripts_dir={openocd_dir}/openocd/scripts
debug.server.openocd.script={build.path}/openocd.cfg
33 changes: 25 additions & 8 deletions system/extras/prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,37 @@ if [ ! -f "$BUILD_PATH/sketch" ]; then
mkdir -p "$BUILD_PATH/sketch"
fi

# Create empty build.opt if build_opt.h does not exists in the original sketch dir
# Then add or append -fmacro-prefix-map option to change __FILE__ absolute path of
# the board platform folder to a relative path by using '.'.
# (i.e. the folder containing boards.txt)
# Create empty build.opt or clear it if build_opt.h does not exists in the original sketch dir
if [ ! -f "$BUILD_SOURCE_PATH/build_opt.h" ]; then
printf '\n-fmacro-prefix-map="%s"=.' "${BOARD_PLATFORM_PATH//\\/\\\\}" > "$BUILD_PATH/sketch/build.opt"
true >"$BUILD_PATH/sketch/build.opt"
else
# Else copy the build_opt.h as build.opt
# Workaround to the header file preprocessing done by arduino-cli
# See https://github.com/arduino/arduino-cli/issues/1338
cp "$BUILD_SOURCE_PATH/build_opt.h" "$BUILD_PATH/sketch/build.opt"
printf '\n-fmacro-prefix-map="%s"=.' "${BOARD_PLATFORM_PATH//\\/\\\\}" >> "$BUILD_PATH/sketch/build.opt"
cp -f "$BUILD_SOURCE_PATH/build_opt.h" "$BUILD_PATH/sketch/build.opt"
fi
# Then append -fmacro-prefix-map option to change __FILE__ absolute path of
# the board platform folder to a relative path by using '.'.
# (i.e. the folder containing boards.txt)
UNAME_OS="$(uname -s)"
case "${UNAME_OS}" in
Windows*)
i=0
prefix=""
while [ "$i" -le "${#BOARD_PLATFORM_PATH}" ]; do
prefix=${prefix}${BOARD_PLATFORM_PATH:$i:1}
if [ "${BOARD_PLATFORM_PATH:$i:1}" == "\\" ]; then
prefix=${prefix}"\\"
fi
i="$((i + 1))"
done
;;
*)
prefix=${BOARD_PLATFORM_PATH}
;;
esac

printf '\n-fmacro-prefix-map="%s"=.' "${prefix}" >>"$BUILD_PATH/sketch/build.opt"

# Force include of SrcWrapper library
echo "#include <SrcWrapper.h>" > "$BUILD_PATH/sketch/SrcWrapper.cpp"
echo "#include <SrcWrapper.h>" >"$BUILD_PATH/sketch/SrcWrapper.cpp"
Loading