summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-11-13 13:37:29 +0700
committerhathach <[email protected]>2024-11-13 13:37:29 +0700
commit42ead3a8e06bc48d6ddbdcbd0f8e018a00e7de32 (patch)
tree8e05b42e03b0a7f9bca89108afd4b7f8afc45ece
parentaeae2966a2afa669068e54eef7c4dd2dceffaa0d (diff)
hil cleanup flahser
-rw-r--r--.idea/cmake.xml13
-rw-r--r--test/hil/hfp.json33
-rwxr-xr-xtest/hil/hil_test.py59
-rw-r--r--test/hil/tinyusb.json136
4 files changed, 158 insertions, 83 deletions
diff --git a/.idea/cmake.xml b/.idea/cmake.xml
index 625bfa916..1210c49e7 100644
--- a/.idea/cmake.xml
+++ b/.idea/cmake.xml
@@ -54,7 +54,14 @@
</envs>
</ADDITIONAL_GENERATION_ENVIRONMENT>
</configuration>
- <configuration PROFILE_NAME="espressif_p4_function_ev" ENABLED="false" TOOLCHAIN_NAME="ESP-IDF" GENERATION_OPTIONS="-DBOARD=espressif_p4_function_ev">
+ <configuration PROFILE_NAME="espressif_p4_function_ev" ENABLED="false" TOOLCHAIN_NAME="ESP-IDF" GENERATION_OPTIONS="-DBOARD=espressif_p4_function_ev -DLOG=1">
+ <ADDITIONAL_GENERATION_ENVIRONMENT>
+ <envs>
+ <env name="ESPBAUD" value="1500000" />
+ </envs>
+ </ADDITIONAL_GENERATION_ENVIRONMENT>
+ </configuration>
+ <configuration PROFILE_NAME="espressif_p4_function_ev-CFG_TUD_DWC2_DMA" ENABLED="false" GENERATION_DIR="cmake-build-espressif_p4_function_ev-CFG_TUD_DWC2_DMA" TOOLCHAIN_NAME="ESP-IDF" GENERATION_OPTIONS="-DBOARD=espressif_p4_function_ev -DLOG=1 -DCFLAGS_CLI=&quot;-DCFG_TUD_DWC2_DMA=1&quot;">
<ADDITIONAL_GENERATION_ENVIRONMENT>
<envs>
<env name="ESPBAUD" value="1500000" />
@@ -92,9 +99,9 @@
<configuration PROFILE_NAME="stm32f303disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f303disco -DLOG=0 -DLOGGER=RTT" />
<configuration PROFILE_NAME="stm32f411disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f411disco -DLOG=1 -DLOGGER=RTT" />
<configuration PROFILE_NAME="stm32f412disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f412disco -DLOG=1 -DLOGGER=RTT" />
- <configuration PROFILE_NAME="stm32f723disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f723disco -DLOG=1 -DLOGGER=RTT" />
+ <configuration PROFILE_NAME="stm32f723disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f723disco -DLOG=0" />
<configuration PROFILE_NAME="stm32f723disco-CFG_TUD_DWC2_DMA" ENABLED="false" GENERATION_DIR="cmake-build-stm32f723disco-CFG_TUD_DWC2_DMA" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f723disco -DLOG=1 -DLOGGER=RTT -DCFLAGS_CLI=&quot;-DCFG_TUD_DWC2_DMA=1&quot;" />
- <configuration PROFILE_NAME="stm32f723disco_host1" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f723disco -DLOG=1 -DRHPORT_HOST=1" />
+ <configuration PROFILE_NAME="stm32f723disco_device1" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f723disco -DLOG=0 -DRHPORT_DEVICE=1" />
<configuration PROFILE_NAME="stm32f769disco" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32f769disco -DLOG=1 -DLOGGER=RTT" />
<configuration PROFILE_NAME="stm32g0b1nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32g0b1nucleo" />
<configuration PROFILE_NAME="stm32g474nucleo" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=stm32g474nucleo" />
diff --git a/test/hil/hfp.json b/test/hil/hfp.json
index e79a3cfc9..8ba7a8f44 100644
--- a/test/hil/hfp.json
+++ b/test/hil/hfp.json
@@ -3,23 +3,38 @@
{
"name": "stm32l412nucleo",
"uid": "41003B000E504E5457323020",
- "flasher": "jlink",
- "flasher_sn": "774470029",
- "flasher_args": "-device STM32L412KB"
+ "tests": {
+ "device": true, "host": false, "dual": false
+ },
+ "flasher": {
+ "name": "jlink",
+ "uid": "774470029",
+ "args": "-device STM32L412KB"
+ }
},
{
"name": "stm32f746disco",
"uid": "210041000C51343237303334",
- "flasher": "jlink",
- "flasher_sn": "770935966",
- "flasher_args": "-device STM32F746NG"
+ "tests": {
+ "device": true, "host": false, "dual": false
+ },
+ "flasher": {
+ "name": "jlink",
+ "uid": "770935966",
+ "args": "-device STM32F746NG"
+ }
},
{
"name": "lpcxpresso43s67",
"uid": "08F000044528BAAA8D858F58C50700F5",
- "flasher": "jlink",
- "flasher_sn": "728973776",
- "flasher_args": "-device LPC43S67_M4"
+ "tests": {
+ "device": true, "host": false, "dual": false
+ },
+ "flasher": {
+ "name": "jlink",
+ "uid": "728973776",
+ "args": "-device LPC43S67_M4"
+ }
}
]
}
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py
index b395c28a4..e7f1953b1 100755
--- a/test/hil/hil_test.py
+++ b/test/hil/hil_test.py
@@ -158,119 +158,137 @@ def run_cmd(cmd, cwd=None):
def flash_jlink(board, firmware):
+ flasher = board['flasher']
script = ['halt', 'r', f'loadfile {firmware}.elf', 'r', 'go', 'exit']
f_jlink = f'{board["name"]}_{os.path.basename(firmware)}.jlink'
with open(f_jlink, 'w') as f:
f.writelines(f'{s}\n' for s in script)
- ret = run_cmd(f'JLinkExe -USB {board["flasher_sn"]} {board["flasher_args"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile {f_jlink}')
+ ret = run_cmd(f'JLinkExe -USB {flasher["uid"]} {flasher["args"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile {f_jlink}')
os.remove(f_jlink)
return ret
def reset_jlink(board):
+ flasher = board['flasher']
script = ['halt', 'r', 'go', 'exit']
f_jlink = f'{board["name"]}_reset.jlink'
if not os.path.exists(f_jlink):
with open(f_jlink, 'w') as f:
f.writelines(f'{s}\n' for s in script)
- ret = run_cmd(f'JLinkExe -USB {board["flasher_sn"]} {board["flasher_args"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile {f_jlink}')
+ ret = run_cmd(f'JLinkExe -USB {flasher["uid"]} {flasher["args"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile {f_jlink}')
return ret
def flash_stlink(board, firmware):
- return run_cmd(f'STM32_Programmer_CLI --connect port=swd sn={board["flasher_sn"]} --write {firmware}.elf --go')
+ flasher = board['flasher']
+ return run_cmd(f'STM32_Programmer_CLI --connect port=swd sn={flasher["uid"]} --write {firmware}.elf --go')
def reset_stlink(board):
- return run_cmd(f'STM32_Programmer_CLI --connect port=swd sn={board["flasher_sn"]} --rst --go')
+ flasher = board['flasher']
+ return run_cmd(f'STM32_Programmer_CLI --connect port=swd sn={flasher["uid"]} --rst --go')
def flash_stflash(board, firmware):
- ret = run_cmd(f'st-flash --serial {board["flasher_sn"]} write {firmware}.bin 0x8000000')
+ flasher = board['flasher']
+ ret = run_cmd(f'st-flash --serial {flasher["uid"]} write {firmware}.bin 0x8000000')
return ret
def reset_stflash(board):
+ flasher = board['flasher']
return subprocess.CompletedProcess(args=['dummy'], returncode=0)
def flash_openocd(board, firmware):
- ret = run_cmd(f'openocd -c "adapter serial {board["flasher_sn"]}" {board["flasher_args"]} -c "program {firmware}.elf reset exit"')
+ flasher = board['flasher']
+ ret = run_cmd(f'openocd -c "adapter serial {flasher["uid"]}" {flasher["args"]} -c "program {firmware}.elf reset exit"')
return ret
def reset_openocd(board):
- ret = run_cmd(f'openocd -c "adapter serial {board["flasher_sn"]}" {board["flasher_args"]} -c "reset exit"')
+ flasher = board['flasher']
+ ret = run_cmd(f'openocd -c "adapter serial {flasher["uid"]}" {flasher["args"]} -c "reset exit"')
return ret
def flash_openocd_wch(board, firmware):
+ flasher = board['flasher']
f_wch = f"wch-riscv_{board['uid']}.cfg"
if not os.path.exists(f_wch):
with open(f_wch, 'w') as file:
file.write(WCH_RISCV_CONTENT)
- ret = run_cmd(f'openocd_wch -c "adapter serial {board["flasher_sn"]}" -f {f_wch} '
+ ret = run_cmd(f'openocd_wch -c "adapter serial {flasher["uid"]}" -f {f_wch} '
f'-c "program {firmware}.elf reset exit"')
return ret
def reset_openocd_wch(board):
+ flasher = board['flasher']
f_wch = f"wch-riscv_{board['uid']}.cfg"
if not os.path.exists(f_wch):
with open(f_wch, 'w') as file:
file.write(WCH_RISCV_CONTENT)
- ret = run_cmd(f'openocd_wch -c "adapter serial {board["flasher_sn"]}" -f {f_wch} -c "program reset exit"')
+ ret = run_cmd(f'openocd_wch -c "adapter serial {flasher["uid"]}" -f {f_wch} -c "program reset exit"')
return ret
def flash_openocd_adi(board, firmware):
- ret = run_cmd(f'{OPENCOD_ADI_PATH}/src/openocd -c "adapter serial {board["flasher_sn"]}" -s {OPENCOD_ADI_PATH}/tcl '
- f'{board["flasher_args"]} -c "program {firmware}.elf reset exit"')
+ flasher = board['flasher']
+ ret = run_cmd(f'{OPENCOD_ADI_PATH}/src/openocd -c "adapter serial {flasher["uid"]}" -s {OPENCOD_ADI_PATH}/tcl '
+ f'{flasher["args"]} -c "program {firmware}.elf reset exit"')
return ret
def reset_openocd_adi(board):
- ret = run_cmd(f'{OPENCOD_ADI_PATH}/src/openocd -c "adapter serial {board["flasher_sn"]}" -s {OPENCOD_ADI_PATH}/tcl '
- f'{board["flasher_args"]} -c "program reset exit"')
+ flasher = board['flasher']
+ ret = run_cmd(f'{OPENCOD_ADI_PATH}/src/openocd -c "adapter serial {flasher["uid"]}" -s {OPENCOD_ADI_PATH}/tcl '
+ f'{flasher["args"]} -c "program reset exit"')
return ret
def flash_wlink_rs(board, firmware):
+ flasher = board['flasher']
# wlink use index for probe selection and lacking usb serial support
ret = run_cmd(f'wlink flash {firmware}.elf')
return ret
def reset_wlink_rs(board):
+ flasher = board['flasher']
# wlink use index for probe selection and lacking usb serial support
ret = run_cmd(f'wlink reset')
return ret
def flash_esptool(board, firmware):
- port = get_serial_dev(board["flasher_sn"], None, None, 0)
+ flasher = board['flasher']
+ port = get_serial_dev(flasher["uid"], None, None, 0)
fw_dir = os.path.dirname(f'{firmware}.bin')
with open(f'{fw_dir}/config.env') as f:
idf_target = json.load(f)['IDF_TARGET']
with open(f'{fw_dir}/flash_args') as f:
flash_args = f.read().strip().replace('\n', ' ')
- command = (f'esptool.py --chip {idf_target} -p {port} {board["flasher_args"]} '
+ command = (f'esptool.py --chip {idf_target} -p {port} {flasher["args"]} '
f'--before=default_reset --after=hard_reset write_flash {flash_args}')
ret = run_cmd(command, cwd=fw_dir)
return ret
def reset_esptool(board):
+ flasher = board['flasher']
return subprocess.CompletedProcess(args=['dummy'], returncode=0)
def flash_uniflash(board, firmware):
- ret = run_cmd(f'dslite.sh {board["flasher_args"]} -f {firmware}.hex')
+ flasher = board['flasher']
+ ret = run_cmd(f'dslite.sh {flasher["args"]} -f {firmware}.hex')
return ret
def reset_uniflash(board):
+ flasher = board['flasher']
return subprocess.CompletedProcess(args=['dummy'], returncode=0)
@@ -307,13 +325,14 @@ def test_dual_host_info_to_device_cdc(board):
# Tests: host
# -------------------------------------------------------------
def test_host_device_info(board):
+ flasher = board['flasher']
declared_devs = [f'{d["vid_pid"]}_{d["serial"]}' for d in board['tests']['dev_attached']]
- port = get_serial_dev(board["flasher_sn"], None, None, 0)
+ port = get_serial_dev(flasher["uid"], None, None, 0)
ser = open_serial_dev(port)
# reset device since we can miss the first line
- ret = globals()[f'reset_{board["flasher"].lower()}'](board)
+ ret = globals()[f'reset_{flasher["name"].lower()}'](board)
assert ret.returncode == 0, 'Failed to reset device'
data = ser.read(1000)
@@ -494,7 +513,7 @@ host_test = [
def test_board(board):
name = board['name']
- flasher = board['flasher'].lower()
+ flasher = board['flasher']
# default to all tests
test_list = list(device_tests)
@@ -540,7 +559,7 @@ def test_board(board):
# flash firmware. It may fail randomly, retry a few times
for i in range(3):
- ret = globals()[f'flash_{flasher}'](board, fw_name)
+ ret = globals()[f'flash_{flasher["name"].lower()}'](board, fw_name)
if ret.returncode == 0:
break
else:
diff --git a/test/hil/tinyusb.json b/test/hil/tinyusb.json
index f3ef9dcf7..4d450cc5a 100644
--- a/test/hil/tinyusb.json
+++ b/test/hil/tinyusb.json
@@ -7,9 +7,11 @@
"only": ["device/cdc_msc_freertos", "device/hid_composite_freertos", "host/device_info"],
"dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002427"}]
},
- "flasher": "esptool",
- "flasher_sn": "4ea4f48f6bc3ee11bbb9d00f9e1b1c54",
- "flasher_args": "-b 1500000"
+ "flasher": {
+ "name": "esptool",
+ "uid": "4ea4f48f6bc3ee11bbb9d00f9e1b1c54",
+ "args": "-b 1500000"
+ }
},
{
"name": "espressif_s3_devkitm",
@@ -20,9 +22,11 @@
"tests": {
"only": ["device/cdc_msc_freertos", "device/hid_composite_freertos"]
},
- "flasher": "esptool",
- "flasher_sn": "3ea619acd1cdeb11a0a0b806e93fd3f1",
- "flasher_args": "-b 1500000"
+ "flasher": {
+ "name": "esptool",
+ "uid": "3ea619acd1cdeb11a0a0b806e93fd3f1",
+ "args": "-b 1500000"
+ }
},
{
"name": "feather_nrf52840_express",
@@ -30,9 +34,11 @@
"tests": {
"device": true, "host": false, "dual": false
},
- "flasher": "jlink",
- "flasher_sn": "000682804350",
- "flasher_args": "-device nrf52840_xxaa"
+ "flasher": {
+ "name": "jlink",
+ "uid": "000682804350",
+ "args": "-device nrf52840_xxaa"
+ }
},
{
"name": "max32666fthr",
@@ -40,9 +46,11 @@
"tests": {
"device": true, "host": false, "dual": false
},
- "flasher": "openocd_adi",
- "flasher_sn": "E6614C311B597D32",
- "flasher_args": "-f interface/cmsis-dap.cfg -f target/max32665.cfg"
+ "flasher": {
+ "name": "openocd_adi",
+ "uid": "E6614C311B597D32",
+ "args": "-f interface/cmsis-dap.cfg -f target/max32665.cfg"
+ }
},
{
"name": "metro_m4_express",
@@ -51,9 +59,11 @@
"device": true, "host": false, "dual": true,
"dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002130"}]
},
- "flasher": "jlink",
- "flasher_sn": "123456",
- "flasher_args": "-device ATSAMD51J19"
+ "flasher": {
+ "name": "jlink",
+ "uid": "123456",
+ "args": "-device ATSAMD51J19"
+ }
},
{
"name": "lpcxpresso11u37",
@@ -61,9 +71,11 @@
"tests": {
"device": true, "host": false, "dual": false
},
- "flasher": "jlink",
- "flasher_sn": "000724441579",
- "flasher_args": "-device LPC11U37/401"
+ "flasher": {
+ "name": "jlink",
+ "uid": "000724441579",
+ "args": "-device LPC11U37/401"
+ }
},
{
"name": "ra4m1_ek",
@@ -73,9 +85,11 @@
"skip": ["device/cdc_msc", "device/cdc_msc_freertos"]
},
"comment": "MSC is slow to enumerated #2602",
- "flasher": "jlink",
- "flasher_sn": "000831174392",
- "flasher_args": "-device R7FA4M1AB"
+ "flasher": {
+ "name": "jlink",
+ "uid": "000831174392",
+ "args": "-device R7FA4M1AB"
+ }
},
{
"name": "raspberry_pi_pico",
@@ -84,9 +98,11 @@
"device": true, "host": false, "dual": false,
"dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002470"}]
},
- "flasher": "openocd",
- "flasher_sn": "E6614103E72C1D2F",
- "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\""
+ "flasher": {
+ "name": "openocd",
+ "uid": "E6614103E72C1D2F",
+ "args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\""
+ }
},
{
"name": "raspberry_pi_pico2",
@@ -95,16 +111,20 @@
"device": true, "host": false, "dual": false,
"dev_attached": [{"vid_pid": "1a86_55d4", "serial": "533D004242"}]
},
- "flasher": "openocd",
- "flasher_sn": "E6633861A3978538",
- "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2350.cfg -c \"adapter speed 5000\""
+ "flasher": {
+ "name": "openocd",
+ "uid": "E6633861A3978538",
+ "args": "-f interface/cmsis-dap.cfg -f target/rp2350.cfg -c \"adapter speed 5000\""
+ }
},
{
"name": "stm32f072disco",
"uid": "3A001A001357364230353532",
- "flasher": "jlink",
- "flasher_sn": "779541626",
- "flasher_args": "-device stm32f072rb"
+ "name": "jlink",
+ "flasher": {
+ "uid": "779541626",
+ "args": "-device stm32f072rb"
+ }
},
{
"name": "stm32f723disco",
@@ -116,9 +136,11 @@
"device": true, "host": true, "dual": false,
"dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2003414"}]
},
- "flasher": "jlink",
- "flasher_sn": "000776606156",
- "flasher_args": "-device stm32f723ie"
+ "flasher": {
+ "name": "jlink",
+ "uid": "000776606156",
+ "args": "-device stm32f723ie"
+ }
},
{
"name": "stm32h743nucleo",
@@ -129,9 +151,11 @@
"tests": {
"device": true, "host": false, "dual": false
},
- "flasher": "stlink",
- "flasher_sn": "004C00343137510F39383538",
- "flasher_args": ""
+ "flasher": {
+ "name": "stlink",
+ "uid": "004C00343137510F39383538",
+ "args": ""
+ }
},
{
"name": "stm32g0b1nucleo",
@@ -139,9 +163,11 @@
"tests": {
"device": true, "host": false, "dual": false
},
- "flasher": "openocd",
- "flasher_sn": "066FFF495087534867063844",
- "flasher_args": "-f interface/stlink.cfg -f target/stm32g0x.cfg"
+ "flasher": {
+ "name": "openocd",
+ "uid": "066FFF495087534867063844",
+ "args": "-f interface/stlink.cfg -f target/stm32g0x.cfg"
+ }
}
],
"boards-skip": [
@@ -154,9 +180,11 @@
"tests": {
"device": true, "host": false, "dual": false
},
- "flasher": "jlink",
- "flasher_sn": "000778170924",
- "flasher_args": "-device stm32f769ni"
+ "flasher": {
+ "name": "jlink",
+ "uid": "000778170924",
+ "args": "-device stm32f769ni"
+ }
},
{
"name": "mimxrt1015_evk",
@@ -164,9 +192,11 @@
"tests": {
"device": true, "host": false, "dual": false
},
- "flasher": "jlink",
- "flasher_sn": "000726284213",
- "flasher_args": "-device MIMXRT1015DAF5A"
+ "flasher": {
+ "name": "jlink",
+ "uid": "000726284213",
+ "args": "-device MIMXRT1015DAF5A"
+ }
},
{
"name": "nanoch32v203",
@@ -174,9 +204,11 @@
"tests": {
"device": true, "host": false, "dual": false
},
- "flasher": "openocd_wch",
- "flasher_sn": "EBCA8F0670AF",
- "flasher_args": ""
+ "flasher": {
+ "name": "openocd_wch",
+ "uid": "EBCA8F0670AF",
+ "args": ""
+ }
},
{
"name": "stm32f407disco",
@@ -184,9 +216,11 @@
"tests": {
"device": true, "host": false, "dual": false
},
- "flasher": "jlink",
- "flasher_sn": "000773661813",
- "flasher_args": "-device stm32f407vg"
+ "flasher": {
+ "name": "jlink",
+ "uid": "000773661813",
+ "args": "-device stm32f407vg"
+ }
}
]
}