RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account
Forums → General →

Can you use a USB floppy drive with RISC OS on a Pi?

Subscribe to Can you use a USB floppy drive with RISC OS on a Pi? 120 posts, 16 voices

Posts per page:

Pages: 1 2 3 4 5

 
Jan 25, 2019 8:42pm
Avatar Matt Price (2343) 71 posts

I know it would never read Filecore discs, but might be an interesting use for FAT32 discs

 
Jan 25, 2019 9:31pm
Avatar Dave Higton (1515) 2375 posts

A floppy disc from the PC world would be formatted as FAT12.

 
Jan 25, 2019 11:44pm
Avatar Jon Abbott (1421) 2138 posts

Being USB won’t they fall under SCSIFS and be considered a very small HD? Don’t they need to be handled by ADFS to be considered a floppy? Or does SCSIFS support SCSI based floppies?

If they do end up as small HD, its probably possible to write an ADFS shim Module to translate DiscOp/MiscOp into their SCSI equivalent.

I’d say its probably worth trying. I don’t think I have a USB floppy drive to try it myself.

 
Jan 25, 2019 11:55pm
Avatar Rick Murray (539) 10559 posts

It’ll tell you “drive empty” – so maybe SCSI doesn’t understand floppies?

Funny thing is, though, that the drive loads a fair amount of data prior to the disc being “visible”, and when in use the lamp blinks like a harddisc, so I’m wondering if the drive isn’t handling the disc stuff itself and presenting itself as some weird sort of removable media device?

 
Jan 26, 2019 5:24am
Avatar Chris Mahoney (1684) 1687 posts

Most USB floppy drives are funny beasts; apparently they handle a lot of the “disc control” stuff themselves instead of leaving it up to the OS. A typical USB drive connected to a Windows PC will not read Microsoft’s 1.7 MB “DMF” format, likewise a drive connected to a Mac will not read Apple’s 800 kB or 1.6 MB formats. Presumably Acorn’s similar formats would run into the same issue.

Theoretically DOSFS should work, but perhaps it doesn’t have the necessary code to handle a USB drive.

 
Jan 26, 2019 7:28am
Avatar Jon Abbott (1421) 2138 posts

I’m wondering if the drive isn’t handling the disc stuff itself and presenting itself as some weird sort of removable media device?

Think of them as the hardware equivalent of ADFS, you’d need a FileCore level driver to interact with them as the FDC in the USB drive isn’t directly accessible. However, it might be possible to add a USB driver into my ADFS shim Module that comes with ADFFS for RO5, providing support for at least 1.44MB. Other sizes would be dependent on what the floppy drive supports.

I suspect there’s either a floppy standard in the USB 1.1 specs, or they present themselves as a generic removable media of fixed size, based on what the FDC initially identified the floppy size as.

What would be more useful is a Kryoflux driver. I’ve just re-raised my request for the Kryflux driver source.

 
Jan 26, 2019 1:47pm
Avatar Jon Abbott (1421) 2138 posts

Managed to get my hands on a USB floppy today, the USB descriptor is:

=============================================
 Device USB5
=============================================
:  0 :  2 : total size of ServiceCall block : 91
:  2 :  2 : offset to descriptor list       : 0x20
:  4 : 20 : name                            : USB5
: 24 :  1 : bus number                      : 1
: 25 :  1 : device address                  : 5
: 26 :  1 : host address                    : 2
: 27 :  1 : host port                       : 5
: 28 :  1 : speed                           : 2 full speed
---------------------------------------------

 Standard Device Descriptor
+----+----+---------------------------+----------+------------+
:Off :Sz  :Name                       :Value hex :Value dec   :
+----+----+---------------------------+----------+------------+
:  0 :  1 : bLength                   :       12 :         18 : 
:  1 :  1 : bDescriptorType           :        1 :          1 : 
:  2 :  2 : bcdUSB                    :      110 :        272 : 
:  4 :  1 : bDeviceClass              :        0 :          0 : 
:  5 :  1 : bDeviceSubClass           :        0 :          0 : 
:  6 :  1 : bDeviceProtocol           :        0 :          0 : 
:  7 :  1 : bMaxPacketSize            :        8 :          8 : 
:  8 :  2 : idVendor                  :      57b :       1403 : 
: 10 :  2 : idProduct                 :        0 :          0 : 
: 12 :  2 : bcdDevice                 :      601 :       1537 : 
: 14 :  1 : iManufacturer             :        1 :          1 : 'Y-E DATA'
: 15 :  1 : iProduct                  :        2 :          2 : 'USB Floppy Drive'
: 16 :  1 : iSerialNumber             :        0 :          0 : ''
: 17 :  1 : bNumConfigurations        :        1 :          1 : 
+----+----+---------------------------+----------+------------+

 Standard Configuration Descriptor
+----+----+---------------------------+----------+------------+
:Off :Sz  :Name                       :Value hex :Value dec   :
+----+----+---------------------------+----------+------------+
:  0 :  1 : bLength                   :        9 :          9 : 
:  1 :  1 : bDescriptorType           :        2 :          2 : 
:  2 :  2 : wTotalLength              :       27 :         39 : 
:  4 :  1 : bNumInterfaces            :        1 :          1 : 
:  5 :  1 : bConfigurationValue       :        1 :          1 : 
:  6 :  1 : iConfiguration            :        0 :          0 : ''
:  7 :  1 : bmAttributes              :       80 :        128 : (bit7) USB 1.0 bus powered (bit6) Bus powered, (bit5) No remote wakeup
:  8 :  1 : bMaxPower                 :       fa :        250 : 500mA
+----+----+---------------------------+----------+------------+

     Standard Interface Descriptor
    +----+----+---------------------------+----------+------------+
    :Off :Sz  :Name                       :Value hex :Value dec   :
    +----+----+---------------------------+----------+------------+
    :  0 :  1 : bLength                   :        9 :          9 : 
    :  1 :  1 : bDescriptorType           :        4 :          4 : 
    :  2 :  1 : bInterfaceNumber          :        0 :          0 : 
    :  3 :  1 : bAlternateSetting         :        0 :          0 : 
    :  4 :  1 : bNumEndpoints             :        3 :          3 : 
    :  5 :  1 : bInterfaceClass           :        8 :          8 : Mass Storage
    :  6 :  1 : bInterfaceSubClass        :        4 :          4 : 
    :  7 :  1 : bInterfaceProtocol        :        0 :          0 : 
    :  8 :  1 : iInterface                :        4 :          4 : 'FLOPPY'
    +----+----+---------------------------+----------+------------+

         Standard Endpoint Descriptor
        +----+----+---------------------------+----------+------------+
        :Off :Sz  :Name                       :Value hex :Value dec   :
        +----+----+---------------------------+----------+------------+
        :  0 :  1 : bLength                   :        7 :          7 : 
        :  1 :  1 : bDescriptorType           :        5 :          5 : 
        :  2 :  1 : bEndpointAddress          :       81 :        129 : Endpoint 1 - IN
        :  3 :  1 : bmAttributes              :        2 :          2 : Bulk
        :  4 :  2 : wMaxPacketSize            :       40 :         64 : 1 x 64 byte max packets
        :  6 :  1 : bInterval                 :        0 :          0 : 
        +----+----+---------------------------+----------+------------+

         Standard Endpoint Descriptor
        +----+----+---------------------------+----------+------------+
        :Off :Sz  :Name                       :Value hex :Value dec   :
        +----+----+---------------------------+----------+------------+
        :  0 :  1 : bLength                   :        7 :          7 : 
        :  1 :  1 : bDescriptorType           :        5 :          5 : 
        :  2 :  1 : bEndpointAddress          :        2 :          2 : Endpoint 2 - OUT
        :  3 :  1 : bmAttributes              :        2 :          2 : Bulk
        :  4 :  2 : wMaxPacketSize            :       40 :         64 : 1 x 64 byte max packets
        :  6 :  1 : bInterval                 :        0 :          0 : 
        +----+----+---------------------------+----------+------------+

         Standard Endpoint Descriptor
        +----+----+---------------------------+----------+------------+
        :Off :Sz  :Name                       :Value hex :Value dec   :
        +----+----+---------------------------+----------+------------+
        :  0 :  1 : bLength                   :        7 :          7 : 
        :  1 :  1 : bDescriptorType           :        5 :          5 : 
        :  2 :  1 : bEndpointAddress          :       83 :        131 : Endpoint 3 - IN
        :  3 :  1 : bmAttributes              :        3 :          3 : Interrupt
        :  4 :  2 : wMaxPacketSize            :        2 :          2 : 1 x 2 byte max packets
        :  6 :  1 : bInterval                 :       10 :         16 : 
        +----+----+---------------------------+----------+------------+
 
Jan 26, 2019 3:05pm
Avatar Colin (478) 2294 posts

I don’t think so.

The device uses UFI commands (bInterfaceSubClass=4) as opposed to SCSI commands (bInterfaceSubClass=6) and SCSISoftUSB only registers with SCSI. It does look as though it will try to attach the device. Does scsi:devices show it?

 
Jan 26, 2019 3:18pm
Avatar Steffen Huber (91) 1643 posts

It is a really long time since I read that USB class stuff, but I seem to remember that RISC OS mass storage driver (USBSoftSCSI) supports only the HD/CD/DVD typical classes (class-subclass-protocol) like 8-6-50 (SCSI passthrough) and 8-2-50 (MMC), both “bulk only” (i.e. both commands and data are transfered via bulk endpoints).

Jon’s device above reports 8-4-0, which is UFI Control/Bulk/Interrupt – confusingly, I cannot see the typical control endpoint for it…I don’t think there is any code in RISC OS that would translate typical floppy track/sector addressing into logical blocks as expected by SCSIFS to then put ’em through to DOSFS.

Didn’t Dave Higton have a pseudo filing system for Fat32 for USB sticks some long time ago? Maybe this could be souped up easily. Or have a small utility that transfers the whole floppy image, which should then be easily readable with DOSFS image fs capability.

 
Jan 26, 2019 3:47pm
Avatar Jon Abbott (1421) 2138 posts

SCSISoftUSB is taking over the device, so I can’t connect to the endpoint without RMKilling SCSISoftUSB. It appears in scsi:devices as 0:0:0 with no details, so SCSISoftUSB doesn’t know what to do with it.

 
Jan 26, 2019 4:13pm
Avatar Steffen Huber (91) 1643 posts

IIRC, USBSoftSCSI only creates the necessary DeviceFS handles to communicate with the endpoints, but does not do anything with them unless it actively tries to access the device (which it won’t do, because it does not recognize it as Bulk-Only). I think you can just scan for those handles and “steal” them to communicate yourself with the device.

Sometimes, it is a good thing that file system handles are global resources in RISC OS world…

 
Jan 26, 2019 4:37pm
Avatar Colin (478) 2294 posts

It looks like, in SCSISoftUSB, the NetBSD part matches the device – because NETBSD can handle it – but the riscos part only does SCSI I think it should fail to match if it is not SCSI. If you have !closefiles you can check if any USB endpoints are open when you plug it in. I think it could be sending SCSI commands to a UFI device and getting nowhere.

 
Jan 26, 2019 9:20pm
Avatar Dave Higton (1515) 2375 posts

Didn’t Dave Higton have a pseudo filing system for Fat32 for USB sticks some long time ago? Maybe this could be souped up easily.

I did have a sort-of filing system (read only) for FAT32 and FAT16, I think, but it was all predicated on being able to read any chosen block from the device. This was a long time ago, so please forgive the fact that I can no longer remember much about it (it was soon obsolete because an enormously more capable alternative came along).

The first challenge is to be able to read blocks off any device, and I don’t think anyone has done that yet for a USB floppy.

How much use would it be anyway, to be able to read data from a DOS-formatted floppy disc?

 
Jan 26, 2019 9:48pm
Avatar Jon Abbott (1421) 2138 posts

If you have !closefiles you can check if any USB endpoints are open when you plug it in.

The device is being opened by USBSoftSCSI (I think) for R/W:

devices#endpoint1;interface0;alternate0;bulk;size32768:$.USB5 (R)
devices#endpoint2;interface0;alternate0;bulk;size32768:$.USB5 (W)

Any clues on how to send a command to it? I’ve tried sending ADSC blocks with UFI commands to the endpoint2 file handle, which doesn’t work.

 
Jan 27, 2019 6:26am
Avatar Tristan M. (2946) 1046 posts

How much use would it be anyway, to be able to read data from a DOS-formatted floppy disc?

I would have another way to back up a subset of my floppies. Maybe run some in DOSBox. Besides that, no idea.

 
Jan 27, 2019 8:26am
Avatar Jon Abbott (1421) 2138 posts

It would be very useful if you’re trying to transfer stuff to/from non-networked RiscPC/Arc. At the minute, I have to FTP the files to a RiscPC, then copy onto floppy for use on Arc’s.

 
Jan 27, 2019 9:48am
Avatar Colin Ferris (399) 1058 posts

Someone was doing a Arc floppy interface – but it seemed to have stalled :-(

Being able to use a DOS floppy to transfer info to a CNC machine – would be nice.

 
Jan 27, 2019 9:54am
Avatar Colin Ferris (399) 1058 posts

As a note – someone was asking about SCSI interface for the new machines – is there a USB > SCSI interface?

 
Jan 27, 2019 10:02am
Avatar Colin (478) 2294 posts

which doesn’t work

I think there are 2 options.

1) Get the LIMITED_SCOPE flag enabled in scsisoftusb.h.global then you can mess about with the UFI interface as much as you like as it won’t recognise a UFI device.

2) Modify scsisoftusb by translating the SCSI commands to UFI commands so that the floppy is handled by SCSIFS.

 
Jan 27, 2019 10:58am
Avatar Jon Abbott (1421) 2138 posts

Modify scsisoftusb by translating the SCSI commands to UFI commands so that the floppy is handled by SCSIFS

According to the spec “The UFI Command Set is based on the SCSI-2 and SFF-8070i command set”, so SCSISoftUSB may not need major changes to support floppies.

I’ve tried RMKilling SCSISoftUSB and still can’t get the floppy to respond, so I’m not sure I’m sending the commands to it correctly. Essentially I’m sending TEST UNIT READY via an ADSC block to endpoint2 and waiting for the response on endpoint1, which never appears.

 
Jan 27, 2019 11:59am
Avatar Colin (478) 2294 posts

You send the ADSC over the control interface (usb_msc_cbi_1.1.pdf 4.1) – below is a BASIC function to do a control request. Any responses are via the bulk IN endpoint – I think.

DEF PROCusb_control(usb$,bmRType%,bRequest%,wValue%,wIndex%,wLength%,buf%)
  SYS "XDeviceFS_CallDevice",(1<<31),usb$+CHR$(0),,(bmRType% OR (bRequest%<<8) OR (wValue%<<16)),(wIndex% OR (wLength%<<16)),buf%, 0 
ENDPROC

I should add it would be used something like

PROCusb_control("USB8", &21, 0, 0, 0, 12, buf%)

where buf% points to the 12 byte UFI command.

 
Jan 27, 2019 12:33pm
Avatar Steffen Huber (91) 1643 posts

I’ve tried RMKilling SCSISoftUSB and still can’t get the floppy to respond, so I’m not sure I’m sending the commands to it correctly. Essentially I’m sending TEST UNIT READY via an ADSC block to endpoint2 and waiting for the response on endpoint1, which never appears.

That would only work for “bulk only transport” devices. Floppy is Control/Bulk/Interrupt, so you drive it with commads via the Control endpoint and read the response data via the bulk endpoint.

 
Jan 27, 2019 3:40pm
Avatar Jon Abbott (1421) 2138 posts

You send the ADSC over the control interface (usb_msc_cbi_1.1.pdf 4.1) – below is a BASIC function to do a control request.

Thanks, the DeviceFS_CallDevice 0 documentation bares very little relation to reality. Ironically, I did originally code it that way but was confused by the documentation.

Using your example, I do now have it reading sectors so now need to figure out:

  1. how to scan the USB devices to find the floppy
  2. how to find the file handles of the endpoints that SCSISoftUSB has opened for the device
 
Jan 27, 2019 4:11pm
Avatar Colin (478) 2294 posts

2) Get SCSISoftUSB changed – or change it and supply a softload version. You never know what SCSISoftUSB is doing to the endpoints.

1)

SYS "OS_ServiceCall",1,&D2,0 TO,,usb_list%

The format of the returned usb_list is given here it’s a list of USBServiceAnswer structures containing the usb descriptors for each device. When you have finished with the list you need to delete it with.

DEF PROCusb_delete_list
    LOCAL item%
    WHILE usb_list% <> 0
        item%=!usb_list%
        SYS "OS_Module",7,,usb_list%
        usb_list%=item%
    ENDWHILE
ENDPROC

You need to traverse the usbdescriptors looking for an interface descriptor with bInterfaceClass=8, bInterfaceSubClass=4 – names are from my usbdescriptors program which you showed output from earlier. All the values in that output come from the USBServiceAnswer list. Note that all the descriptors have length values so you can work out where the next descriptor in the list is. Once you find the USBServiceCall containing the UFI interface USBServiceCall.devname is the USB device.

I could knock up a BASIC program to find the device if you would like?

 
Jan 27, 2019 5:16pm
Avatar Colin (478) 2294 posts

This will list all UFI interfaces on all devices

usb_list% = 0
ON ERROR PROCerror
SYS "OS_ServiceCall",1,&D2,0 TO,,usb_list%

iface% = 0
item% = usb_list%
WHILE item%
    index% = 1
    svc% = item% + 4
    REPEAT
        iface% = FNusb_findInterface(svc%, 8,4, -1, index%)
        index% += 1
        IF iface% <> 0 THEN
            SYS "XOS_GenerateError",svc%+4 TO usb$
            PRINT usb$;" bInterfaceNumber=";iface%?2;" bAlternateSetting=";iface%?3
        ENDIF
    UNTIL iface% = 0
    item% =!item%
ENDWHILE

PROCusb_delete_list
END

DEF PROCusb_delete_list
    LOCAL item%
    WHILE usb_list% <> 0
        item%=!usb_list%
        SYS "OS_Module",7,,usb_list%
        usb_list%=item%
    ENDWHILE
ENDPROC

DEF FNusb_findInterface(svc%,class%,subClass%,protocol%,index%)
    LOCAL desc%,prevIface%
    IF index% <= 0 THEN = 0
    desc% = svc% + (svc%!2 AND &FFFF)
    prevIface% = -1
    WHILE desc%?0 <> 0
        IF FNusb_isInterfaceClass(desc%,class%,subClass%,protocol%) AND prevIface% <> desc%?2 THEN
            index% -= 1
            prevIface%=desc%?2
            IF index%=0 :=desc%
        ENDIF
        desc% += desc%?0
    ENDWHILE
= 0

DEF FNusb_isInterfaceClass(iface%,class%,subClass%,protocol%)
  IF iface% = 0 THEN = FALSE
= (iface%?1 = 4 AND (iface%?5 = class% OR class% = -1) AND (iface%?6 = subClass% OR subClass% = -1) AND (iface%?7 = protocol% OR protocol% = -1))


DEF PROCerror
    ON ERROR OFF
    PROCusb_delete_list
    PRINT REPORT$;" at line ";ERL
END

Next page

Pages: 1 2 3 4 5

Reply

To post replies, please first log in.

Forums → General →

Search forums

Social

Follow us on and

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

RISC OS IPR

RISC OS is an Open Source operating system owned by RISC OS Developments Ltd and licensed primarily under the Apache 2.0 license.

Description

General discussions.

Voices

  • Matt Price (2343)
  • Dave Higton (1515)
  • Jon Abbott (1421)
  • Rick Murray (539)
  • Chris Mahoney (1684)
  • Colin (478)
  • Steffen Huber (91)
  • Tristan M. (2946)
  • Colin Ferris (399)

Options

  • Forums
  • Login
Site design © RISC OS Open Limited 2018 except where indicated
The RISC OS Open Beast theme is based on Beast's default layout

Valid XHTML 1.0  |  Valid CSS

Powered by Beast © 2006 Josh Goebel and Rick Olson
This site runs on Rails

Hosted by Arachsys