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.

fix_framework_weakness.py 1.5KB

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