This commit is contained in:
Sergey
2021-06-15 13:12:14 +03:00
parent 3358523c70
commit 398bb884ec
568 changed files with 11799 additions and 8556 deletions

View File

@@ -8,10 +8,10 @@ Import("env")
# Custom HEX from ELF
env.AddPostAction(
join("$BUILD_DIR","${PROGNAME}.elf"),
join("$BUILD_DIR", "${PROGNAME}.elf"),
env.VerboseAction(" ".join([
"$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
"\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
"\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
]), "Building $TARGET"))
# In-line command with arguments

View File

@@ -28,7 +28,7 @@ if len(platform_packages) == 0:
else:
platform_name = PackageSpec(platform_packages[0]).name
if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "tool-stm32duino" ]:
if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino" ]:
platform_name = "framework-arduinoststm32"
FRAMEWORK_DIR = platform.get_package_dir(platform_name)

View File

@@ -27,11 +27,12 @@ def encrypt_file(input, output_file, file_length):
output_file.write(input_file)
return
# Encrypt ${PROGNAME}.bin and save it as build.firmware
# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
def encrypt(source, target, env):
print("Encrypting to:", board.get("build.firmware"))
fwname = board.get("build.encrypt")
print("Encrypting %s to %s" % (target[0].path, fwname))
firmware = open(target[0].path, "rb")
renamed = open(target[0].dir.path + "/" + board.get("build.firmware"), "wb")
renamed = open(target[0].dir.path + "/" + fwname, "wb")
length = os.path.getsize(target[0].path)
encrypt_file(firmware, renamed, length)
@@ -39,8 +40,8 @@ def encrypt(source, target, env):
firmware.close()
renamed.close()
if 'firmware' in board.get("build").keys():
marlin.add_post_action(encrypt);
if 'encrypt' in board.get("build").keys():
marlin.add_post_action(encrypt);
else:
print("You need to define output file via board_build.firmware = 'filename' parameter")
exit(1);
print("LERDGE builds require output file via board_build.encrypt = 'filename' parameter")
exit(1);

View File

@@ -7,10 +7,12 @@ 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 os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
s = join(src, item)
d = join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
@@ -64,7 +66,7 @@ def encrypt_mks(source, target, env, new_name):
renamed.close()
def add_post_action(action):
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", action);
env.AddPostAction(join("$BUILD_DIR", "${PROGNAME}.bin"), action);
# Apply customizations for a MKS Robin
def prepare_robin(address, ldname, fwname):

View File

@@ -2,27 +2,28 @@
# buildroot/share/PlatformIO/scripts/mks_encrypt.py
#
# Apply encryption and save as 'build.firmware' for these environments:
# - env:mks_robin_stm32
# - env:mks_robin
# - env:mks_robin_e3
# - env:flsun_hispeedv1
# - env:mks_robin_nano35_stm32
# - env:mks_robin_nano35
#
Import("env")
from SCons.Script import DefaultEnvironment
board = DefaultEnvironment().BoardConfig()
if 'firmware' in board.get("build").keys():
if 'encrypt' in board.get("build").keys():
import marlin
# Encrypt ${PROGNAME}.bin and save it as build.firmware
# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
def encrypt(source, target, env):
marlin.encrypt_mks(source, target, env, board.get("build.firmware"))
marlin.encrypt_mks(source, target, env, board.get("build.encrypt"))
marlin.add_post_action(encrypt);
else:
import sys
print("You need to define output file via board_build.firmware = 'filename' parameter", file=sys.stderr)
print("You need to define output file via board_build.encrypt = 'filename' parameter", file=sys.stderr)
env.Exit(1);

View File

@@ -1,11 +1,5 @@
#
# buildroot/share/PlatformIO/scripts/mks_robin_nano35.py
#
Import("env")
import marlin
marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin")
env.Replace(
UPLOADER="curl",
UPLOADCMD="$UPLOADER -v -H 'Content-Type:application/octet-stream' http://$UPLOADERFLAGS/upload?X-Filename=Robin_Nano35.bin --data-binary @$BUILD_DIR/Robin_nano35.bin"
)

View File

@@ -6,10 +6,13 @@ from os.path import join
Import("env")
env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.elf",
env.VerboseAction(" ".join([
"$OBJCOPY", "-O", "srec",
"\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PROGNAME}.srec\""
]), "Building " + join("$BUILD_DIR", "${PROGNAME}.srec"))
)
board = env.BoardConfig()
board_keys = board.get("build").keys()
if 'encrypt' in board_keys:
env.AddPostAction(
join("$BUILD_DIR", "${PROGNAME}.bin"),
env.VerboseAction(" ".join([
"$OBJCOPY", "-O", "srec",
"\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encrypt")) + "\""
]), "Building $TARGET")
)

View File

@@ -1,23 +1,18 @@
#
# stm32_bootloader.py
#
import os,sys,shutil,marlin
import os,sys,marlin
Import("env")
from SCons.Script import DefaultEnvironment
board = DefaultEnvironment().BoardConfig()
#
# Copy the firmware.bin file to build.firmware, no encryption
#
def noencrypt(source, target, env):
firmware = os.path.join(target[0].dir.path, board.get("build.firmware"))
shutil.copy(target[0].path, firmware)
board_keys = board.get("build").keys()
#
# For build.offset define LD_FLASH_OFFSET, used by ldscript.ld
#
if 'offset' in board.get("build").keys():
if 'offset' in board_keys:
LD_FLASH_OFFSET = board.get("build.offset")
marlin.relocate_vtab(LD_FLASH_OFFSET)
@@ -35,9 +30,13 @@ if 'offset' in board.get("build").keys():
env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
#
# Only copy the file if there's no encrypt
# For build.rename simply rename the firmware file.
#
board_keys = board.get("build").keys()
if 'firmware' in board_keys and ('encrypt' not in board_keys or board.get("build.encrypt") == 'No'):
import marlin
marlin.add_post_action(noencrypt)
if 'rename' in board_keys:
def rename_target(source, target, env):
firmware = os.path.join(target[0].dir.path, board.get("build.rename"))
import shutil
shutil.copy(target[0].path, firmware)
marlin.add_post_action(rename_target)

View File

@@ -0,0 +1,23 @@
#
# stm32_serialbuffer.py
#
Import("env")
# Marlin has `RX_BUFFER_SIZE` and `TX_BUFFER_SIZE` to configure the
# buffer size for receiving and transmitting data respectively.
# Stm32duino uses another set of defines for the same purpose,
# so we get the values from the Marlin configuration and set
# them in `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE`.
# It is not possible to change the values at runtime, they must
# be set with build flags.
#
# The script will set the value as the default one (64 bytes)
# or the user-configured one, whichever is higher.
mf = env["MARLIN_FEATURES"]
rxBuf = str(max(64, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0))
txBuf = str(max(64, int(mf["TX_BUFFER_SIZE"]) if "TX_BUFFER_SIZE" in mf else 0))
build_flags = env.get('BUILD_FLAGS')
build_flags.append("-DSERIAL_RX_BUFFER_SIZE=" + rxBuf)
build_flags.append("-DSERIAL_TX_BUFFER_SIZE=" + txBuf)
env.Replace(BUILD_FLAGS=build_flags)