Skip to content

Commit

Permalink
tools/psoc6/mpy-psoc6.py: Added openocd fw-loader error handling.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Nov 22, 2023
1 parent 80f1a25 commit 8f68019
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions tools/psoc6/mpy-psoc6.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,12 @@ def fwloader_setup():
def fwloader_update_kitprog():
def parse_output_for_error(fwloader_stdout):
fwloader_out_lines = fwloader_stdout.decode().split("\n")
print(fwloader_out_lines)
for line in fwloader_out_lines:
if "Error" in line:
raise Exception(colour_str_error(line))

print("Updating kitprog3 firmware...")
fwloader_cmd = "fw-loader --update-kp3 all"
print(fwloader_cmd)
fwloader_args = shlex.split(fwloader_cmd)

fwl_proc = subprocess.Popen(fwloader_args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
Expand Down Expand Up @@ -359,25 +357,28 @@ def device_setup(board, version, update_dbg_fw=False, quiet=False):

print("MicroPython PSoC6 Version :: ", version)

openocd_download_install()
openocd_board_conf_download(board)
mpy_firmware_download("hello-world", board, "v0.3.0")
mpy_firmware_download("mpy-psoc6", board, version)

if not quiet:
wait_and_request_board_connect()

if update_dbg_fw:
fwloader_download_install()
fwloader_update_kitprog()
fwloader_remove()
try:
fwloader_update_kitprog()
finally:
fwloader_remove()

mpy_firmware_deploy("hello-world", board)
mpy_firmware_deploy("mpy-psoc6", board)
openocd_download_install()
openocd_board_conf_download(board)
mpy_firmware_download("hello-world", board, "v0.3.0")
mpy_firmware_download("mpy-psoc6", board, version)

openocd_remove()
mpy_firmware_remove("hello-world", board)
mpy_firmware_remove("mpy-psoc6", board)
try:
mpy_firmware_deploy("hello-world", board)
mpy_firmware_deploy("mpy-psoc6", board)
finally:
openocd_remove()
mpy_firmware_remove("hello-world", board)
mpy_firmware_remove("mpy-psoc6", board)

print(colour_str_success("Device setup completed :)"))

Expand All @@ -389,17 +390,18 @@ def device_erase(board, quiet=False):
if board != "CY8CPROTO-062-4343W":
raise Exception(colour_str_error("error: board is not supported"))

openocd_download_install()
openocd_board_conf_download(board)
mpy_firmware_download("device-erase", board, "v0.3.0")

if not quiet:
wait_and_request_board_connect()

mpy_firmware_deploy("device-erase", board)
openocd_download_install()
openocd_board_conf_download(board)
mpy_firmware_download("device-erase", board, "v0.3.0")

openocd_remove()
mpy_firmware_remove("device-erase", board)
try:
mpy_firmware_deploy("device-erase", board)
finally:
openocd_remove()
mpy_firmware_remove("device-erase", board)

print(colour_str_success("Device erase completed :)"))

Expand Down

0 comments on commit 8f68019

Please sign in to comment.