You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
6 years ago
|
from os.path import join
|
||
5 years ago
|
from os.path import expandvars
|
||
6 years ago
|
Import("env", "projenv")
|
||
|
|
||
|
# Relocate firmware from 0x08000000 to 0x08002000
|
||
|
#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
|
||
|
#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
|
||
|
|
||
|
# Custom HEX from ELF
|
||
|
env.AddPostAction(
|
||
5 years ago
|
join("$BUILD_DIR","${PROGNAME}.elf"),
|
||
6 years ago
|
env.VerboseAction(" ".join([
|
||
5 years ago
|
"$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
|
||
5 years ago
|
"\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
|
||
5 years ago
|
]), "Building $TARGET"))
|
||
6 years ago
|
|
||
|
# please keep $SOURCE variable, it will be replaced with a path to firmware
|
||
|
|
||
|
# Generic
|
||
|
#env.Replace(
|
||
|
# UPLOADER="serial_upload.bat"
|
||
|
# UPLOADCMD="$UPLOADER stm32loader.py $SOURCE"
|
||
|
#)
|
||
|
|
||
|
# In-line command with arguments
|
||
5 years ago
|
UPLOAD_TOOL="stm32flash"
|
||
|
platform = env.PioPlatform()
|
||
|
if platform.get_package_dir("tool-stm32duino") != None:
|
||
5 years ago
|
UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"")
|
||
5 years ago
|
|
||
6 years ago
|
env.Replace(
|
||
5 years ago
|
UPLOADER=UPLOAD_TOOL,
|
||
5 years ago
|
UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT")
|
||
6 years ago
|
)
|
||
|
|
||
6 years ago
|
# Python callback
|
||
|
#def on_upload(source, target, env):
|
||
|
# print source, target
|
||
|
# firmware_path = str(source[0])
|
||
|
# # do something
|
||
|
# env.Execute(".\serial_upload.bat")
|
||
|
|
||
|
#env.Replace(UPLOADCMD=on_upload)
|