greatscottgadgets/luna

gateware.usb.usb2.device tests failing

miek opened this issue · 1 comments

miek commented

The usb2.device simulation tests have recently started failing:

$ python -m luna.gateware.usb.usb2.device
EFF
======================================================================
ERROR: test_enumeration (__main__.FullDeviceTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 40, in run_test
    self.simulate(vcd_suffix=process_function.__name__)
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 141, in simulate
    self.sim.run()
  File "/home/mike/projects/amaranth/amaranth/sim/core.py", line 177, in run
    while self.advance():
  File "/home/mike/projects/amaranth/amaranth/sim/core.py", line 168, in advance
    return self._engine.advance()
  File "/home/mike/projects/amaranth/amaranth/sim/pysim.py", line 319, in advance
    self._step()
  File "/home/mike/projects/amaranth/amaranth/sim/pysim.py", line 308, in _step
    process.run()
  File "/home/mike/projects/amaranth/amaranth/sim/_pycoro.py", line 125, in run
    self.coroutine.throw(exn)
  File "/home/mike/projects/amaranth/amaranth/sim/_pycoro.py", line 64, in run
    command = self.coroutine.send(response)
  File "/home/mike/projects/amaranth/amaranth/sim/core.py", line 91, in wrapper
    yield from process()
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 35, in test_case
    yield from process_function(self)
  File "/home/mike/projects/luna/luna/gateware/usb/usb2/device.py", line 514, in test_enumeration
    handshake, data = yield from self.get_descriptor(DescriptorTypes.DEVICE, length=18)
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 512, in get_descriptor
    descriptor = yield from self.control_request_in(0x80,
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 428, in control_request_in
    yield from self.setup_transaction(request_type, request, value, index, length)
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 391, in setup_transaction
    response = yield from self.out_transaction(
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 230, in out_transaction
    data = yield from self.receive_packet()
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 182, in receive_packet
    yield from self.wait_until(self.utmi.tx_valid, timeout=timeout)
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 174, in wait_until
    raise RuntimeError(f"Timeout waiting for '{strobe.name}' to go high!")
RuntimeError: Timeout waiting for 'tx_valid' to go high!

======================================================================
FAIL: test_descriptor_zlp (__main__.LongDescriptorTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 40, in run_test
    self.simulate(vcd_suffix=process_function.__name__)
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 141, in simulate
    self.sim.run()
  File "/home/mike/projects/amaranth/amaranth/sim/core.py", line 177, in run
    while self.advance():
  File "/home/mike/projects/amaranth/amaranth/sim/core.py", line 168, in advance
    return self._engine.advance()
  File "/home/mike/projects/amaranth/amaranth/sim/pysim.py", line 319, in advance
    self._step()
  File "/home/mike/projects/amaranth/amaranth/sim/pysim.py", line 308, in _step
    process.run()
  File "/home/mike/projects/amaranth/amaranth/sim/_pycoro.py", line 125, in run
    self.coroutine.throw(exn)
  File "/home/mike/projects/amaranth/amaranth/sim/_pycoro.py", line 64, in run
    command = self.coroutine.send(response)
  File "/home/mike/projects/amaranth/amaranth/sim/core.py", line 91, in wrapper
    yield from process()
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 35, in test_case
    yield from process_function(self)
  File "/home/mike/projects/luna/luna/gateware/usb/usb2/device.py", line 622, in test_descriptor_zlp
    handshake, data = yield from self.get_descriptor(DescriptorTypes.CONFIGURATION, length=request_length)
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 512, in get_descriptor
    descriptor = yield from self.control_request_in(0x80,
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 434, in control_request_in
    pid, packet = yield from self.in_transfer(data_pid=USBPacketID.DATA1)
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 350, in in_transfer
    pid, packet = yield from self.in_transaction(
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 323, in in_transaction
    self.assertEqual(pid, data_pid.byte())
AssertionError: 75 != <USBPacketID.128|64|DATA0|ACK|OUT: 195>

======================================================================
FAIL: test_long_descriptor (__main__.LongDescriptorTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 40, in run_test
    self.simulate(vcd_suffix=process_function.__name__)
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 141, in simulate
    self.sim.run()
  File "/home/mike/projects/amaranth/amaranth/sim/core.py", line 177, in run
    while self.advance():
  File "/home/mike/projects/amaranth/amaranth/sim/core.py", line 168, in advance
    return self._engine.advance()
  File "/home/mike/projects/amaranth/amaranth/sim/pysim.py", line 319, in advance
    self._step()
  File "/home/mike/projects/amaranth/amaranth/sim/pysim.py", line 308, in _step
    process.run()
  File "/home/mike/projects/amaranth/amaranth/sim/_pycoro.py", line 125, in run
    self.coroutine.throw(exn)
  File "/home/mike/projects/amaranth/amaranth/sim/_pycoro.py", line 64, in run
    command = self.coroutine.send(response)
  File "/home/mike/projects/amaranth/amaranth/sim/core.py", line 91, in wrapper
    yield from process()
  File "/home/mike/projects/luna/luna/gateware/test/utils.py", line 35, in test_case
    yield from process_function(self)
  File "/home/mike/projects/luna/luna/gateware/usb/usb2/device.py", line 604, in test_long_descriptor
    handshake, data = yield from self.get_descriptor(DescriptorTypes.CONFIGURATION, length=len(descriptor))
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 512, in get_descriptor
    descriptor = yield from self.control_request_in(0x80,
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 434, in control_request_in
    pid, packet = yield from self.in_transfer(data_pid=USBPacketID.DATA1)
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 350, in in_transfer
    pid, packet = yield from self.in_transaction(
  File "/home/mike/projects/luna/luna/gateware/test/usb2.py", line 323, in in_transaction
    self.assertEqual(pid, data_pid.byte())
AssertionError: 75 != <USBPacketID.128|64|DATA0|ACK|OUT: 195>

----------------------------------------------------------------------
Ran 3 tests in 0.700s

FAILED (failures=2, errors=1)

It seems to be caused by an upstream change in Amaranth, doing a bisect between v0.3 and main points to 58a0c6827953480ef435a37620decf7a9c0e6c88 as the first failing commit.

That commit was part of amaranth-lang/amaranth#739, so we may want to raise a note there.