🔨 PlatformIO 6 compatibility
This commit is contained in:
committed by
Sven Soost
parent
eee1018122
commit
6fde6ce9c4
@@ -5,248 +5,249 @@
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
import subprocess,os,re
|
||||
Import("env")
|
||||
import subprocess,os,re
|
||||
Import("env")
|
||||
|
||||
from platformio.package.meta import PackageSpec
|
||||
from platformio.project.config import ProjectConfig
|
||||
from platformio.package.meta import PackageSpec
|
||||
from platformio.project.config import ProjectConfig
|
||||
|
||||
verbose = 0
|
||||
FEATURE_CONFIG = {}
|
||||
verbose = 0
|
||||
FEATURE_CONFIG = {}
|
||||
|
||||
def validate_pio():
|
||||
PIO_VERSION_MIN = (6, 0, 1)
|
||||
try:
|
||||
from platformio import VERSION as PIO_VERSION
|
||||
weights = (1000, 100, 1)
|
||||
version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)])
|
||||
version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)])
|
||||
if version_cur < version_min:
|
||||
print()
|
||||
print("**************************************************")
|
||||
print("****** An update to PlatformIO is ******")
|
||||
print("****** required to build Marlin Firmware. ******")
|
||||
print("****** ******")
|
||||
print("****** Minimum version: ", PIO_VERSION_MIN, " ******")
|
||||
print("****** Current Version: ", PIO_VERSION, " ******")
|
||||
print("****** ******")
|
||||
print("****** Update PlatformIO and try again. ******")
|
||||
print("**************************************************")
|
||||
print()
|
||||
exit(1)
|
||||
except SystemExit:
|
||||
exit(1)
|
||||
except:
|
||||
print("Can't detect PlatformIO Version")
|
||||
def validate_pio():
|
||||
PIO_VERSION_MIN = (6, 0, 1)
|
||||
try:
|
||||
from platformio import VERSION as PIO_VERSION
|
||||
weights = (1000, 100, 1)
|
||||
version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)])
|
||||
version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)])
|
||||
if version_cur < version_min:
|
||||
print()
|
||||
print("**************************************************")
|
||||
print("****** An update to PlatformIO is ******")
|
||||
print("****** required to build Marlin Firmware. ******")
|
||||
print("****** ******")
|
||||
print("****** Minimum version: ", PIO_VERSION_MIN, " ******")
|
||||
print("****** Current Version: ", PIO_VERSION, " ******")
|
||||
print("****** ******")
|
||||
print("****** Update PlatformIO and try again. ******")
|
||||
print("**************************************************")
|
||||
print()
|
||||
exit(1)
|
||||
except SystemExit:
|
||||
exit(1)
|
||||
except:
|
||||
print("Can't detect PlatformIO Version")
|
||||
|
||||
def blab(str,level=1):
|
||||
if verbose >= level:
|
||||
print("[deps] %s" % str)
|
||||
def blab(str,level=1):
|
||||
if verbose >= level:
|
||||
print("[deps] %s" % str)
|
||||
|
||||
def add_to_feat_cnf(feature, flines):
|
||||
def add_to_feat_cnf(feature, flines):
|
||||
|
||||
try:
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
except:
|
||||
FEATURE_CONFIG[feature] = {}
|
||||
try:
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
except:
|
||||
FEATURE_CONFIG[feature] = {}
|
||||
|
||||
# Get a reference to the FEATURE_CONFIG under construction
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
# Get a reference to the FEATURE_CONFIG under construction
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
|
||||
# Split up passed lines on commas or newlines and iterate
|
||||
# Add common options to the features config under construction
|
||||
# For lib_deps replace a previous instance of the same library
|
||||
atoms = re.sub(r',\s*', '\n', flines).strip().split('\n')
|
||||
for line in atoms:
|
||||
parts = line.split('=')
|
||||
name = parts.pop(0)
|
||||
if name in ['build_flags', 'extra_scripts', 'build_src_filter', 'lib_ignore']:
|
||||
feat[name] = '='.join(parts)
|
||||
blab("[%s] %s=%s" % (feature, name, feat[name]), 3)
|
||||
else:
|
||||
for dep in re.split(r',\s*', line):
|
||||
lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0)
|
||||
lib_re = re.compile('(?!^' + lib_name + '\\b)')
|
||||
if not 'lib_deps' in feat: feat['lib_deps'] = {}
|
||||
feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
|
||||
blab("[%s] lib_deps = %s" % (feature, dep), 3)
|
||||
# Split up passed lines on commas or newlines and iterate
|
||||
# Add common options to the features config under construction
|
||||
# For lib_deps replace a previous instance of the same library
|
||||
atoms = re.sub(r',\\s*', '\n', flines).strip().split('\n')
|
||||
for line in atoms:
|
||||
parts = line.split('=')
|
||||
name = parts.pop(0)
|
||||
if name in ['build_flags', 'extra_scripts', 'build_src_filter', 'lib_ignore']:
|
||||
feat[name] = '='.join(parts)
|
||||
blab("[%s] %s=%s" % (feature, name, feat[name]), 3)
|
||||
else:
|
||||
for dep in re.split(r",\s*", line):
|
||||
lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0)
|
||||
lib_re = re.compile('(?!^' + lib_name + '\\b)')
|
||||
feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
|
||||
blab("[%s] lib_deps = %s" % (feature, dep), 3)
|
||||
|
||||
def load_features():
|
||||
blab("========== Gather [features] entries...")
|
||||
for key in ProjectConfig().items('features'):
|
||||
feature = key[0].upper()
|
||||
if not feature in FEATURE_CONFIG:
|
||||
FEATURE_CONFIG[feature] = { 'lib_deps': [] }
|
||||
add_to_feat_cnf(feature, key[1])
|
||||
def load_config():
|
||||
blab("========== Gather [features] entries...")
|
||||
items = ProjectConfig().items('features')
|
||||
for key in items:
|
||||
feature = key[0].upper()
|
||||
if not feature in FEATURE_CONFIG:
|
||||
FEATURE_CONFIG[feature] = { 'lib_deps': [] }
|
||||
add_to_feat_cnf(feature, key[1])
|
||||
|
||||
# Add options matching custom_marlin.MY_OPTION to the pile
|
||||
blab("========== Gather custom_marlin entries...")
|
||||
for n in env.GetProjectOptions():
|
||||
key = n[0]
|
||||
mat = re.match(r'custom_marlin\.(.+)', key)
|
||||
if mat:
|
||||
try:
|
||||
val = env.GetProjectOption(key)
|
||||
except:
|
||||
val = None
|
||||
if val:
|
||||
opt = mat[1].upper()
|
||||
blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val ))
|
||||
add_to_feat_cnf(opt, val)
|
||||
# Add options matching custom_marlin.MY_OPTION to the pile
|
||||
blab("========== Gather custom_marlin entries...")
|
||||
all_opts = env.GetProjectOptions()
|
||||
for n in all_opts:
|
||||
key = n[0]
|
||||
mat = re.match(r'custom_marlin\.(.+)', key)
|
||||
if mat:
|
||||
try:
|
||||
val = env.GetProjectOption(key)
|
||||
except:
|
||||
val = None
|
||||
if val:
|
||||
opt = mat.group(1).upper()
|
||||
blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val ))
|
||||
add_to_feat_cnf(opt, val)
|
||||
|
||||
def get_all_known_libs():
|
||||
known_libs = []
|
||||
for feature in FEATURE_CONFIG:
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
if not 'lib_deps' in feat:
|
||||
continue
|
||||
for dep in feat['lib_deps']:
|
||||
known_libs.append(PackageSpec(dep).name)
|
||||
return known_libs
|
||||
def get_all_known_libs():
|
||||
known_libs = []
|
||||
for feature in FEATURE_CONFIG:
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
if not 'lib_deps' in feat:
|
||||
continue
|
||||
for dep in feat['lib_deps']:
|
||||
known_libs.append(PackageSpec(dep).name)
|
||||
return known_libs
|
||||
|
||||
def get_all_env_libs():
|
||||
env_libs = []
|
||||
lib_deps = env.GetProjectOption('lib_deps')
|
||||
for dep in lib_deps:
|
||||
env_libs.append(PackageSpec(dep).name)
|
||||
return env_libs
|
||||
def get_all_env_libs():
|
||||
env_libs = []
|
||||
lib_deps = env.GetProjectOption('lib_deps')
|
||||
for dep in lib_deps:
|
||||
env_libs.append(PackageSpec(dep).name)
|
||||
return env_libs
|
||||
|
||||
def set_env_field(field, value):
|
||||
proj = env.GetProjectConfig()
|
||||
proj.set("env:" + env['PIOENV'], field, value)
|
||||
def set_env_field(field, value):
|
||||
proj = env.GetProjectConfig()
|
||||
proj.set("env:" + env['PIOENV'], field, value)
|
||||
|
||||
# All unused libs should be ignored so that if a library
|
||||
# exists in .pio/lib_deps it will not break compilation.
|
||||
def force_ignore_unused_libs():
|
||||
env_libs = get_all_env_libs()
|
||||
known_libs = get_all_known_libs()
|
||||
diff = (list(set(known_libs) - set(env_libs)))
|
||||
lib_ignore = env.GetProjectOption('lib_ignore') + diff
|
||||
blab("Ignore libraries: %s" % lib_ignore)
|
||||
set_env_field('lib_ignore', lib_ignore)
|
||||
# All unused libs should be ignored so that if a library
|
||||
# exists in .pio/lib_deps it will not break compilation.
|
||||
def force_ignore_unused_libs():
|
||||
env_libs = get_all_env_libs()
|
||||
known_libs = get_all_known_libs()
|
||||
diff = (list(set(known_libs) - set(env_libs)))
|
||||
lib_ignore = env.GetProjectOption('lib_ignore') + diff
|
||||
blab("Ignore libraries: %s" % lib_ignore)
|
||||
set_env_field('lib_ignore', lib_ignore)
|
||||
|
||||
def apply_features_config():
|
||||
load_features()
|
||||
blab("========== Apply enabled features...")
|
||||
for feature in FEATURE_CONFIG:
|
||||
if not env.MarlinHas(feature):
|
||||
continue
|
||||
def apply_features_config():
|
||||
load_config()
|
||||
blab("========== Apply enabled features...")
|
||||
for feature in FEATURE_CONFIG:
|
||||
if not env.MarlinFeatureIsEnabled(feature):
|
||||
continue
|
||||
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
|
||||
if 'lib_deps' in feat and len(feat['lib_deps']):
|
||||
blab("========== Adding lib_deps for %s... " % feature, 2)
|
||||
if 'lib_deps' in feat and len(feat['lib_deps']):
|
||||
blab("========== Adding lib_deps for %s... " % feature, 2)
|
||||
|
||||
# feat to add
|
||||
deps_to_add = {}
|
||||
for dep in feat['lib_deps']:
|
||||
deps_to_add[PackageSpec(dep).name] = dep
|
||||
blab("==================== %s... " % dep, 2)
|
||||
# feat to add
|
||||
deps_to_add = {}
|
||||
for dep in feat['lib_deps']:
|
||||
deps_to_add[PackageSpec(dep).name] = dep
|
||||
blab("==================== %s... " % dep, 2)
|
||||
|
||||
# Does the env already have the dependency?
|
||||
deps = env.GetProjectOption('lib_deps')
|
||||
for dep in deps:
|
||||
name = PackageSpec(dep).name
|
||||
if name in deps_to_add:
|
||||
del deps_to_add[name]
|
||||
# Does the env already have the dependency?
|
||||
deps = env.GetProjectOption('lib_deps')
|
||||
for dep in deps:
|
||||
name = PackageSpec(dep).name
|
||||
if name in deps_to_add:
|
||||
del deps_to_add[name]
|
||||
|
||||
# Are there any libraries that should be ignored?
|
||||
lib_ignore = env.GetProjectOption('lib_ignore')
|
||||
for dep in deps:
|
||||
name = PackageSpec(dep).name
|
||||
if name in deps_to_add:
|
||||
del deps_to_add[name]
|
||||
# Are there any libraries that should be ignored?
|
||||
lib_ignore = env.GetProjectOption('lib_ignore')
|
||||
for dep in deps:
|
||||
name = PackageSpec(dep).name
|
||||
if name in deps_to_add:
|
||||
del deps_to_add[name]
|
||||
|
||||
# Is there anything left?
|
||||
if len(deps_to_add) > 0:
|
||||
# Only add the missing dependencies
|
||||
set_env_field('lib_deps', deps + list(deps_to_add.values()))
|
||||
# Is there anything left?
|
||||
if len(deps_to_add) > 0:
|
||||
# Only add the missing dependencies
|
||||
set_env_field('lib_deps', deps + list(deps_to_add.values()))
|
||||
|
||||
if 'build_flags' in feat:
|
||||
f = feat['build_flags']
|
||||
blab("========== Adding build_flags for %s: %s" % (feature, f), 2)
|
||||
new_flags = env.GetProjectOption('build_flags') + [ f ]
|
||||
env.Replace(BUILD_FLAGS=new_flags)
|
||||
if 'build_flags' in feat:
|
||||
f = feat['build_flags']
|
||||
blab("========== Adding build_flags for %s: %s" % (feature, f), 2)
|
||||
new_flags = env.GetProjectOption('build_flags') + [ f ]
|
||||
env.Replace(BUILD_FLAGS=new_flags)
|
||||
|
||||
if 'extra_scripts' in feat:
|
||||
blab("Running extra_scripts for %s... " % feature, 2)
|
||||
env.SConscript(feat['extra_scripts'], exports="env")
|
||||
if 'extra_scripts' in feat:
|
||||
blab("Running extra_scripts for %s... " % feature, 2)
|
||||
env.SConscript(feat['extra_scripts'], exports="env")
|
||||
|
||||
if 'build_src_filter' in feat:
|
||||
blab("========== Adding build_src_filter for %s... " % feature, 2)
|
||||
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['build_src_filter'])
|
||||
cur_srcs = re.findall(r'[+-](<.*?>)', build_src_filter)
|
||||
for d in my_srcs:
|
||||
if d in cur_srcs:
|
||||
build_src_filter = re.sub(r'[+-]' + d, '', build_src_filter)
|
||||
if 'build_src_filter' in feat:
|
||||
blab("========== Adding build_src_filter for %s... " % feature, 2)
|
||||
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['build_src_filter'])
|
||||
cur_srcs = re.findall(r'[+-](<.*?>)', build_src_filter)
|
||||
for d in my_srcs:
|
||||
if d in cur_srcs:
|
||||
build_src_filter = re.sub(r'[+-]' + d, '', build_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)
|
||||
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, 2)
|
||||
lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
|
||||
set_env_field('lib_ignore', lib_ignore)
|
||||
if 'lib_ignore' in feat:
|
||||
blab("========== Adding lib_ignore for %s... " % feature, 2)
|
||||
lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
|
||||
set_env_field('lib_ignore', lib_ignore)
|
||||
|
||||
#
|
||||
# Use the compiler to get a list of all enabled features
|
||||
#
|
||||
def load_marlin_features():
|
||||
if 'MARLIN_FEATURES' in env:
|
||||
return
|
||||
#
|
||||
# Use the compiler to get a list of all enabled features
|
||||
#
|
||||
def load_marlin_features():
|
||||
if 'MARLIN_FEATURES' in env:
|
||||
return
|
||||
|
||||
# Process defines
|
||||
from preprocessor import run_preprocessor
|
||||
define_list = run_preprocessor(env)
|
||||
marlin_features = {}
|
||||
for define in define_list:
|
||||
feature = define[8:].strip().decode().split(' ')
|
||||
feature, definition = feature[0], ' '.join(feature[1:])
|
||||
marlin_features[feature] = definition
|
||||
env['MARLIN_FEATURES'] = marlin_features
|
||||
# Process defines
|
||||
from preprocessor import run_preprocessor
|
||||
define_list = run_preprocessor(env)
|
||||
marlin_features = {}
|
||||
for define in define_list:
|
||||
feature = define[8:].strip().decode().split(' ')
|
||||
feature, definition = feature[0], ' '.join(feature[1:])
|
||||
marlin_features[feature] = definition
|
||||
env['MARLIN_FEATURES'] = marlin_features
|
||||
|
||||
#
|
||||
# Return True if a matching feature is enabled
|
||||
#
|
||||
def MarlinHas(env, feature):
|
||||
load_marlin_features()
|
||||
r = re.compile('^' + feature + '$')
|
||||
found = list(filter(r.match, env['MARLIN_FEATURES']))
|
||||
#
|
||||
# Return True if a matching feature is enabled
|
||||
#
|
||||
def MarlinFeatureIsEnabled(env, feature):
|
||||
load_marlin_features()
|
||||
r = re.compile('^' + feature + '$')
|
||||
found = list(filter(r.match, env['MARLIN_FEATURES']))
|
||||
|
||||
# Defines could still be 'false' or '0', so check
|
||||
some_on = False
|
||||
if len(found):
|
||||
for f in found:
|
||||
val = env['MARLIN_FEATURES'][f]
|
||||
if val in [ '', '1', 'true' ]:
|
||||
some_on = True
|
||||
elif val in env['MARLIN_FEATURES']:
|
||||
some_on = env.MarlinHas(val)
|
||||
# Defines could still be 'false' or '0', so check
|
||||
some_on = False
|
||||
if len(found):
|
||||
for f in found:
|
||||
val = env['MARLIN_FEATURES'][f]
|
||||
if val in [ '', '1', 'true' ]:
|
||||
some_on = True
|
||||
elif val in env['MARLIN_FEATURES']:
|
||||
some_on = env.MarlinFeatureIsEnabled(val)
|
||||
|
||||
return some_on
|
||||
return some_on
|
||||
|
||||
validate_pio()
|
||||
validate_pio()
|
||||
|
||||
try:
|
||||
verbose = int(env.GetProjectOption('custom_verbose'))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
verbose = int(env.GetProjectOption('custom_verbose'))
|
||||
except:
|
||||
pass
|
||||
|
||||
#
|
||||
# Add a method for other PIO scripts to query enabled features
|
||||
#
|
||||
env.AddMethod(MarlinHas)
|
||||
#
|
||||
# Add a method for other PIO scripts to query enabled features
|
||||
#
|
||||
env.AddMethod(MarlinFeatureIsEnabled)
|
||||
|
||||
#
|
||||
# Add dependencies for enabled Marlin features
|
||||
#
|
||||
apply_features_config()
|
||||
force_ignore_unused_libs()
|
||||
#
|
||||
# Add dependencies for enabled Marlin features
|
||||
#
|
||||
apply_features_config()
|
||||
force_ignore_unused_libs()
|
||||
|
||||
#print(env.Dump())
|
||||
#print(env.Dump())
|
||||
|
||||
from signature import compute_build_signature
|
||||
compute_build_signature(env)
|
||||
from signature import compute_build_signature
|
||||
compute_build_signature(env)
|
||||
|
||||
@@ -2,72 +2,75 @@
|
||||
# marlin.py
|
||||
# Helper module with some commonly-used functions
|
||||
#
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
import os,shutil
|
||||
|
||||
from SCons.Script import DefaultEnvironment
|
||||
env = DefaultEnvironment()
|
||||
|
||||
from os.path import join
|
||||
|
||||
def copytree(src, dst, symlinks=False, ignore=None):
|
||||
for item in src.iterdir():
|
||||
if item.is_dir():
|
||||
shutil.copytree(item, dst / item.name, symlinks, ignore)
|
||||
else:
|
||||
shutil.copy2(item, dst / item.name)
|
||||
for item in os.listdir(src):
|
||||
s = join(src, item)
|
||||
d = join(dst, item)
|
||||
if os.path.isdir(s):
|
||||
shutil.copytree(s, d, symlinks, ignore)
|
||||
else:
|
||||
shutil.copy2(s, d)
|
||||
|
||||
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))
|
||||
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)
|
||||
replace_define("VECT_TAB_ADDR", address)
|
||||
|
||||
# Relocate the vector table with a new offset
|
||||
def relocate_vtab(address):
|
||||
replace_define("VECT_TAB_OFFSET", address)
|
||||
replace_define("VECT_TAB_OFFSET", address)
|
||||
|
||||
# Replace the existing -Wl,-T with the given ldscript path
|
||||
def custom_ld_script(ldname):
|
||||
apath = str(Path("buildroot/share/PlatformIO/ldscripts", ldname).resolve())
|
||||
for i, flag in enumerate(env["LINKFLAGS"]):
|
||||
if "-Wl,-T" in flag:
|
||||
env["LINKFLAGS"][i] = "-Wl,-T" + apath
|
||||
elif flag == "-T":
|
||||
env["LINKFLAGS"][i + 1] = apath
|
||||
apath = os.path.abspath("buildroot/share/PlatformIO/ldscripts/" + ldname)
|
||||
for i, flag in enumerate(env["LINKFLAGS"]):
|
||||
if "-Wl,-T" in flag:
|
||||
env["LINKFLAGS"][i] = "-Wl,-T" + apath
|
||||
elif flag == "-T":
|
||||
env["LINKFLAGS"][i + 1] = apath
|
||||
|
||||
# Encrypt ${PROGNAME}.bin and save it with a new name. This applies (mostly) to MKS boards
|
||||
# This PostAction is set up by offset_and_rename.py for envs with 'build.encrypt_mks'.
|
||||
# Encrypt ${PROGNAME}.bin and save it with a new name
|
||||
# Called by specific encrypt() functions, mostly for MKS boards
|
||||
def encrypt_mks(source, target, env, new_name):
|
||||
import sys
|
||||
import sys
|
||||
|
||||
key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E]
|
||||
key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E]
|
||||
|
||||
# If FIRMWARE_BIN is defined by config, override all
|
||||
mf = env["MARLIN_FEATURES"]
|
||||
if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"]
|
||||
# If FIRMWARE_BIN is defined by config, override all
|
||||
mf = env["MARLIN_FEATURES"]
|
||||
if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"]
|
||||
|
||||
fwpath = Path(target[0].path)
|
||||
fwfile = fwpath.open("rb")
|
||||
enfile = Path(target[0].dir.path, new_name).open("wb")
|
||||
length = fwpath.stat().st_size
|
||||
position = 0
|
||||
try:
|
||||
while position < length:
|
||||
byte = fwfile.read(1)
|
||||
if 320 <= position < 31040:
|
||||
byte = chr(ord(byte) ^ key[position & 31])
|
||||
if sys.version_info[0] > 2:
|
||||
byte = bytes(byte, 'latin1')
|
||||
enfile.write(byte)
|
||||
position += 1
|
||||
finally:
|
||||
fwfile.close()
|
||||
enfile.close()
|
||||
fwpath.unlink()
|
||||
fwpath = target[0].path
|
||||
fwfile = open(fwpath, "rb")
|
||||
enfile = open(target[0].dir.path + "/" + new_name, "wb")
|
||||
length = os.path.getsize(fwpath)
|
||||
position = 0
|
||||
try:
|
||||
while position < length:
|
||||
byte = fwfile.read(1)
|
||||
if position >= 320 and position < 31040:
|
||||
byte = chr(ord(byte) ^ key[position & 31])
|
||||
if sys.version_info[0] > 2:
|
||||
byte = bytes(byte, 'latin1')
|
||||
enfile.write(byte)
|
||||
position += 1
|
||||
finally:
|
||||
fwfile.close()
|
||||
enfile.close()
|
||||
os.remove(fwpath)
|
||||
|
||||
def add_post_action(action):
|
||||
env.AddPostAction(str(Path("$BUILD_DIR", "${PROGNAME}.bin")), action);
|
||||
env.AddPostAction(join("$BUILD_DIR", "${PROGNAME}.bin"), action);
|
||||
|
||||
@@ -14,7 +14,6 @@ YHCB2004 = red-scorp/LiquidCrystal_AIP31068@^1.0.4
|
||||
HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip
|
||||
build_src_filter=+<src/lcd/extui/mks_ui>
|
||||
extra_scripts=download_mks_assets.py
|
||||
MARLIN_TEST_BUILD = build_src_filter=+<src/tests>
|
||||
POSTMORTEM_DEBUGGING = build_src_filter=+<src/HAL/shared/cpu_exception> +<src/HAL/shared/backtrace>
|
||||
build_flags=-funwind-tables
|
||||
MKS_WIFI_MODULE = QRCode=https://github.com/makerbase-mks/QRCode/archive/master.zip
|
||||
@@ -27,6 +26,8 @@ HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster
|
||||
build_src_filter=+<src/feature/digipot>
|
||||
HAS_TMC26X = TMC26XStepper=https://github.com/MarlinFirmware/TMC26XStepper/archive/master.zip
|
||||
build_src_filter=+<src/module/stepper/TMC26X.cpp>
|
||||
HAS_L64XX = Arduino-L6470@0.8.0
|
||||
build_src_filter=+<src/libs/L64XX> +<src/module/stepper/L64xx.cpp> +<src/gcode/feature/L6470> +<src/HAL/shared/HAL_spi_L6470.cpp>
|
||||
LIB_INTERNAL_MAX31865 = build_src_filter=+<src/libs/MAX31865.cpp>
|
||||
NEOPIXEL_LED = adafruit/Adafruit NeoPixel@~1.8.0
|
||||
build_src_filter=+<src/feature/leds/neopixel.cpp>
|
||||
@@ -37,7 +38,7 @@ USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4
|
||||
USES_LIQUIDTWI2 = LiquidTWI2@1.2.7
|
||||
HAS_LCDPRINT = build_src_filter=+<src/lcd/lcdprint.cpp>
|
||||
HAS_MARLINUI_HD44780 = build_src_filter=+<src/lcd/HD44780>
|
||||
HAS_MARLINUI_U8GLIB = marlinfirmware/U8glib-HAL@~0.5.2
|
||||
HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.5.2
|
||||
build_src_filter=+<src/lcd/dogm>
|
||||
HAS_(FSMC|SPI|LTDC)_TFT = build_src_filter=+<src/HAL/STM32/tft> +<src/HAL/STM32F1/tft> +<src/lcd/tft_io>
|
||||
HAS_FSMC_TFT = build_src_filter=+<src/HAL/STM32/tft/tft_fsmc.cpp> +<src/HAL/STM32F1/tft/tft_fsmc.cpp>
|
||||
@@ -99,8 +100,6 @@ HAS_MCP3426_ADC = build_src_filter=+<src/feature/adc> +<s
|
||||
AUTO_BED_LEVELING_BILINEAR = build_src_filter=+<src/feature/bedlevel/abl>
|
||||
AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = build_src_filter=+<src/gcode/bedlevel/abl>
|
||||
X_AXIS_TWIST_COMPENSATION = build_src_filter=+<src/feature/x_twist.cpp> +<src/lcd/menu/menu_x_twist.cpp> +<src/gcode/probe/M423.cpp>
|
||||
BD_SENSOR = markyue/Panda_SoftMasterI2C
|
||||
build_src_filter=+<src/feature/bedlevel/bdl> +<src/gcode/probe/M102.cpp>
|
||||
MESH_BED_LEVELING = build_src_filter=+<src/feature/bedlevel/mbl> +<src/gcode/bedlevel/mbl>
|
||||
AUTO_BED_LEVELING_UBL = build_src_filter=+<src/feature/bedlevel/ubl> +<src/gcode/bedlevel/ubl>
|
||||
UBL_HILBERT_CURVE = build_src_filter=+<src/feature/bedlevel/hilbert_curve.cpp>
|
||||
@@ -119,7 +118,7 @@ EMERGENCY_PARSER = build_src_filter=+<src/feature/e_parser
|
||||
EASYTHREED_UI = build_src_filter=+<src/feature/easythreed_ui.cpp>
|
||||
I2C_POSITION_ENCODERS = build_src_filter=+<src/feature/encoder_i2c.cpp>
|
||||
IIC_BL24CXX_EEPROM = build_src_filter=+<src/libs/BL24CXX.cpp>
|
||||
SPI_FLASH = build_src_filter=+<src/libs/W25Qxx.cpp>
|
||||
HAS_SPI_FLASH = build_src_filter=+<src/libs/W25Qxx.cpp>
|
||||
HAS_ETHERNET = build_src_filter=+<src/feature/ethernet.cpp> +<src/gcode/feature/network/M552-M554.cpp>
|
||||
HAS_FANCHECK = build_src_filter=+<src/feature/fancheck.cpp> +<src/gcode/temp/M123.cpp>
|
||||
HAS_FANMUX = build_src_filter=+<src/feature/fanmux.cpp>
|
||||
@@ -187,7 +186,6 @@ HAS_DUPLICATION_MODE = build_src_filter=+<src/gcode/control/M6
|
||||
LIN_ADVANCE = build_src_filter=+<src/gcode/feature/advance>
|
||||
PHOTO_GCODE = build_src_filter=+<src/gcode/feature/camera>
|
||||
CONTROLLER_FAN_EDITABLE = build_src_filter=+<src/gcode/feature/controllerfan>
|
||||
HAS_SHAPING = build_src_filter=+<src/gcode/feature/input_shaping>
|
||||
GCODE_MACROS = build_src_filter=+<src/gcode/feature/macro>
|
||||
GRADIENT_MIX = build_src_filter=+<src/gcode/feature/mixing/M166.cpp>
|
||||
HAS_SAVED_POSITIONS = build_src_filter=+<src/gcode/feature/pause/G60.cpp> +<src/gcode/feature/pause/G61.cpp>
|
||||
@@ -202,13 +200,12 @@ AUTO_REPORT_POSITION = build_src_filter=+<src/gcode/host/M154.
|
||||
REPETIER_GCODE_M360 = build_src_filter=+<src/gcode/host/M360.cpp>
|
||||
HAS_GCODE_M876 = build_src_filter=+<src/gcode/host/M876.cpp>
|
||||
HAS_RESUME_CONTINUE = build_src_filter=+<src/gcode/lcd/M0_M1.cpp>
|
||||
SET_PROGRESS_MANUALLY = build_src_filter=+<src/gcode/lcd/M73.cpp>
|
||||
LCD_SET_PROGRESS_MANUALLY = build_src_filter=+<src/gcode/lcd/M73.cpp>
|
||||
HAS_STATUS_MESSAGE = build_src_filter=+<src/gcode/lcd/M117.cpp>
|
||||
HAS_PREHEAT = build_src_filter=+<src/gcode/lcd/M145.cpp>
|
||||
HAS_LCD_CONTRAST = build_src_filter=+<src/gcode/lcd/M250.cpp>
|
||||
HAS_GCODE_M255 = build_src_filter=+<src/gcode/lcd/M255.cpp>
|
||||
HAS_LCD_BRIGHTNESS = build_src_filter=+<src/gcode/lcd/M256.cpp>
|
||||
HAS_SOUND = build_src_filter=+<src/gcode/lcd/M300.cpp>
|
||||
HAS_BUZZER = build_src_filter=+<src/gcode/lcd/M300.cpp>
|
||||
TOUCH_SCREEN_CALIBRATION = build_src_filter=+<src/gcode/lcd/M995.cpp>
|
||||
ARC_SUPPORT = build_src_filter=+<src/gcode/motion/G2_G3.cpp>
|
||||
GCODE_MOTION_MODES = build_src_filter=+<src/gcode/motion/G80.cpp>
|
||||
@@ -242,6 +239,5 @@ HAS_MICROSTEPS = build_src_filter=+<src/gcode/control/M3
|
||||
(ESP3D_)?WIFISUPPORT = AsyncTCP, ESP Async WebServer
|
||||
ESP3DLib=https://github.com/luc-github/ESP3DLib/archive/master.zip
|
||||
arduinoWebSockets=links2004/WebSockets@2.3.4
|
||||
luc-github/ESP32SSDP@1.1.1
|
||||
luc-github/ESP32SSDP@^1.1.1
|
||||
lib_ignore=ESPAsyncTCP
|
||||
build_flags=-DSRCHOME=${platformio.src_dir}/src -DHALHOME=SRCHOME
|
||||
|
||||
@@ -13,17 +13,15 @@
|
||||
[platformio]
|
||||
src_dir = Marlin
|
||||
boards_dir = buildroot/share/PlatformIO/boards
|
||||
default_envs = STM32G0B1RE_btt
|
||||
default_envs = mega2560
|
||||
include_dir = Marlin
|
||||
extra_configs =
|
||||
Marlin/config.ini
|
||||
ini/avr.ini
|
||||
ini/due.ini
|
||||
ini/esp32.ini
|
||||
ini/features.ini
|
||||
ini/lpc176x.ini
|
||||
ini/native.ini
|
||||
ini/samd21.ini
|
||||
ini/samd51.ini
|
||||
ini/stm32-common.ini
|
||||
ini/stm32f0.ini
|
||||
@@ -46,13 +44,12 @@ extra_configs =
|
||||
build_flags = -g3 -D__MARLIN_FIRMWARE__ -DNDEBUG
|
||||
-fmax-errors=5
|
||||
extra_scripts =
|
||||
pre:buildroot/share/PlatformIO/scripts/configuration.py
|
||||
pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
|
||||
pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py
|
||||
pre:buildroot/share/PlatformIO/scripts/preflight-checks.py
|
||||
post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py
|
||||
lib_deps =
|
||||
default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared> -<src/tests>
|
||||
default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
|
||||
-<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
|
||||
-<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
|
||||
-<src/lcd/e3v2/common> -<src/lcd/e3v2/creality> -<src/lcd/e3v2/proui> -<src/lcd/e3v2/jyersui> -<src/lcd/e3v2/marlinui>
|
||||
@@ -104,7 +101,6 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared> -<src/t
|
||||
-<src/feature/backlash.cpp>
|
||||
-<src/feature/baricuda.cpp> -<src/gcode/feature/baricuda>
|
||||
-<src/feature/bedlevel/abl> -<src/gcode/bedlevel/abl>
|
||||
-<src/feature/bedlevel/bdl> -<src/gcode/probe/M102.cpp>
|
||||
-<src/feature/bedlevel/mbl> -<src/gcode/bedlevel/mbl>
|
||||
-<src/feature/bedlevel/ubl> -<src/gcode/bedlevel/ubl>
|
||||
-<src/feature/bedlevel/hilbert_curve.cpp>
|
||||
@@ -193,7 +189,6 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared> -<src/t
|
||||
-<src/gcode/feature/advance>
|
||||
-<src/gcode/feature/camera>
|
||||
-<src/gcode/feature/i2c>
|
||||
-<src/gcode/feature/input_shaping>
|
||||
-<src/gcode/feature/L6470>
|
||||
-<src/gcode/feature/leds/M150.cpp>
|
||||
-<src/gcode/feature/leds/M7219.cpp>
|
||||
@@ -223,7 +218,6 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared> -<src/t
|
||||
-<src/gcode/lcd/M0_M1.cpp>
|
||||
-<src/gcode/lcd/M73.cpp>
|
||||
-<src/gcode/lcd/M117.cpp>
|
||||
-<src/gcode/lcd/M145.cpp>
|
||||
-<src/gcode/lcd/M250.cpp> -<src/gcode/lcd/M255.cpp> -<src/gcode/lcd/M256.cpp>
|
||||
-<src/gcode/lcd/M300.cpp>
|
||||
-<src/gcode/lcd/M414.cpp>
|
||||
@@ -251,6 +245,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared> -<src/t
|
||||
-<src/gcode/units/M82_M83.cpp>
|
||||
-<src/gcode/units/M149.cpp>
|
||||
-<src/libs/BL24CXX.cpp> -<src/libs/W25Qxx.cpp>
|
||||
-<src/libs/L64XX> -<src/module/stepper/L64xx.cpp> -<src/HAL/shared/HAL_spi_L6470.cpp>
|
||||
-<src/libs/MAX31865.cpp>
|
||||
-<src/libs/hex_print.cpp>
|
||||
-<src/libs/least_squares_fit.cpp>
|
||||
@@ -268,14 +263,14 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared> -<src/t
|
||||
# Default values apply to all 'env:' prefixed environments
|
||||
#
|
||||
[env]
|
||||
framework = arduino
|
||||
extra_scripts = ${common.extra_scripts}
|
||||
build_flags = ${common.build_flags}
|
||||
lib_deps = ${common.lib_deps}
|
||||
monitor_speed = 250000
|
||||
monitor_eol = LF
|
||||
monitor_echo = yes
|
||||
monitor_filters = colorize, time, send_on_enter
|
||||
framework = arduino
|
||||
extra_scripts = ${common.extra_scripts}
|
||||
build_flags = ${common.build_flags}
|
||||
lib_deps = ${common.lib_deps}
|
||||
monitor_speed = 250000
|
||||
monitor_eol = LF
|
||||
monitor_echo = yes
|
||||
monitor_filters = colorize, time, send_on_enter
|
||||
|
||||
#
|
||||
# Just print the dependency tree
|
||||
|
||||
Reference in New Issue
Block a user