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

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