m-labs / artiq

A leading-edge control system for quantum information experiments
https://m-labs.hk/artiq
GNU Lesser General Public License v3.0
435 stars 201 forks source link

MonInj can't handle >64 TTL channels #1727

Closed lriesebos closed 3 years ago

lriesebos commented 3 years ago

Bug Report

One-Line Summary

MonInj seems to break when we have more than 64 TTL channels to monitor, see https://forum.m-labs.hk/d/207-moninj-failure-and-disabled-outputs .

Issue Details

Steps to Reproduce

  1. Step 1. Flash gateware with more than 64 TTL channels (e.g. this json file with just over 64 TTL channels including the TTL channels used for the Urukul boards)
  2. Step 2. Start an artiq session
  3. Step 3. Get struct.error: unpack requires a buffer of 6 bytes

Expected Behavior

All TTL channels work fine with MonInj, both for Kasli and KC705.

Actual (undesired) Behavior

Both for Kasli and KC705, the error shown below occurs when starting the dashboard which initiates the MonInj connection. TTL outputs of the device become unreliable, rendering the coredevice useless. When MonInj is not started (i.e. using artiq_run), the gateware runs fine. I would expect this is some addressing limitation somewhere, causing a 6 bit address to overflow, but I am not familiar enough with the firmware/gateware to point out the exact lines.

[nix-shell:~/red-chamber]$ artiq_dashboard 

(process:23064): Gtk-WARNING **: 16:41:29.782: Locale not supported by C library.
    Using the fallback 'C' locale.
Gtk-Message: 16:41:29.844: Failed to load module "canberra-gtk-module"
Gtk-Message: 16:41:29.845: Failed to load module "canberra-gtk-module"
qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
No XVisualInfo for format QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
Falling back to using screens root_visual.
INFO:dashboard:root:ARTIQ dashboard 6.7602.ec4270fb connected to ::1
ERROR:dashboard:artiq.dashboard.moninj:lost connection to core device moninj
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/nix/store/35pv6fwf7xykj8dqym8p5rjp5jk0lxi6-python3-3.8.8-env/lib/python3.8/site-packages/artiq/dashboard/moninj.py", line 472, in stop
    await self.dm.close()
  File "/nix/store/35pv6fwf7xykj8dqym8p5rjp5jk0lxi6-python3-3.8.8-env/lib/python3.8/site-packages/artiq/dashboard/moninj.py", line 421, in close
    await asyncio.wait_for(self.core_connector_task, None)
  File "/nix/store/qy5z9gcld7dljm4i5hj3z8a9l6p37y81-python3-3.8.8/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
    return await fut
  File "/nix/store/35pv6fwf7xykj8dqym8p5rjp5jk0lxi6-python3-3.8.8-env/lib/python3.8/site-packages/artiq/dashboard/moninj.py", line 396, in core_connector
    await self.core_connection.close()
  File "/nix/store/35pv6fwf7xykj8dqym8p5rjp5jk0lxi6-python3-3.8.8-env/lib/python3.8/site-packages/artiq/coredevice/comm_moninj.py", line 54, in close
    await asyncio.wait_for(self._receive_task, None)
  File "/nix/store/qy5z9gcld7dljm4i5hj3z8a9l6p37y81-python3-3.8.8/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
    return await fut
  File "/nix/store/35pv6fwf7xykj8dqym8p5rjp5jk0lxi6-python3-3.8.8-env/lib/python3.8/site-packages/artiq/coredevice/comm_moninj.py", line 91, in _receive_cr
    channel, override, value = struct.unpack(
struct.error: unpack requires a buffer of 6 bytes

Your System (omit irrelevant parts)

sbourdeauducq commented 3 years ago

@SidaChen1999 Is there anything in the core device log (Kasli UART) when the problem occurs?

SidaChen1999 commented 3 years ago

Sometimes it will show an error ERROR(runtime::moninj): moninj aborted: unexpected end of stream as he suggested. But not always.