def test_session(ep, address, bus_speed): start_length = 10 end_length = 19 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) for pktLength in range(start_length, end_length + 1): # < 17 fails session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="ISO", transType="OUT", dataLength=pktLength, interEventDelay=20, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="ISO", transType="IN", dataLength=pktLength, interEventDelay=58, )) return session
def test_session(ep, address, bus_speed): # Note, EP0_MAX_PACKET_SIZE set to 8 in test to speed things up maxPktLength = 8 startLength = 8 endLength = 20 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) for dataLength in range(startLength, endLength + 1): session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="SETUP", dataLength=8, interEventDelay= 1000, # Large delay to allow for packet generation )) thisDataLength = dataLength while thisDataLength > 0: pktLength = maxPktLength if thisDataLength < maxPktLength: pktLength = thisDataLength thisDataLength = thisDataLength - pktLength session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="IN", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="OUT", dataLength=0, )) return session
def test_session(ep, address, bus_speed): ep_loopback = ep ep_loopback_kill = ep + 1 start_length = 10 end_length = 20 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # TODO randomise packet lengths and data for pktLength in range(start_length, end_length + 1): session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_loopback, endpointType="BULK", transType="OUT", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_loopback, endpointType="BULK", transType="IN", dataLength=pktLength, )) pktLength = start_length # Loopback and die.. session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_loopback_kill, endpointType="BULK", transType="OUT", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_loopback_kill, endpointType="BULK", transType="IN", dataLength=pktLength, )) return session
def test_session(ep, address, bus_speed): ied = 200 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) for pktLength in range(10, 20): session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="IN", dataLength=pktLength, interEventDelay=ied, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep + 1, endpointType="BULK", transType="IN", dataLength=pktLength, interEventDelay=ied, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep + 2, endpointType="BULK", transType="IN", dataLength=pktLength, interEventDelay=ied, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep + 3, endpointType="BULK", transType="IN", dataLength=pktLength, interEventDelay=ied, )) return session
def test_session(ep, address, bus_speed): frameNumber = 52 # Note, for frame number 52 we expect A5 34 40 on the bus session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # Start with a valid transaction */ session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=10, )) session.add_event( CreateSofToken(frameNumber, interEventDelay=INTER_TRANSACTION_DELAY)) session.add_event( CreateSofToken(frameNumber + 1, interEventDelay=INTER_TRANSACTION_DELAY)) session.add_event( CreateSofToken(frameNumber + 2, interEventDelay=INTER_TRANSACTION_DELAY)) session.add_event( CreateSofToken(frameNumber + 3, interEventDelay=INTER_TRANSACTION_DELAY)) session.add_event( CreateSofToken(frameNumber + 4, interEventDelay=INTER_TRANSACTION_DELAY)) # Finish with valid transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=11, interEventDelay=6000, )) return session
def test_session(ep, address, bus_speed, arch): if arch == "xs3": pytest.xfail("Known failure on xs3") address = 1 ep = 1 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # Start with a valid transaction */ session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", direction="OUT", dataLength=10, )) # tmp hack for xs2 - for xs2 the shim will throw away the short token and # it will never be seen by the xCORE if arch == "xs3": # Create a short token, only PID and 2nd byte shorttoken = TxPacket( pid=USB_PID["OUT"], data_bytes=[0x81], interEventDelay=100, ) session.add_event(shorttoken) # Finish with valid transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", direction="OUT", dataLength=11, interEventDelay=6000, )) return session
def test_session(ep, address, bus_speed): pktLength = 10 frameNumber = 52 # Note, for frame number 52 we expect A5 34 40 on the bus interEventDelay = USB_PKT_TIMINGS["TX_TO_TX_PACKET_DELAY"] session = UsbSession( bus_speed=bus_speed, run_enumeration=False, device_address=address, initial_delay=19000 * 1000 * 1000, # fs ) session.add_event(UsbDeviceAttach()) session.add_event(CreateSofToken(frameNumber, interEventDelay=100)) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, interEventDelay=interEventDelay, ) ) frameNumber = frameNumber + 1 pktLength = pktLength + 1 session.add_event(CreateSofToken(frameNumber)) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, interEventDelay=interEventDelay, ) ) return session
def test_session(ep, address, bus_speed): session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) for pktLength in range(10, 20): session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=4, endpointType="BULK", transType="OUT", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=5, endpointType="BULK", transType="OUT", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=6, endpointType="BULK", transType="OUT", dataLength=pktLength, )) return session
def test_session(ep, address, bus_speed): start_length = 0 end_length = start_length + 10 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) for pktLength in range(start_length, end_length): session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="SETUP", dataLength=8, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="IN", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="OUT", dataLength=0, )) return session
def test_session(ep, address, bus_speed): pytest.xfail("Known failure (on XS3)") frameNumber = 52 # Note, for frame number 52 we expect A5 34 40 on the bus session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # Start with a valid transaction */ session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", direction="OUT", dataLength=10, )) session.add_event(CreateSofToken(frameNumber)) session.add_event(CreateSofToken(frameNumber + 1)) session.add_event(CreateSofToken(frameNumber + 2)) session.add_event(CreateSofToken(frameNumber + 3, badCrc=True)) # Invalidate the CRC session.add_event(CreateSofToken(frameNumber + 4)) # Finish with valid transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", direction="OUT", dataLength=11, interEventDelay=6000, )) return session
def test_session(ep, address, bus_speed): ied = 500 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="SETUP", dataLength=8, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="OUT", dataLength=10, )) # Expect 0 length IN transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="IN", dataLength=0, )) return session
def test_session(ep, address, bus_speed): pktLength = 10 ied = 500 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, )) # Expect NAK's from DUT session.add_event( TokenPacket( pid=USB_PID["IN"], address=address, endpoint=ep, )) session.add_event(RxHandshakePacket(pid=USB_PID["NAK"])) session.add_event( TokenPacket( pid=USB_PID["OUT"], address=address, endpoint=ep, interEventDelay=ied, )) session.add_event( TxDataPacket( dataPayload=session.getPayload_out(ep, pktLength), pid=USB_PID["DATA0"], )) session.add_event(RxHandshakePacket(pid=USB_PID["NAK"])) return session
def test_session(ep, address, bus_speed): pktLength = 10 ied = 4000 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) for pktLength in range(10, 14): if pktLength == 12: session.add_event( TokenPacket( pid=USB_PID["IN"], address=address, endpoint=ep, interEventDelay=ied, )) session.add_event( RxDataPacket( dataPayload=session.getPayload_in(ep, pktLength, resend=True), pid=USB_PID["DATA0"], )) session.add_event(TxHandshakePacket(pid=0xFF)) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="IN", dataLength=pktLength, interEventDelay=ied, )) return session
def test_session(ep, address, bus_speed, core_freq, dummy_threads): total_threads = dummy_threads + 2 # 1 thread for xud another for test code if (core_freq / total_threads < 100.0) and bus_speed == "HS": pytest.xfail("Test doesn't pass without 100MIPS (issue #277)") # The large inter-event delay is to give the DUT time to perform checking ied = 500 session = UsbSession( bus_speed=bus_speed, run_enumeration=False, device_address=address ) for length in range(10, 15): session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=length, interEventDelay=ied, ) ) # Simulate missing data payload if length == 11: session.add_event( TokenPacket( endpoint=ep, address=address, pid=USB_PID["OUT"], interEventDelay=ied, ) ) return session
def test_session(ep, address, bus_speed): # Note, quite big gap to allow checking ied = 4000 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) for pktLength in range(10, 15): if pktLength == 12: session.add_event( TokenPacket( pid=USB_PID["IN"], address=address, endpoint=ep, interEventDelay=ied, )) session.add_event( RxDataPacket(dataPayload=session.getPayload_in( ep, pktLength, resend=True))) # Missing ACK - simulate CRC fail at host session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="IN", dataLength=pktLength, interEventDelay=ied, )) return session
def test_session(ep, address, bus_speed): session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # Reserved/Invalid PID session.add_event( TokenPacket( pid=USB_PID["RESERVED"], address=address, endpoint=ep, )) # Valid IN but not for DUT session.add_event( TokenPacket( pid=USB_PID["IN"], address=address + 1, endpoint=ep, )) # Valid OUT but not for DUT session.add_event( TokenPacket( pid=USB_PID["OUT"], address=address + 1, endpoint=ep, )) # Valid OUT transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=10, )) # Valid SETUP but not for us.. session.add_event( TokenPacket( pid=USB_PID["SETUP"], address=address + 2, endpoint=ep, )) # Valid OUT transaction # Note, quite big gap to allow checking. session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=11, interEventDelay=6000, )) # Valid PING but not for us.. session.add_event( TokenPacket( pid=USB_PID["PING"], address=address + 2, endpoint=ep, )) # Finish with some valid transactions session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=12, interEventDelay=6000, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=13, interEventDelay=6000, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=14, interEventDelay=6000, )) return session
def test_session(ep, address, bus_speed): pktLength = 10 session = UsbSession( bus_speed=bus_speed, run_enumeration=False, device_address=address ) ep_ctrl = ep + 1 # Ping EP, expect stall session.add_event( TokenPacket( pid=USB_PID["PING"], address=address, endpoint=ep, ) ) session.add_event(RxHandshakePacket(pid=USB_PID["STALL"])) # And again session.add_event( TokenPacket( pid=USB_PID["PING"], address=address, endpoint=ep, ) ) session.add_event(RxHandshakePacket(pid=USB_PID["STALL"])) # Valid transaction to another EP informing test code to clear stall session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_ctrl, endpointType="BULK", transType="OUT", dataLength=pktLength, ) ) # Expect normal transactions session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, ) ) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, ) ) return session
def test_session(ep, address, bus_speed): session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # The large inter-frame gap is to give the DUT time to print its output interEventDelay = 500 # Valid OUT transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=10, interEventDelay=interEventDelay, )) # Pretend the ACK went missing on the way to host. Re-send same packet # xCORE should ACK but throw pkt away session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=11, interEventDelay=interEventDelay, resend=True, )) # Send some valid OUT transactions session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=12, interEventDelay=interEventDelay, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=13, interEventDelay=interEventDelay, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=14, interEventDelay=interEventDelay, )) return session
def test_session(ep, address, bus_speed): # The large inter-event delays are to give the DUT time to do checking on # the fly session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # Valid OUT transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=10, )) # Another valid OUT transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=11, interEventDelay=6000, )) # OUT transaction with bad data CRC session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=12, interEventDelay=6000, badDataCrc=True, )) # Due to bad CRC, XUD will not ACK and expect a resend of the same # packet - DATA PID won't be toggled session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=12, interEventDelay=6000, )) # PID will be toggled as normal session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=13, interEventDelay=6000, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=14, interEventDelay=6000, )) return session
def test_session(ep, address, bus_speed): session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # The large inter-frame gap is to give the DUT time to print its output interEventDelay = 500 # Valid OUT transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=10, interEventDelay=interEventDelay, )) # OUT Transaction with invalid DATA PID. XCORE should ignore packet - no ACK session.add_event( TokenPacket( pid=USB_PID["OUT"], address=address, endpoint=ep, interEventDelay=interEventDelay, )) session.add_event( TxDataPacket( dataPayload=session.getPayload_out(ep, 11, resend=True), pid=USB_PID["DATA1"] & 0xF, )) # Send some valid OUT transactions session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=11, interEventDelay=interEventDelay, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=12, interEventDelay=interEventDelay, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=13, interEventDelay=interEventDelay, )) return session
def test_session(ep, address, bus_speed): pktLength = 10 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) ep_ctrl = ep + 1 # Valid transactions on test EP's session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="IN", dataLength=pktLength, )) # Expect test EP's to be halted session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, halted=True, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, halted=True, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="IN", halted=True, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="IN", halted=True, )) # Valid transaction to another EP informing test code to clear stall session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_ctrl, endpointType="BULK", transType="OUT", dataLength=pktLength, )) # Check EP no working as normal session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, interEventDelay=1000, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="IN", dataLength=pktLength, )) # EP now re-halted session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, halted=True, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="IN", halted=True, )) # Valid transaction to another EP informing test code to clear stall session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_ctrl, endpointType="BULK", transType="OUT", dataLength=pktLength, )) # Check EP now working as normal session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="IN", dataLength=pktLength, )) return session
def test_session(ep, address, bus_speed): # Large inter-event delay is to give the DUT time to perform checking ied = 6000 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # Valid OUT transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=10, )) # Assert RxError during packet # xCORE should ignore the packet and not handshake... session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=11, interEventDelay=ied, rxeAssertDelay_data=5, )) # Re-send.. session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=11, interEventDelay=ied, )) # Valid OUT transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=12, interEventDelay=ied, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=13, interEventDelay=ied, rxeAssertDelay_data=1, )) # Re-send session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=13, interEventDelay=ied, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=14, interEventDelay=ied, )) return session
def test_session(ep, address, bus_speed): ied = 500 pktLength = 10 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # Ctrl transaction 0 session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="SETUP", dataLength=8, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="OUT", dataLength=10, )) # Expect 0 length IN transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="IN", dataLength=0, )) # Ctrl transaction 1 session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="SETUP", dataLength=8, )) # Check that the EP is now Halted - i.e. as if the previous request could not be handled session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="IN", dataLength=pktLength, halted=True, interEventDelay=1000, )) # Check that EP is un-Halted on a SETUP # Ctrl transaction 2 session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="SETUP", dataLength=8, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="IN", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="OUT", dataLength=0, )) return session
def test_session(ep, address, bus_speed): session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # Ping test EP, expect NAK session.add_event( TokenPacket( pid=USB_PID["PING"], address=address, endpoint=ep, )) session.add_event(RxHandshakePacket(pid=USB_PID["NAK"])) # And again session.add_event( TokenPacket( pid=USB_PID["PING"], address=address, endpoint=ep, )) session.add_event(RxHandshakePacket(pid=USB_PID["NAK"])) # Send packet to "ctrl" EP, DUT should mark test EP as ready session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep + 1, endpointType="BULK", transType="OUT", dataLength=10, )) # Ping test EP again - expect ACK session.add_event( TokenPacket( pid=USB_PID["PING"], address=address, endpoint=ep, interEventDelay=6000, )) session.add_event(RxHandshakePacket(pid=USB_PID["ACK"])) # And again.. session.add_event( TokenPacket( pid=USB_PID["PING"], address=address, endpoint=ep, interEventDelay=6000, )) session.add_event(RxHandshakePacket(pid=USB_PID["ACK"])) # Send out to EP 2.. expect ack session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=10, interEventDelay=6000, )) # Re-Ping EP 2, expect NAK session.add_event( TokenPacket( pid=USB_PID["PING"], address=address, endpoint=ep, )) session.add_event(RxHandshakePacket(pid=USB_PID["NAK"])) # And again session.add_event( TokenPacket( pid=USB_PID["PING"], address=address, endpoint=ep, )) session.add_event(RxHandshakePacket(pid=USB_PID["NAK"])) # Send a packet to "ctrl" EP so the DUT knows it can exit. session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep + 1, endpointType="BULK", transType="OUT", dataLength=10, )) return session
def test_session(ep, address, bus_speed): pktLength = 10 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) ep_ctrl = ep + 1 # Expect test EP's to be halted session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, halted=True, )) # Inform DUT to un-halt OUT EP via ctrl EP session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_ctrl, endpointType="BULK", transType="OUT", dataLength=pktLength, )) # Expect normal transaction on OUT EP session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, )) # ---- # Expect normal transaction on OUT EP session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_ctrl, endpointType="BULK", transType="OUT", dataLength=pktLength, interEventDelay=500, )) # Expect EP to now be re-halted session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, halted=True, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_ctrl, endpointType="BULK", transType="OUT", dataLength=pktLength, interEventDelay=500, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="BULK", transType="OUT", dataLength=pktLength, )) return session
def test_session(ep, address, bus_speed): ied = 500 trafficAddress1 = (address + 1) % 128 trafficAddress2 = (address + 127) % 128 start_length = 0 end_length = start_length + 10 session = UsbSession( bus_speed=bus_speed, run_enumeration=False, device_address=address ) for pktLength in range(start_length, end_length): # SETUP to another address (Note, DUT would not see ACK) session.add_event( TokenPacket( pid=USB_PID["SETUP"], address=trafficAddress1, endpoint=ep, ) ) session.add_event( TxDataPacket( dataPayload=[1, 2, 3, 4, 5, 6, 7, 8], pid=USB_PID["DATA0"], ) ) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="SETUP", dataLength=8, ) ) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="IN", dataLength=pktLength, ) ) # SETUP to another address (Note, DUT would not see ACK) session.add_event( TokenPacket( pid=USB_PID["SETUP"], address=trafficAddress2, endpoint=ep, ) ) session.add_event( TxDataPacket( dataPayload=[1, 2, 3, 4, 5, 6, 7, 8], pid=USB_PID["DATA0"], ) ) session.add_event( TokenPacket( pid=USB_PID["IN"], address=trafficAddress2, endpoint=ep, interEventDelay=1000, ) ) # Send 0 length OUT transaction session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep, endpointType="CONTROL", transType="OUT", dataLength=0, ) ) return session
def test_session(ep, address, bus_speed): ep_loopback = ep ep_loopback_kill = ep + 1 start_length = 200 end_length = 203 session = UsbSession(bus_speed=bus_speed, run_enumeration=False, device_address=address) # TODO randomise packet lengths and data for pktLength in range(start_length, end_length + 1): session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_loopback, endpointType="ISO", transType="OUT", dataLength=pktLength, )) # Was min IPG supported on iso loopback to not nak # This was 420, had to increase when moved to lib_xud (14.1.2 tools) # increased again from 437 when SETUP/OUT checking added # increaed from 477 when adding xs3 session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_loopback, endpointType="ISO", transType="IN", dataLength=pktLength, interEventDelay=498, )) pktLength = 10 # Loopback and die.. session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_loopback_kill, endpointType="ISO", transType="OUT", dataLength=pktLength, )) session.add_event( UsbTransaction( session, deviceAddress=address, endpointNumber=ep_loopback_kill, endpointType="ISO", transType="IN", dataLength=pktLength, )) return session