Can you use a USB floppy drive with RISC OS on a Pi?
Jeffrey Lee (213) 6048 posts |
And the underlying SCSI commands? (The UFI commands are basically SCSI commands) You’ve written a program that can read (and write?) USB floppies by sending UFI commands straight to the USB stack. UFI commands are just SCSI commands. What happens if you send the UFI/SCSI commands to SCSI_Op instead? |
Jon Abbott (1421) 2651 posts |
SCSIFS_DiscOp does now access the floppy, but doesn’t return, requiring a reboot to recover. From my experience over the past few days, that’s a result of not calling REQUEST_SENSE around a READ. If you don’t do that, the drive just rejects commands. I’ve not looked at the linux driver yet, but to get it working I coded DiscOp 1 as:
The first REQUEST_SENSE puts the drive into a known state and without the others the drive dies.
I know all that, I just don’t know how to call SCSI_Op as it’s not documented on the wiki. I did try doing a Lookup for it in StrongHelp which just crashes on a Pi3 (v2.90-1 from PackMan). Anyhow, I have now eventually found the help file in question which doesn’t really help me. How do I change a DeviceFS_CallDevice call to SCSI_Op? If StrongHelp is to be believed, I need to implement call back code, wrap the command in a SCSI control block and it wants an “access key” – whatever that is! I’m using Colin’s code from the front page:
If you want to translate that into a SCSI_Op equivalent, I’ll certainly try it. I have to say that the documentation on the wiki for both USB and SCSI is woefully inadequate, these must have been implemented by RISCOS devs – didn’t they consider documenting their creations? Why for example does DeviceFS_CallDevice need bit 31 set – there’s no mention of it in the documentation. |
Colin (478) 2433 posts |
Last try – scsisoftusbd3. I don’t hold out much hope for it I’d need a floppy drive here to investigate further. I’ve bracketed all commands, except the sense command, with a sense command with 0 parameter length. Note any changes are only affecting UFI devices. |
Jon Abbott (1421) 2651 posts |
Just reports “The disc drive is empty”
REQUEST SENSE should be 18, bytes 2, 12 and13 hold the result. |
Steve Pampling (1551) 8170 posts |
Most curious. I’m not sure whether what I’m seeing is an artefact of Jon’s quoting, a problem with Reporter, or a fault in the driver you’re working on but notice in the long lines that get wrapped after column 79 and character 80 is missing. As a regular user of remote SSH sessions onto switches I tend to set the line length to 132
|
Jeffrey Lee (213) 6048 posts |
There’s no direct equivalent, since SCSI_Op accepts both the SCSI command ptr and the data buffer ptr in the same call. Callbacks and access keys are optional (IIRC SCSIFS will use an access key to lock access to a device if it’s able to successfully mount it). Here are a couple of examples: SCSI_READ = 1<<24 SCSI_WRITE = 1<<25 DEF PROCrequestsense cmd%!0=(lun%<<13)+3 cmd%!4=18 cmd%!8=0 SYS "SCSI_Op",device%+SCSI_READ+(1<<27),12,cmd%,buf%,18 ENDPROC DEF PROCtestunitready cmd%!0=(lun%<<13) cmd%!4=0 cmd%!12=0 SYS "SCSI_Op",device%+(1<<27),12,cmd% ENDPROC *devices outputs device IDs in the form bus:dev.lun, which corresponds to a device% value of dev+(bus<<3)+(lun<<5)
There’s some (probably partially outdated) SCSI docs in CVS: https://www.riscosopen.org/viewer/view/apache/RiscOS/Sources/HWSupport/SCSI/SCSIDriver/doc/Spec?rev=1.2 USB docs are also there (IIRC these used to be on iyonix.com back in the day): https://www.riscosopen.org/viewer/view/mixed/RiscOS/Sources/HWSupport/USB/NetBSD/build/Doc/USB?rev=1.5
IIRC bit 31 is for “driver specific operations”, e.g. operation 5+(1<<31) on a USB device may do something completely different to 5+(1<<31) on a UART device. |
Raik (463) 2061 posts |
Have try. The screenshot of USBInfo looks very promising. |
Colin (478) 2433 posts |
scsisoftusbd3 turned out to be a load of rubbish I used MODE_SENSE instead of REQUEST_SENSE and did it wrong anyway.
I think it’s a problem with the reporter part of RISC OS’s DebugLib. That does the 80 char wrap. I have no problem with reporter with my own library.
Your SCSI commands as you have written them may well work however they are not standard SCSI commands. The standard length of those scsi commands would have a command length of 6. Commands sent by scsiswitch use the standard lengths.
NetBSD gets the status with a REQUEST_SENSE command if it is a CBI device which doesn’t have an interrupt end point by responding to STATUS_CMD_UNKNOWN when the transfer completes in umass_scsipi_cb in umass_scsipi.c. We don’t appear to do that. For a CBI device with an interrupt endpoint the interrupt endpoint is opened with the ‘bulk’ special field which I think means it will fail to open as the endpoint it specifies isn’t bulk. I think it should work with SCSISoftUSB but will require some work – you really need a device available to test. |
Steve Pampling (1551) 8170 posts |
I’m not sure whether what I’m seeing is an artefact of Jon’s quoting, a problem with Reporter, or a fault in the driver you’re working on That would be the 10 year old stuff here and here you’re referring to then? |
Colin (478) 2433 posts |
The first one. debug_reporter_output discards a character when it wraps. |
Martin Avison (27) 1494 posts |
Reporter itself is not limited to only 80 characters – it copes with lines up to 255 long. |
Jon Abbott (1421) 2651 posts |
Did you want me to test a corrected version? scsisoftusbd2 was pretty close as *. scsi::0.$ did attempt to read the floppy. |
Colin (478) 2433 posts |
scsisoftusbd2 just forced the scsi commands to be 12 bytes long – it didn’t use any sense commands. I can’t see an easy fix and scsisoftusb has done a good job at mangling the NetBSD code – which is easier to understand. So I’ll send for a USB floppy drive and a floppy disc and see what I can do. I appear to have thrown all of my floppy discs out – who knew I’d find a use for one. Unfortunately it will take about a week to arrive so nothing will happen quickly. |
Colin (478) 2433 posts |
My floppy drive just arrived but the bad news – or is it good – is that it appears to be working fine with scsisoftusbd2. The icon is on the iconbar and clicking on it gives the error ’Disc drive is empty" as expected.
I’m just waiting for a floppy to arrive to test if it is working with a disc in. |
Jon Abbott (1421) 2651 posts |
What’s different between your USB Descriptor and mine? Accessing mine with SCSIsoftUSBD2 just results in a locked machine. |
Colin (478) 2433 posts |
Nothing really.
|
Will Ling (519) 98 posts |
Just to pop another in the mix… I dug out an old usb floppy drive to try with scsisoftusbd2
|
Colin (478) 2433 posts |
If anyone is feeling experimental would they like to try this usbstack. It replaces the current USB stack. The version of SCSISoftUSB it contains is much closer to the NetBSD version – it doesn’t use devicefs to transfer data. However SCSISoftUSB is not complete it doesn’t support scatter lists – the netbsd code doesn’t support them. This means it fails to write depending on whether the front end uses scatter lists or not. I have a FATFS pen drive that reads and writes but a card reader with a filecore sdcard gives an error when writing – I think *save uses scatterlists. It would be interesting to know if your floppy disc works as the code is close to the original NetBSD code. If you want to test it I’d take the precaution of having no USB drives connected to the computer just in case there is a problem. So if using a pi just use sdfs as the disc, run the application then plug the disc drive in. I’d use a spare disc as well just in case. Just run the application. It copies the modules to RAMFS before loading them. I’ve tested it on a Pi B+ and ArmX6. |
Will Ling (519) 98 posts |
Well, that worked! Not an extensive test, but it appears to read, and write. It opened up under fat32fs and I could read the text file I put on the disc from Windows when I was checking it worked earlier. |
Raik (463) 2061 posts |
Wow!!! If I try a old TopModel (1,6M) or !Killer (800kB) disc it gives a “Target Error – Medium Error”. Edit: Is also working with my Titanium if I remove the “EHCI” and “kick_” lines from !run. |
Colin (478) 2433 posts |
Good. It only took me a couple of days, while waiting for the drive, to make the SCSISoftUSB module from scratch with the only changes to the NetBSD code – other than forcing UFI commands to 12 bytes for risc os – being due to compiler differences – bodes well for porting other netbsd usb stuff. At least it shows that the problem is in the ROOL SCSISoftUSB module and it should be able to read DOS discs. I’ll see if I can get it to work when the disc arrives. |
Jon Abbott (1421) 2651 posts |
With this stack it does now display my floppy correctly in *devices but I don’t get an icon for the drive. The keyboard on my pi-top also becomes unusable, with major key repeat issues. It appears to be dropping or missing both up and down key data. Keyboard issue aside, I’d say it’s progress given the current USB stack can’t ID my floppy. |
Colin (478) 2433 posts |
Ah ok this was an old project that I dusted off and it didn’t have the repeating keyboard fix in it. Try usbstack2. This version has scatterlists working. I have a suspicion that your device is working like an 8:4:1 device where it uses a REQUEST_SENSE command instead of the interrupt endpoint which it is supposed to use. If you get any Reporter output can you send it to me to the address on this page. |
Jon Abbott (1421) 2651 posts |
Keyboard is no different with usbstack2. I’ve not yet managed to get debug output from a *. to work, the machine keeps locking up with the new USB stack. Between the keyboard issues and locking, a *. reported the drive as empty, although the *devices output clearly shows it has a 720KB floppy inserted.
The data is coming in via interrupt endpoint, from my limited understanding of the UFI spec. the REQUEST_SENSE is required after all commands to both check the result and to clear any errors. If the sense value not zero the device is to reject commands until its cleared. When I read that bit (dont have it to hand, but probably in the REQUEST SENSE section), I added REQUEST_SENSE around all commands and all the previous issues I noted went away.
Getting it from my Pi to eMail involves three computers…so I’ll attach it direct from my pi-top instead… *Devices
Inserting the device:
Debug output from *devices
|
Colin (478) 2433 posts |
If you look at your debug output output from *devices
inserting the device
The scsi_entry_point_handler is the entry point for SCSI requests – the numbers in brackets are line number and time in cs. When you insert the device the INQUIRY command fails waiting in umass_setup_transfer for 1 second before a cancel command (reason=6) is sent from SCSI. When you do *devices the INQUIRY command succeeds. So in usbstack3 I’ve cleared the endpoint stall on attachment. I’ve also disabled the loading of DWCDriver in the !run file – it should work without it. |