add target reset (#21292)

This commit is contained in:
Jason2866 2024-04-27 21:52:39 +02:00 committed by GitHub
parent b3c075c666
commit 27d2a0a2d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 29 additions and 0 deletions

View File

@ -335,6 +335,35 @@ def esp32_use_external_crashreport(*args, **kwargs):
)
print(Fore.YELLOW + output[0]+": \n"+output[1]+" in "+output[2])
def reset_target(*args, **kwargs):
esptoolpy = join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py")
upload_port = join(env.get("UPLOAD_PORT", "none"))
if "none" in upload_port:
env.AutodetectUploadPort()
upload_port = join(env.get("UPLOAD_PORT", "none"))
esptoolpy_flags = [
"--no-stub",
"--chip", mcu,
"--port", upload_port,
"flash_id"
]
esptoolpy_cmd = [env["PYTHONEXE"], esptoolpy] + esptoolpy_flags
print("Try to reset device")
subprocess.call(esptoolpy_cmd, shell=False)
env.AddCustomTarget(
name="reset_target",
dependencies=None,
actions=[
reset_target
],
title="Reset ESP32 target",
description="This command resets ESP32x target via esptoolpy",
)
env.AddCustomTarget(
name="downloadfs",
dependencies=None,