2021-02-27 22:38:57 -06:00
|
|
|
#
|
|
|
|
# STM32F103RC_fysetc.py
|
|
|
|
#
|
2020-06-02 21:04:22 -05:00
|
|
|
import os
|
2019-06-26 00:40:29 -05:00
|
|
|
from os.path import join
|
2019-08-10 01:45:36 -05:00
|
|
|
from os.path import expandvars
|
2020-06-02 21:04:22 -05:00
|
|
|
Import("env")
|
2019-06-26 00:40:29 -05:00
|
|
|
|
2020-06-16 02:39:53 -05:00
|
|
|
# Relocate firmware from 0x08000000 to 0x08008000
|
2020-06-02 21:04:22 -05:00
|
|
|
#for define in env['CPPDEFINES']:
|
2020-05-25 15:48:33 -05:00
|
|
|
# if define[0] == "VECT_TAB_ADDR":
|
|
|
|
# env['CPPDEFINES'].remove(define)
|
2020-06-16 02:39:53 -05:00
|
|
|
#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08008000"))
|
2019-06-26 00:40:29 -05:00
|
|
|
|
2020-06-02 21:04:22 -05:00
|
|
|
#custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld")
|
|
|
|
#for i, flag in enumerate(env["LINKFLAGS"]):
|
|
|
|
# if "-Wl,-T" in flag:
|
|
|
|
# env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
|
|
|
|
# elif flag == "-T":
|
|
|
|
# env["LINKFLAGS"][i + 1] = custom_ld_script
|
|
|
|
|
2019-06-26 00:40:29 -05:00
|
|
|
# Custom HEX from ELF
|
|
|
|
env.AddPostAction(
|
2019-08-10 01:45:36 -05:00
|
|
|
join("$BUILD_DIR","${PROGNAME}.elf"),
|
2019-06-26 00:40:29 -05:00
|
|
|
env.VerboseAction(" ".join([
|
2019-08-10 01:45:36 -05:00
|
|
|
"$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
|
2019-08-12 19:50:34 -05:00
|
|
|
"\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
|
2019-08-10 01:45:36 -05:00
|
|
|
]), "Building $TARGET"))
|
2019-06-26 00:40:29 -05:00
|
|
|
|
|
|
|
# In-line command with arguments
|
2019-08-10 01:45:36 -05:00
|
|
|
UPLOAD_TOOL="stm32flash"
|
|
|
|
platform = env.PioPlatform()
|
|
|
|
if platform.get_package_dir("tool-stm32duino") != None:
|
2019-08-12 19:50:34 -05:00
|
|
|
UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"")
|
2019-08-10 01:45:36 -05:00
|
|
|
|
2019-07-18 05:54:50 -05:00
|
|
|
env.Replace(
|
2019-08-10 01:45:36 -05:00
|
|
|
UPLOADER=UPLOAD_TOOL,
|
2020-03-31 13:59:08 -05:00
|
|
|
UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT")
|
2019-07-18 05:54:50 -05:00
|
|
|
)
|