My Marlin configs for Fabrikator Mini and CTC i3 Pro B

fix_framework_weakness.py 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from os.path import join, isfile
  2. import shutil
  3. from pprint import pprint
  4. Import("env")
  5. if env.MarlinFeatureIsEnabled("POSTMORTEM_DEBUGGING"):
  6. FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple")
  7. patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done")
  8. # patch file only if we didn't do it before
  9. if not isfile(patchflag_path):
  10. print("Patching libmaple exception handlers")
  11. original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S")
  12. backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak")
  13. src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S")
  14. assert isfile(original_file) and isfile(src_file)
  15. shutil.copyfile(original_file, backup_file)
  16. shutil.copyfile(src_file, original_file);
  17. def _touch(path):
  18. with open(path, "w") as fp:
  19. fp.write("")
  20. env.Execute(lambda *args, **kwargs: _touch(patchflag_path))
  21. print("Done patching exception handler")
  22. print("Libmaple modified and ready for post mortem debugging")
  23. rxBuf = env["MARLIN_FEATURES"]["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in env["MARLIN_FEATURES"] else "0"
  24. txBuf = env["MARLIN_FEATURES"]["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in env["MARLIN_FEATURES"] else "0"
  25. if int(rxBuf) < 64:
  26. rxBuf = "64"
  27. if int(txBuf) < 64:
  28. txBuf = "64"
  29. build_flags = env.get('BUILD_FLAGS')
  30. build_flags.append("-DUSART_RX_BUF_SIZE=" + rxBuf + " -DUSART_TX_BUF_SIZE=" + txBuf)
  31. env.Replace(BUILD_FLAGS=build_flags)