2019-06-26 07:40:29 +02:00
|
|
|
from os.path import join
|
2019-08-10 08:45:36 +02:00
|
|
|
from os.path import expandvars
|
2019-06-26 07:40:29 +02:00
|
|
|
Import("env", "projenv")
|
|
|
|
|
|
|
|
# Relocate firmware from 0x08000000 to 0x08002000
|
|
|
|
#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
|
|
|
|
#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
|
|
|
|
#env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/fysetc_aio_ii.ld")
|
|
|
|
|
|
|
|
# Custom HEX from ELF
|
|
|
|
env.AddPostAction(
|
2019-08-10 08:45:36 +02:00
|
|
|
join("$BUILD_DIR","${PROGNAME}.elf"),
|
2019-06-26 07:40:29 +02:00
|
|
|
env.VerboseAction(" ".join([
|
2019-08-10 08:45:36 +02:00
|
|
|
"$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
|
2019-08-13 02:50:34 +02:00
|
|
|
"\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
|
2019-08-10 08:45:36 +02:00
|
|
|
]), "Building $TARGET"))
|
2019-06-26 07:40:29 +02:00
|
|
|
|
|
|
|
# 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
|
2019-08-10 08:45:36 +02:00
|
|
|
UPLOAD_TOOL="stm32flash"
|
|
|
|
platform = env.PioPlatform()
|
|
|
|
if platform.get_package_dir("tool-stm32duino") != None:
|
2019-08-13 02:50:34 +02:00
|
|
|
UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"")
|
2019-08-10 08:45:36 +02:00
|
|
|
|
2019-07-18 12:54:50 +02:00
|
|
|
env.Replace(
|
2019-08-10 08:45:36 +02:00
|
|
|
UPLOADER=UPLOAD_TOOL,
|
2019-08-13 02:50:34 +02:00
|
|
|
UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr $UPLOAD_PORT -R -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"")
|
2019-07-18 12:54:50 +02:00
|
|
|
)
|
|
|
|
|
2019-06-26 07:40:29 +02:00
|
|
|
# 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)
|