mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-15 21:40:18 +00:00
Fix LPC54 build.
This commit is contained in:
parent
9dd896904c
commit
b9e614bd39
@ -1,7 +1,7 @@
|
||||
MCU_VARIANT = LPC54628
|
||||
MCU_CORE = LPC54628
|
||||
|
||||
PORT ?= 0
|
||||
PORT ?= 1
|
||||
|
||||
CFLAGS += -DCPU_LPC54628J512ET180
|
||||
CFLAGS += -Wno-error=double-promotion
|
||||
|
@ -8,12 +8,11 @@ CFLAGS += \
|
||||
-flto \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_LPC54XXX \
|
||||
-DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' \
|
||||
-DBOARD_TUD_RHPORT=$(PORT)
|
||||
|
||||
ifeq ($(PORT), 1)
|
||||
$(info "PORT1 High Speed")
|
||||
CFLAGS += -DBOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
|
||||
|
||||
CFLAGS += -DBOARD_TUD_RHPORT=1
|
||||
# LPC55 Highspeed Port1 can only write to USB_SRAM region
|
||||
CFLAGS += -DCFG_TUSB_MEM_SECTION='__attribute__((section("m_usb_global")))'
|
||||
else
|
||||
|
28
test/hitl/hitl_config.json
Normal file
28
test/hitl/hitl_config.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"devices": [
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -21,11 +21,16 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
# udev rules :
|
||||
# SUBSYSTEM=="block", SUBSYSTEMS=="usb", MODE="0666", PROGRAM="/bin/sh -c 'echo $$ID_SERIAL_SHORT | rev | cut -c -8 | rev'", SYMLINK+="blkUSB_%c.%s{bInterfaceNumber}"
|
||||
# SUBSYSTEM=="tty", SUBSYSTEMS=="usb", MODE="0666", PROGRAM="/bin/sh -c 'echo $$ID_SERIAL_SHORT | rev | cut -c -8 | rev'", SYMLINK+="ttyUSB_%c.%s{bInterfaceNumber}"
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import serial
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
def flash_jlink(sn, dev, firmware):
|
||||
script = ['halt', 'r', f'loadfile {firmware}', 'r', 'go', 'exit']
|
||||
@ -34,9 +39,12 @@ def flash_jlink(sn, dev, firmware):
|
||||
f.close()
|
||||
ret = subprocess.run(f'JLinkExe -USB {sn} -device {dev} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink',
|
||||
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
os.remove('flash.jlink')
|
||||
assert ret.returncode == 0, 'Flash failed'
|
||||
|
||||
def test_cdc_dual_ports(port1, port2):
|
||||
def test_cdc_dual_ports(id):
|
||||
port1 = f'/dev/ttyUSB_{id[-8:]}.00'
|
||||
port2 = f'/dev/ttyUSB_{id[-8:]}.02'
|
||||
# Wait device enum
|
||||
timeout = 10
|
||||
while timeout:
|
||||
@ -46,8 +54,9 @@ def test_cdc_dual_ports(port1, port2):
|
||||
timeout = timeout - 1
|
||||
|
||||
assert os.path.exists(port1) and os.path.exists(port2), \
|
||||
'Port not available'
|
||||
'Device not available'
|
||||
|
||||
# Echo test
|
||||
ser1 = serial.Serial(port1)
|
||||
ser2 = serial.Serial(port2)
|
||||
|
||||
@ -68,9 +77,109 @@ def test_cdc_dual_ports(port1, port2):
|
||||
|
||||
print('cdc_dual_ports test done')
|
||||
|
||||
def test_cdc_msc(id):
|
||||
port = f'/dev/ttyUSB_{id[-8:]}.00'
|
||||
block = f'/dev/blkUSB_{id[-8:]}.02'
|
||||
# Wait device enum
|
||||
timeout = 10
|
||||
while timeout:
|
||||
if os.path.exists(port) and os.path.exists(block):
|
||||
break
|
||||
time.sleep(1)
|
||||
timeout = timeout - 1
|
||||
|
||||
assert os.path.exists(port) and os.path.exists(block), \
|
||||
'Device not available'
|
||||
|
||||
# Echo test
|
||||
ser = serial.Serial(port)
|
||||
|
||||
ser.timeout = 1
|
||||
|
||||
str = b"test_str"
|
||||
ser.write(str)
|
||||
ser.flush()
|
||||
assert ser.read(100) == str, 'Port wrong data'
|
||||
|
||||
# Block test
|
||||
f = open(block, 'rb')
|
||||
data = f.read()
|
||||
|
||||
readme = \
|
||||
b"This is tinyusb's MassStorage Class demo.\r\n\r\n\
|
||||
If you find any bugs or get any questions, feel free to file an\r\n\
|
||||
issue at github.com/hathach/tinyusb"
|
||||
|
||||
assert data[0x600:0x600 + len(readme)] == readme, 'Block wrong data'
|
||||
print('cdc_msc test done')
|
||||
|
||||
def test_dfu(id):
|
||||
# Wait device enum
|
||||
timeout = 10
|
||||
while timeout:
|
||||
ret = subprocess.run(f'dfu-util -l',
|
||||
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
stdout = ret.stdout.decode()
|
||||
if f'serial="{id}"' in stdout and 'Found DFU: [cafe:4000]' in stdout:
|
||||
break
|
||||
time.sleep(1)
|
||||
timeout = timeout - 1
|
||||
|
||||
assert timeout, 'Device not available'
|
||||
|
||||
# Test upload
|
||||
try:
|
||||
os.remove('dfu0')
|
||||
os.remove('dfu1')
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
ret = subprocess.run(f'dfu-util -S {id} -a 0 -U dfu0',
|
||||
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
assert ret.returncode == 0, 'Upload failed'
|
||||
|
||||
ret = subprocess.run(f'dfu-util -S {id} -a 1 -U dfu1',
|
||||
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
assert ret.returncode == 0, 'Upload failed'
|
||||
|
||||
with open('dfu0') as f:
|
||||
assert 'Hello world from TinyUSB DFU! - Partition 0' in f.read(), 'Wrong uploaded data'
|
||||
|
||||
with open('dfu1') as f:
|
||||
assert 'Hello world from TinyUSB DFU! - Partition 1' in f.read(), 'Wrong uploaded data'
|
||||
|
||||
os.remove('dfu0')
|
||||
os.remove('dfu1')
|
||||
|
||||
print('dfu test done')
|
||||
|
||||
def test_dfu_runtime(id):
|
||||
# Wait device enum
|
||||
timeout = 10
|
||||
while timeout:
|
||||
ret = subprocess.run(f'dfu-util -l',
|
||||
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
stdout = ret.stdout.decode()
|
||||
if f'serial="{id}"' in stdout and 'Found Runtime: [cafe:4000]' in stdout:
|
||||
break
|
||||
time.sleep(1)
|
||||
timeout = timeout - 1
|
||||
|
||||
assert timeout, 'Device not available'
|
||||
|
||||
print('dfu_runtime test done')
|
||||
|
||||
|
||||
|
||||
flash_jlink('774470029', 'stm32l412kb', 'examples/device/cdc_dual_ports/_build/stm32l412nucleo/cdc_dual_ports.elf')
|
||||
|
||||
test_cdc_dual_ports('/dev/ttyUSB_57323020.00', '/dev/ttyUSB_57323020.02')
|
||||
if __name__ == '__main__':
|
||||
with open(f'{os.path.dirname(__file__)}/hitl_config.json') 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'] == 'jlink':
|
||||
flash_jlink(device['debugger_sn'], device['device'], test['firmware'])
|
||||
else:
|
||||
# ToDo
|
||||
pass
|
||||
locals()[f'test_{test["name"]}'](device['uid'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user