rbino / ems-qart

A Qt application to flash EMS 64M cartridges
GNU General Public License v3.0
181 stars 13 forks source link

Can't connect to cart unless I plug it in after starting the application #21

Open blaxpot opened 1 year ago

blaxpot commented 1 year ago

Under Linux, I can't get the cart to connect unless I plug it in after starting the application.

Here is some output from stdout/dmesg/udevadm when connecting the cart before starting the application, and clicking the UI to refresh the cart status after starting the application. I notice that the LED on the cartridge stays on and dmesg reports that the device is resetting:

# ems-qart
Failed to open device, libusb error:  LIBUSB_ERROR_IO
Failed to open device, libusb error:  LIBUSB_ERROR_IO
^C
# dmesg -w
[  917.906544] usb 1-4: new full-speed USB device number 26 using xhci_hcd
[  918.047810] usb 1-4: New USB device found, idVendor=4670, idProduct=9394, bcdDevice= 2.88
[  918.047825] usb 1-4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[  927.770374] usb 1-4: reset full-speed USB device number 26 using xhci_hcd
[  932.980448] usb 1-4: USB disconnect, device number 26
[  933.103135] usb 1-4: new full-speed USB device number 27 using xhci_hcd
[  933.243692] usb 1-4: New USB device found, idVendor=4670, idProduct=9394, bcdDevice= 2.88
[  933.243696] usb 1-4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[  948.250709] usb 1-4: reset full-speed USB device number 27 using xhci_hcd
[  953.460487] usb 1-4: USB disconnect, device number 27
[  953.583408] usb 1-4: new full-speed USB device number 28 using xhci_hcd
[  953.727466] usb 1-4: New USB device found, idVendor=4670, idProduct=9394, bcdDevice= 2.88
[  953.727483] usb 1-4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
# udevadm monitor
KERNEL[918.037801] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[918.040113] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[918.040407] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
KERNEL[918.040512] bind     /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [918.610442] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [918.614315] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [918.616546] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
UDEV  [918.626510] bind     /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[927.759624] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[927.901842] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[932.970029] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
KERNEL[932.971042] unbind   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[932.971158] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[933.233005] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[933.236615] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[933.236656] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
KERNEL[933.236683] bind     /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [933.240078] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [933.241674] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [933.242359] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
UDEV  [933.242913] unbind   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [933.243262] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [933.792445] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [933.795724] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [933.797914] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
UDEV  [933.809117] bind     /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[948.240015] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[948.381147] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[953.450027] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
KERNEL[953.451052] unbind   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[953.451159] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[953.717414] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[953.721511] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[953.721868] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
KERNEL[953.721986] bind     /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [953.725658] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [953.729103] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [953.731166] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
UDEV  [953.734892] unbind   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [953.736631] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [954.302511] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [954.303696] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [954.304451] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
UDEV  [954.307920] bind     /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)

Here is similar output if I start the application before plugging the cart in, then click the UI to refresh the cart status. I notice that the LED on the cart turns off once it's connected:

# ems-qart
Could not find device, is it plugged in?
^C
# dmesg -w
[ 1786.343312] usb 1-4: new full-speed USB device number 34 using xhci_hcd
[ 1786.484754] usb 1-4: New USB device found, idVendor=4670, idProduct=9394, bcdDevice= 2.88
[ 1786.484773] usb 1-4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
# udevadm monitor
KERNEL[1786.474917] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[1786.477861] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
KERNEL[1786.477961] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
KERNEL[1786.478032] bind     /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [1787.058236] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [1787.061997] change   /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
UDEV  [1787.064320] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0 (usb)
UDEV  [1787.075300] bind     /devices/pci0000:00/0000:00:14.0/usb1/1-4 (usb)
blaxpot commented 1 year ago

Also maybe worth mentioning that if I close the application after it says the cart is connected, then open it again, it fails to connect. In this case the LED on the cart stays off.

I need to unplug the cart, start the application, plug the cart in, then click refresh in the UI to get it connected again.

rbino commented 1 year ago

Hmm, strange, the USB resets seem to be hardware-related. Can you verify if the cart works with the original software (if that still works somewhere)? I don't have a cartridge near me so I can't check if the LED always turns on as soon as I attach it, I'll verify when I have one

blaxpot commented 1 year ago

Yes, it still works with the Windows software. Afaik it's behaved this way on Linux since I bought it several years ago. I tried to use this software / ems-flasher years ago and had similar issues with resets.

In fact it works okay with this software also, as long as I follow the procedure I described above I can flash ROMs and save files just fine.

blaxpot commented 1 year ago

It looks like maybe https://github.com/rbino/ems-qart/issues/18 might be the same issue / related.

I wonder if my workaround might help that person?