Skip to content

Commit

Permalink
🔨 PlatformIO 6 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jul 20, 2023
1 parent d6e767e commit e8b5641
Show file tree
Hide file tree
Showing 16 changed files with 266 additions and 287 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@
* TMC26X Stepper Driver options
*
* The TMC26XStepper library is required for this stepper driver.
* https://github.com/trinamic/TMC26XStepper
* https://github.com/MarlinFirmware/TMC26XStepper
*/
#if HAS_DRIVER(TMC26X)

Expand Down
7 changes: 2 additions & 5 deletions buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
import os, marlin
Import("env")

STM32_FLASH_SIZE = 256

for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_ADDR":
env['CPPDEFINES'].remove(define)
if define[0] == "STM32_FLASH_SIZE":
STM32_FLASH_SIZE = define[1]

# Relocate firmware from 0x08000000 to 0x08007000
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
marlin.relocate_firmware("0x08007000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103RC_SKR_MINI_" + str(STM32_FLASH_SIZE) + "K.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand Down
4 changes: 2 additions & 2 deletions buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Import("env", "projenv")

# Relocate firmware from 0x08000000 to 0x08002000
#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
#import marlin
#marlin.relocate_firmware("0x08001000")

# Custom HEX from ELF
env.AddPostAction(
Expand Down
4 changes: 2 additions & 2 deletions buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import os, marlin
Import("env")

# Relocate firmware from 0x08000000 to 0x08007000
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
marlin.relocate_firmware("0x08007000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103RE_SKR_E3_DIP.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand Down
8 changes: 2 additions & 6 deletions buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
import os, marlin
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"))
marlin.relocate_firmware("0x08010000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103VE_longer.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand All @@ -14,7 +11,6 @@
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")
Expand Down
9 changes: 2 additions & 7 deletions buildroot/share/PlatformIO/scripts/chitu_crypt.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import os
import struct
import os,struct,marlin
Import("env")

# Relocate firmware from 0x08000000 to 0x08008800
for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_ADDR":
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x8008800"))
marlin.relocate_firmware("0x08008800")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/chitu_f103.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand All @@ -15,7 +11,6 @@
elif flag == "-T":
env["LINKFLAGS"][i + 1] = custom_ld_script


def calculate_crc(contents, seed):
accumulating_xor_value = seed;

Expand Down
4 changes: 2 additions & 2 deletions buildroot/share/PlatformIO/scripts/fysetc_STM32S6.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
shutil.copy(full_file_name, variant_dir)

# Relocate firmware from 0x08000000 to 0x08002000
#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
#import marlin
#marlin.relocate_firmware("0x08010000")
#env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/fysetc_aio_ii.ld")

# Custom HEX from ELF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
import os, marlin
Import("env")

# Relocate firmware from 0x08000000 to 0x0800A000
env['CPPDEFINES'].remove(("VECT_TAB_ADDR", "0x8000000"))
#alternatively, for STSTM <=5.1.0 use line below
#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x0800A000"))
marlin.relocate_firmware("0x0800A000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/jgaurora_a5s_a1.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand Down Expand Up @@ -45,4 +42,3 @@ def addboot(source,target,env):
#os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin')

env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", addboot);

17 changes: 17 additions & 0 deletions buildroot/share/PlatformIO/scripts/marlin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# buildroot/share/PlatformIO/scripts/marlin.py
# Helper module with some commonly-used functions
#
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()

def replace_define(field, value):
envdefs = env['CPPDEFINES'].copy()
for define in envdefs:
if define[0] == field:
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append((field, value))

# Relocate the firmware to a new address, such as "0x08005000"
def relocate_firmware(address):
replace_define("VECT_TAB_ADDR", address)
7 changes: 2 additions & 5 deletions buildroot/share/PlatformIO/scripts/mks_robin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
import os, marlin
Import("env")

# Relocate firmware from 0x08000000 to 0x08007000
for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_ADDR":
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
marlin.relocate_firmware("0x08007000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand Down
8 changes: 2 additions & 6 deletions buildroot/share/PlatformIO/scripts/mks_robin_lite.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
import os, marlin
Import("env")

# Relocate firmware from 0x08000000 to 0x08005000
for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_ADDR":
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000"))
marlin.relocate_firmware("0x08005000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_lite.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand All @@ -14,7 +11,6 @@
elif flag == "-T":
env["LINKFLAGS"][i + 1] = custom_ld_script


# Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
def encrypt(source, target, env):
import sys
Expand Down
8 changes: 2 additions & 6 deletions buildroot/share/PlatformIO/scripts/mks_robin_lite3.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
import os, marlin
Import("env")

# Relocate firmware from 0x08000000 to 0x08005000
for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_ADDR":
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000"))
marlin.relocate_firmware("0x08005000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_lite.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand All @@ -14,7 +11,6 @@
elif flag == "-T":
env["LINKFLAGS"][i + 1] = custom_ld_script


# Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
def encrypt(source, target, env):
import sys
Expand Down
8 changes: 2 additions & 6 deletions buildroot/share/PlatformIO/scripts/mks_robin_mini.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
import os, marlin
Import("env")

# Relocate firmware from 0x08000000 to 0x08007000
for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_ADDR":
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
marlin.relocate_firmware("0x08007000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_mini.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand All @@ -14,7 +11,6 @@
elif flag == "-T":
env["LINKFLAGS"][i + 1] = custom_ld_script


# Encrypt ${PROGNAME}.bin and save it as 'Robin_mini.bin'
def encrypt(source, target, env):
import sys
Expand Down
8 changes: 2 additions & 6 deletions buildroot/share/PlatformIO/scripts/mks_robin_nano.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
import os, marlin
Import("env")

# Relocate firmware from 0x08000000 to 0x08007000
for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_ADDR":
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
marlin.relocate_firmware("0x08007000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_nano.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand All @@ -14,7 +11,6 @@
elif flag == "-T":
env["LINKFLAGS"][i + 1] = custom_ld_script


# Encrypt ${PROGNAME}.bin and save it as 'Robin_nano.bin'
def encrypt(source, target, env):
import sys
Expand Down
7 changes: 2 additions & 5 deletions buildroot/share/PlatformIO/scripts/mks_robin_pro.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
import os, marlin
Import("env")

# Relocate firmware from 0x08000000 to 0x08007000
for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_ADDR":
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
marlin.relocate_firmware("0x08007000")

custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_pro.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand Down
Loading

0 comments on commit e8b5641

Please sign in to comment.