My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

stm32_bootloader.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #
  2. # stm32_bootloader.py
  3. #
  4. import os,sys,shutil
  5. Import("env")
  6. from SCons.Script import DefaultEnvironment
  7. board = DefaultEnvironment().BoardConfig()
  8. #
  9. # Copy the firmware.bin file to build.firmware, no encryption
  10. #
  11. def noencrypt(source, target, env):
  12. firmware = os.path.join(target[0].dir.path, board.get("build.firmware"))
  13. shutil.copy(target[0].path, firmware)
  14. #
  15. # For build.offset define LD_FLASH_OFFSET, used by ldscript.ld
  16. #
  17. if 'offset' in board.get("build").keys():
  18. LD_FLASH_OFFSET = board.get("build.offset")
  19. # Remove an existing VECT_TAB_OFFSET from CPPDEFINES
  20. for define in env['CPPDEFINES']:
  21. if define[0] == "VECT_TAB_OFFSET":
  22. env['CPPDEFINES'].remove(define)
  23. # Replace VECT_TAB_OFFSET with our LD_FLASH_OFFSET
  24. env['CPPDEFINES'].append(("VECT_TAB_OFFSET", LD_FLASH_OFFSET))
  25. # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json)
  26. maximum_ram_size = board.get("upload.maximum_ram_size")
  27. for i, flag in enumerate(env["LINKFLAGS"]):
  28. if "-Wl,--defsym=LD_FLASH_OFFSET" in flag:
  29. env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET
  30. if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
  31. env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
  32. #
  33. # Only copy the file if there's no encrypt
  34. #
  35. board_keys = board.get("build").keys()
  36. if 'firmware' in board_keys and not 'encrypt' in board_keys:
  37. env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt)