retry test up to 2 times, somehow open serial failed randomly with rp2040
This commit is contained in:
@@ -201,13 +201,15 @@ def reset_stflash(board):
|
|||||||
|
|
||||||
def flash_openocd(board, firmware):
|
def flash_openocd(board, firmware):
|
||||||
flasher = board['flasher']
|
flasher = board['flasher']
|
||||||
ret = run_cmd(f'openocd -c "adapter serial {flasher["uid"]}" {flasher["args"]} -c "program {firmware}.elf reset exit"')
|
ret = run_cmd(f'openocd -c "tcl_port disabled" -c "gdb_port disabled" -c "adapter serial {flasher["uid"]}" '
|
||||||
|
f'{flasher["args"]} -c init -c halt -c "program {firmware}.elf verify" -c reset -c exit')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def reset_openocd(board):
|
def reset_openocd(board):
|
||||||
flasher = board['flasher']
|
flasher = board['flasher']
|
||||||
ret = run_cmd(f'openocd -c "adapter serial {flasher["uid"]}" {flasher["args"]} -c "reset exit"')
|
ret = run_cmd(f'openocd -c "tcl_port disabled" -c "gdb_port disabled" -c "adapter serial {flasher["uid"]}" '
|
||||||
|
f'{flasher["args"]} -c "reset exit"')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@@ -560,25 +562,31 @@ def test_board(board):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# flash firmware. It may fail randomly, retry a few times
|
# flash firmware. It may fail randomly, retry a few times
|
||||||
for i in range(3):
|
max_rety = 2
|
||||||
|
for i in range(max_rety):
|
||||||
ret = globals()[f'flash_{flasher["name"].lower()}'](board, fw_name)
|
ret = globals()[f'flash_{flasher["name"].lower()}'](board, fw_name)
|
||||||
if ret.returncode == 0:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
print(f'Flashing failed, retry {i+1}')
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
if ret.returncode == 0:
|
if ret.returncode == 0:
|
||||||
try:
|
try:
|
||||||
ret = globals()[f'test_{test.replace("/", "_")}'](board)
|
globals()[f'test_{test.replace("/", "_")}'](board)
|
||||||
print('OK')
|
print('OK')
|
||||||
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if i == max_rety - 1:
|
||||||
err_count += 1
|
err_count += 1
|
||||||
print(STATUS_FAILED)
|
print(STATUS_FAILED)
|
||||||
print(f' {e}')
|
print(f' {e}')
|
||||||
else:
|
else:
|
||||||
|
print()
|
||||||
|
print(f' Test failed: {e}, retry {i+1}')
|
||||||
|
time.sleep(1)
|
||||||
|
else:
|
||||||
|
print(f'Flashing failed, retry {i+1}')
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
if ret.returncode != 0:
|
||||||
err_count += 1
|
err_count += 1
|
||||||
print(f'Flash {STATUS_FAILED}')
|
print(f'Flash {STATUS_FAILED}')
|
||||||
|
|
||||||
return err_count
|
return err_count
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user