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.3KB

1234567891011121314151617181920212223242526272829303132333435
  1. #
  2. # fix_framework_weakness.py
  3. #
  4. import pioutil
  5. if pioutil.is_pio_build():
  6. import shutil
  7. from os.path import join, isfile
  8. from pprint import pprint
  9. Import("env")
  10. if env.MarlinHas("POSTMORTEM_DEBUGGING"):
  11. FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple")
  12. patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done")
  13. # patch file only if we didn't do it before
  14. if not isfile(patchflag_path):
  15. print("Patching libmaple exception handlers")
  16. original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S")
  17. backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak")
  18. src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S")
  19. assert isfile(original_file) and isfile(src_file)
  20. shutil.copyfile(original_file, backup_file)
  21. shutil.copyfile(src_file, original_file);
  22. def _touch(path):
  23. with open(path, "w") as fp:
  24. fp.write("")
  25. env.Execute(lambda *args, **kwargs: _touch(patchflag_path))
  26. print("Done patching exception handler")
  27. print("Libmaple modified and ready for post mortem debugging")