update hil test and json (remove troublesome lpc54608), run hil test on ci with IAR build

This commit is contained in:
hathach
2023-08-09 18:46:23 +07:00
parent 1abfa9ac75
commit 1268d1a093
6 changed files with 146 additions and 175 deletions

View File

@@ -1,92 +1,18 @@
{
"devices": [
"boards": [
{
"name": "stm32l412nucleo",
"uid": "41003B000E504E5457323020",
"debugger": "jlink",
"debugger_sn": "774470029",
"device": "STM32L412KB",
"tests": [
{
"name": "cdc_dual_ports",
"firmware": "examples/device/cdc_dual_ports/_build/stm32l412nucleo/cdc_dual_ports.elf"
},
{
"name": "cdc_msc",
"firmware": "examples/device/cdc_msc/_build/stm32l412nucleo/cdc_msc.elf"
},
{
"name": "dfu",
"firmware": "examples/device/dfu/_build/stm32l412nucleo/dfu.elf"
},
{
"name": "dfu_runtime",
"firmware": "examples/device/dfu_runtime/_build/stm32l412nucleo/dfu_runtime.elf"
},
{
"name": "hid_boot_interface",
"firmware": "examples/device/hid_boot_interface/_build/stm32l412nucleo/hid_boot_interface.elf"
},
{
"name": "board_test",
"firmware": "examples/device/board_test/_build/stm32l412nucleo/board_test.elf"
}
]
"cpu": "STM32L412KB"
},
{
"name": "stm32f746disco",
"uid": "210041000C51343237303334",
"debugger": "jlink",
"debugger_sn": "770935966",
"device": "STM32F746NG",
"tests": [
{
"name": "cdc_dual_ports",
"firmware": "examples/device/cdc_dual_ports/_build/stm32f746disco/cdc_dual_ports.elf"
},
{
"name": "cdc_msc",
"firmware": "examples/device/cdc_msc/_build/stm32f746disco/cdc_msc.elf"
},
{
"name": "dfu",
"firmware": "examples/device/dfu/_build/stm32f746disco/dfu.elf"
},
{
"name": "dfu_runtime",
"firmware": "examples/device/dfu_runtime/_build/stm32f746disco/dfu_runtime.elf"
},
{
"name": "hid_boot_interface",
"firmware": "examples/device/hid_boot_interface/_build/stm32f746disco/hid_boot_interface.elf"
},
{
"name": "board_test",
"firmware": "examples/device/board_test/_build/stm32f746disco/board_test.elf"
}
]
},
{
"uid": "0123456789ABCDEF",
"debugger": "jlink",
"debugger_sn": "727600775",
"device": "LPC54608J512",
"tests": [
{
"name": "cdc_dual_ports",
"firmware": "examples/device/cdc_dual_ports/_build/lpcxpresso54628/cdc_dual_ports.elf"
},
{
"name": "dfu",
"firmware": "examples/device/dfu/_build/lpcxpresso54628/dfu.elf"
},
{
"name": "dfu_runtime",
"firmware": "examples/device/dfu_runtime/_build/lpcxpresso54628/dfu_runtime.elf"
},
{
"name": "board_test",
"firmware": "examples/device/board_test/_build/lpcxpresso54628/board_test.elf"
}
]
"cpu": "STM32F746NG"
}
]
}

View File

@@ -32,6 +32,21 @@ import serial
import subprocess
import json
def get_serial_dev(id, product, ifnum):
# get usb serial by id
return f'/dev/serial/by-id/usb-TinyUSB_{product}_{id}-if{ifnum:02d}'
def get_disk_dev(id, lun):
# get usb disk by id
return f'/dev/disk/by-id/usb-TinyUSB_Mass_Storage_{id}-0:{lun}'
def get_hid_dev(id, product, event):
return f'/dev/input/by-id/usb-TinyUSB_{product}_{id}-{event}'
def flash_jlink(sn, dev, firmware):
script = ['halt', 'r', f'loadfile {firmware}', 'r', 'go', 'exit']
f = open('flash.jlink', 'w')
@@ -43,9 +58,15 @@ def flash_jlink(sn, dev, firmware):
os.remove('flash.jlink')
assert ret.returncode == 0, 'Flash failed\n' + stdout
def test_board_test(id):
# Dummy test
pass
def test_cdc_dual_ports(id):
port1 = f'/dev/ttyUSB_{id[-8:]}.00'
port2 = f'/dev/ttyUSB_{id[-8:]}.02'
port1 = get_serial_dev(id, "TinyUSB_Device", 0)
port2 = get_serial_dev(id, "TinyUSB_Device", 2)
# Wait device enum
timeout = 10
while timeout:
@@ -75,10 +96,9 @@ def test_cdc_dual_ports(id):
assert ser1.read(100) == str2.lower(), 'Port1 wrong data'
assert ser2.read(100) == str2.upper(), 'Port2 wrong data'
print('cdc_dual_ports test done')
def test_cdc_msc(id):
port = f'/dev/ttyUSB_{id[-8:]}.00'
port = get_serial_dev(id, "TinyUSB_Device", 0)
file = f'/media/blkUSB_{id[-8:]}.02/README.TXT'
# Wait device enum
timeout = 10
@@ -110,7 +130,6 @@ If you find any bugs or get any questions, feel free to file an\r\n\
issue at github.com/hathach/tinyusb"
assert data == readme, 'MSC wrong data'
print('cdc_msc test done')
def test_dfu(id):
# Wait device enum
@@ -150,7 +169,6 @@ def test_dfu(id):
os.remove('dfu0')
os.remove('dfu1')
print('dfu test done')
def test_dfu_runtime(id):
# Wait device enum
@@ -166,12 +184,11 @@ def test_dfu_runtime(id):
assert timeout, 'Device not available'
print('dfu_runtime test done')
def test_hid_boot_interface(id):
kbd = f'/dev/input/by-id/usb-TinyUSB_TinyUSB_Device_{id}-event-kbd'
mouse1 = f'/dev/input/by-id/usb-TinyUSB_TinyUSB_Device_{id}-if01-event-mouse'
mouse2 = f'/dev/input/by-id/usb-TinyUSB_TinyUSB_Device_{id}-if01-mouse'
kbd = get_hid_dev(id, 'TinyUSB_Device', 'event-kbd')
mouse1 = get_hid_dev(id, 'TinyUSB_Device', 'if01-event-mouse')
mouse2 = get_hid_dev(id, 'TinyUSB_Device', 'if01-mouse')
# Wait device enum
timeout = 10
while timeout:
@@ -182,11 +199,6 @@ def test_hid_boot_interface(id):
assert timeout, 'Device not available'
print('hid_boot_interface test done')
def test_board_test(id):
# Dummy test
pass
if __name__ == '__main__':
if len(sys.argv) != 2:
@@ -197,12 +209,42 @@ if __name__ == '__main__':
with open(f'{os.path.dirname(__file__)}/{sys.argv[1]}') as f:
config = json.load(f)
for device in config['devices']:
print(f"Testing device:{device['device']}")
for test in device['tests']:
if device['debugger'].lower() == 'jlink':
flash_jlink(device['debugger_sn'], device['device'], test['firmware'])
# all possible tests, board_test is last to disable board's usb
all_tests = [
'cdc_dual_ports', 'cdc_msc', 'dfu', 'dfu_runtime', 'hid_boot_interface', 'board_test'
]
for board in config['boards']:
print(f'Testing board:{board["name"]}')
# default to all tests
if 'tests' in board:
test_list = board['tests']
else:
test_list = all_tests
# remove skip_tests
if 'tests_skip' in board:
for skip in board['tests_skip']:
if skip in test_list:
test_list.remove(skip)
for test in test_list:
mk_elf = f'examples/device/{test}/_build/{board["name"]}/{test}.elf'
cmake_elf = f'cmake-build/cmake-build-{board["name"]}/device/{test}/{test}.elf'
if os.path.isfile(cmake_elf):
elf = cmake_elf
elif os.path.isfile(mk_elf):
elf = mk_elf
else:
print(f'Cannot find firmware file for {test}')
sys.exit(-1)
if board['debugger'].lower() == 'jlink':
flash_jlink(board['debugger_sn'], board['cpu'], elf)
else:
# ToDo
pass
locals()[f'test_{test["name"]}'](device['uid'])
print(f' {test} ...', end='')
locals()[f'test_{test}'](board['uid'])
print('OK')