STM32F103RC_fysetc.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import os
  2. from os.path import join
  3. from os.path import expandvars
  4. Import("env")
  5. # Relocate firmware from 0x08000000 to 0x08008000
  6. #import marlin
  7. #marlin.relocate_firmware("0x08008000")
  8. #custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld")
  9. #for i, flag in enumerate(env["LINKFLAGS"]):
  10. # if "-Wl,-T" in flag:
  11. # env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
  12. # elif flag == "-T":
  13. # env["LINKFLAGS"][i + 1] = custom_ld_script
  14. # Custom HEX from ELF
  15. env.AddPostAction(
  16. join("$BUILD_DIR","${PROGNAME}.elf"),
  17. env.VerboseAction(" ".join([
  18. "$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
  19. "\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
  20. ]), "Building $TARGET"))
  21. # In-line command with arguments
  22. UPLOAD_TOOL="stm32flash"
  23. platform = env.PioPlatform()
  24. if platform.get_package_dir("tool-stm32duino") != None:
  25. UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"")
  26. env.Replace(
  27. UPLOADER=UPLOAD_TOOL,
  28. UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT")
  29. )