|
@@ -1,8 +1,7 @@
|
1
|
1
|
from os.path import join
|
|
2
|
+from os.path import expandvars
|
2
|
3
|
Import("env", "projenv")
|
3
|
4
|
|
4
|
|
-platform = env.PioPlatform()
|
5
|
|
-
|
6
|
5
|
# Relocate firmware from 0x08000000 to 0x08002000
|
7
|
6
|
#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728))
|
8
|
7
|
#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
|
|
@@ -10,14 +9,11 @@ platform = env.PioPlatform()
|
10
|
9
|
|
11
|
10
|
# Custom HEX from ELF
|
12
|
11
|
env.AddPostAction(
|
13
|
|
- "$BUILD_DIR/${PROGNAME}.elf",
|
|
12
|
+ join("$BUILD_DIR","${PROGNAME}.elf"),
|
14
|
13
|
env.VerboseAction(" ".join([
|
15
|
|
- "$OBJCOPY",
|
16
|
|
- "-O",
|
17
|
|
- "ihex",
|
18
|
|
- '"$BUILD_DIR/${PROGNAME}.elf"',
|
19
|
|
- '"$BUILD_DIR/${PROGNAME}.hex"'
|
20
|
|
- ]), "Building $TARGET"))
|
|
14
|
+ "$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
|
|
15
|
+ "'" + join("$BUILD_DIR","${PROGNAME}.hex") + "'", # Note: $BUILD_DIR is a full path
|
|
16
|
+ ]), "Building $TARGET"))
|
21
|
17
|
|
22
|
18
|
# please keep $SOURCE variable, it will be replaced with a path to firmware
|
23
|
19
|
|
|
@@ -28,12 +24,16 @@ env.AddPostAction(
|
28
|
24
|
#)
|
29
|
25
|
|
30
|
26
|
# In-line command with arguments
|
|
27
|
+UPLOAD_TOOL="stm32flash"
|
|
28
|
+platform = env.PioPlatform()
|
|
29
|
+if platform.get_package_dir("tool-stm32duino") != None:
|
|
30
|
+ UPLOAD_TOOL=expandvars("'" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "'")
|
|
31
|
+
|
31
|
32
|
env.Replace(
|
32
|
|
- UPLOADER=platform.get_package_dir("tool-stm32duino") + '/stm32flash/stm32flash',
|
33
|
|
- UPLOADCMD='"${UPLOADER}" -v -i rts,-dtr,dtr,-rts -R -b 115200 -g 0x8000000 -w "${BUILD_DIR}/${PROGNAME}.hex" ${UPLOAD_PORT}'
|
|
33
|
+ UPLOADER=UPLOAD_TOOL,
|
|
34
|
+ UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr $UPLOAD_PORT -R -w '" + join("$BUILD_DIR","${PROGNAME}.hex") + "'")
|
34
|
35
|
)
|
35
|
36
|
|
36
|
|
-
|
37
|
37
|
# Python callback
|
38
|
38
|
#def on_upload(source, target, env):
|
39
|
39
|
# print source, target
|