stm32_bootloader.py 1000 B

123456789101112131415161718192021222324252627
  1. import os,sys,shutil,marlin
  2. Import("env")
  3. from SCons.Script import DefaultEnvironment
  4. board = DefaultEnvironment().BoardConfig()
  5. def noencrypt(source, target, env):
  6. firmware = os.path.join(target[0].dir.path, board.get("build.firmware"))
  7. # do not overwrite encrypted firmware if present
  8. if not os.path.isfile(firmware):
  9. shutil.copy(target[0].path, firmware)
  10. if 'offset' in board.get("build").keys():
  11. LD_FLASH_OFFSET = board.get("build.offset")
  12. marlin.replace_define("VECT_TAB_OFFSET", LD_FLASH_OFFSET)
  13. maximum_ram_size = board.get("upload.maximum_ram_size")
  14. for i, flag in enumerate(env["LINKFLAGS"]):
  15. if "-Wl,--defsym=LD_FLASH_OFFSET" in flag:
  16. env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET
  17. if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
  18. env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
  19. if 'firmware' in board.get("build").keys():
  20. env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt);