mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-17 08:45:13 +00:00
add hil support for dual host_info_to_cdc
replace itsybitsy m4 by metro m4 + max3421e
This commit is contained in:
parent
858ad66c93
commit
0db42aac71
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Host example will get device descriptors of attached devices and print it out via device cdc as follows:
|
/* Host example will get device descriptors of attached devices and print it out via device cdc as follows:
|
||||||
* Device 1: ID 046d:c52f
|
* Device 1: ID 046d:c52f SN 11223344
|
||||||
Device Descriptor:
|
Device Descriptor:
|
||||||
bLength 18
|
bLength 18
|
||||||
bDescriptorType 1
|
bDescriptorType 1
|
||||||
@ -147,7 +147,21 @@ void print_device_info(uint8_t daddr) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cdc_printf("Device %u: ID %04x:%04x\r\n", daddr, desc_device.idVendor, desc_device.idProduct);
|
// Get String descriptor using Sync API
|
||||||
|
uint16_t serial[64];
|
||||||
|
uint16_t buf[128];
|
||||||
|
|
||||||
|
cdc_printf("Device %u: ID %04x:%04x SN ", daddr, desc_device.idVendor, desc_device.idProduct);
|
||||||
|
xfer_result = tuh_descriptor_get_serial_string_sync(daddr, LANGUAGE_ID, serial, sizeof(serial));
|
||||||
|
if (XFER_RESULT_SUCCESS != xfer_result) {
|
||||||
|
serial[0] = 'n';
|
||||||
|
serial[1] = '/';
|
||||||
|
serial[2] = 'a';
|
||||||
|
serial[3] = 0;
|
||||||
|
}
|
||||||
|
print_utf16(serial, TU_ARRAY_SIZE(serial));
|
||||||
|
tud_cdc_write_str("\r\n");
|
||||||
|
|
||||||
cdc_printf("Device Descriptor:\r\n");
|
cdc_printf("Device Descriptor:\r\n");
|
||||||
cdc_printf(" bLength %u\r\n" , desc_device.bLength);
|
cdc_printf(" bLength %u\r\n" , desc_device.bLength);
|
||||||
cdc_printf(" bDescriptorType %u\r\n" , desc_device.bDescriptorType);
|
cdc_printf(" bDescriptorType %u\r\n" , desc_device.bDescriptorType);
|
||||||
@ -160,9 +174,6 @@ void print_device_info(uint8_t daddr) {
|
|||||||
cdc_printf(" idProduct 0x%04x\r\n" , desc_device.idProduct);
|
cdc_printf(" idProduct 0x%04x\r\n" , desc_device.idProduct);
|
||||||
cdc_printf(" bcdDevice %04x\r\n" , desc_device.bcdDevice);
|
cdc_printf(" bcdDevice %04x\r\n" , desc_device.bcdDevice);
|
||||||
|
|
||||||
// Get String descriptor using Sync API
|
|
||||||
uint16_t buf[128];
|
|
||||||
|
|
||||||
cdc_printf(" iManufacturer %u " , desc_device.iManufacturer);
|
cdc_printf(" iManufacturer %u " , desc_device.iManufacturer);
|
||||||
xfer_result = tuh_descriptor_get_manufacturer_string_sync(daddr, LANGUAGE_ID, buf, sizeof(buf));
|
xfer_result = tuh_descriptor_get_manufacturer_string_sync(daddr, LANGUAGE_ID, buf, sizeof(buf));
|
||||||
if (XFER_RESULT_SUCCESS == xfer_result ) {
|
if (XFER_RESULT_SUCCESS == xfer_result ) {
|
||||||
@ -178,10 +189,7 @@ void print_device_info(uint8_t daddr) {
|
|||||||
tud_cdc_write_str("\r\n");
|
tud_cdc_write_str("\r\n");
|
||||||
|
|
||||||
cdc_printf(" iSerialNumber %u " , desc_device.iSerialNumber);
|
cdc_printf(" iSerialNumber %u " , desc_device.iSerialNumber);
|
||||||
xfer_result = tuh_descriptor_get_serial_string_sync(daddr, LANGUAGE_ID, buf, sizeof(buf));
|
tud_cdc_write_str((char*)serial); // serial is already to UTF-8
|
||||||
if (XFER_RESULT_SUCCESS == xfer_result) {
|
|
||||||
print_utf16(buf, TU_ARRAY_SIZE(buf));
|
|
||||||
}
|
|
||||||
tud_cdc_write_str("\r\n");
|
tud_cdc_write_str("\r\n");
|
||||||
|
|
||||||
cdc_printf(" bNumConfigurations %u\r\n" , desc_device.bNumConfigurations);
|
cdc_printf(" bNumConfigurations %u\r\n" , desc_device.bNumConfigurations);
|
||||||
|
@ -3,6 +3,9 @@ set(SAM_FAMILY samd51)
|
|||||||
set(JLINK_DEVICE ATSAMD51J19)
|
set(JLINK_DEVICE ATSAMD51J19)
|
||||||
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
|
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
|
||||||
|
|
||||||
|
# force max3421e for testing with hardware-in-the-loop
|
||||||
|
set(MAX3421_HOST 1)
|
||||||
|
|
||||||
function(update_board TARGET)
|
function(update_board TARGET)
|
||||||
target_compile_definitions(${TARGET} PUBLIC
|
target_compile_definitions(${TARGET} PUBLIC
|
||||||
__SAMD51J19A__
|
__SAMD51J19A__
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import serial
|
import serial
|
||||||
@ -212,14 +213,39 @@ def flash_uniflash(board, firmware):
|
|||||||
|
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# Tests
|
# Tests: dual
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
def test_board_test(board):
|
|
||||||
|
def test_dual_host_info_to_device_cdc(board):
|
||||||
|
uid = board['uid']
|
||||||
|
declared_devs = [f'{d["vid_pid"]}_{d["serial"]}' for d in board['tests']['dual_attached']]
|
||||||
|
|
||||||
|
port = get_serial_dev(uid, 'TinyUSB', "TinyUSB_Device", 0)
|
||||||
|
ser = open_serial_dev(port)
|
||||||
|
# read from cdc, first line should contain vid/pid and serial
|
||||||
|
data = ser.read(1000)
|
||||||
|
lines = data.decode('utf-8').splitlines()
|
||||||
|
enum_dev_sn = []
|
||||||
|
for l in lines:
|
||||||
|
vid_pid_sn = re.search(r'ID ([0-9a-fA-F]+):([0-9a-fA-F]+) SN (\w+)', l)
|
||||||
|
if vid_pid_sn:
|
||||||
|
print(f'\r\n {l} ', end='')
|
||||||
|
enum_dev_sn.append(f'{vid_pid_sn.group(1)}_{vid_pid_sn.group(2)}_{vid_pid_sn.group(3)}')
|
||||||
|
|
||||||
|
assert(set(declared_devs) == set(enum_dev_sn)), \
|
||||||
|
f'Enumerated devices {enum_dev_sn} not match with declared {declared_devs}'
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------------------------
|
||||||
|
# Tests: device
|
||||||
|
# -------------------------------------------------------------
|
||||||
|
def test_device_board_test(board):
|
||||||
# Dummy test
|
# Dummy test
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_cdc_dual_ports(board):
|
def test_device_cdc_dual_ports(board):
|
||||||
uid = board['uid']
|
uid = board['uid']
|
||||||
port1 = get_serial_dev(uid, 'TinyUSB', "TinyUSB_Device", 0)
|
port1 = get_serial_dev(uid, 'TinyUSB', "TinyUSB_Device", 0)
|
||||||
port2 = get_serial_dev(uid, 'TinyUSB', "TinyUSB_Device", 2)
|
port2 = get_serial_dev(uid, 'TinyUSB', "TinyUSB_Device", 2)
|
||||||
@ -241,7 +267,7 @@ def test_cdc_dual_ports(board):
|
|||||||
assert ser2.read(100) == str2.upper(), 'Port2 wrong data'
|
assert ser2.read(100) == str2.upper(), 'Port2 wrong data'
|
||||||
|
|
||||||
|
|
||||||
def test_cdc_msc(board):
|
def test_device_cdc_msc(board):
|
||||||
uid = board['uid']
|
uid = board['uid']
|
||||||
# Echo test
|
# Echo test
|
||||||
port = get_serial_dev(uid, 'TinyUSB', "TinyUSB_Device", 0)
|
port = get_serial_dev(uid, 'TinyUSB', "TinyUSB_Device", 0)
|
||||||
@ -262,11 +288,11 @@ issue at github.com/hathach/tinyusb"
|
|||||||
assert data == readme, 'MSC wrong data'
|
assert data == readme, 'MSC wrong data'
|
||||||
|
|
||||||
|
|
||||||
def test_cdc_msc_freertos(board):
|
def test_device_cdc_msc_freertos(board):
|
||||||
test_cdc_msc(board)
|
test_device_cdc_msc(board)
|
||||||
|
|
||||||
|
|
||||||
def test_dfu(board):
|
def test_device_dfu(board):
|
||||||
uid = board['uid']
|
uid = board['uid']
|
||||||
|
|
||||||
# Wait device enum
|
# Wait device enum
|
||||||
@ -308,7 +334,7 @@ def test_dfu(board):
|
|||||||
os.remove(f_dfu1)
|
os.remove(f_dfu1)
|
||||||
|
|
||||||
|
|
||||||
def test_dfu_runtime(board):
|
def test_device_dfu_runtime(board):
|
||||||
uid = board['uid']
|
uid = board['uid']
|
||||||
|
|
||||||
# Wait device enum
|
# Wait device enum
|
||||||
@ -325,7 +351,7 @@ def test_dfu_runtime(board):
|
|||||||
assert timeout, 'Device not available'
|
assert timeout, 'Device not available'
|
||||||
|
|
||||||
|
|
||||||
def test_hid_boot_interface(board):
|
def test_device_hid_boot_interface(board):
|
||||||
uid = board['uid']
|
uid = board['uid']
|
||||||
kbd = get_hid_dev(uid, 'TinyUSB', 'TinyUSB_Device', 'event-kbd')
|
kbd = get_hid_dev(uid, 'TinyUSB', 'TinyUSB_Device', 'event-kbd')
|
||||||
mouse1 = get_hid_dev(uid, 'TinyUSB', 'TinyUSB_Device', 'if01-event-mouse')
|
mouse1 = get_hid_dev(uid, 'TinyUSB', 'TinyUSB_Device', 'if01-event-mouse')
|
||||||
@ -341,7 +367,7 @@ def test_hid_boot_interface(board):
|
|||||||
assert timeout, 'HID device not available'
|
assert timeout, 'HID device not available'
|
||||||
|
|
||||||
|
|
||||||
def test_hid_composite_freertos(id):
|
def test_device_hid_composite_freertos(id):
|
||||||
# TODO implement later
|
# TODO implement later
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -351,13 +377,15 @@ def test_hid_composite_freertos(id):
|
|||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# all possible tests: board_test is added last to disable board's usb
|
# all possible tests: board_test is added last to disable board's usb
|
||||||
all_tests = [
|
all_tests = [
|
||||||
'cdc_dual_ports',
|
'device/cdc_dual_ports',
|
||||||
'cdc_msc',
|
'device/cdc_msc',
|
||||||
'dfu',
|
'device/dfu',
|
||||||
'cdc_msc_freertos', # dont test 2 cdc_msc next to each other, since they have same vid/pid. Can be confused by host
|
'device/cdc_msc_freertos', # don't test 2 cdc_msc next to each other
|
||||||
'dfu_runtime',
|
'device/dfu_runtime',
|
||||||
'hid_boot_interface',
|
'device/hid_boot_interface',
|
||||||
'board_test'
|
|
||||||
|
'dual/host_info_to_device_cdc',
|
||||||
|
'device/board_test'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -366,23 +394,23 @@ def test_board(board):
|
|||||||
flasher = board['flasher'].lower()
|
flasher = board['flasher'].lower()
|
||||||
|
|
||||||
# default to all tests
|
# default to all tests
|
||||||
if 'tests' in board:
|
test_list = list(all_tests)
|
||||||
test_list = board['tests'] + ['board_test']
|
|
||||||
else:
|
|
||||||
test_list = list(all_tests)
|
|
||||||
|
|
||||||
# remove skip_tests
|
if 'tests' in board:
|
||||||
if 'tests_skip' in board:
|
board_tests = board['tests']
|
||||||
for skip in board['tests_skip']:
|
if 'only' in board_tests:
|
||||||
if skip in test_list:
|
test_list = board_tests['only'] + ['device/board_test']
|
||||||
test_list.remove(skip)
|
if 'skip' in board_tests:
|
||||||
|
for skip in board_tests['skip']:
|
||||||
|
if skip in test_list:
|
||||||
|
test_list.remove(skip)
|
||||||
|
|
||||||
err_count = 0
|
err_count = 0
|
||||||
for test in test_list:
|
for test in test_list:
|
||||||
fw_dir = f'cmake-build/cmake-build-{name}/device/{test}'
|
fw_dir = f'cmake-build/cmake-build-{name}/{test}'
|
||||||
if not os.path.exists(fw_dir):
|
if not os.path.exists(fw_dir):
|
||||||
fw_dir = f'examples/cmake-build-{name}/device/{test}'
|
fw_dir = f'examples/cmake-build-{name}/{test}'
|
||||||
fw_name = f'{fw_dir}/{test}'
|
fw_name = f'{fw_dir}/{os.path.basename(test)}'
|
||||||
print(f'{name:30} {test:20} ... ', end='')
|
print(f'{name:30} {test:20} ... ', end='')
|
||||||
|
|
||||||
if not os.path.exists(fw_dir):
|
if not os.path.exists(fw_dir):
|
||||||
@ -400,7 +428,7 @@ def test_board(board):
|
|||||||
|
|
||||||
if ret.returncode == 0:
|
if ret.returncode == 0:
|
||||||
try:
|
try:
|
||||||
ret = globals()[f'test_{test}'](board)
|
ret = globals()[f'test_{test.replace("/", "_")}'](board)
|
||||||
print('OK')
|
print('OK')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err_count += 1
|
err_count += 1
|
||||||
@ -409,7 +437,6 @@ def test_board(board):
|
|||||||
else:
|
else:
|
||||||
err_count += 1
|
err_count += 1
|
||||||
print('Flash failed')
|
print('Flash failed')
|
||||||
|
|
||||||
return err_count
|
return err_count
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,11 +8,18 @@
|
|||||||
"flasher_args": "-device nrf52840_xxaa"
|
"flasher_args": "-device nrf52840_xxaa"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "itsybitsy_m4",
|
"name": "metro_m4_express",
|
||||||
"uid": "D784B28C5338533335202020FF044726",
|
"uid": "9995AD485337433231202020FF100A34",
|
||||||
"flasher": "openocd",
|
"flasher": "openocd",
|
||||||
"flasher_sn": "E6614C311B597D32",
|
"flasher_sn": "E6633861A3978538",
|
||||||
"flasher_args": "-f interface/cmsis-dap.cfg -f target/atsame5x.cfg -c \"adapter speed 5000\""
|
"flasher_args": "-f interface/cmsis-dap.cfg -f target/atsame5x.cfg",
|
||||||
|
"tests": {
|
||||||
|
"dual_attached": [
|
||||||
|
{
|
||||||
|
"vid_pid": "1a86_55d4", "serial": "52D2002130"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "max32666fthr",
|
"name": "max32666fthr",
|
||||||
@ -31,7 +38,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ra4m1_ek",
|
"name": "ra4m1_ek",
|
||||||
"uid": "152E163038303131393346E46F26574B",
|
"uid": "152E163038303131393346E46F26574B",
|
||||||
"tests_skip": ["cdc_msc", "cdc_msc_freertos"],
|
"tests": {
|
||||||
|
"skip": ["device/cdc_msc", "device/cdc_msc_freertos"]
|
||||||
|
},
|
||||||
"comment": "MSC is slow to enumerated #2602",
|
"comment": "MSC is slow to enumerated #2602",
|
||||||
"flasher": "jlink",
|
"flasher": "jlink",
|
||||||
"flasher_sn": "000831174392",
|
"flasher_sn": "000831174392",
|
||||||
@ -77,9 +86,9 @@
|
|||||||
{
|
{
|
||||||
"name": "espressif_s3_devkitm",
|
"name": "espressif_s3_devkitm",
|
||||||
"uid": "84F703C084E4",
|
"uid": "84F703C084E4",
|
||||||
"tests": [
|
"tests": {
|
||||||
"cdc_msc_freertos", "hid_composite_freertos"
|
"only": ["device/cdc_msc_freertos", "device/hid_composite_freertos"]
|
||||||
],
|
},
|
||||||
"flasher": "esptool",
|
"flasher": "esptool",
|
||||||
"flasher_sn": "3ea619acd1cdeb11a0a0b806e93fd3f1",
|
"flasher_sn": "3ea619acd1cdeb11a0a0b806e93fd3f1",
|
||||||
"flasher_args": "-b 921600"
|
"flasher_args": "-b 921600"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user