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.

jgaurora_a5s_a1_with_bootloader.py 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import os
  2. Import("env")
  3. # Relocate firmware from 0x08000000 to 0x0800A000
  4. env['CPPDEFINES'].remove(("VECT_TAB_ADDR", "0x8000000"))
  5. #alternatively, for STSTM <=5.1.0 use line below
  6. #env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
  7. env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x0800A000"))
  8. custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/jgaurora_a5s_a1.ld")
  9. for i, flag in enumerate(env["LINKFLAGS"]):
  10. if "-Wl,-T" in flag:
  11. env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
  12. elif flag == "-T":
  13. env["LINKFLAGS"][i + 1] = custom_ld_script
  14. #append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin'
  15. def addboot(source,target,env):
  16. firmware = open(target[0].path, "rb")
  17. lengthfirmware = os.path.getsize(target[0].path)
  18. bootloader_dir = "buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin"
  19. bootloader = open(bootloader_dir, "rb")
  20. lengthbootloader = os.path.getsize(bootloader_dir)
  21. firmware_with_boothloader_dir = target[0].dir.path +'/firmware_with_bootloader.bin'
  22. if os.path.exists(firmware_with_boothloader_dir):
  23. os.remove(firmware_with_boothloader_dir)
  24. firmwareimage = open(firmware_with_boothloader_dir, "wb")
  25. position = 0
  26. while position < lengthbootloader:
  27. byte = bootloader.read(1)
  28. firmwareimage.write(byte)
  29. position += 1
  30. position = 0
  31. while position < lengthfirmware:
  32. byte = firmware.read(1)
  33. firmwareimage.write(byte)
  34. position += 1
  35. bootloader.close()
  36. firmware.close()
  37. firmwareimage.close()
  38. firmware_without_bootloader_dir = target[0].dir.path+'/firmware_for_sd_upload.bin'
  39. if os.path.exists(firmware_without_bootloader_dir):
  40. os.remove(firmware_without_bootloader_dir)
  41. os.rename(target[0].path, firmware_without_bootloader_dir)
  42. #os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin')
  43. env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", addboot);