Skip to content

Commit b41232c

Browse files
authored
Fix: STM32 build env setup cleanup to avoid mismatch with target names (ExpressLRS#689)
* Fix: STM32 build env setup cleanup to avoid mismatch with target names * scripts: comments added into build_env_setup.py
1 parent 00a7427 commit b41232c

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

src/python/build_env_setup.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,40 @@
1717
if target_name == "FRSKY_TX_R9M_VIA_STLINK_OLD_BOOTLOADER_DEPRECATED":
1818
print("you are using the old bootloader, please update this will be removed soon")
1919
env.AddPostAction("buildprog", opentx.gen_frsky)
20-
elif "APLHA_900_TX" in target_name:
21-
env.Replace(UPLOADCMD=upload_via_esp8266_backpack.on_upload)
22-
elif "_R9M_" in target_name or "ES915TX" in target_name or "GHOST_2400_TX" in target_name or \
23-
"NAMIMNORC_VOYAGER" in target_name or "NAMIMNORC_FLASH" in target_name:
20+
21+
# Check whether the target is using WIFI (backpack logger) upload
22+
elif "_WIFI" in target_name:
23+
# Generate 'firmware.elrs' file to be used for uploading (prio to bin file).
24+
# This enables support for OTA updates with the "overlay double" R9M module
25+
# bootloader. Bin file upload also requires the correct FLASH_OFFSET value
26+
# and that can be ignored when '.elrs' file is used.
2427
env.AddPostAction("buildprog", opentx.gen_elrs)
2528
env.AddPreAction("upload", opentx.gen_elrs)
26-
if "WIFI" in target_name:
27-
env.Replace(UPLOADCMD=upload_via_esp8266_backpack.on_upload)
28-
else:
29-
env.Replace(UPLOADCMD=stlink.on_upload)
30-
elif "_STLINK" in target_name:
31-
env.Replace(UPLOADCMD=stlink.on_upload)
29+
env.Replace(UPLOADCMD=upload_via_esp8266_backpack.on_upload)
30+
31+
# Check whether the target is using FC passthrough upload (receivers)
3232
elif "_BETAFLIGHTPASSTHROUGH" in target_name:
3333
env.Replace(UPLOADCMD=UARTupload.on_upload)
34+
35+
# Check whether the target is using DFU upload
3436
elif "_DFU" in target_name:
3537
board = env.BoardConfig()
3638
# PIO's ststm32 forces stm32f103 to upload via maple_upload,
37-
# but we really actually truly want dfu-util
39+
# but we really actually truly want dfu-util.
3840
env.Replace(UPLOADER="dfu-util", UPLOADERFLAGS=["-d", "0483:df11",
3941
"-s", "%s:leave" % board.get("upload.offset_address", "0x08001000"),
4042
"-D"], UPLOADCMD='$UPLOADER $UPLOADERFLAGS "${SOURCE.get_abspath()}"')
43+
44+
# Default to ST-Link uploading
45+
# Note: this target is also used to build 'firmware.elrs' binary
46+
# for handset flashing
47+
else:
48+
if "_TX_" in target_name:
49+
# Generate 'firmware.elrs' file for TX targets only
50+
env.AddPostAction("buildprog", opentx.gen_elrs)
51+
env.AddPreAction("upload", opentx.gen_elrs)
52+
env.Replace(UPLOADCMD=stlink.on_upload)
53+
4154
elif platform in ['espressif8266']:
4255
env.AddPostAction("buildprog", esp_compress.compressFirmware)
4356
env.AddPreAction("${BUILD_DIR}/spiffs.bin",

0 commit comments

Comments
 (0)