STM32F103RC_fysetc.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from os.path import join
  2. from os.path import expandvars
  3. Import("env", "projenv")
  4. # Relocate firmware from 0x08000000 to 0x08002000
  5. #import marlin
  6. #marlin.relocate_firmware("0x08001000")
  7. # Custom HEX from ELF
  8. env.AddPostAction(
  9. join("$BUILD_DIR","${PROGNAME}.elf"),
  10. env.VerboseAction(" ".join([
  11. "$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
  12. "\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
  13. ]), "Building $TARGET"))
  14. # please keep $SOURCE variable, it will be replaced with a path to firmware
  15. # Generic
  16. #env.Replace(
  17. # UPLOADER="serial_upload.bat"
  18. # UPLOADCMD="$UPLOADER stm32loader.py $SOURCE"
  19. #)
  20. # In-line command with arguments
  21. UPLOAD_TOOL="stm32flash"
  22. platform = env.PioPlatform()
  23. if platform.get_package_dir("tool-stm32duino") != None:
  24. UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"")
  25. env.Replace(
  26. UPLOADER=UPLOAD_TOOL,
  27. UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr $UPLOAD_PORT -R -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"")
  28. )
  29. # Python callback
  30. #def on_upload(source, target, env):
  31. # print source, target
  32. # firmware_path = str(source[0])
  33. # # do something
  34. # env.Execute(".\serial_upload.bat")
  35. #env.Replace(UPLOADCMD=on_upload)