zyonee / opencbm

35 stars 12 forks source link

xum1541 on a pro micro - works only the first command. After that, led blinking. #1

Open cladybdi opened 7 years ago

cladybdi commented 7 years ago

Dear Bjorn,

I've a problem using a pro micro compatible board (avr32u4 based), loaded with xum1541-PROMICRO-v07.hex original file (not recompiled).

The first command I type, cbmctrl detect, works fine, finding a 1571 n. 8 device. After that, whatever command I try to type as second one leaves the device in a hang state, with led blinking. Checking with an oscilloscope, I find that both CLK and DATA still be held low (+5V level), without any kind of level transition.

The third command, sent after a CTRL^C, produce a similar behavior, reporting in addiction the following two information: [XUM1541] device capabilities 03 status 01 previous command was interrupted, resetting But in this case both the CLK and DATA goes up (0v Level) for a while.

A cbmctrl reset make the led stop blinking but after I'm still not able to make commands work properly. The only solution I found to make it works again is the reboot of the PC, but sometimes the error occurs also at first command sent. A powercycle of the 1571 doesn't solve the problem.

I don't understand very well linux device drivers but seems to be something related to the usb ones... don't you think? At regards, I googled to find something, but what I found is that the only problem could be caused by a wrong libusb library. But seems not to be the case:

root@clady-desktop:~# ldd /usr/local/lib/opencbm/plugin/libopencbm-xum1541.so linux-vdso.so.1 => (0x00007ffd1453c000) libusb-0.1.so.4 => /lib/x86_64-linux-gnu/libusb-0.1.so.4 (0x00007fb2fa621000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb2fa25a000) /lib64/ld-linux-x86-64.so.2 (0x00005611a197f000)

Following you can find the debug logs.

I don't know if could be interesting for you but I'm speaking, about that, directly with the original developers of opencbm, Nate and Spiro, inside a Google group https://groups.google.com/d/msg/zoomfloppy-users/LkQynrq0eSQ/h1IXdEdoGwAJ

I apologize if it's no longer interesting for you. Thanks anyway for the attention.

SECOND COMMAND root@clady-desktop:~# XUM1541_DEBUG=99 cbmctrl detect [XUM1541] scanning usb ... [XUM1541] scanning bus 009 [XUM1541] device 1d6b:0003 at 001 [XUM1541] scanning bus 008 [XUM1541] device 16d0:0504 at 006 [XUM1541] found xu/xum1541 version 0507 on bus 008, device 006 [XUM1541] xum1541 name: xum1541 floppy adapter (PROMICRO) [XUM1541] xum1541 serial number: 0 [XUM1541] firmware version 7, library version 7 [XUM1541] device capabilities 03 status 00 [XUM1541] [xum1541_init] No tape support. [XUM1541] write 16 2 bytes from address 0x7ffdb4e759b0 flags 2 [XUM1541] wrote 2 bytes [XUM1541] xum1541_wait_status checking for status

THIRD COMMAND root@clady-desktop:~# XUM1541_DEBUG=99 cbmctrl detect [XUM1541] scanning usb ... [XUM1541] scanning bus 009 [XUM1541] device 1d6b:0003 at 001 [XUM1541] scanning bus 008 [XUM1541] device 16d0:0504 at 006 [XUM1541] found xu/xum1541 version 0507 on bus 008, device 006 [XUM1541] xum1541 name: xum1541 floppy adapter (PROMICRO) [XUM1541] xum1541 serial number: 0 [XUM1541] firmware version 7, library version 7 [XUM1541] device capabilities 03 status 01 previous command was interrupted, resetting [XUM1541] [xum1541_init] No tape support. [XUM1541] write 16 2 bytes from address 0x7ffe21765ce0 flags 2 [XUM1541] wrote 2 bytes [XUM1541] xum1541_wait_status checking for status
modeler commented 5 years ago

I have exactly the same issue with my ZoomFloppy on both Windows 10 and Linux. It seems to be something to do with USB 3, if I do the same thing on my older laptop which has USB 2 ports, no issues.

git-minix commented 5 years ago

I have exactly the same issue with my ZoomFloppy on Linux Mint 18.3 and a ROG Crosshair VII Hero board with a Ryzen 2700x. I've tested it on the USB 2.0 ports of the board.

Any chance to get this bug solved after more than 2 years?

git-minix commented 5 years ago

some additional information to the reproducible issues. Issue persists if I replace the Floppy device (1581 , 1571), replace the IEC Bus cable, or replace the USB cable.

What works is d64copy (read and write with 1571) and imgcopy with (1581 , 1571).

cbmformat works, but after the format the zoomfloppy is blocking.

nibread with my 1571 failed (it worked fine in the past on Win 7 on my old PC)

$ nibread -D8 t4.nib

nibread - Commodore 1541/1571 disk image nibbler (C) Peter Rittwage and the rest of the C64 Preservation Project team http://c64preservation.com Revision 2014 - Built May 31 2019 11:52:18

Drive Version: 73,CBM DOS V3.0 1571,00,00 Drive type: 1571 Bumping... Initializing Sending 1571 SRQ support code... Uploading floppy-side code ($0454 bytes, $300-$754)...done. Starting custom drive code...Started! Testing communication...done. Passed initial communication test. Testing code upload...done. Passed code verification test. Passed all basic port checks.

USB error in xum1541_wait_status: LIBUSB_ERROR_IO USB error in xum1541_ioctl cmd: LIBUSB_ERROR_NO_DEVICE 18.0:

git-minix commented 5 years ago

and here the usbmon trace (to the first posting) $ cbmctrl status 8

ffff97fb27334780 574048555 S Ci:1:010:0 s 80 06 0300 0000 00ff 255 < ffff97fb27334780 574051265 C Ci:1:010:0 0 4 = 04030904 ffff97fb27334780 574051288 S Ci:1:010:0 s 80 06 0302 0409 00ff 255 < ffff97fb27334780 574064254 C Ci:1:010:0 0 72 = 48037800 75006d00 31003500 34003100 20006600 6c006f00 70007000 79002000 ffff97fb27334780 574064276 S Ci:1:010:0 s 80 06 0300 0000 00ff 255 < ffff97fb27334780 574068253 C Ci:1:010:0 0 4 = 04030904 ffff97fb27334780 574068271 S Ci:1:010:0 s 80 06 0303 0409 00ff 255 < ffff97fb27334780 574073255 C Ci:1:010:0 0 8 = 08033000 30003000 ffff97fb27334780 574073283 S Co:1:010:0 s 00 09 0001 0000 0000 0 ffff97fb27334780 574075253 C Co:1:010:0 0 0 ffff97fb27334780 574075299 S Ci:1:010:0 s a0 01 0000 0000 0008 8 < ffff97fb27334780 574079267 C Ci:1:010:0 0 8 = 081b0000 00000000 ffff97fb27334780 574079317 S Bo:1:010:4 -115 4 = 09130200 ffff97fb27334780 574079362 C Bo:1:010:4 0 4 > ffff97fb27334780 574079375 S Bo:1:010:4 -115 2 = 486f ffff97fb27334780 574079419 C Bo:1:010:4 0 2 > ffff97fb27334780 574079439 S Bi:1:010:3 -115 3 <

after here it hangs. In the first call of "cbmctrl status 8" (where all woŕks) this follows

ffff97fb3312bd40 755745983 C Bi:1:011:3 0 3 = 020000 ffff97fb3312bd40 755746083 S Co:1:011:0 s 20 03 0000 0000 0000 0 ffff97fb3312bd40 755746824 C Co:1:011:0 0 0

git-minix commented 5 years ago

what works fine with cbmctrl is download and upload - no issues after several executions

git-minix commented 5 years ago

UPDATE: I bought a xu1541 and compiled in opencbm the xu1541 plugin. No issue here - I can execute multiple detect and status commands without any issues.

My conclusion: The problem is not (directly) in opencbm or is a libusb version opencbm problem. The problem lies in the ZoomFloppy firmware, which crashes with simple commands such as cbmctrl detect and cbmctrl status [drive#] The problem also occurs with nibread, here probably caused by timing problems in the Zoomflopy firmware - presumably through the use of the new compiler avr-gcc 4.7.2.

git-minix commented 5 years ago

The only chance to get the root cause of the problems is debugging the xum1541 firmware - but: "To enable the debug build, uncomment the appropriate line in the Makefile. ... Debug printing via the UART is not supported on ZoomFloppy since it has to use this pin for the IEC DATA connection. Another route for debugging should be found for it." A working debugging solution is essential to get any progress here.

jtgans commented 4 years ago

Okay, so today I've run into this exact issue. Transcripts:

omoikane:~/Code/opencbm/xum1541$ XUM1541_DEBUG=99 cbmctrl dir 8
[XUM1541] scanning usb ...
[XUM1541] device 174c:3074
[XUM1541] device 0bda:0411
[XUM1541] device 0bda:0411
[XUM1541] device 174c:3074
[XUM1541] device 1d6b:0003
[XUM1541] device 0b05:1915
[XUM1541] device 0b05:1916
[XUM1541] device 174c:2074
[XUM1541] device b58e:9e84
[XUM1541] device 14cd:168a
[XUM1541] device 0403:6001
[XUM1541] device 16d0:0504
[XUM1541] found xu/xum1541 version 0508 on bus 11, device 43
[XUM1541] xum1541 name: xum1541 floppy adapter (PROMICRO)
[XUM1541] xum1541 serial number:   0
[XUM1541] firmware version 8, library version 8
[XUM1541] device capabilities 03 status 00
[XUM1541] [xum1541_init] No tape support.
[XUM1541] write 16 2 bytes from address 0x7ffe2b6b90c6 flags 2
[XUM1541] wrote 2 bytes (28 f0)
[XUM1541] xum1541_wait_status checking for status
[XUM1541] return val = 2
[XUM1541] wait done, extended status 2
[XUM1541] write done, got 2 bytes
[XUM1541] write 16 2 bytes from address 0x5609abd91510 flags 0
[XUM1541] wrote 2 bytes (24 30)
[XUM1541] xum1541_wait_status checking for status
[XUM1541] return val = 2
[XUM1541] wait done, extended status 2
[XUM1541] write done, got 2 bytes
[XUM1541] write 16 1 bytes from address 0x7ffe2b6b90c7 flags 2
[XUM1541] wrote 1 bytes (3f)
[XUM1541] xum1541_wait_status checking for status
[XUM1541] return val = 1
[XUM1541] wait done, extended status 1
[XUM1541] write done, got 1 bytes
[XUM1541] write 16 2 bytes from address 0x7ffe2b6b90c6 flags 3
[XUM1541] wrote 2 bytes (48 6f)
[XUM1541] xum1541_wait_status checking for status
[XUM1541] return val = 2
[XUM1541] wait done, extended status 2
[XUM1541] write done, got 2 bytes
[XUM1541] read 16 38 bytes to address 0x7ffe2b6b9150
[XUM1541] read 25 bytes (37 34 2c 44 52 49 56 45 ...)
[XUM1541] read done, got 25 bytes
[XUM1541] write 16 1 bytes from address 0x7ffe2b6b90c7 flags 2
[XUM1541] wrote 1 bytes (5f)
[XUM1541] xum1541_wait_status checking for status
[XUM1541] return val = 1
[XUM1541] wait done, extended status 1
[XUM1541] write done, got 1 bytes
74,drive not ready,00,00
[XUM1541] write 16 2 bytes from address 0x7ffe2b6b90f6 flags 2
[XUM1541] wrote 2 bytes (28 e0)
[XUM1541] xum1541_wait_status checking for status
[XUM1541] return val = 2
[XUM1541] wait done, extended status 2
[XUM1541] write done, got 2 bytes
[XUM1541] Closing USB link

Output from the xum1541's firmware v8, built from opencbm's trunk with DEBUG turned on and output sent to a 5v serial line:

usbconfchg
cmd 1 (-15)
bsti 3 0 1 1 1 1 0 0
bsto 4 4 1 1 1 0 1 0
wr:16 2
cwr 2, atn 2, talk 0
wrv=2
bsti 3 0 1 1 1 1 0 0
bsto 4 4 1 1 1 0 1 0
wr:16 2
cwr 2, atn 0, talk 0
wrv=2
bsti 3 0 1 1 1 1 0 0
bsto 4 4 1 1 1 0 1 0
wr:16 1
cwr 1, atn 2, talk 0
wrv=1
bsti 3 0 1 1 1 1 0 0
bsto 4 4 1 1 1 0 1 0
wr:16 2
cwr 2, atn 2, talk 1
wrv=2
bsti 3 0 1 1 1 1 0 0
bsto 4 4 1 1 1 0 1 0
rd:16 38
crd 38
rv=25
bsti 3 0 1 1 1 1 0 0
bsto 4 4 1 1 1 0 1 0
wr:16 1
cwr 1, atn 2, talk 0
wrv=1
bsti 3 0 1 1 1 1 0 0
bsto 4 4 1 1 1 0 1 0
wr:16 2
cwr 2, atn 2, talk 0
wrv=2
cmd 3 (-13)

This status command worked fine. Sadly, the second fails:

omoikane:~/Code/opencbm/xum1541$ XUM1541_DEBUG=99 cbmctrl dir 8
[XUM1541] scanning usb ...
[XUM1541] device 174c:3074
[XUM1541] device 0bda:0411
[XUM1541] device 0bda:0411
[XUM1541] device 174c:3074
[XUM1541] device 1d6b:0003
[XUM1541] device 0b05:1915
[XUM1541] device 0b05:1916
[XUM1541] device 174c:2074
[XUM1541] device b58e:9e84
[XUM1541] device 14cd:168a
[XUM1541] device 0403:6001
[XUM1541] device 16d0:0504
[XUM1541] found xu/xum1541 version 0508 on bus 11, device 43
[XUM1541] xum1541 name: xum1541 floppy adapter (PROMICRO)
[XUM1541] xum1541 serial number:   0
[XUM1541] firmware version 8, library version 8
[XUM1541] device capabilities 03 status 00
[XUM1541] [xum1541_init] No tape support.
[XUM1541] write 16 2 bytes from address 0x7fff841765c6 flags 2
[XUM1541] wrote 2 bytes (28 f0)
[XUM1541] xum1541_wait_status checking for status

And the debug output:

usbconfchg
cmd 1 (-15)
bsti 3 0 1 1 1 1 0 0
bsto 4 2 1 1 1 0 1 0
ERR: bulk cmd 40 not impl.
usbblk err
jtgans commented 4 years ago

For the life of me, I can't figure out what command "40" is, or where it's coming from. The source doesn't seem to have any XUM1541 #defines for this constant anywhere. All I can figure is that the firmware is mis-parsing a bulk transfer and this errant "40" is laying about somewhere in RAM.

Possibly a buffer underrun?

jtgans commented 4 years ago

The firmware was built from the opencbm master branch at https://github.com/opencbm/opencbm, commit 369f2a5795c3fdfa0fa249bf2ef982336c078685 and built using avr-gcc v5.4.0 on Ubuntu 20.04LTS with libusb2 0.3.4-0.1. USB transport type (v3 or v2) doesn't seem to matter, and using an external high powered hub also doesn't seem to help at all.

jtgans commented 4 years ago

cbmctrl reset seems to work because it's sent as a USB control message, not a bulk transfer in https://github.com/OpenCBM/OpenCBM/blob/369f2a5795c3fdfa0fa249bf2ef982336c078685/xum1541/commands.c#L638

jtgans commented 4 years ago

Aha, I see. It's 40 decimal, 28 hex. Seems to be coming from opencbm's xum1541 driver deliberately.

jtgans commented 4 years ago

Further details and a better diagnosis on this than what I've come up with so far are here: https://groups.google.com/forum/#!topic/zoomfloppy-users/tZ_9YudbH3E

sagacity commented 3 years ago

I'm running into the same issue, on two Windows10 machines and on a MacBook. I'm using the latest (0.4.99.103) version of OpenCBM. reset works, but all other commands hang on xum1541_wait_status checking for status.

Has there been any progress on this topic? Can I help, somehow?

nospam2000 commented 3 years ago

I have probably the same issue with my first 1541 (with ALPS drive and spring-load-mechanism). Even the first command fails, so I cannot read the version Here the command output of the first command after power on:

> XUM1541_DEBUG=99 cbmctrl status 8
[XUM1541] scanning usb ...
[XUM1541] device 16d0:0504
[XUM1541] found xu/xum1541 version 0508 on bus 1, device 13
[XUM1541] xum1541 name: xum1541 floppy adapter (PROMICRO)
[XUM1541] xum1541 serial number:   0
[XUM1541] firmware version 8, library version 8
[XUM1541] device capabilities 03 status 00
[XUM1541] [xum1541_init] No tape support.
[XUM1541] write 16 2 bytes from address 0x7ffeede782fe flags 3
[XUM1541] wrote 2 bytes (48 6f)
[XUM1541] xum1541_wait_status checking for status

My second 1541 (with the Mitsumi/Newtronics drive, reset status "73,cbm dos v2.6 1541,00,00") works without problems using the same XUM1541 Pro Micro adapter, same computer (iMac) and cbm tools, here it's output:

> XUM1541_DEBUG=99 cbmctrl status 8
[XUM1541] scanning usb ...
[XUM1541] device 16d0:0504
[XUM1541] found xu/xum1541 version 0508 on bus 1, device 13
[XUM1541] xum1541 name: xum1541 floppy adapter (PROMICRO)
[XUM1541] xum1541 serial number:   0
[XUM1541] firmware version 8, library version 8
[XUM1541] device capabilities 03 status 00
[XUM1541] [xum1541_init] No tape support.
[XUM1541] write 16 2 bytes from address 0x7ffeee10b2fe flags 3
[XUM1541] wrote 2 bytes (48 6f)
[XUM1541] xum1541_wait_status checking for status
[XUM1541] return val = 2
[XUM1541] wait done, extended status 2
[XUM1541] write done, got 2 bytes
[XUM1541] read 16 38 bytes to address 0x7ffeee10b350
[XUM1541] read 27 bytes (37 33 2c 43 42 4d 20 44 ...)
[XUM1541] read done, got 27 bytes
[XUM1541] write 16 1 bytes from address 0x7ffeee10b2ff flags 2
[XUM1541] wrote 1 bytes (5f)
[XUM1541] xum1541_wait_status checking for status
[XUM1541] return val = 1
[XUM1541] wait done, extended status 1
[XUM1541] write done, got 1 bytes
73,cbm dos v2.6 1541,00,00
[XUM1541] Closing USB link

I already use the V0.8 firmware from here which includes a timing fix. After recognizing, that the 0.8 firmware from here is not binary identical I also tried that, but with the same result.

I would guess there is another protocol/timing problem which depends on the 1541 firmware version.

Which quarz oscillator does the prebuild Pro Mini firmware expect? I have here 16MHz 3.3V Pro Micro boards but also 8MHz 5V boards. For the XUM1541 I was using a 16 MHz 3.3V board.

Michael