From aa21d50196442e40aa009e61a72d5c4c435551e0 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 11 Dec 2023 15:23:09 +0700 Subject: [PATCH] rename hil json debugger to flasher, replace jlink cpu with flasher_args --- test/hil/hil_hfp.json | 18 +++++++++--------- test/hil/hil_pi4.json | 12 ++++++------ test/hil/hil_test.py | 16 ++++++++-------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/hil/hil_hfp.json b/test/hil/hil_hfp.json index 58f550901..e79a3cfc9 100644 --- a/test/hil/hil_hfp.json +++ b/test/hil/hil_hfp.json @@ -3,23 +3,23 @@ { "name": "stm32l412nucleo", "uid": "41003B000E504E5457323020", - "debugger": "jlink", - "debugger_sn": "774470029", - "cpu": "STM32L412KB" + "flasher": "jlink", + "flasher_sn": "774470029", + "flasher_args": "-device STM32L412KB" }, { "name": "stm32f746disco", "uid": "210041000C51343237303334", - "debugger": "jlink", - "debugger_sn": "770935966", - "cpu": "STM32F746NG" + "flasher": "jlink", + "flasher_sn": "770935966", + "flasher_args": "-device STM32F746NG" }, { "name": "lpcxpresso43s67", "uid": "08F000044528BAAA8D858F58C50700F5", - "debugger": "jlink", - "debugger_sn": "728973776", - "cpu": "LPC43S67_M4" + "flasher": "jlink", + "flasher_sn": "728973776", + "flasher_args": "-device LPC43S67_M4" } ] } diff --git a/test/hil/hil_pi4.json b/test/hil/hil_pi4.json index 6ebb6c8f0..e9a6721ea 100644 --- a/test/hil/hil_pi4.json +++ b/test/hil/hil_pi4.json @@ -3,9 +3,9 @@ { "name": "raspberry_pi_pico", "uid": "E6614C311B764A37", - "debugger": "openocd", - "debugger_sn": "E6614103E72C1D2F", - "debugger_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\"" + "flasher": "openocd", + "flasher_sn": "E6614103E72C1D2F", + "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\"" }, { "name": "espressif_s3_devkitc", @@ -13,9 +13,9 @@ "tests": [ "cdc_msc_freertos", "hid_composite_freertos" ], - "debugger": "esptool", - "debugger_sn": "461cb8d7decdeb119be9b506e93fd3f1", - "debugger_args": "-b 1500000" + "flasher": "esptool", + "flasher_sn": "461cb8d7decdeb119be9b506e93fd3f1", + "flasher_args": "-b 1500000" } ] } diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py index fe31a54e8..9cb009264 100644 --- a/test/hil/hil_test.py +++ b/test/hil/hil_test.py @@ -43,7 +43,7 @@ def get_serial_dev(id, vendor_str, product_str, ifnum): # known vendor and product return f'/dev/serial/by-id/usb-{vendor_str}_{product_str}_{id}-if{ifnum:02d}' else: - # just use id: mostly for cp210x/ftdi debugger + # just use id: mostly for cp210x/ftdi flasher pattern = f'/dev/serial/by-id/usb-*_{id}-if{ifnum:02d}*' port_list = glob.glob(pattern) return port_list[0] @@ -100,14 +100,14 @@ def read_disk_file(id, fname): # ------------------------------------------------------------- -# Flash with debugger +# Flashing firmware # ------------------------------------------------------------- def flash_jlink(board, firmware): script = ['halt', 'r', f'loadfile {firmware}', 'r', 'go', 'exit'] with open('flash.jlink', 'w') as f: f.writelines(f'{s}\n' for s in script) ret = subprocess.run( - f'JLinkExe -USB {board["debugger_sn"]} -device {board["cpu"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink', + f'JLinkExe -USB {board["flasher_sn"]} {board["flasher_args"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) os.remove('flash.jlink') return ret @@ -115,19 +115,19 @@ def flash_jlink(board, firmware): def flash_openocd(board, firmware): ret = subprocess.run( - f'openocd -c "adapter serial {board["debugger_sn"]}" {board["debugger_args"]} -c "program {firmware} reset exit"', + f'openocd -c "adapter serial {board["flasher_sn"]}" {board["flasher_args"]} -c "program {firmware} reset exit"', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) return ret def flash_esptool(board, firmware): - port = get_serial_dev(board["debugger_sn"], None, None, 0) + port = get_serial_dev(board["flasher_sn"], None, None, 0) dir = os.path.dirname(firmware) with open(f'{dir}/config.env') as f: IDF_TARGET = json.load(f)['IDF_TARGET'] with open(f'{dir}/flash_args') as f: flash_args = f.read().strip().replace('\n', ' ') - command = (f'esptool.py --chip {IDF_TARGET} -p {port} {board["debugger_args"]} ' + command = (f'esptool.py --chip {IDF_TARGET} -p {port} {board["flasher_args"]} ' f'--before=default_reset --after=hard_reset write_flash {flash_args}') ret = subprocess.run(command, shell=True, cwd=dir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) return ret @@ -286,7 +286,7 @@ def main(config_file, board): for item in config_boards: print(f'Testing board:{item["name"]}') - debugger = item['debugger'].lower() + flasher = item['flasher'].lower() # default to all tests if 'tests' in item: @@ -325,7 +325,7 @@ def main(config_file, board): print(f' {test} ...', end='') # flash firmware - ret = globals()[f'flash_{debugger}'](item, fw) + ret = globals()[f'flash_{flasher}'](item, fw) assert ret.returncode == 0, 'Flash failed\n' + ret.stdout.decode() # run test