My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stm32_bootloader.py 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #
  2. # stm32_bootloader.py
  3. #
  4. import os,sys,marlin
  5. Import("env")
  6. from SCons.Script import DefaultEnvironment
  7. board = DefaultEnvironment().BoardConfig()
  8. board_keys = board.get("build").keys()
  9. #
  10. # For build.offset define LD_FLASH_OFFSET, used by ldscript.ld
  11. #
  12. if 'offset' in board_keys:
  13. LD_FLASH_OFFSET = board.get("build.offset")
  14. marlin.relocate_vtab(LD_FLASH_OFFSET)
  15. # Flash size
  16. maximum_flash_size = int(board.get("upload.maximum_size") / 1024)
  17. marlin.replace_define('STM32_FLASH_SIZE', maximum_flash_size)
  18. # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json)
  19. maximum_ram_size = board.get("upload.maximum_ram_size")
  20. for i, flag in enumerate(env["LINKFLAGS"]):
  21. if "-Wl,--defsym=LD_FLASH_OFFSET" in flag:
  22. env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET
  23. if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
  24. env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
  25. #
  26. # For build.rename simply rename the firmware file.
  27. #
  28. if 'rename' in board_keys:
  29. def rename_target(source, target, env):
  30. firmware = os.path.join(target[0].dir.path, board.get("build.rename"))
  31. import shutil
  32. shutil.copy(target[0].path, firmware)
  33. marlin.add_post_action(rename_target)