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
No known key found for this signature in database
GPG Key ID: F5D50C6D51D17CBA
6 changed files with 146 additions and 175 deletions

View File

@ -32,7 +32,7 @@ jobs:
# Alphabetical order
# Note: bundle multiple families into a matrix since there is only one self-hosted instance can
# run IAR build. Too many matrix can hurt due to setup/teardown overhead.
- 'stm32f0 stm32f1 stm32f7 stm32g0 stm32g4 stm32h7 stm32l4'
- 'stm32f0 stm32f1 stm32f4 stm32f7 stm32g0 stm32g4 stm32h7 stm32l4'
steps:
- name: Clean workspace
run: |
@ -49,82 +49,85 @@ jobs:
- name: Build
run: python3 tools/build_cmake.py ${{ matrix.family }} -DTOOLCHAIN=iar -DCMAKE_BUILD_TYPE=MinSizeRel
# Upload binaries for hardware test with self-hosted
- name: Prepare stm32l412nucleo Artifacts
if: contains(matrix.family, 'stm32l4')
working-directory: ${{github.workspace}}/cmake-build/cmake-build-stm32l412nucleo
- name: Test on actual hardware (hardware in the loop)
run: |
find device/ -name "*.elf" -exec mv {} ../../ \;
python3 tools/hitl_test.py hitl_hfp.json
- name: Upload Artifacts for stm32l412nucleo
if: contains(matrix.family, 'stm32l4') && github.repository_owner == 'hathach'
uses: actions/upload-artifact@v3
with:
name: stm32l4
path: |
*.elf
# # Upload binaries for hardware test with self-hosted
# - name: Prepare stm32l412nucleo Artifacts
# if: contains(matrix.family, 'stm32l4')
# working-directory: ${{github.workspace}}/cmake-build/cmake-build-stm32l412nucleo
# run: |
# find device/ -name "*.elf" -exec mv {} ../../ \;
#
# - name: Upload Artifacts for stm32l412nucleo
# if: contains(matrix.family, 'stm32l4') && github.repository_owner == 'hathach'
# uses: actions/upload-artifact@v3
# with:
# name: stm32l4
# path: |
# *.elf
# ---------------------------------------
# Hardware in the loop (HIL)
# Current self-hosted instance is running on an EPYC 7232 server hosted by HiFiPhile user
# - STM32L412 Nucleo with on-board jlink as ttyACM0
# ---------------------------------------
hw-stm32l412nucleo-test:
needs: cmake
runs-on: [self-hosted, Linux, X64, hifiphile]
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Download stm32l4 Artifacts
uses: actions/download-artifact@v3
with:
name: stm32l4
- name: Create flash.sh
run: |
echo > flash.sh 'echo halt > flash.jlink'
echo >> flash.sh 'echo r >> flash.jlink'
echo >> flash.sh 'echo loadfile $1 >> flash.jlink'
echo >> flash.sh 'echo r >> flash.jlink'
echo >> flash.sh 'echo go >> flash.jlink'
echo >> flash.sh 'echo exit >> flash.jlink'
echo >> flash.sh 'cmdout=$(JLinkExe -USB 774470029 -device stm32l412kb -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink)'
echo >> flash.sh 'if (( $? )) ; then echo $cmdout ; fi'
chmod +x flash.sh
- name: Test cdc_dual_ports
run: |
./flash.sh cdc_dual_ports.elf
while (! ([ -e /dev/ttyACM1 ] && [ -e /dev/ttyACM2 ])) && [ $SECONDS -le 10 ]; do :; done
test -e /dev/ttyACM1 && echo "ttyACM1 exists"
test -e /dev/ttyACM2 && echo "ttyACM2 exists"
# Debian does not auto mount usb drive. skip this test for now
- name: Test cdc_msc
if: false
run: |
./flash.sh cdc_msc.elf
readme='/media/pi/TinyUSB MSC/README.TXT'
while (! ([ -e /dev/ttyACM1 ] && [ -f "$readme" ])) && [ $SECONDS -le 10 ]; do :; done
test -e /dev/ttyACM1 && echo "ttyACM1 exists"
test -f "$readme" && echo "$readme exists"
cat "$readme"
- name: Test dfu
run: |
./flash.sh dfu.elf
while (! (dfu-util -l | grep "Found DFU")) && [ $SECONDS -le 10 ]; do :; done
dfu-util -d cafe -a 0 -U dfu0
dfu-util -d cafe -a 1 -U dfu1
grep "TinyUSB DFU! - Partition 0" dfu0
grep "TinyUSB DFU! - Partition 1" dfu1
- name: Test dfu_runtime
run: |
./flash.sh dfu_runtime.elf
while (! (dfu-util -l | grep "Found Runtime")) && [ $SECONDS -le 10 ]; do :; done
# hw-stm32l412nucleo-test:
# needs: cmake
# runs-on: [self-hosted, Linux, X64, hifiphile]
#
# steps:
# - name: Clean workspace
# run: |
# echo "Cleaning up previous run"
# rm -rf "${{ github.workspace }}"
# mkdir -p "${{ github.workspace }}"
#
# - name: Download stm32l4 Artifacts
# uses: actions/download-artifact@v3
# with:
# name: stm32l4
#
# - name: Create flash.sh
# run: |
# echo > flash.sh 'echo halt > flash.jlink'
# echo >> flash.sh 'echo r >> flash.jlink'
# echo >> flash.sh 'echo loadfile $1 >> flash.jlink'
# echo >> flash.sh 'echo r >> flash.jlink'
# echo >> flash.sh 'echo go >> flash.jlink'
# echo >> flash.sh 'echo exit >> flash.jlink'
# echo >> flash.sh 'cmdout=$(JLinkExe -USB 774470029 -device stm32l412kb -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink)'
# echo >> flash.sh 'if (( $? )) ; then echo $cmdout ; fi'
# chmod +x flash.sh
#
# - name: Test cdc_dual_ports
# run: |
# ./flash.sh cdc_dual_ports.elf
# while (! ([ -e /dev/ttyACM1 ] && [ -e /dev/ttyACM2 ])) && [ $SECONDS -le 10 ]; do :; done
# test -e /dev/ttyACM1 && echo "ttyACM1 exists"
# test -e /dev/ttyACM2 && echo "ttyACM2 exists"
#
# # Debian does not auto mount usb drive. skip this test for now
# - name: Test cdc_msc
# if: false
# run: |
# ./flash.sh cdc_msc.elf
# readme='/media/pi/TinyUSB MSC/README.TXT'
# while (! ([ -e /dev/ttyACM1 ] && [ -f "$readme" ])) && [ $SECONDS -le 10 ]; do :; done
# test -e /dev/ttyACM1 && echo "ttyACM1 exists"
# test -f "$readme" && echo "$readme exists"
# cat "$readme"
#
# - name: Test dfu
# run: |
# ./flash.sh dfu.elf
# while (! (dfu-util -l | grep "Found DFU")) && [ $SECONDS -le 10 ]; do :; done
# dfu-util -d cafe -a 0 -U dfu0
# dfu-util -d cafe -a 1 -U dfu1
# grep "TinyUSB DFU! - Partition 0" dfu0
# grep "TinyUSB DFU! - Partition 1" dfu1
#
# - name: Test dfu_runtime
# run: |
# ./flash.sh dfu_runtime.elf
# while (! (dfu-util -l | grep "Found Runtime")) && [ $SECONDS -le 10 ]; do :; done

1
.idea/cmake.xml generated
View File

@ -52,7 +52,6 @@
<configuration PROFILE_NAME="ra6m5 PORT0" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=ra6m5_ek -DLOG=3 -DLOGGER=RTT -DTRACE_ETM=1 -DPORT=0" />
<configuration PROFILE_NAME="uno_r4" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=uno_r4 -DLOG=4 -DLOGGER=RTT" />
<configuration PROFILE_NAME="portenta_c33" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=portenta_c33 -DLOG=3" />
<configuration PROFILE_NAME="lpc54628 PORT0" ENABLED="true" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=lpcxpresso54628 -DLOG=4 -DLOGGER=RTT -DPORT=0" />
</configurations>
</component>
</project>

View File

@ -17,6 +17,7 @@ family_add_subdirectory(cdc_uac2)
family_add_subdirectory(dfu)
family_add_subdirectory(dfu_runtime)
family_add_subdirectory(dynamic_configuration)
family_add_subdirectory(hid_boot_interface)
family_add_subdirectory(hid_composite)
family_add_subdirectory(hid_composite_freertos)
family_add_subdirectory(hid_generic_inout)

View File

@ -1,7 +1,7 @@
set(MCU_VARIANT LPC55S69)
set(MCU_CORE LPC55S69_cm33_core0)
set(JLINK_DEVICE LPC55S69)
set(JLINK_DEVICE LPC55S69_M33_0)
set(PYOCD_TARGET LPC55S69)
set(NXPLINK_DEVICE LPC55S69:LPCXpresso55S69)

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')