From 85b6eb23bdf3ec4efc14a0211c650f44894cd269 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Wed, 29 Nov 2023 10:42:38 +0100 Subject: [PATCH 1/9] tools/psoc6/mpy-psoc6.py: Fixed scaping characters from banner. Signed-off-by: enriquezgarc --- tools/psoc6/mpy-psoc6.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/psoc6/mpy-psoc6.py b/tools/psoc6/mpy-psoc6.py index a17374b496e9c..82a5bda49a297 100644 --- a/tools/psoc6/mpy-psoc6.py +++ b/tools/psoc6/mpy-psoc6.py @@ -476,12 +476,12 @@ def print_retro_banner(): print("################################################") print(" Welcome to the ") print(" __ __ _ ___ _ _ ") - print("| \/ (_)__ _ _ ___| _ \_ _| |_| |_ ___ _ _") - print("| |\/| | / _| '_/ _ \ _/ || | _| ' \/ _ \ ' \\") - print("|_|_ |_|_\__|_| \___/_| \_, |\__|_||_\___/_||_|") - print("| _ \/ __| ___ / __|/ / |__/") - print("| _/\__ \/ _ \ (__/ _ \\") - print("|_| |___/\___/\___\___/") + print("| \\/ (_)__ _ _ ___| _ \\_ _| |_| |_ ___ _ _") + print("| |\\/| | / _| '_/ _ \\ _/ || | _| ' \\/ _ \\ ' \\") + print("|_|_ |_|_\\__|_| \\___/_| \\_, |\\__|_||_\\___/_||_|") + print("| _ \\/ __| ___ / __|/ / |__/") + print("| _/\\__ \\/ _ \\ (__/ _ \\") + print("|_| |___/\\___/\\___\\___/") print("") print(" Quick Start ") print("################################################") From 035eb5a8503b96dbab7219f1d8b3a53d45e3c9bc Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Mon, 4 Dec 2023 13:14:12 +0100 Subject: [PATCH 2/9] tools/psoc6/mpy-psoc6.py: Exceptions as sys.exit without traceback. Signed-off-by: enriquezgarc --- tools/psoc6/mpy-psoc6.py | 169 ++++++++++++++++++++++++++------------- 1 file changed, 115 insertions(+), 54 deletions(-) diff --git a/tools/psoc6/mpy-psoc6.py b/tools/psoc6/mpy-psoc6.py index 82a5bda49a297..ba28efc17a3e0 100644 --- a/tools/psoc6/mpy-psoc6.py +++ b/tools/psoc6/mpy-psoc6.py @@ -36,7 +36,7 @@ def set_environment(): os.system("color") # Enable colouring in cmd and powershell elif sys.platform == "darwin": opsys = "mac" - raise Exception(colour_str_error("OS unsupported")) + sys.exit(colour_str_error("OS unsupported")) def mpy_get_fw_hex_file_name(file_name, board): @@ -52,6 +52,11 @@ def mpy_firmware_deploy(file_name, board, serial_adapter_sn=None): def mpy_firmware_download(file_name, board, version): + def mpy_firmware_clean(file_name, board): + file_name_for_board = mpy_get_fw_hex_file_name(file_name, board) + if os.path.exists(file_name_for_board): + os.remove(file_name_for_board) + print( "Downloading " + str(file_name) + " " + str(version) + " for " + str(board) + " board..." ) @@ -66,18 +71,24 @@ def mpy_firmware_download(file_name, board, version): "https://github.com/infineon/micropython/releases/" + sub_url + "/" + file_name_for_board ) + # Clean if existing from previous run + # It is not sure if it is the same version + mpy_firmware_clean(file_name, board) + res = requests.get(file_url) open(file_name_for_board, "wb").write(res.content) -def mpy_firmware_remove(file_name, board): - os.remove(mpy_get_fw_hex_file_name(file_name, board)) - - def fwloader_download_install(): file_extension = ".zip" fwloader_compressed = "fwloader" + file_extension + def is_fwloader_already_installed(): + if os.path.exists(os.path.join("fw-loader", "bin", "fw-loader")): + return True + + return False + def get_fwloader_file_url_name(): if opsys == "linux": file_os_suffix = "linux" @@ -101,6 +112,10 @@ def get_fwloader_file_url_name(): return file_url, file_name + def clean_fwloader(file_name): + if os.path.exists(file_name): + os.remove(file_name) + def download_fwloader(file_url, file_name): res = requests.get(file_url) open(file_name, "wb").write(res.content) @@ -122,15 +137,20 @@ def fwloader_setup(): sh_proc = subprocess.Popen(sh_args) sh_proc.wait() except: - raise Exception(colour_str_error("bash error")) + sys.exit(colour_str_error("bash error")) os.chmod(os.path.join("fw-loader", "bin", "fw-loader"), 0o755) - print("Downloading fw-loader...") - file_url, file_name = get_fwloader_file_url_name() - download_fwloader(file_url, file_name) - print("Extracting fw-loader...") - extract_fwloader() + if not is_fwloader_already_installed(): + print("Downloading fw-loader...") + file_url, file_name = get_fwloader_file_url_name() + clean_fwloader(file_name) + download_fwloader(file_url, file_name) + print("Extracting fw-loader...") + extract_fwloader() + else: + print("fw-loader installation skipped. Already installed") + fwloader_setup() @@ -139,7 +159,7 @@ def parse_output_for_error(fwloader_stdout): fwloader_out_lines = fwloader_stdout.decode().split("\n") for line in fwloader_out_lines: if "Error" in line: - raise Exception(colour_str_error(line)) + sys.exit(colour_str_error(line)) print("Updating kitprog3 firmware...") fwloader_cmd = "fw-loader --update-kp3 all" @@ -150,10 +170,10 @@ def parse_output_for_error(fwloader_stdout): out, err = fwl_proc.communicate(timeout=90) except: fwl_proc.kill() - raise Exception(colour_str_error("fwloader error")) + sys.exit(colour_str_error("fwloader error")) if err: - raise Exception(colour_str_error(err.decode())) + sys.exit(colour_str_error(err.decode())) parse_output_for_error(out) @@ -163,21 +183,32 @@ def parse_output_for_error(fwloader_stdout): def fwloader_remove(): file_extension = ".zip" fwloader_compressed = "fwloader" + file_extension - os.remove(fwloader_compressed) - shutil.rmtree("fw-loader") - shutil.rmtree("kp-firmware") + if os.path.exists(fwloader_compressed): + os.remove(fwloader_compressed) + if os.path.exists("fw-loader"): + shutil.rmtree("fw-loader") + if os.path.exists("kp-firmware"): + shutil.rmtree("kp-firmware") def openocd_download_install(): if opsys == "linux": file_os_suffix = "linux" file_extension = ".tar.gz" + openocd_exe = "openocd" elif opsys == "win": file_os_suffix = "windows" file_extension = ".zip" + openocd_exe = "openocd.exe" openocd_compressed = "openocd" + file_extension + def is_openocd_already_installed(): + if os.path.exists(os.path.join("openocd", "bin", openocd_exe)): + return True + + return False + def get_openocd_file_url_name(): filename_base = "openocd-4.4.0.2134-" url_base = "https://github.com/Infineon/micropython/releases/download/v0.3.0/" @@ -187,6 +218,10 @@ def get_openocd_file_url_name(): return file_url, file_name + def clean_openocd(file_name): + if os.path.exists(file_name): + os.remove(file_name) + def download_openocd(file_url, file_name): res = requests.get(file_url) open(file_name, "wb").write(res.content) @@ -213,13 +248,18 @@ def openocd_setup(): sh_proc = subprocess.Popen(sh_args) sh_proc.wait() except: - raise Exception(colour_str_error("bash error")) + sys.exit(colour_str_error("bash error")) + + if not is_openocd_already_installed(): + print("Downloading openocd...") + file_url, file_name = get_openocd_file_url_name() + clean_openocd(file_name) + download_openocd(file_url, file_name) + print("Extracting openocd...") + extract_openocd() + else: + print("openocd already available. Installation skipped") - print("Downloading openocd...") - file_url, file_name = get_openocd_file_url_name() - download_openocd(file_url, file_name) - print("Extracting openocd...") - extract_openocd() openocd_setup() @@ -237,6 +277,11 @@ def openocd_board_conf_download(board): if board == "CY8CPROTO-062-4343W": file_name = "qspi_config_" + str(board) + ".cfg" file_url = "https://github.com/infineon/micropython/releases/download/v0.3.0/" + file_name + + # Clean file if exists from previous run + if os.path.exists(file_name): + os.remove(file_name) + res = requests.get(file_url) open(file_name, "wb").write(res.content) @@ -278,10 +323,10 @@ def openocd_program(board, hex_file, serial_adapter_sn=None): out, err = ocd_proc.communicate(timeout=20) except: ocd_proc.kill() - raise Exception(colour_str_error("openocd error")) + sys.exit(colour_str_error("openocd error")) if err: - raise Exception(colour_str_error(err.decode())) + sys.exit(colour_str_error(err.decode() + "Are you sure the board is connected?")) def openocd_remove(): @@ -291,9 +336,11 @@ def openocd_remove(): file_extension = ".zip" openocd_compressed = "openocd" + file_extension + if os.path.exists(openocd_compressed): + os.remove(openocd_compressed) - os.remove(openocd_compressed) - shutil.rmtree("openocd") + if os.path.exists("openocd"): + shutil.rmtree("openocd") def validate_board_name(board_name): @@ -304,14 +351,24 @@ def validate_board_name(board_name): break if not board_supported: - raise Exception(colour_str_error("error: board is not supported")) + sys.exit(colour_str_error("error: board is not supported")) def select_board(): - def validate_board_index(board_index): + def validate_user_input(user_input): + def invalid_exit(): + sys.exit(colour_str_error("error: board ID is not valid")) + + try: + board_index = int(user_input) + except: + invalid_exit() + max_board_index = len(boards) if board_index < 0 or board_index > max_board_index: - raise Exception(colour_str_error("error: board ID not valid")) + invalid_exit() + + return board_index print("") print(" Supported MicroPython PSoC6 boards ") @@ -325,8 +382,9 @@ def validate_board_index(board_index): print("") print("") - board_index = int(input(colour_str_highlight("Please type the desired board ID: "))) - validate_board_index(board_index) + board_index = validate_user_input( + input(colour_str_highlight("Please type the desired board ID: ")) + ) board = boards[board_index]["name"] return board @@ -362,24 +420,17 @@ def device_setup(board, version, update_dbg_fw=False, quiet=False): if update_dbg_fw: fwloader_download_install() - try: - fwloader_update_kitprog() - finally: - fwloader_remove() + fwloader_update_kitprog() time.sleep(10) # Wait for the device to restart openocd_download_install() openocd_board_conf_download(board) + mpy_firmware_download("hello-world", board, "v0.3.0") mpy_firmware_download("mpy-psoc6", board, version) - 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) + mpy_firmware_deploy("hello-world", board) + mpy_firmware_deploy("mpy-psoc6", board) print(colour_str_success("Device setup completed :)")) @@ -389,20 +440,17 @@ def device_setup(board, version, update_dbg_fw=False, quiet=False): def device_erase(board, quiet=False): if board != "CY8CPROTO-062-4343W": - raise Exception(colour_str_error("error: board is not supported")) + sys.exit(colour_str_error("error: board is not supported")) if not quiet: wait_and_request_board_connect() openocd_download_install() openocd_board_conf_download(board) + mpy_firmware_download("device-erase", board, "v0.3.0") - try: - mpy_firmware_deploy("device-erase", board) - finally: - openocd_remove() - mpy_firmware_remove("device-erase", board) + mpy_firmware_deploy("device-erase", board) print(colour_str_success("Device erase completed :)")) @@ -424,6 +472,9 @@ def download_arduino_lab(): file_name = "Arduino.Lab.for.Micropython-" + file_os_suffix + file_name_extension file_url = url_base + file_name + if os.path.exists(file_name): + os.remove(file_name) + res = requests.get(file_url) open(file_name, "wb").write(res.content) @@ -457,7 +508,7 @@ def launch_arduino_lab(): ide_proc = subprocess.Popen(mpy_ide) ide_proc.wait() except: - raise Exception(colour_str_error("error: Could not launch Arduino Lab IDE")) + sys.exit(colour_str_error("error: Could not launch Arduino Lab IDE")) os.chdir(parent_dir) @@ -467,8 +518,8 @@ def launch_arduino_lab(): def arduino_lab_install_package_remove(): - print("Cleaning up Arduino Lab for Micropython installation package...") - os.remove("arduino-for-micropython.zip") + if os.path.exists("arduino-for-micropython.zip"): + os.remove("arduino-for-micropython.zip") def quick_start(board, version): @@ -499,6 +550,12 @@ def print_exit_banner(): wait_user_termination() +def clean_tool_downloads(): + fwloader_remove() + openocd_remove() + arduino_lab_install_package_remove() + + def parser(): def main_parser_func(args): parser.print_help() @@ -621,5 +678,9 @@ def __call__(self, parser, namespace, values, option_string, **kwargs): if __name__ == "__main__": - set_environment() - parser() + try: + set_environment() + parser() + except KeyboardInterrupt: + print(colour_str_error("error: keyboard interrupt")) + clean_tool_downloads() From f730bb03288ec937650c70e9ac472b3f2130775b Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Mon, 4 Dec 2023 13:29:10 +0100 Subject: [PATCH 3/9] tools/psoc6/mpy-psoc6.py: Update fw board by default in device-update. Signed-off-by: enriquezgarc --- tools/psoc6/mpy-psoc6.py | 53 ++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/tools/psoc6/mpy-psoc6.py b/tools/psoc6/mpy-psoc6.py index ba28efc17a3e0..fafa5e33819b1 100644 --- a/tools/psoc6/mpy-psoc6.py +++ b/tools/psoc6/mpy-psoc6.py @@ -45,10 +45,10 @@ def mpy_get_fw_hex_file_name(file_name, board): def mpy_firmware_deploy(file_name, board, serial_adapter_sn=None): - print("Deploying firmware...") + print(f"Deploying firmware {file_name} ...") hex_file = mpy_get_fw_hex_file_name(file_name, board) openocd_program(board, hex_file, serial_adapter_sn) - print(colour_str_success("Firmware deployed successfully")) + print(colour_str_success(f"Firmware {file_name} deployed successfully")) def mpy_firmware_download(file_name, board, version): @@ -84,7 +84,12 @@ def fwloader_download_install(): fwloader_compressed = "fwloader" + file_extension def is_fwloader_already_installed(): - if os.path.exists(os.path.join("fw-loader", "bin", "fw-loader")): + if opsys == "linux": + fwloader = "fw-loader" + elif opsys == "win": + fwloader = "fw-loader.exe" + + if os.path.exists(os.path.join("fw-loader", "bin", fwloader)): return True return False @@ -119,7 +124,7 @@ def clean_fwloader(file_name): def download_fwloader(file_url, file_name): res = requests.get(file_url) open(file_name, "wb").write(res.content) - os.rename(file_name, fwloader_compressed) + os.replace(file_name, fwloader_compressed) def extract_fwloader(): compress_file = zipfile.ZipFile(fwloader_compressed) @@ -167,7 +172,7 @@ def parse_output_for_error(fwloader_stdout): fwl_proc = subprocess.Popen(fwloader_args, stderr=subprocess.PIPE, stdout=subprocess.PIPE) try: - out, err = fwl_proc.communicate(timeout=90) + out, err = fwl_proc.communicate(timeout=20) except: fwl_proc.kill() sys.exit(colour_str_error("fwloader error")) @@ -225,7 +230,7 @@ def clean_openocd(file_name): def download_openocd(file_url, file_name): res = requests.get(file_url) open(file_name, "wb").write(res.content) - os.rename(file_name, openocd_compressed) + os.replace(file_name, openocd_compressed) def extract_openocd(): if opsys == "linux": @@ -286,7 +291,7 @@ def openocd_board_conf_download(board): open(file_name, "wb").write(res.content) # Rename config file - os.rename(file_name, "qspi_config.cfg") + os.replace(file_name, "qspi_config.cfg") # Move to parent dir os.chdir(parent_dir) @@ -402,7 +407,7 @@ def wait_user_termination(): input(colour_str_highlight("Press ENTER to continue...\n")) -def device_setup(board, version, update_dbg_fw=False, quiet=False): +def device_setup(board, version, skip_update_dbg_fw=True, quiet=False): if board is None: board = select_board() else: @@ -418,7 +423,7 @@ def device_setup(board, version, update_dbg_fw=False, quiet=False): if not quiet: wait_and_request_board_connect() - if update_dbg_fw: + if not skip_update_dbg_fw: fwloader_download_install() fwloader_update_kitprog() time.sleep(10) # Wait for the device to restart @@ -459,6 +464,17 @@ def device_erase(board, quiet=False): def arduino_lab_download_and_launch(): + def is_arduino_lab_already_installed(): + if opsys == "linux": + inolab = "arduino-lab-micropython-ide" + elif opsys == "win": + inolab = "Arduino Lab for Micropython.exe" + + if os.path.exists(os.path.join("arduino-lab-mpy", inolab)): + return True + + return False + def download_arduino_lab(): print("Downloading Arduino Lab for Micropython...") @@ -478,7 +494,7 @@ def download_arduino_lab(): res = requests.get(file_url) open(file_name, "wb").write(res.content) - os.rename(file_name, "arduino-for-micropython.zip") + os.replace(file_name, "arduino-for-micropython.zip") def extract_arduino_lab(): print("Extracting Arduino Lab for Micropython...") @@ -512,8 +528,12 @@ def launch_arduino_lab(): os.chdir(parent_dir) - download_arduino_lab() - extract_arduino_lab() + if not is_arduino_lab_already_installed(): + download_arduino_lab() + extract_arduino_lab() + else: + print("Arduino Lab already available. Installation skipped") + launch_arduino_lab() @@ -543,7 +563,7 @@ def print_exit_banner(): print(colour_str_success("################################################")) print_retro_banner() - device_setup(board, version, True) + device_setup(board, version, False) arduino_lab_download_and_launch() arduino_lab_install_package_remove() print_exit_banner() @@ -564,7 +584,7 @@ def parser_quick_start(args): quick_start(args.board, args.version) def parser_device_setup(args): - device_setup(args.board, args.version, args.u, args.q) + device_setup(args.board, args.version, args.skip_fw_update, args.q) def parser_firmware_deploy(args): openocd_program(args.board, args.hexfile) @@ -635,7 +655,10 @@ def __call__(self, parser, namespace, values, option_string, **kwargs): "-q", action="store_true", help="Quiet. Do not prompt any user confirmation request" ) parser_ds.add_argument( - "-u", action="store_true", help="Update board Kitprog3 debugger firmware" + "-s", + "--skip-fw-update", + action="store_true", + help="Skip board Kitprog3 debugger firmware update", ) parser_ds.set_defaults(func=parser_device_setup) From a82fc3040e6730aca4895eb5e722cc77d691fbab Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Thu, 14 Dec 2023 13:20:20 +0100 Subject: [PATCH 4/9] docs/psoc6/installation.rst: Update python script option. Signed-off-by: enriquezgarc --- docs/psoc6/installation.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/psoc6/installation.rst b/docs/psoc6/installation.rst index e974d1f052a70..9838f45407959 100644 --- a/docs/psoc6/installation.rst +++ b/docs/psoc6/installation.rst @@ -146,6 +146,7 @@ MicropPython firmware version: You can run any command any time you want to upgrade to the latest MicroPython firmware version. This command will take care of the following steps: +* Download and install fw-loader, which will be used to update the board flasher firmware. * Download and install openocd, which is the software required to deploy a firmware file on PSoC6™ controllers * Download the latest ``.hex`` file for your select board * Deploy the latest version of MicroPython firmware on your board @@ -190,7 +191,8 @@ Updating the flasher firmware The evaluation PSoC6™ boards include an integrated hardware programmer tool using `KitProg `_ firmware. Some older boards will come preflashed with KitProg version 2. In MicroPython PSoC6™ port it is required to use KitProg version 3, and the setup process will fail for version 2. -If you need to update the KitProg firmware, you can use the flag ``-u`` for updating the firmware version in the MicropPython device setup process. +By default, the device setup automatically updates the flasher firmware, ensuring compatibility with the rest of the flashing tools. +If you want to skip the KitProg firmware update step, you can use the flag ``-s`` or ``--skip-fw-update`` during the ``device-setup`` process. .. tabs:: @@ -198,7 +200,7 @@ If you need to update the KitProg firmware, you can use the flag ``-u`` for upda .. code-block:: bash - python mpy-psoc6.py device-setup -u + python mpy-psoc6.py device-setup -s .. warning:: @@ -304,6 +306,3 @@ Programmer User Guide `_. - - - From 44a17103b52bb94c2491f7ff4ca769b1cffa95fd Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Wed, 10 Jan 2024 15:31:39 +0100 Subject: [PATCH 5/9] tools/psoc6/mpy-psoc6.mpy: Extended fw-loader timeout. Signed-off-by: enriquezgarc --- tools/psoc6/mpy-psoc6.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/psoc6/mpy-psoc6.py b/tools/psoc6/mpy-psoc6.py index fafa5e33819b1..6a5261f0a79e0 100644 --- a/tools/psoc6/mpy-psoc6.py +++ b/tools/psoc6/mpy-psoc6.py @@ -172,7 +172,7 @@ def parse_output_for_error(fwloader_stdout): fwl_proc = subprocess.Popen(fwloader_args, stderr=subprocess.PIPE, stdout=subprocess.PIPE) try: - out, err = fwl_proc.communicate(timeout=20) + out, err = fwl_proc.communicate(timeout=100) except: fwl_proc.kill() sys.exit(colour_str_error("fwloader error")) From 1f619a80f1bcb0e586a8621eccfe595b9be3d3ed Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Mon, 15 Jan 2024 15:42:35 +0100 Subject: [PATCH 6/9] tools/psoc6/my-psoc6.py: Added openocd install to fimware-deploy. Signed-off-by: enriquezgarc --- tools/psoc6/mpy-psoc6.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/psoc6/mpy-psoc6.py b/tools/psoc6/mpy-psoc6.py index 6a5261f0a79e0..44995eefc58bc 100644 --- a/tools/psoc6/mpy-psoc6.py +++ b/tools/psoc6/mpy-psoc6.py @@ -587,6 +587,8 @@ def parser_device_setup(args): device_setup(args.board, args.version, args.skip_fw_update, args.q) def parser_firmware_deploy(args): + openocd_download_install() + openocd_board_conf_download(args.board) openocd_program(args.board, args.hexfile) def parser_device_erase(args): @@ -684,8 +686,7 @@ def __call__(self, parser, namespace, values, option_string, **kwargs): "firmware-deploy", description="Firmware deployment on MicroPython device. \ Use this command to deploy an existing .hex file \ - on a PSoC6 board. \ - Requires openocd available on the system path.", + on a PSoC6 board.", ) parser_fd.add_argument( "-b", "--board", default=None, type=str, required=True, help="PSoC6 prototyping kit name" From c85798a39c5a3a4542c6ac1e5cbc3d2f04900635 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Mon, 15 Jan 2024 15:43:07 +0100 Subject: [PATCH 7/9] docs/psoc6/installation.rst: Updated according to changes in script. Signed-off-by: enriquezgarc --- docs/psoc6/installation.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/psoc6/installation.rst b/docs/psoc6/installation.rst index 9838f45407959..c773dcb9c3735 100644 --- a/docs/psoc6/installation.rst +++ b/docs/psoc6/installation.rst @@ -210,11 +210,7 @@ If you want to skip the KitProg firmware update step, you can use the flag ``-s` Direct binary flashing ---------------------- -Another alternative to program the board is to directly provide the binary file. The ``firmware-deploy`` command is providing this option. -This commands is skipping all the tools download and installation, neither download the MicoPython firmware. -Therefore, it requires that `openocd `_ is already installed and available in the system path. -In exchange, it will be faster for batch flashing, or any situation where subsequent binary flashing needs to be performed. - +Another alternative to program the board is to directly provide the binary file. The ``firmware-deploy`` command is enabling this option. The board needs to be specified, and the path and name of the ``.hex`` file: .. tabs:: From b01028218ab32cad3453f3d02ff5de22f19bbc60 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Tue, 16 Jan 2024 09:37:53 +0100 Subject: [PATCH 8/9] tools/psoc6/mpy-psoc6.py: Added progress messages to firmware-deploy. Signed-off-by: enriquezgarc --- tools/psoc6/mpy-psoc6.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/psoc6/mpy-psoc6.py b/tools/psoc6/mpy-psoc6.py index 44995eefc58bc..02697cba64762 100644 --- a/tools/psoc6/mpy-psoc6.py +++ b/tools/psoc6/mpy-psoc6.py @@ -570,6 +570,14 @@ def print_exit_banner(): wait_user_termination() +def firmware_deploy(board, hex_file): + openocd_download_install() + openocd_board_conf_download(board) + print(f"Deploying hex file {hex_file} ...") + openocd_program(board, hex_file) + print(colour_str_success(f"Firmware {hex_file} deployed successfully")) + + def clean_tool_downloads(): fwloader_remove() openocd_remove() @@ -587,9 +595,7 @@ def parser_device_setup(args): device_setup(args.board, args.version, args.skip_fw_update, args.q) def parser_firmware_deploy(args): - openocd_download_install() - openocd_board_conf_download(args.board) - openocd_program(args.board, args.hexfile) + firmware_deploy(args.board, args.hexfile) def parser_device_erase(args): device_erase(args.board, args.q) From 6d7931153027b2029a97498ccd332c00f65ca692 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Tue, 16 Jan 2024 09:50:51 +0100 Subject: [PATCH 9/9] tools/psoc6/mpy-psoc6.py: Minor fix. Signed-off-by: enriquezgarc --- tools/psoc6/mpy-psoc6.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/psoc6/mpy-psoc6.py b/tools/psoc6/mpy-psoc6.py index 02697cba64762..1e20a36a65c75 100644 --- a/tools/psoc6/mpy-psoc6.py +++ b/tools/psoc6/mpy-psoc6.py @@ -16,15 +16,15 @@ def colour_str_success(msg): def colour_str_error(msg): - green_str_start = "\x1b[1;31;40m" + red_str_start = "\x1b[1;31;40m" str_color_end = "\x1b[0m" - return green_str_start + msg + str_color_end + return red_str_start + msg + str_color_end def colour_str_highlight(msg): - green_str_start = "\x1b[1;35;40m" + purple_str_start = "\x1b[1;35;40m" str_color_end = "\x1b[0m" - return green_str_start + msg + str_color_end + return purple_str_start + msg + str_color_end def set_environment():