diff options
| author | Georgiy Bondarenko <69736697+nehilo@users.noreply.github.com> | 2021-03-04 20:54:23 +0300 |
|---|---|---|
| committer | Georgiy Bondarenko <69736697+nehilo@users.noreply.github.com> | 2021-03-04 20:54:23 +0300 |
| commit | e8701195e66f2d27ffe17fb514eae8173795aaf7 (patch) | |
| tree | 9f519c4abf6556b9ae7190a6210d87ead1dfadde /buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py | |
| download | kp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.tar.xz kp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.zip | |
Initial commit
Diffstat (limited to 'buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py')
| -rw-r--r-- | buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py b/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py new file mode 100644 index 0000000..ece47ed --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py @@ -0,0 +1,33 @@ +import os +Import("env") + +# Relocate firmware from 0x08000000 to 0x08010000 +for define in env['CPPDEFINES']: + if define[0] == "VECT_TAB_ADDR": + env['CPPDEFINES'].remove(define) +env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000")) + +custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103VE_longer.ld") +for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,-T" in flag: + env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script + elif flag == "-T": + env["LINKFLAGS"][i + 1] = custom_ld_script + + +# Rename ${PROGNAME}.bin and save it as 'project.bin' (No encryption on the Longer3D) +def encrypt(source, target, env): + firmware = open(target[0].path, "rb") + marlin_alfa = open(target[0].dir.path +'/project.bin', "wb") + length = os.path.getsize(target[0].path) + position = 0 + try: + while position < length: + byte = firmware.read(1) + marlin_alfa.write(byte) + position += 1 + finally: + firmware.close() + marlin_alfa.close() + +env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); |
