2019-06-26 01:40:29 -04:00
|
|
|
from os.path import join
|
2019-08-10 02:45:36 -04:00
|
|
|
from os.path import expandvars
|
2019-06-26 01:40:29 -04:00
|
|
|
Import("env", "projenv")
|
|
|
|
|
2020-05-25 16:48:33 -04:00
|
|
|
# Relocate firmware from 0x08000000 to 0x08010000
|
|
|
|
# for define in env['CPPDEFINES']:
|
|
|
|
# if define[0] == "VECT_TAB_ADDR":
|
|
|
|
# env['CPPDEFINES'].remove(define)
|
2019-06-26 01:40:29 -04:00
|
|
|
#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
|
|
|
|
#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
|
|
|
|
|
|
|
|
# Custom HEX from ELF
|
|
|
|
env.AddPostAction(
|
2019-08-10 02:45:36 -04:00
|
|
|
join("$BUILD_DIR","${PROGNAME}.elf"),
|
2019-06-26 01:40:29 -04:00
|
|
|
env.VerboseAction(" ".join([
|
2019-08-10 02:45:36 -04:00
|
|
|
"$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
|
2019-08-12 20:50:34 -04:00
|
|
|
"\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
|
2019-08-10 02:45:36 -04:00
|
|
|
]), "Building $TARGET"))
|
2019-06-26 01:40:29 -04:00
|
|
|
|
|
|
|
# In-line command with arguments
|
2019-08-10 02:45:36 -04:00
|
|
|
UPLOAD_TOOL="stm32flash"
|
|
|
|
platform = env.PioPlatform()
|
|
|
|
if platform.get_package_dir("tool-stm32duino") != None:
|
2019-08-12 20:50:34 -04:00
|
|
|
UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"")
|
2019-08-10 02:45:36 -04:00
|
|
|
|
2019-07-18 06:54:50 -04:00
|
|
|
env.Replace(
|
2019-08-10 02:45:36 -04:00
|
|
|
UPLOADER=UPLOAD_TOOL,
|
2020-03-31 14:59:08 -04:00
|
|
|
UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT")
|
2019-07-18 06:54:50 -04:00
|
|
|
)
|