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 ca194ca commit ba38d4f
Show file tree
Hide file tree
Showing 20 changed files with 278 additions and 320 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,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
6 changes: 2 additions & 4 deletions buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
Import("env")

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

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

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

# 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("env")
import os
import random
import struct
import uuid
import os,random,struct,uuid,marlin

# Relocate firmware from 0x08000000 to 0x08008800
env['CPPDEFINES'].remove(("VECT_TAB_ADDR", "0x8000000"))
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08008800"))
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
20 changes: 10 additions & 10 deletions buildroot/share/PlatformIO/scripts/common-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def add_to_feat_cnf(feature, flines):
parts = dep.split('=')
name = parts.pop(0)
rest = '='.join(parts)
if name in ['extra_scripts', 'src_filter', 'lib_ignore']:
if name in ['extra_scripts', 'build_src_filter', 'lib_ignore']:
feat[name] = rest
else:
feat['lib_deps'] += [dep]
Expand Down Expand Up @@ -146,19 +146,19 @@ def apply_features_config():
blab("Running extra_scripts for %s... " % feature)
env.SConscript(feat['extra_scripts'], exports="env")

if 'src_filter' in feat:
blab("Adding src_filter for %s... " % feature)
src_filter = ' '.join(env.GetProjectOption('src_filter'))
if 'build_src_filter' in feat:
blab("Adding build_src_filter for %s... " % feature)
build_src_filter = ' '.join(env.GetProjectOption('build_src_filter'))
# first we need to remove the references to the same folder
my_srcs = re.findall( r'[+-](<.*?>)', feat['src_filter'])
cur_srcs = re.findall( r'[+-](<.*?>)', src_filter)
my_srcs = re.findall( r'[+-](<.*?>)', feat['build_src_filter'])
cur_srcs = re.findall( r'[+-](<.*?>)', build_src_filter)
for d in my_srcs:
if d in cur_srcs:
src_filter = re.sub(r'[+-]' + d, '', src_filter)
build_src_filter = re.sub(r'[+-]' + d, '', build_src_filter)

src_filter = feat['src_filter'] + ' ' + src_filter
set_env_field('src_filter', [src_filter])
env.Replace(SRC_FILTER=src_filter)
build_src_filter = feat['build_src_filter'] + ' ' + build_src_filter
set_env_field('build_src_filter', [build_src_filter])
env.Replace(SRC_FILTER=build_src_filter)

if 'lib_ignore' in feat:
blab("Adding lib_ignore for %s... " % feature)
Expand Down
8 changes: 2 additions & 6 deletions buildroot/share/PlatformIO/scripts/creality.py
Original file line number Diff line number Diff line change
@@ -1,12 +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/creality.ld")

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
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
7 changes: 2 additions & 5 deletions buildroot/share/PlatformIO/scripts/mks_robin_e3.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_e3.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
Expand Down
7 changes: 2 additions & 5 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 Down
7 changes: 2 additions & 5 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 Down
7 changes: 2 additions & 5 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 Down
7 changes: 2 additions & 5 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 Down
7 changes: 2 additions & 5 deletions buildroot/share/PlatformIO/scripts/mks_robin_nano35.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 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
8 changes: 2 additions & 6 deletions buildroot/share/PlatformIO/scripts/stm32_bootloader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os,sys,shutil
import os,sys,shutil,marlin
Import("env")

from SCons.Script import DefaultEnvironment
Expand All @@ -12,11 +12,7 @@ def noencrypt(source, target, env):

if 'offset' in board.get("build").keys():
LD_FLASH_OFFSET = board.get("build.offset")

for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_OFFSET":
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append(("VECT_TAB_OFFSET", LD_FLASH_OFFSET))
marlin.replace_define("VECT_TAB_OFFSET", LD_FLASH_OFFSET)

maximum_ram_size = board.get("upload.maximum_ram_size")

Expand Down
Loading

0 comments on commit ba38d4f

Please sign in to comment.