Support for MEEB 3DP board (#18138)
This commit is contained in:
61
buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py
Normal file
61
buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py
Normal file
@ -0,0 +1,61 @@
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
import ConfigParser as configparser
|
||||
|
||||
import os
|
||||
Import("env", "projenv")
|
||||
# access to global build environment
|
||||
print(env)
|
||||
# access to project build environment (is used source files in "src" folder)
|
||||
print(projenv)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read("platformio.ini")
|
||||
|
||||
#com_port = config.get("env:STM32F103RC_cc_meeb_3dp", "upload_port")
|
||||
#print('Use the {0:s} to reboot the board to dfu mode.'.format(com_port))
|
||||
|
||||
#
|
||||
# Upload actions
|
||||
#
|
||||
|
||||
def before_upload(source, target, env):
|
||||
print("before_upload")
|
||||
# do some actions
|
||||
# use com_port
|
||||
#
|
||||
env.Execute("pwd")
|
||||
|
||||
def after_upload(source, target, env):
|
||||
print("after_upload")
|
||||
# do some actions
|
||||
#
|
||||
#
|
||||
env.Execute("pwd")
|
||||
|
||||
print("Current build targets", map(str, BUILD_TARGETS))
|
||||
|
||||
env.AddPreAction("upload", before_upload)
|
||||
env.AddPostAction("upload", after_upload)
|
||||
|
||||
flash_size = 0
|
||||
vect_tab_addr = 0
|
||||
|
||||
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))
|
||||
|
||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103RC_MEEB_3DP.ld")
|
||||
for i, flag in enumerate(env["LINKFLAGS"]):
|
||||
if "-Wl,-T" in flag:
|
||||
env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
|
||||
elif flag == "-T":
|
||||
env["LINKFLAGS"][i + 1] = custom_ld_script
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
import os,shutil
|
||||
from SCons.Script import DefaultEnvironment
|
||||
from platformio import util
|
||||
|
||||
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)
|
||||
if os.path.isdir(s):
|
||||
shutil.copytree(s, d, symlinks, ignore)
|
||||
else:
|
||||
shutil.copy2(s, d)
|
||||
|
||||
env = DefaultEnvironment()
|
||||
platform = env.PioPlatform()
|
||||
board = env.BoardConfig()
|
||||
|
||||
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple")
|
||||
assert os.path.isdir(FRAMEWORK_DIR)
|
||||
assert os.path.isdir("buildroot/share/PlatformIO/variants")
|
||||
|
||||
variant = board.get("build.variant")
|
||||
variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant)
|
||||
|
||||
source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant)
|
||||
assert os.path.isdir(source_dir)
|
||||
|
||||
if os.path.isdir(variant_dir):
|
||||
shutil.rmtree(variant_dir)
|
||||
|
||||
if not os.path.isdir(variant_dir):
|
||||
os.mkdir(variant_dir)
|
||||
|
||||
copytree(source_dir, variant_dir)
|
Reference in New Issue
Block a user