usb: storage: add quirks for CASIO calculators
Subsystems (2)
PATCH 1/1 usb: storage: add quirks for CASIO calculators
CASIO calculators using USB Mass Storage, bearing
product IDs 6102 and 6103, always report non-zero
dCSWDataResidue for requested transfer length
Quoted 1 line
4096 bytes while bCSWStatus == 0.
Information about an fx-CG50 (OS 3.11):
T: Bus=03 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#= 24 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=07cf ProdID=6102 Rev= 1.00 S: Manufacturer=CASIO MassStorage Device S: Product=CASIO MassStorage Device S: SerialNumber=0000xdPUBVUq C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
Information about an fx-9750GIII (OS 3.71):
T: Bus=03 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#= 25 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=07cf ProdID=6103 Rev= 1.00 S: Manufacturer=CASIO MassStorage Device S: Product=CASIO MassStorage Device S: SerialNumber=000000000001 C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/storage/unusual_devs.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/usb/storage/unusual_devs.h +19 -0
@@ -1168,6 +1168,25 @@ UNUSUAL_DEV( 0x07cf, 0x1167, 0x0100, 0x0100, "EX-N1 DigitalCamera", USB_SC_8070, USB_PR_DEVICE, NULL, 0), +/* +* CASIO calculators using UMS for "USB Key" mode always +* reports non-zero residue when the transfer length is larger +* than 4096 bytes. +* +* Reported by Thomas Touhey <[email protected]> +* and augmented by 0v0katai <[email protected]> +*/ +UNUSUAL_DEV (0x07cf ,0x6102 ,0x0100 ,0x0100 , +"Casio" , +"fx-CP400" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_IGNORE_RESIDUE ), +UNUSUAL_DEV (0x07cf ,0x6103 ,0x0100 ,0x0100 , +"Casio" , +"fx-CG50" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_IGNORE_RESIDUE ), +/* Submitted by Hartmut Wahl <[email protected]>*/ UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001, "Samsung",
Signature · 1 line
2.56.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 16 lines
CASIO calculators using USB Mass Storage, bearing
product IDs 6102 and 6103, always report non-zero
dCSWDataResidue for requested transfer lengthQuoted 1 line
4096 bytes while bCSWStatus == 0.
Information about an fx-CG50 (OS 3.11):
T: Bus=03 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#= 24 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=07cf ProdID=6102 Rev= 1.00 S: Manufacturer=CASIO MassStorage Device S: Product=CASIO MassStorage Device S: SerialNumber=0000xdPUBVUqC:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
[ ... ]
Quoted 5 lines
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0msCc stable <[email protected]>Signed-off-by Thomas Touhey <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Alan Stern
maintainerQuoted 4 lines · Thomas Touhey
CASIO calculators using USB Mass Storage, bearing
product IDs 6102 and 6103, always report non-zero
dCSWDataResidue for requested transfer lengthQuoted 1 line
4096 bytes while bCSWStatus == 0.
Do the calculators' Mass Storage interface work correctly when the quirk is present? In other words, is the non-zero dCSWDataResidue value simply wrong, or does it accurately reflect the fact that the device hasn't accepted anything beyond the first 4 KB of the data transfer?
If the latter is true then the quirk won't help. Instead it would be necessary to set the device's max_sectors value to 8, limiting individual transfers to 8 * 512 = 4096 bytes.
How much storage space do these devices provide?
Alan Stern
Quoted 64 lines
Information about an fx-CG50 (OS 3.11):
T: Bus=03 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#= 24 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=07cf ProdID=6102 Rev= 1.00 S: Manufacturer=CASIO MassStorage Device S: Product=CASIO MassStorage Device S: SerialNumber=0000xdPUBVUq C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0msInformation about an fx-9750GIII (OS 3.71):
T: Bus=03 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#= 25 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=07cf ProdID=6103 Rev= 1.00 S: Manufacturer=CASIO MassStorage Device S: Product=CASIO MassStorage Device S: SerialNumber=000000000001 C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0msCc stable <[email protected]>Signed-off-by Thomas Touhey <[email protected]>--- drivers/usb/storage/unusual_devs.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/usb/storage/unusual_devs.h +19
-0@@ -1168,6 +1168,25 @@ UNUSUAL_DEV( 0x07cf, 0x1167, 0x0100, 0x0100, "EX-N1 DigitalCamera", USB_SC_8070, USB_PR_DEVICE, NULL, 0), +/* +* CASIO calculators using UMS for "USB Key" mode always +* reports non-zero residue when the transfer length is larger +* than 4096 bytes. +* +* Reported by Thomas Touhey <[email protected]> +* and augmented by 0v0katai <[email protected]> +*/ +UNUSUAL_DEV (0x07cf ,0x6102 ,0x0100 ,0x0100 , +"Casio" , +"fx-CP400" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_IGNORE_RESIDUE ), +UNUSUAL_DEV (0x07cf ,0x6103 ,0x0100 ,0x0100 , +"Casio" , +"fx-CG50" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_IGNORE_RESIDUE ), +/* Submitted by Hartmut Wahl <[email protected]>*/ UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001, "Samsung",Signature · 1 line
2.56.0
Hey, thanks for your review and response!
Quoted 1 line
How much storage space do these devices provide?
Usually between 2MB to around 32MB (usually around 15-20MB on modern devices).
Quoted 4 lines
Do the calculators' Mass Storage interface work correctly when the quirk is present? In other words, is the non-zero dCSWDataResidue value simply wrong, or does it accurately reflect the fact that the device hasn't accepted anything beyond the first 4 KB of the data transfer?
It does, the dCSWDataResidue is wrong. We made two experiments, one on Linux and one on Win32.
0v0katai (quoted in the commit) tested this on Win32 with the default driver (USBSTOR), which seems to already ignore the CSW residue in this situation. They wrote a random 1M file it, read it back, then compared SHA256 hashes; they were identical. The writing part can be found in the attached "test-win32-write1M.pcapng" file.
I tested this on Linux by applying the quirk using "options usb-storage quirks=07cf:6102:r,07cf:6103:r" with modprobe, starting my Graph 90+E (French variant of the fx-CG50) in USB Key mode, writing the file ("test-linux-00-write4M" file), detaching, reattaching, reading the file ("test-linux-01-read4M"), then diff-ing both the source and the obtained file. Identical once again. :-)
Let me know if there are additional tests I should run!
Regards,
Thomas Touhey
P-S: Resending with all recipients this time, because I answered to you only by mistake. Sorry, new to the git review process by e-mail :-)
Quoted 84 lines · Alan Stern
Quoted 4 lines · Thomas Touhey
CASIO calculators using USB Mass Storage, bearing
product IDs 6102 and 6103, always report non-zero
dCSWDataResidue for requested transfer lengthQuoted 1 line
4096 bytes while bCSWStatus == 0.
Do the calculators' Mass Storage interface work correctly when the quirk is present? In other words, is the non-zero dCSWDataResidue value simply wrong, or does it accurately reflect the fact that the device hasn't accepted anything beyond the first 4 KB of the data transfer?
If the latter is true then the quirk won't help. Instead it would be necessary to set the device's
max_sectorsvalue to 8, limiting individual transfers to 8 * 512 = 4096 bytes.How much storage space do these devices provide?
Alan Stern
Quoted 64 lines
Information about an fx-CG50 (OS 3.11):
T: Bus=03 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#= 24 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=07cf ProdID=6102 Rev= 1.00 S: Manufacturer=CASIO MassStorage Device S: Product=CASIO MassStorage Device S: SerialNumber=0000xdPUBVUq C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0msInformation about an fx-9750GIII (OS 3.71):
T: Bus=03 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#= 25 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=07cf ProdID=6103 Rev= 1.00 S: Manufacturer=CASIO MassStorage Device S: Product=CASIO MassStorage Device S: SerialNumber=000000000001 C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0msCc stable <[email protected]>Signed-off-by Thomas Touhey <[email protected]>--- drivers/usb/storage/unusual_devs.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/usb/storage/unusual_devs.h +19
-1@@ -1168,6 +1168,25 @@ UNUSUAL_DEV( 0x07cf, 0x1167, 0x0100, 0x0100, "EX-N1 DigitalCamera", USB_SC_8070, USB_PR_DEVICE, NULL, 0), +/* +* CASIO calculators using UMS for "USB Key" mode always +* reports non-zero residue when the transfer length is larger +* than 4096 bytes. +* +* Reported by Thomas Touhey <[email protected]> +* and augmented by 0v0katai <[email protected]> +*/ +UNUSUAL_DEV (0x07cf ,0x6102 ,0x0100 ,0x0100 , +"Casio" , +"fx-CP400" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_IGNORE_RESIDUE ), +UNUSUAL_DEV (0x07cf ,0x6103 ,0x0100 ,0x0100 , +"Casio" , +"fx-CG50" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_IGNORE_RESIDUE ), +/* Submitted by Hartmut Wahl <[email protected]>*/ UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001, "Samsung", --2.56.0
A message that is not in the archive (sent off-list or not yet received): CAFCjBVE3zDqQnWdHmU6rwHHfRrS_p7r+PwsyXhbqVSEk4Vc-Lg@mail.gmail.com
Quoted 20 lines · Thomas Touhey
Hey, thanks for your review and response!
Quoted 1 line
How much storage space do these devices provide?
Usually between 2MB to around 32MB (usually around 15-20MB on modern devices).
Quoted 4 lines
Do the calculators' Mass Storage interface work correctly when the quirk is present? In other words, is the non-zero dCSWDataResidue value simply wrong, or does it accurately reflect the fact that the device hasn't accepted anything beyond the first 4 KB of the data transfer?
It does, the dCSWDataResidue is wrong. We made two experiments, one on Linux and one on Win32.
0v0katai (quoted in the commit) tested this on Win32 with the default driver (USBSTOR), which seems to already ignore the CSW residue in this situation. They wrote a random 1M file it, read it back, then compared SHA256 hashes; they were identical. The writing part can be found in the attached "test-win32-write1M.pcapng" file.
Quoted 8 lines
I tested this on Linux by applying the quirk using "options usb-storage quirks=07cf:6102:r,07cf:6103:r" with modprobe, starting my Graph 90+E (French variant of the fx-CG50) in USB Key mode, writing the file ("test-linux-00-write4M" file), detaching, reattaching, reading the file ("test-linux-01-read4M"), then diff-ing both the source and the obtained file. Identical once again. :-)
Let me know if there are additional tests I should run!
No, that's fine. I just wanted to make sure you had considered this possibility.
As for the patch:
Alan Stern
Tested on a Casio fx-9750GIII running OS 3.71 (USB ID 07cf:6103).
With US_FL_IGNORE_RESIDUE enabled through the usb-storage runtime quirks parameter, 8 KiB reads and a 1 MiB write/readback test passed. The readback was verified using SHA-256 and cmp after disconnecting and reconnecting the calculator.