Robby Candra
3 years ago
committed by
Scott Lahteine
37 changed files with 1116 additions and 1082 deletions
@ -1,40 +1,43 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py |
|||
# STM32F103RC_MEEB_3DP.py |
|||
# |
|||
try: |
|||
import pioutil |
|||
if pioutil.is_pio_build(): |
|||
|
|||
try: |
|||
import configparser |
|||
except ImportError: |
|||
except ImportError: |
|||
import ConfigParser as configparser |
|||
|
|||
import os |
|||
Import("env", "projenv") |
|||
import os |
|||
Import("env", "projenv") |
|||
|
|||
config = configparser.ConfigParser() |
|||
config.read("platformio.ini") |
|||
config = configparser.ConfigParser() |
|||
config.read("platformio.ini") |
|||
|
|||
# |
|||
# Upload actions |
|||
# |
|||
def before_upload(source, target, env): |
|||
# |
|||
# Upload actions |
|||
# |
|||
def before_upload(source, target, env): |
|||
env.Execute("pwd") |
|||
|
|||
def after_upload(source, target, env): |
|||
def after_upload(source, target, env): |
|||
env.Execute("pwd") |
|||
|
|||
env.AddPreAction("upload", before_upload) |
|||
env.AddPostAction("upload", after_upload) |
|||
env.AddPreAction("upload", before_upload) |
|||
env.AddPostAction("upload", after_upload) |
|||
|
|||
flash_size = 0 |
|||
vect_tab_addr = 0 |
|||
flash_size = 0 |
|||
vect_tab_addr = 0 |
|||
|
|||
for define in env['CPPDEFINES']: |
|||
for define in env['CPPDEFINES']: |
|||
if define[0] == "VECT_TAB_ADDR": |
|||
vect_tab_addr = define[1] |
|||
if define[0] == "STM32_FLASH_SIZE": |
|||
flash_size = define[1] |
|||
|
|||
print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr)) |
|||
print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size)) |
|||
print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr)) |
|||
print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size)) |
|||
|
|||
import marlin |
|||
marlin.custom_ld_script("STM32F103RC_MEEB_3DP.ld") |
|||
import marlin |
|||
marlin.custom_ld_script("STM32F103RC_MEEB_3DP.ld") |
|||
|
@ -1,25 +1,28 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py |
|||
# STM32F103RC_fysetc.py |
|||
# |
|||
from os.path import join |
|||
from os.path import expandvars |
|||
Import("env") |
|||
import pioutil |
|||
if pioutil.is_pio_build(): |
|||
import os |
|||
from os.path import join |
|||
from os.path import expandvars |
|||
Import("env") |
|||
|
|||
# Custom HEX from ELF |
|||
env.AddPostAction( |
|||
# Custom HEX from ELF |
|||
env.AddPostAction( |
|||
join("$BUILD_DIR", "${PROGNAME}.elf"), |
|||
env.VerboseAction(" ".join([ |
|||
"$OBJCOPY", "-O ihex", "$TARGET", |
|||
"\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path |
|||
]), "Building $TARGET")) |
|||
|
|||
# In-line command with arguments |
|||
UPLOAD_TOOL="stm32flash" |
|||
platform = env.PioPlatform() |
|||
if platform.get_package_dir("tool-stm32duino") != None: |
|||
# In-line command with arguments |
|||
UPLOAD_TOOL="stm32flash" |
|||
platform = env.PioPlatform() |
|||
if platform.get_package_dir("tool-stm32duino") != None: |
|||
UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"") |
|||
|
|||
env.Replace( |
|||
env.Replace( |
|||
UPLOADER=UPLOAD_TOOL, |
|||
UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT") |
|||
) |
|||
) |
|||
|
@ -1,30 +1,32 @@ |
|||
# |
|||
# STM32F1_create_variant.py |
|||
# |
|||
import os,shutil,marlin |
|||
from SCons.Script import DefaultEnvironment |
|||
from platformio import util |
|||
import pioutil |
|||
if pioutil.is_pio_build(): |
|||
import os,shutil,marlin |
|||
from SCons.Script import DefaultEnvironment |
|||
from platformio import util |
|||
|
|||
env = DefaultEnvironment() |
|||
platform = env.PioPlatform() |
|||
board = env.BoardConfig() |
|||
env = DefaultEnvironment() |
|||
platform = env.PioPlatform() |
|||
board = env.BoardConfig() |
|||
|
|||
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple") |
|||
assert os.path.isdir(FRAMEWORK_DIR) |
|||
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple") |
|||
assert os.path.isdir(FRAMEWORK_DIR) |
|||
|
|||
source_root = os.path.join("buildroot", "share", "PlatformIO", "variants") |
|||
assert os.path.isdir(source_root) |
|||
source_root = os.path.join("buildroot", "share", "PlatformIO", "variants") |
|||
assert os.path.isdir(source_root) |
|||
|
|||
variant = board.get("build.variant") |
|||
variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant) |
|||
variant = board.get("build.variant") |
|||
variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant) |
|||
|
|||
source_dir = os.path.join(source_root, variant) |
|||
assert os.path.isdir(source_dir) |
|||
source_dir = os.path.join(source_root, variant) |
|||
assert os.path.isdir(source_dir) |
|||
|
|||
if os.path.isdir(variant_dir): |
|||
if os.path.isdir(variant_dir): |
|||
shutil.rmtree(variant_dir) |
|||
|
|||
if not os.path.isdir(variant_dir): |
|||
if not os.path.isdir(variant_dir): |
|||
os.mkdir(variant_dir) |
|||
|
|||
marlin.copytree(source_dir, variant_dir) |
|||
marlin.copytree(source_dir, variant_dir) |
|||
|
@ -1,16 +1,16 @@ |
|||
# |
|||
# common-dependencies-post.py |
|||
# post:common-dependencies-post.py |
|||
# Convenience script to add build flags for Marlin Enabled Features |
|||
# |
|||
import pioutil |
|||
if pioutil.is_pio_build(): |
|||
Import("env", "projenv") |
|||
|
|||
Import("env") |
|||
Import("projenv") |
|||
|
|||
def apply_board_build_flags(): |
|||
def apply_board_build_flags(): |
|||
if not 'BOARD_CUSTOM_BUILD_FLAGS' in env['MARLIN_FEATURES']: |
|||
return |
|||
projenv.Append(CCFLAGS=env['MARLIN_FEATURES']['BOARD_CUSTOM_BUILD_FLAGS'].split()) |
|||
|
|||
# We need to add the board build flags in a post script |
|||
# so the platform build script doesn't overwrite the custom CCFLAGS |
|||
apply_board_build_flags() |
|||
# We need to add the board build flags in a post script |
|||
# so the platform build script doesn't overwrite the custom CCFLAGS |
|||
apply_board_build_flags() |
|||
|
@ -1,16 +1,18 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/custom_board.py |
|||
# custom_board.py |
|||
# |
|||
# - For build.address replace VECT_TAB_ADDR to relocate the firmware |
|||
# - For build.ldscript use one of the linker scripts in buildroot/share/PlatformIO/ldscripts |
|||
# |
|||
import marlin |
|||
board = marlin.env.BoardConfig() |
|||
import pioutil |
|||
if pioutil.is_pio_build(): |
|||
import marlin |
|||
board = marlin.env.BoardConfig() |
|||
|
|||
address = board.get("build.address", "") |
|||
if address: |
|||
address = board.get("build.address", "") |
|||
if address: |
|||
marlin.relocate_firmware(address) |
|||
|
|||
ldscript = board.get("build.ldscript", "") |
|||
if ldscript: |
|||
ldscript = board.get("build.ldscript", "") |
|||
if ldscript: |
|||
marlin.custom_ld_script(ldscript) |
|||
|
@ -1,5 +1,5 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/mks_robin.py |
|||
# mks_robin.py |
|||
# |
|||
import robin |
|||
robin.prepare("0x08007000", "mks_robin.ld", "Robin.bin") |
|||
|
@ -1,5 +1,5 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/mks_robin_e3.py |
|||
# mks_robin_e3.py |
|||
# |
|||
import robin |
|||
robin.prepare("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin") |
|||
|
@ -1,5 +1,5 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/mks_robin_e3p.py |
|||
# mks_robin_e3p.py |
|||
# |
|||
import robin |
|||
robin.prepare("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin") |
|||
|
@ -1,5 +1,5 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/mks_robin_lite.py |
|||
# mks_robin_lite.py |
|||
# |
|||
import robin |
|||
robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite.bin") |
|||
|
@ -1,5 +1,5 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/mks_robin_lite3.py |
|||
# mks_robin_lite3.py |
|||
# |
|||
import robin |
|||
robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite3.bin") |
|||
|
@ -1,5 +1,5 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/mks_robin_mini.py |
|||
# mks_robin_mini.py |
|||
# |
|||
import robin |
|||
robin.prepare("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin") |
|||
|
@ -1,5 +1,5 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/mks_robin_nano.py |
|||
# mks_robin_nano.py |
|||
# |
|||
import robin |
|||
robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin") |
|||
|
@ -1,5 +1,5 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/mks_robin_nano35.py |
|||
# mks_robin_nano35.py |
|||
# |
|||
import robin |
|||
robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin") |
|||
|
@ -1,5 +1,5 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/mks_robin_pro.py |
|||
# mks_robin_pro.py |
|||
# |
|||
import robin |
|||
robin.prepare("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin") |
|||
|
@ -1,8 +1,8 @@ |
|||
# |
|||
# buildroot/share/PlatformIO/scripts/pioutil.py |
|||
# pioutil.py |
|||
# |
|||
|
|||
# Detect that 'vscode init' is running |
|||
def is_vscode_init(): |
|||
# Make sure 'vscode init' is not the current command |
|||
def is_pio_build(): |
|||
from SCons.Script import COMMAND_LINE_TARGETS |
|||
return "idedata" in COMMAND_LINE_TARGETS or "_idedata" in COMMAND_LINE_TARGETS |
|||
return "idedata" not in COMMAND_LINE_TARGETS and "_idedata" not in COMMAND_LINE_TARGETS |
|||
|
@ -1,59 +1,61 @@ |
|||
# |
|||
# stm32_serialbuffer.py |
|||
# |
|||
Import("env") |
|||
|
|||
# Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to |
|||
# configure buffer sizes for receiving \ transmitting serial data. |
|||
# Stm32duino uses another set of defines for the same purpose, so this |
|||
# script gets the values from the configuration and uses them to define |
|||
# `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build |
|||
# flags so they are available for use by the platform. |
|||
# |
|||
# The script will set the value as the default one (64 bytes) |
|||
# or the user-configured one, whichever is higher. |
|||
# |
|||
# Marlin's default buffer sizes are 128 for RX and 32 for TX. |
|||
# The highest value is taken (128/64). |
|||
# |
|||
# If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are |
|||
# defined, the first of these values will be used as the minimum. |
|||
build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"] |
|||
mf = env["MARLIN_FEATURES"] |
|||
import pioutil |
|||
if pioutil.is_pio_build(): |
|||
Import("env") |
|||
|
|||
# Get a build flag's value or None |
|||
def getBuildFlagValue(name): |
|||
# Get a build flag's value or None |
|||
def getBuildFlagValue(name): |
|||
for flag in build_flags: |
|||
if isinstance(flag, list) and flag[0] == name: |
|||
return flag[1] |
|||
|
|||
return None |
|||
|
|||
# Get an overriding buffer size for RX or TX from the build flags |
|||
def getInternalSize(side): |
|||
# Get an overriding buffer size for RX or TX from the build flags |
|||
def getInternalSize(side): |
|||
return getBuildFlagValue(f"MF_{side}_BUFFER_SIZE") or \ |
|||
getBuildFlagValue(f"SERIAL_{side}_BUFFER_SIZE") or \ |
|||
getBuildFlagValue(f"USART_{side}_BUF_SIZE") |
|||
|
|||
# Get the largest defined buffer size for RX or TX |
|||
def getBufferSize(side, default): |
|||
# Get the largest defined buffer size for RX or TX |
|||
def getBufferSize(side, default): |
|||
# Get a build flag value or fall back to the given default |
|||
internal = int(getInternalSize(side) or default) |
|||
flag = side + "_BUFFER_SIZE" |
|||
# Return the largest value |
|||
return max(int(mf[flag]), internal) if flag in mf else internal |
|||
|
|||
# Add a build flag if it's not already defined |
|||
def tryAddFlag(name, value): |
|||
# Add a build flag if it's not already defined |
|||
def tryAddFlag(name, value): |
|||
if getBuildFlagValue(name) is None: |
|||
env.Append(BUILD_FLAGS=[f"-D{name}={value}"]) |
|||
|
|||
# Get the largest defined buffer sizes for RX or TX, using defaults for undefined |
|||
rxBuf = getBufferSize("RX", 128) |
|||
txBuf = getBufferSize("TX", 64) |
|||
|
|||
# Provide serial buffer sizes to the stm32duino platform |
|||
tryAddFlag("SERIAL_RX_BUFFER_SIZE", rxBuf) |
|||
tryAddFlag("SERIAL_TX_BUFFER_SIZE", txBuf) |
|||
tryAddFlag("USART_RX_BUF_SIZE", rxBuf) |
|||
tryAddFlag("USART_TX_BUF_SIZE", txBuf) |
|||
# Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to |
|||
# configure buffer sizes for receiving \ transmitting serial data. |
|||
# Stm32duino uses another set of defines for the same purpose, so this |
|||
# script gets the values from the configuration and uses them to define |
|||
# `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build |
|||
# flags so they are available for use by the platform. |
|||
# |
|||
# The script will set the value as the default one (64 bytes) |
|||
# or the user-configured one, whichever is higher. |
|||
# |
|||
# Marlin's default buffer sizes are 128 for RX and 32 for TX. |
|||
# The highest value is taken (128/64). |
|||
# |
|||
# If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are |
|||
# defined, the first of these values will be used as the minimum. |
|||
build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"] |
|||
mf = env["MARLIN_FEATURES"] |
|||
|
|||
# Get the largest defined buffer sizes for RX or TX, using defaults for undefined |
|||
rxBuf = getBufferSize("RX", 128) |
|||
txBuf = getBufferSize("TX", 64) |
|||
|
|||
# Provide serial buffer sizes to the stm32duino platform |
|||
tryAddFlag("SERIAL_RX_BUFFER_SIZE", rxBuf) |
|||
tryAddFlag("SERIAL_TX_BUFFER_SIZE", txBuf) |
|||
tryAddFlag("USART_RX_BUF_SIZE", rxBuf) |
|||
tryAddFlag("USART_TX_BUF_SIZE", txBuf) |
|||
|
Loading…
Reference in new issue