Rename, clean up boards/variants (#21655)
* Consolidate variant scripts * Rename Marlin-local boards * Simplify variants where possible * Rename variants * CHITU_F103 and MEEB_3DP: Maple platform `platformio-build-stm32f1.py` uses the 'board' name, not 'board_build.variant' so folder names match 'board' and not `board_build.variant`.
This commit is contained in:
parent
69d85cce2d
commit
ee016e605c
1
.github/workflows/test-builds.yml
vendored
1
.github/workflows/test-builds.yml
vendored
@ -90,6 +90,7 @@ jobs:
|
|||||||
- NUCLEO_F767ZI
|
- NUCLEO_F767ZI
|
||||||
- REMRAM_V1
|
- REMRAM_V1
|
||||||
- BTT_SKR_SE_BX
|
- BTT_SKR_SE_BX
|
||||||
|
- chitu_f103
|
||||||
|
|
||||||
# Put lengthy tests last
|
# Put lengthy tests last
|
||||||
|
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
{
|
|
||||||
"build": {
|
|
||||||
"core": "stm32",
|
|
||||||
"cpu": "cortex-m4",
|
|
||||||
"extra_flags": "-DSTM32F407xx",
|
|
||||||
"f_cpu": "168000000L",
|
|
||||||
"hwids": [
|
|
||||||
[
|
|
||||||
"0x1EAF",
|
|
||||||
"0x0003"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"0x0483",
|
|
||||||
"0x3748"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"mcu": "stm32f407zgt6",
|
|
||||||
"variant": "LERDGE",
|
|
||||||
"ldscript": "LERDGE.ld"
|
|
||||||
},
|
|
||||||
"debug": {
|
|
||||||
"jlink_device": "STM32F407ZG",
|
|
||||||
"openocd_target": "stm32f4x",
|
|
||||||
"svd_path": "STM32F40x.svd",
|
|
||||||
"tools": {
|
|
||||||
"stlink": {
|
|
||||||
"server": {
|
|
||||||
"arguments": [
|
|
||||||
"-f",
|
|
||||||
"scripts/interface/stlink.cfg",
|
|
||||||
"-c",
|
|
||||||
"transport select hla_swd",
|
|
||||||
"-f",
|
|
||||||
"scripts/target/stm32f4x.cfg",
|
|
||||||
"-c",
|
|
||||||
"reset_config none"
|
|
||||||
],
|
|
||||||
"executable": "bin/openocd",
|
|
||||||
"package": "tool-openocd"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"frameworks": [
|
|
||||||
"arduino",
|
|
||||||
"stm32cube"
|
|
||||||
],
|
|
||||||
"name": "STM32F407ZGT6(192k RAM. 1024k Flash)",
|
|
||||||
"upload": {
|
|
||||||
"disable_flushing": false,
|
|
||||||
"maximum_ram_size": 196608,
|
|
||||||
"maximum_size": 1048576,
|
|
||||||
"protocol": "stlink",
|
|
||||||
"protocols": [
|
|
||||||
"stlink",
|
|
||||||
"dfu",
|
|
||||||
"jlink"
|
|
||||||
],
|
|
||||||
"require_upload_port": true,
|
|
||||||
"use_1200bps_touch": false,
|
|
||||||
"wait_for_upload_port": false
|
|
||||||
},
|
|
||||||
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f407ZG.html",
|
|
||||||
"vendor": "Generic"
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"build": {
|
|
||||||
"core": "arduino",
|
|
||||||
"extra_flags": "-DARDUINO_AVR_MEGA2560",
|
|
||||||
"f_cpu": "16000000L",
|
|
||||||
"hwids": [
|
|
||||||
[
|
|
||||||
"0x27b2",
|
|
||||||
"0x0002"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"mcu": "atmega2560",
|
|
||||||
"variant": "fysetcf6"
|
|
||||||
},
|
|
||||||
"debug": {
|
|
||||||
"simavr_target": "atmega2560",
|
|
||||||
"avr-stub": {
|
|
||||||
"speed": 115200
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"frameworks": [
|
|
||||||
"arduino"
|
|
||||||
],
|
|
||||||
"name": "FYSETC F6",
|
|
||||||
"upload": {
|
|
||||||
"maximum_ram_size": 8192,
|
|
||||||
"maximum_size": 258048,
|
|
||||||
"protocol": "wiring",
|
|
||||||
"require_upload_port": true,
|
|
||||||
"speed": 115200
|
|
||||||
},
|
|
||||||
"url": "https://www.fysetc.com/",
|
|
||||||
"vendor": "FYSETC"
|
|
||||||
}
|
|
@ -5,7 +5,7 @@
|
|||||||
"extra_flags": "-DSTM32H743xx",
|
"extra_flags": "-DSTM32H743xx",
|
||||||
"f_cpu": "400000000L",
|
"f_cpu": "400000000L",
|
||||||
"mcu": "stm32h743iit6",
|
"mcu": "stm32h743iit6",
|
||||||
"variant": "BTT_SKR_SE_BX"
|
"variant": "MARLIN_BTT_SKR_SE_BX"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"jlink_device": "STM32H743II",
|
"jlink_device": "STM32H743II",
|
@ -15,7 +15,7 @@
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
"mcu": "stm32f407vgt6",
|
"mcu": "stm32f407vgt6",
|
||||||
"variant": "BIGTREE_BTT002"
|
"variant": "MARLIN_BIGTREE_BTT002"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"jlink_device": "STM32F407VG",
|
"jlink_device": "STM32F407VG",
|
@ -15,7 +15,7 @@
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
"mcu": "stm32f407zgt6",
|
"mcu": "stm32f407zgt6",
|
||||||
"variant": "BIGTREE_GTR_V1"
|
"variant": "MARLIN_BIGTREE_GTR_V1"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"jlink_device": "STM32F407ZG",
|
"jlink_device": "STM32F407ZG",
|
@ -15,7 +15,7 @@
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
"mcu": "stm32f407zgt6",
|
"mcu": "stm32f407zgt6",
|
||||||
"variant": "BIGTREE_SKR_PRO_1v1"
|
"variant": "MARLIN_BIGTREE_SKR_PRO_11"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"jlink_device": "STM32F407ZG",
|
"jlink_device": "STM32F407ZG",
|
@ -15,8 +15,7 @@
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
"mcu": "stm32f103zet6",
|
"mcu": "stm32f103zet6",
|
||||||
"variant": "CHITU_F103",
|
"variant": "marlin_CHITU_F103"
|
||||||
"ldscript": "chitu_f103.ld"
|
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"jlink_device": "STM32F103ZE",
|
"jlink_device": "STM32F103ZE",
|
@ -16,7 +16,7 @@
|
|||||||
],
|
],
|
||||||
"ldscript": "stm32f401rc.ld",
|
"ldscript": "stm32f401rc.ld",
|
||||||
"mcu": "stm32f401rct6",
|
"mcu": "stm32f401rct6",
|
||||||
"variant": "FYSETC_CHEETAH_V20"
|
"variant": "MARLIN_FYSETC_CHEETAH_V20"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"jlink_device": "STM32F401RC",
|
"jlink_device": "STM32F401RC",
|
@ -18,7 +18,7 @@
|
|||||||
"ldscript": "stm32f103xc.ld"
|
"ldscript": "stm32f103xc.ld"
|
||||||
},
|
},
|
||||||
"mcu": "stm32f103rct6",
|
"mcu": "stm32f103rct6",
|
||||||
"variant": "MEEB_3DP"
|
"variant": "marlin_MEEB_3DP"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"jlink_device": "STM32F103RC",
|
"jlink_device": "STM32F103RC",
|
@ -14,9 +14,8 @@
|
|||||||
"0x3748"
|
"0x3748"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"ldscript": "stm32f401xe.ld",
|
|
||||||
"mcu": "stm32f401vet6",
|
"mcu": "stm32f401vet6",
|
||||||
"variant": "STEVAL_F401VE"
|
"variant": "MARLIN_STEVAL_F401VE"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"jlink_device": "STM32F401VE",
|
"jlink_device": "STM32F401VE",
|
@ -14,8 +14,7 @@
|
|||||||
"0x3748"
|
"0x3748"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"mcu": "stm32f407zgt6",
|
"mcu": "stm32f407zgt6"
|
||||||
"variant": "FLY_F407ZG"
|
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"jlink_device": "STM32F407ZG",
|
"jlink_device": "STM32F407ZG",
|
||||||
@ -49,7 +48,7 @@
|
|||||||
"disable_flushing": false,
|
"disable_flushing": false,
|
||||||
"maximum_ram_size": 196608,
|
"maximum_ram_size": 196608,
|
||||||
"maximum_size": 1048576,
|
"maximum_size": 1048576,
|
||||||
"protocol": "dfu",
|
"protocol": "stlink",
|
||||||
"protocols": [
|
"protocols": [
|
||||||
"stlink",
|
"stlink",
|
||||||
"dfu",
|
"dfu",
|
@ -21,7 +21,7 @@
|
|||||||
"ldscript": "linker_scripts/gcc/flash.ld",
|
"ldscript": "linker_scripts/gcc/flash.ld",
|
||||||
"mcu": "at91sam3x8e",
|
"mcu": "at91sam3x8e",
|
||||||
"usb_product": "Archim",
|
"usb_product": "Archim",
|
||||||
"variant": "archim"
|
"variant": "MARLIN_ARCHIM"
|
||||||
},
|
},
|
||||||
"connectivity": [
|
"connectivity": [
|
||||||
"can"
|
"can"
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# STM32F103RC_MEEB_3DP.py
|
# buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py
|
||||||
#
|
#
|
||||||
try:
|
try:
|
||||||
import configparser
|
import configparser
|
||||||
@ -54,9 +54,5 @@ for define in env['CPPDEFINES']:
|
|||||||
print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr))
|
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:d}KB flash version of stm32f103rct6 chip.'.format(flash_size))
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103RC_MEEB_3DP.ld")
|
import marlin
|
||||||
for i, flag in enumerate(env["LINKFLAGS"]):
|
marlin.custom_ld_script("STM32F103RC_MEEB_3DP.ld")
|
||||||
if "-Wl,-T" in flag:
|
|
||||||
env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
|
|
||||||
elif flag == "-T":
|
|
||||||
env["LINKFLAGS"][i + 1] = custom_ld_script
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
#
|
|
||||||
# STM32F103RC_SKR_MINI.py
|
|
||||||
#
|
|
||||||
import os
|
|
||||||
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"))
|
|
||||||
|
|
||||||
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"]):
|
|
||||||
if "-Wl,-T" in flag:
|
|
||||||
env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
|
|
||||||
elif flag == "-T":
|
|
||||||
env["LINKFLAGS"][i + 1] = custom_ld_script
|
|
@ -1,24 +1,11 @@
|
|||||||
#
|
#
|
||||||
# STM32F103RC_fysetc.py
|
# buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py
|
||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
from os.path import join
|
from os.path import join
|
||||||
from os.path import expandvars
|
from os.path import expandvars
|
||||||
Import("env")
|
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"))
|
|
||||||
|
|
||||||
#custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.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
|
|
||||||
|
|
||||||
# Custom HEX from ELF
|
# Custom HEX from ELF
|
||||||
env.AddPostAction(
|
env.AddPostAction(
|
||||||
join("$BUILD_DIR","${PROGNAME}.elf"),
|
join("$BUILD_DIR","${PROGNAME}.elf"),
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
#
|
|
||||||
# STM32F103RET6_creality.py
|
|
||||||
#
|
|
||||||
import os
|
|
||||||
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"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/creality.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
|
|
@ -1,19 +0,0 @@
|
|||||||
#
|
|
||||||
# STM32F103RE_SKR_E3_DIP.py
|
|
||||||
#
|
|
||||||
import os
|
|
||||||
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"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103RE_SKR_E3_DIP.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
|
|
@ -1,36 +1,22 @@
|
|||||||
#
|
#
|
||||||
# STM32F103VE_longer.py
|
# buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py
|
||||||
# Customizations for env:STM32F103VE_longer
|
# Customizations for env:STM32F103VE_longer
|
||||||
#
|
#
|
||||||
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"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103VE_longer.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
|
|
||||||
|
|
||||||
# Rename ${PROGNAME}.bin and save it as 'project.bin' (No encryption on the Longer3D)
|
# Rename ${PROGNAME}.bin and save it as 'project.bin' (No encryption on the Longer3D)
|
||||||
def encrypt(source, target, env):
|
def encrypt(source, target, env):
|
||||||
firmware = open(target[0].path, "rb")
|
firmware = open(target[0].path, "rb")
|
||||||
marlin_alfa = open(target[0].dir.path +'/project.bin', "wb")
|
renamed = open(target[0].dir.path + '/project.bin', "wb")
|
||||||
length = os.path.getsize(target[0].path)
|
length = os.path.getsize(target[0].path)
|
||||||
position = 0
|
position = 0
|
||||||
try:
|
try:
|
||||||
while position < length:
|
while position < length:
|
||||||
byte = firmware.read(1)
|
byte = firmware.read(1)
|
||||||
marlin_alfa.write(byte)
|
renamed.write(byte)
|
||||||
position += 1
|
position += 1
|
||||||
finally:
|
finally:
|
||||||
firmware.close()
|
firmware.close()
|
||||||
marlin_alfa.close()
|
renamed.close()
|
||||||
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
marlin.add_post_action(encrypt);
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
#
|
#
|
||||||
# STM32F1_create_variant.py
|
# STM32F1_create_variant.py
|
||||||
#
|
#
|
||||||
import os,shutil
|
import os,shutil,marlin
|
||||||
from SCons.Script import DefaultEnvironment
|
from SCons.Script import DefaultEnvironment
|
||||||
from platformio import util
|
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()
|
env = DefaultEnvironment()
|
||||||
platform = env.PioPlatform()
|
platform = env.PioPlatform()
|
||||||
board = env.BoardConfig()
|
board = env.BoardConfig()
|
||||||
@ -36,4 +27,4 @@ if os.path.isdir(variant_dir):
|
|||||||
if not os.path.isdir(variant_dir):
|
if not os.path.isdir(variant_dir):
|
||||||
os.mkdir(variant_dir)
|
os.mkdir(variant_dir)
|
||||||
|
|
||||||
copytree(source_dir, variant_dir)
|
marlin.copytree(source_dir, variant_dir)
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
#
|
|
||||||
# STM32F401VE_STEVAL.py
|
|
||||||
# Customizations for env:STM32F401VE_STEVAL
|
|
||||||
#
|
|
||||||
import os
|
|
||||||
Import("env")
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/variants/STEVAL_F401VE/ldscript.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
|
|
@ -1,21 +1,11 @@
|
|||||||
#
|
#
|
||||||
# chitu_crypt.py
|
# buildroot/share/PlatformIO/scripts/chitu_crypt.py
|
||||||
# Customizations for Chitu boards
|
# Customizations for Chitu boards
|
||||||
#
|
#
|
||||||
Import("env")
|
import os,random,struct,uuid,marlin
|
||||||
import os,random,struct,uuid
|
|
||||||
|
|
||||||
# Relocate firmware from 0x08000000 to 0x08008800
|
# Relocate firmware from 0x08000000 to 0x08008800
|
||||||
env['CPPDEFINES'].remove(("VECT_TAB_ADDR", "0x8000000"))
|
marlin.relocate_firmware("0x08008800")
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08008800"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/chitu_f103.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
|
|
||||||
|
|
||||||
|
|
||||||
def calculate_crc(contents, seed):
|
def calculate_crc(contents, seed):
|
||||||
accumulating_xor_value = seed;
|
accumulating_xor_value = seed;
|
||||||
@ -43,7 +33,7 @@ def xor_block(r0, r1, block_number, block_size, file_key):
|
|||||||
|
|
||||||
for loop_counter in range(0, block_size):
|
for loop_counter in range(0, block_size):
|
||||||
# meant to make sure different bits of the key are used.
|
# meant to make sure different bits of the key are used.
|
||||||
xor_seed = int(loop_counter/key_length)
|
xor_seed = int(loop_counter / key_length)
|
||||||
|
|
||||||
# IP is a scratch register / R12
|
# IP is a scratch register / R12
|
||||||
ip = loop_counter - (key_length * xor_seed)
|
ip = loop_counter - (key_length * xor_seed)
|
||||||
@ -69,7 +59,6 @@ def xor_block(r0, r1, block_number, block_size, file_key):
|
|||||||
#increment the loop_counter
|
#increment the loop_counter
|
||||||
loop_counter = loop_counter + 1
|
loop_counter = loop_counter + 1
|
||||||
|
|
||||||
|
|
||||||
def encrypt_file(input, output_file, file_length):
|
def encrypt_file(input, output_file, file_length):
|
||||||
input_file = bytearray(input.read())
|
input_file = bytearray(input.read())
|
||||||
block_size = 0x800
|
block_size = 0x800
|
||||||
@ -113,11 +102,10 @@ def encrypt_file(input, output_file, file_length):
|
|||||||
output_file.write(input_file)
|
output_file.write(input_file)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'update.cbd'
|
# Encrypt ${PROGNAME}.bin and save it as 'update.cbd'
|
||||||
def encrypt(source, target, env):
|
def encrypt(source, target, env):
|
||||||
firmware = open(target[0].path, "rb")
|
firmware = open(target[0].path, "rb")
|
||||||
update = open(target[0].dir.path +'/update.cbd', "wb")
|
update = open(target[0].dir.path + '/update.cbd', "wb")
|
||||||
length = os.path.getsize(target[0].path)
|
length = os.path.getsize(target[0].path)
|
||||||
|
|
||||||
encrypt_file(firmware, update, length)
|
encrypt_file(firmware, update, length)
|
||||||
@ -125,4 +113,4 @@ def encrypt(source, target, env):
|
|||||||
firmware.close()
|
firmware.close()
|
||||||
update.close()
|
update.close()
|
||||||
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
marlin.add_post_action(encrypt);
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
#
|
|
||||||
# copy_marlin_variant_to_framework.py
|
|
||||||
#
|
|
||||||
import os,shutil
|
|
||||||
from SCons.Script import DefaultEnvironment
|
|
||||||
from platformio import util
|
|
||||||
from platformio.package.meta import PackageSpec
|
|
||||||
|
|
||||||
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()
|
|
||||||
variant = board.get("build.variant")
|
|
||||||
|
|
||||||
platform_packages = env.GetProjectOption('platform_packages')
|
|
||||||
# if there's no framework defined, take it from the class name of platform
|
|
||||||
framewords = {
|
|
||||||
"Ststm32Platform": "framework-arduinoststm32",
|
|
||||||
"AtmelavrPlatform": "framework-arduino-avr"
|
|
||||||
}
|
|
||||||
if len(platform_packages) == 0:
|
|
||||||
platform_name = framewords[platform.__class__.__name__]
|
|
||||||
else:
|
|
||||||
platform_name = PackageSpec(platform_packages[0]).name
|
|
||||||
|
|
||||||
FRAMEWORK_DIR = platform.get_package_dir(platform_name)
|
|
||||||
assert os.path.isdir(FRAMEWORK_DIR)
|
|
||||||
assert os.path.isdir("buildroot/share/PlatformIO/variants")
|
|
||||||
|
|
||||||
variant_dir = os.path.join(FRAMEWORK_DIR, "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)
|
|
13
buildroot/share/PlatformIO/scripts/custom_board.py
Normal file
13
buildroot/share/PlatformIO/scripts/custom_board.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#
|
||||||
|
# buildroot/share/PlatformIO/scripts/custom_board.py
|
||||||
|
#
|
||||||
|
import marlin
|
||||||
|
board = marlin.env.BoardConfig()
|
||||||
|
|
||||||
|
address = board.get("build.address", "")
|
||||||
|
if address:
|
||||||
|
marlin.relocate_firmware(address)
|
||||||
|
|
||||||
|
ldscript = board.get("build.ldscript", "")
|
||||||
|
if ldscript:
|
||||||
|
marlin.custom_ld_script(ldscript)
|
@ -1,5 +1,6 @@
|
|||||||
#
|
#
|
||||||
# download_mks_assets.py
|
# buildroot/share/PlatformIO/scripts/download_mks_assets.py
|
||||||
|
# Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo
|
||||||
#
|
#
|
||||||
Import("env")
|
Import("env")
|
||||||
import os,requests,zipfile,tempfile,shutil
|
import os,requests,zipfile,tempfile,shutil
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
#
|
|
||||||
# fly_mini.py
|
|
||||||
# Customizations for env:FLY_MINI
|
|
||||||
#
|
|
||||||
import os
|
|
||||||
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"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/fly_mini.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
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
#
|
|
||||||
# STM32F401VE_STEVAL.py
|
|
||||||
# Customizations for env:STM32F401VE_STEVAL
|
|
||||||
#
|
|
||||||
import os
|
|
||||||
Import("env")
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/ldscript.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
|
|
@ -1,30 +1,54 @@
|
|||||||
#
|
#
|
||||||
# Generate a generic variant
|
# generic_create_variant.py
|
||||||
#
|
#
|
||||||
import os,shutil
|
# Copy one of the variants from buildroot/platformio/variants into
|
||||||
|
# the appropriate framework variants folder, so that its contents
|
||||||
|
# will be picked up by PlatformIO just like any other variant.
|
||||||
|
#
|
||||||
|
import os,shutil,marlin
|
||||||
from SCons.Script import DefaultEnvironment
|
from SCons.Script import DefaultEnvironment
|
||||||
from platformio import util
|
from platformio import util
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get the platform name from the 'platform_packages' option,
|
||||||
|
# or look it up by the platform.class.name.
|
||||||
|
#
|
||||||
platform = env.PioPlatform()
|
platform = env.PioPlatform()
|
||||||
|
|
||||||
|
from platformio.package.meta import PackageSpec
|
||||||
|
platform_packages = env.GetProjectOption('platform_packages')
|
||||||
|
if len(platform_packages) == 0:
|
||||||
|
framewords = {
|
||||||
|
"Ststm32Platform": "framework-arduinoststm32",
|
||||||
|
"AtmelavrPlatform": "framework-arduino-avr"
|
||||||
|
}
|
||||||
|
platform_name = framewords[platform.__class__.__name__]
|
||||||
|
else:
|
||||||
|
platform_name = PackageSpec(platform_packages[0]).name
|
||||||
|
|
||||||
|
if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "tool-stm32duino" ]:
|
||||||
|
platform_name = "framework-arduinoststm32"
|
||||||
|
|
||||||
|
FRAMEWORK_DIR = platform.get_package_dir(platform_name)
|
||||||
|
assert os.path.isdir(FRAMEWORK_DIR)
|
||||||
|
|
||||||
board = env.BoardConfig()
|
board = env.BoardConfig()
|
||||||
|
|
||||||
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32")
|
#mcu_type = board.get("build.mcu")[:-2]
|
||||||
assert os.path.isdir(FRAMEWORK_DIR)
|
|
||||||
assert os.path.isdir("buildroot/share/PlatformIO/variants")
|
|
||||||
|
|
||||||
mcu_type = board.get("build.mcu")[:-2]
|
|
||||||
variant = board.get("build.variant")
|
variant = board.get("build.variant")
|
||||||
series = mcu_type[:7].upper() + "xx"
|
#series = mcu_type[:7].upper() + "xx"
|
||||||
|
|
||||||
|
# Prepare a new empty folder at the destination
|
||||||
variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant)
|
variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant)
|
||||||
|
if os.path.isdir(variant_dir):
|
||||||
source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant)
|
shutil.rmtree(variant_dir)
|
||||||
assert os.path.isdir(source_dir)
|
|
||||||
|
|
||||||
if not os.path.isdir(variant_dir):
|
if not os.path.isdir(variant_dir):
|
||||||
os.mkdir(variant_dir)
|
os.mkdir(variant_dir)
|
||||||
|
|
||||||
for file_name in os.listdir(source_dir):
|
# Source dir is a local variant sub-folder
|
||||||
full_file_name = os.path.join(source_dir, file_name)
|
source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant)
|
||||||
if os.path.isfile(full_file_name):
|
assert os.path.isdir(source_dir)
|
||||||
shutil.copy(full_file_name, variant_dir)
|
|
||||||
|
marlin.copytree(source_dir, variant_dir)
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py
|
||||||
|
# Customizations for env:jgaurora_a5s_a1
|
||||||
|
#
|
||||||
|
import os,marlin
|
||||||
|
|
||||||
# Relocate firmware from 0x08000000 to 0x0800A000
|
# Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin'
|
||||||
env['CPPDEFINES'].remove(("VECT_TAB_ADDR", "0x8000000"))
|
def addboot(source, target, env):
|
||||||
#alternatively, for STSTM <=5.1.0 use line below
|
|
||||||
#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x0800A000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/jgaurora_a5s_a1.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
|
|
||||||
|
|
||||||
#append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin'
|
|
||||||
def addboot(source,target,env):
|
|
||||||
firmware = open(target[0].path, "rb")
|
firmware = open(target[0].path, "rb")
|
||||||
lengthfirmware = os.path.getsize(target[0].path)
|
lengthfirmware = os.path.getsize(target[0].path)
|
||||||
bootloader_dir = "buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin"
|
bootloader_bin = "buildroot/share/PlatformIO/scripts/" + "jgaurora_bootloader.bin"
|
||||||
bootloader = open(bootloader_dir, "rb")
|
bootloader = open(bootloader_bin, "rb")
|
||||||
lengthbootloader = os.path.getsize(bootloader_dir)
|
lengthbootloader = os.path.getsize(bootloader_bin)
|
||||||
firmware_with_boothloader_dir = target[0].dir.path +'/firmware_with_bootloader.bin'
|
|
||||||
if os.path.exists(firmware_with_boothloader_dir):
|
firmware_with_boothloader_bin = target[0].dir.path + '/firmware_with_bootloader.bin'
|
||||||
os.remove(firmware_with_boothloader_dir)
|
if os.path.exists(firmware_with_boothloader_bin):
|
||||||
firmwareimage = open(firmware_with_boothloader_dir, "wb")
|
os.remove(firmware_with_boothloader_bin)
|
||||||
|
firmwareimage = open(firmware_with_boothloader_bin, "wb")
|
||||||
position = 0
|
position = 0
|
||||||
while position < lengthbootloader:
|
while position < lengthbootloader:
|
||||||
byte = bootloader.read(1)
|
byte = bootloader.read(1)
|
||||||
@ -38,11 +29,11 @@ def addboot(source,target,env):
|
|||||||
bootloader.close()
|
bootloader.close()
|
||||||
firmware.close()
|
firmware.close()
|
||||||
firmwareimage.close()
|
firmwareimage.close()
|
||||||
firmware_without_bootloader_dir = target[0].dir.path+'/firmware_for_sd_upload.bin'
|
|
||||||
if os.path.exists(firmware_without_bootloader_dir):
|
firmware_without_bootloader_bin = target[0].dir.path + '/firmware_for_sd_upload.bin'
|
||||||
os.remove(firmware_without_bootloader_dir)
|
if os.path.exists(firmware_without_bootloader_bin):
|
||||||
os.rename(target[0].path, firmware_without_bootloader_dir)
|
os.remove(firmware_without_bootloader_bin)
|
||||||
|
os.rename(target[0].path, firmware_without_bootloader_bin)
|
||||||
#os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin')
|
#os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin')
|
||||||
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", addboot);
|
marlin.add_post_action(addboot);
|
||||||
|
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
#
|
#
|
||||||
# lerdge.py
|
# buildroot/share/PlatformIO/scripts/lerdge.py
|
||||||
# Customizations for Lerdge build environments
|
# Customizations for Lerdge build environments:
|
||||||
|
# env:LERDGEX env:LERDGEX_usb_flash_drive
|
||||||
|
# env:LERDGES env:LERDGES_usb_flash_drive
|
||||||
|
# env:LERDGEK env:LERDGEK_usb_flash_drive
|
||||||
#
|
#
|
||||||
import os,sys
|
import os,marlin
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
from SCons.Script import DefaultEnvironment
|
from SCons.Script import DefaultEnvironment
|
||||||
board = DefaultEnvironment().BoardConfig()
|
board = DefaultEnvironment().BoardConfig()
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/lerdge.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
|
|
||||||
|
|
||||||
def encryptByte(byte):
|
def encryptByte(byte):
|
||||||
byte = 0xFF & ((byte << 6) | (byte >> 2))
|
byte = 0xFF & ((byte << 6) | (byte >> 2))
|
||||||
i = 0x58 + byte
|
i = 0x58 + byte
|
||||||
@ -35,16 +31,16 @@ def encrypt_file(input, output_file, file_length):
|
|||||||
def encrypt(source, target, env):
|
def encrypt(source, target, env):
|
||||||
print("Encrypting to:", board.get("build.firmware"))
|
print("Encrypting to:", board.get("build.firmware"))
|
||||||
firmware = open(target[0].path, "rb")
|
firmware = open(target[0].path, "rb")
|
||||||
result = open(target[0].dir.path + "/" + board.get("build.firmware"), "wb")
|
renamed = open(target[0].dir.path + "/" + board.get("build.firmware"), "wb")
|
||||||
length = os.path.getsize(target[0].path)
|
length = os.path.getsize(target[0].path)
|
||||||
|
|
||||||
encrypt_file(firmware, result, length)
|
encrypt_file(firmware, renamed, length)
|
||||||
|
|
||||||
firmware.close()
|
firmware.close()
|
||||||
result.close()
|
renamed.close()
|
||||||
|
|
||||||
if 'firmware' in board.get("build").keys():
|
if 'firmware' in board.get("build").keys():
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
marlin.add_post_action(encrypt);
|
||||||
else:
|
else:
|
||||||
print("You need to define output file via board_build.firmware = 'filename' parameter")
|
print("You need to define output file via board_build.firmware = 'filename' parameter")
|
||||||
exit(1);
|
exit(1);
|
||||||
|
75
buildroot/share/PlatformIO/scripts/marlin.py
Normal file
75
buildroot/share/PlatformIO/scripts/marlin.py
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#
|
||||||
|
# buildroot/share/PlatformIO/scripts/marlin.py
|
||||||
|
# Helper module with some commonly-used functions
|
||||||
|
#
|
||||||
|
import os,shutil
|
||||||
|
|
||||||
|
from SCons.Script import DefaultEnvironment
|
||||||
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
def replace_define(field, value):
|
||||||
|
for define in env['CPPDEFINES']:
|
||||||
|
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)
|
||||||
|
|
||||||
|
# Relocate the vector table with a new offset
|
||||||
|
def relocate_vtab(address):
|
||||||
|
replace_define("VECT_TAB_OFFSET", address)
|
||||||
|
|
||||||
|
# Replace the existing -Wl,-T with the given ldscript path
|
||||||
|
def custom_ld_script(ldname):
|
||||||
|
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
|
||||||
|
# Called by specific encrypt() functions, mostly for MKS boards
|
||||||
|
def encrypt_mks(source, target, env, new_name):
|
||||||
|
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]
|
||||||
|
|
||||||
|
firmware = open(target[0].path, "rb")
|
||||||
|
renamed = open(target[0].dir.path + "/" + new_name, "wb")
|
||||||
|
length = os.path.getsize(target[0].path)
|
||||||
|
position = 0
|
||||||
|
try:
|
||||||
|
while position < length:
|
||||||
|
byte = firmware.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')
|
||||||
|
renamed.write(byte)
|
||||||
|
position += 1
|
||||||
|
finally:
|
||||||
|
firmware.close()
|
||||||
|
renamed.close()
|
||||||
|
|
||||||
|
def add_post_action(action):
|
||||||
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", action);
|
||||||
|
|
||||||
|
# Apply customizations for a MKS Robin
|
||||||
|
def prepare_robin(address, ldname, fwname):
|
||||||
|
def encrypt(source, target, env):
|
||||||
|
encrypt_mks(source, target, env, fwname)
|
||||||
|
relocate_firmware(address)
|
||||||
|
custom_ld_script(ldname)
|
||||||
|
add_post_action(encrypt);
|
@ -1,32 +1,28 @@
|
|||||||
import os,sys
|
#
|
||||||
|
# buildroot/share/PlatformIO/scripts/mks_encrypt.py
|
||||||
|
#
|
||||||
|
# Apply encryption and save as 'build.firmware' for these environments:
|
||||||
|
# - env:mks_robin_stm32
|
||||||
|
# - env:flsun_hispeedv1
|
||||||
|
# - env:mks_robin_nano35_stm32
|
||||||
|
#
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
from SCons.Script import DefaultEnvironment
|
from SCons.Script import DefaultEnvironment
|
||||||
board = DefaultEnvironment().BoardConfig()
|
board = DefaultEnvironment().BoardConfig()
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as build.firmware ('Robin.bin')
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/'+ board.get("build.firmware"), "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
|
|
||||||
if 'firmware' in board.get("build").keys():
|
if 'firmware' in board.get("build").keys():
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
import marlin
|
||||||
|
|
||||||
|
# Encrypt ${PROGNAME}.bin and save it as build.firmware
|
||||||
|
def encrypt(source, target, env):
|
||||||
|
marlin.encrypt_mks(source, target, env, "build.firmware")
|
||||||
|
|
||||||
|
marlin.add_post_action(encrypt);
|
||||||
|
|
||||||
else:
|
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.firmware = 'filename' parameter", file=sys.stderr)
|
||||||
exit(1);
|
env.Exit(1);
|
||||||
|
@ -1,39 +1,5 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/mks_robin.py
|
||||||
|
#
|
||||||
# Relocate firmware from 0x08000000 to 0x08007000
|
import marlin
|
||||||
for define in env['CPPDEFINES']:
|
marlin.prepare_robin("0x08007000", "mks_robin.ld", "Robin.bin")
|
||||||
if define[0] == "VECT_TAB_ADDR":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin.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
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'Robin.bin'
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/Robin.bin', "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
@ -1,40 +1,5 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/mks_robin_e3.py
|
||||||
|
#
|
||||||
# Relocate firmware from 0x08000000 to 0x08005000
|
import marlin
|
||||||
for define in env['CPPDEFINES']:
|
marlin.prepare_robin("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin")
|
||||||
if define[0] == "VECT_TAB_ADDR":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_e3.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
|
|
||||||
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/Robin_e3.bin', "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
@ -1,40 +1,5 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/mks_robin_e3p.py
|
||||||
|
#
|
||||||
# Relocate firmware from 0x08000000 to 0x08007000
|
import marlin
|
||||||
for define in env['CPPDEFINES']:
|
marlin.prepare_robin("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin")
|
||||||
if define[0] == "VECT_TAB_ADDR":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.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
|
|
||||||
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'mks_robin_e3p.bin'
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/Robin_e3p.bin', "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
@ -1,40 +1,5 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/mks_robin_lite.py
|
||||||
|
#
|
||||||
# Relocate firmware from 0x08000000 to 0x08005000
|
import marlin
|
||||||
for define in env['CPPDEFINES']:
|
marlin.prepare_robin("0x08005000", "mks_robin_lite.ld", "mksLite.bin")
|
||||||
if define[0] == "VECT_TAB_ADDR":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_lite.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
|
|
||||||
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/mksLite.bin', "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
@ -1,40 +1,5 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/mks_robin_lite3.py
|
||||||
|
#
|
||||||
# Relocate firmware from 0x08000000 to 0x08005000
|
import marlin
|
||||||
for define in env['CPPDEFINES']:
|
marlin.prepare_robin("0x08005000", "mks_robin_lite.ld", "mksLite3.bin")
|
||||||
if define[0] == "VECT_TAB_ADDR":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_lite.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
|
|
||||||
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/mksLite3.bin', "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
@ -1,40 +1,5 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/mks_robin_mini.py
|
||||||
|
#
|
||||||
# Relocate firmware from 0x08000000 to 0x08007000
|
import marlin
|
||||||
for define in env['CPPDEFINES']:
|
marlin.prepare_robin("0x08005000", "mks_robin_mini.ld", "Robin_mini.bin")
|
||||||
if define[0] == "VECT_TAB_ADDR":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_mini.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
|
|
||||||
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'Robin_mini.bin'
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/Robin_mini.bin', "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
@ -1,40 +1,5 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/mks_robin_nano.py
|
||||||
|
#
|
||||||
# Relocate firmware from 0x08000000 to 0x08007000
|
import marlin
|
||||||
for define in env['CPPDEFINES']:
|
marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin")
|
||||||
if define[0] == "VECT_TAB_ADDR":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_nano.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
|
|
||||||
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'Robin_nano.bin'
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/Robin_nano.bin', "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
@ -1,40 +1,5 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/mks_robin_nano35.py
|
||||||
|
#
|
||||||
# Relocate firmware from 0x08000000 to 0x08007000
|
import marlin
|
||||||
for define in env['CPPDEFINES']:
|
marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin")
|
||||||
if define[0] == "VECT_TAB_ADDR":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_nano.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
|
|
||||||
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'Robin_nano35.bin'
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/Robin_nano35.bin', "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
@ -1,39 +1,5 @@
|
|||||||
import os
|
#
|
||||||
Import("env")
|
# buildroot/share/PlatformIO/scripts/mks_robin_pro.py
|
||||||
|
#
|
||||||
# Relocate firmware from 0x08000000 to 0x08007000
|
import marlin
|
||||||
for define in env['CPPDEFINES']:
|
marlin.prepare_robin("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin")
|
||||||
if define[0] == "VECT_TAB_ADDR":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
|
|
||||||
|
|
||||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_pro.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
|
|
||||||
|
|
||||||
# Encrypt ${PROGNAME}.bin and save it as 'Robin.bin'
|
|
||||||
def encrypt(source, target, env):
|
|
||||||
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]
|
|
||||||
|
|
||||||
firmware = open(target[0].path, "rb")
|
|
||||||
robin = open(target[0].dir.path +'/Robin_pro.bin', "wb")
|
|
||||||
length = os.path.getsize(target[0].path)
|
|
||||||
position = 0
|
|
||||||
try:
|
|
||||||
while position < length:
|
|
||||||
byte = firmware.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')
|
|
||||||
robin.write(byte)
|
|
||||||
position += 1
|
|
||||||
finally:
|
|
||||||
firmware.close()
|
|
||||||
robin.close()
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# stm32_bootloader.py
|
# stm32_bootloader.py
|
||||||
#
|
#
|
||||||
import os,sys,shutil
|
import os,sys,shutil,marlin
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
from SCons.Script import DefaultEnvironment
|
from SCons.Script import DefaultEnvironment
|
||||||
@ -20,13 +20,7 @@ def noencrypt(source, target, env):
|
|||||||
if 'offset' in board.get("build").keys():
|
if 'offset' in board.get("build").keys():
|
||||||
LD_FLASH_OFFSET = board.get("build.offset")
|
LD_FLASH_OFFSET = board.get("build.offset")
|
||||||
|
|
||||||
# Remove an existing VECT_TAB_OFFSET from CPPDEFINES
|
marlin.relocate_vtab(LD_FLASH_OFFSET)
|
||||||
for define in env['CPPDEFINES']:
|
|
||||||
if define[0] == "VECT_TAB_OFFSET":
|
|
||||||
env['CPPDEFINES'].remove(define)
|
|
||||||
|
|
||||||
# Replace VECT_TAB_OFFSET with our LD_FLASH_OFFSET
|
|
||||||
env['CPPDEFINES'].append(("VECT_TAB_OFFSET", LD_FLASH_OFFSET))
|
|
||||||
|
|
||||||
# Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json)
|
# Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json)
|
||||||
maximum_ram_size = board.get("upload.maximum_ram_size")
|
maximum_ram_size = board.get("upload.maximum_ram_size")
|
||||||
@ -42,4 +36,5 @@ if 'offset' in board.get("build").keys():
|
|||||||
#
|
#
|
||||||
board_keys = board.get("build").keys()
|
board_keys = board.get("build").keys()
|
||||||
if 'firmware' in board_keys and not 'encrypt' in board_keys:
|
if 'firmware' in board_keys and not 'encrypt' in board_keys:
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt)
|
import marlin
|
||||||
|
marlin.add_post_action(noencrypt)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user