Skip to contentSkip to conversation

Problem: non-SDHC 2GB SD cards are unreadable

DISCUSSION Alexia Death 8 participants 14 messages Apr 13, 2008 – Apr 16, 2008

lore
Share & tools
lore
#0 lore raw

Hello.

Ive come across a very annoying problem with these cards and the fat filesystem driver.

I recently bought 2 2GB Silicon Power SD cards for my camera(they were the smallest available in the store and had reasonable price). Camera was quite happy with them but I ran unexpectedly into trouble when trying to put the images to my Linux PC.

It failed to read the cards and seemed to assume that my 2GB cards are actually 4GB O_o. I put one card back in to the camera and it was fine. I put the card in my photobank and it had no problem coping the images to its internal disk.

Well, that was lame. Simple dumb devices can read the cards but not Linux. So I looked into dmesg to see whats up.

Heres what I saw:

[1193601.137141] sd 2:0:0:0: [sdb] Attached SCSI disk
[1193601.137256] sd 2:0:0:0: Attached scsi generic sg2 type 0
[1193601.156992] sd 2:0:0:1: [sdc] Attached SCSI removable disk
[1193601.157115] sd 2:0:0:1: Attached scsi generic sg3 type 0
[1193601.198450] sd 2:0:0:2: [sdd] 1992704 1024-byte hardware sectors (2041 
MB)
[1193601.206767] sd 2:0:0:2: [sdd] Write Protect is off
[1193601.206785] sd 2:0:0:2: [sdd] Mode Sense: 03 00 00 00
[1193601.206793] sd 2:0:0:2: [sdd] Assuming drive cache: write through
[1193601.227218] sd 2:0:0:2: [sdd] 1992704 1024-byte hardware sectors (2041 
MB)
[1193601.236730] sd 2:0:0:2: [sdd] Write Protect is off
[1193601.236745] sd 2:0:0:2: [sdd] Mode Sense: 03 00 00 00
[1193601.236752] sd 2:0:0:2: [sdd] Assuming drive cache: write through
[1193601.236768]  sdd: sdd1
[1193601.248543]  sdd: p1 exceeds device capacity
[1193601.248740] sd 2:0:0:2: [sdd] Attached SCSI removable disk
[1193601.248853] sd 2:0:0:2: Attached scsi generic sg4 type 0
[1193601.258517] sd 2:0:0:3: [sde] Attached SCSI removable disk
[1193601.258639] sd 2:0:0:3: Attached scsi generic sg5 type 0
[1193602.633223] attempt to access beyond end of device
[1193602.633239] sdd: rw=0, want=7970672, limit=3985408
[1193602.633248] Buffer I/O error on device sdd1, logical block 3985088
[1193602.633260] attempt to access beyond end of device
[1193602.633266] sdd: rw=0, want=7970674, limit=3985408
[1193602.633272] Buffer I/O error on device sdd1, logical block 3985089

,,, and so on.

Trying to mount it results in:

[1194411.241063] FAT: logical sector size too small for device (logical sector 

size = 512)

As I understand the above, my cards report hardware sector size 1024-bytes and FAT logical block size of 512 but the FAT driver insists on using the hardware block size over the logical one... witch obviously results in failure.

http://en.wikipedia.org/wiki/Secure_Digital_card#Compatibility_issues_with_2_GB_and_larger_cards
tells me that this is the result of a hack due to the nature of 2GB cards.

Are there any plans to make 2GB SD cards work? I doubt I'm the only one with such 2GB SD cards(and a camera) and Id be royally screwed right about now if I did not have my photobank and an option to use it as a copy over point...

--
Best, Alexia

PS. Please CC me, I am not subscribed...

#1 lore raw
Quoted 6 lines

http://en.wikipedia.org/wiki/Secure_Digital_card#Compatibility_issues_with_2_GB_and_larger_cards
tells me that this is the result of a hack due to the nature of 2GB cards.

Are there any plans to make 2GB SD cards work? I doubt I'm the only one with such 2GB SD cards(and a camera) and Id be royally screwed right about now if I did not have my photobank and an option to use it as a copy over point...

Mounting it with -o loop ought to work around this if the problem is purely media block size. That is probably the right answer anyway but the solution ought to be managed more elegantly for the user.

Alan

#2 lore raw
Quoted 4 lines · On Sunday 13 April 2008 23:42:11 Alan Cox wrote:
Quoted 4 lines

http://en.wikipedia.org/wiki/Secure_Digital_card#Compatibility_issues_wit
h_2_GB_and_larger_cards tells me that this is the result of a hack due to the nature of 2GB cards.

Quoted 8 lines
Quoted 4 lines

Are there any plans to make 2GB SD cards work? I doubt I'm the only one with such 2GB SD cards(and a camera) and Id be royally screwed right about now if I did not have my photobank and an option to use it as a copy over point...

Mounting it with -o loop ought to work around this if the problem is purely media block size. That is probably the right answer anyway but the solution ought to be managed more elegantly for the user.

It seems the issue is a bit more complicated. Tried it with -o loop. It did mount but the contents was binary garbage... Strangely different binary garbage at each mount...

--
Best,
Alexia

#3 lore raw
In reply to Alexia Death
Quoted 9 lines · Alexia Death
[1193601.236730] sd 2:0:0:2: [sdd] Write Protect is off
[1193601.236745] sd 2:0:0:2: [sdd] Mode Sense: 03 00 00 00
[1193601.236752] sd 2:0:0:2: [sdd] Assuming drive cache: write through
[1193601.236768]  sdd: sdd1
[1193601.248543]  sdd: p1 exceeds device capacity
[1193601.248740] sd 2:0:0:2: [sdd] Attached SCSI removable disk
[1193601.248853] sd 2:0:0:2: Attached scsi generic sg4 type 0
[1193601.258517] sd 2:0:0:3: [sde] Attached SCSI removable disk
[1193601.258639] sd 2:0:0:3: Attached scsi generic sg5 type 0

You are apparently using a SCSI device, so I assume it is a USB based card reader, not a directly attached SD/MMC reader.

My guess is that the problem is the way that the card is presented to the USB mass storage driver by the reader. Generally, there is no problem with 2GB SD cards, so it would be good if you can try a different card reader with your cards.

Also, please supply the "lsusb -v" output for the card reader.

	Arnd <><
#4 lore raw
Quoted 2 lines · On Monday 14 April 2008 03:45:32 you wrote:

You are apparently using a SCSI device, so I assume it is a USB based card reader, not a directly attached SD/MMC reader.

You are correct.

Quoted 2 lines

My guess is that the problem is the way that the card is presented to the USB mass storage driver by the reader.

Yes, Ive come to a conclusion that because reader does not do anything about the speciality of the 2GB cards they wont be readable because Linux usb storage does not know about them either.

Quoted 1 line

Generally, there is no problem with 2GB SD cards,

It seems that in case of non-USB card readers, ie the ones built-in to laptops the speciality is taken care of by the reader driver...

Quoted 1 line

so it would be good if you can try a different card reader with your cards.

I have no different reader to try but I did try connecting the camera. It works.

[1249166.105850] scsi 6:0:0:0: Direct-Access     PENTAX   DIGITAL_CAMERA   
1.20 PQ: 0 ANSI: 0
[1249166.117440] sd 6:0:0:0: [sdb] 3985409 512-byte hardware sectors (2041 MB)
[1249166.122416] sd 6:0:0:0: [sdb] Write Protect is off
[1249166.122431] sd 6:0:0:0: [sdb] Mode Sense: 0a 0a 00 01
[1249166.122438] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[1249166.137400] sd 6:0:0:0: [sdb] 3985409 512-byte hardware sectors (2041 MB)
[1249166.142390] sd 6:0:0:0: [sdb] Write Protect is off
[1249166.142406] sd 6:0:0:0: [sdb] Mode Sense: 0a 0a 00 01
[1249166.142412] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[1249166.142430]  sdb: sdb1
[1249166.176608] sd 6:0:0:0: [sdb] Attached SCSI removable disk
[1249166.176735] sd 6:0:0:0: Attached scsi generic sg2 type 0

As you can see the camera rewrites the hw sectors description and presents it quite differently than the card presents itself. Strangely enough my cardreader/photobank itself has no problem copying from these cards but still presents the cards to the pc "as is".

Quoted 4 lines · On Monday 14 April 2008 02:28:13 Gene Heskett wrote:

I ask because my own camera with much smaller cards, has a similar problem, and everything Just Works(TM) if I plug the usb cable directly into the camera and mount it as a vfat file system. I haven't had the memory card out of my camera in a couple of years.

That is interesting. I did not know there could be problems with smaller cards. However keeping the cards in the camera is not solution for me. I have a card reader to avoid tying the camera down for the copy duration.

Quoted 1 line · On Monday 14 April 2008 03:45:32 you wrote:

Also, please supply the "lsusb -v" output for the card reader.

My cardreader/photobank is of pretty average sort:

Bus 001 Device 015: ID 0424:223a Standard Microsystems Corp. 8-in-1 Card Reader
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00

  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0424 Standard Microsystems Corp.
  idProduct          0x223a 8-in-1 Card Reader
  bcdDevice            2.23
  iManufacturer           1 DCB
  iProduct                2     DCB201
  iSerial                 3 000111111111
  bNumConfigurations      1

Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 39
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 96mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk (Zip)
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
** UNRECOGNIZED: 07 21 07 e8 03 fe ff
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00

  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0

bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0000
(Bus Powered)

Bus 001 Device 001: ID 0000:0000
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10

  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         0 Full speed (or root) hub
  bMaxPacketSize0        64
  idVendor           0x0000
  idProduct          0x0000
  bcdDevice            2.06
  iManufacturer           3 Linux 2.6.24-8-generic uhci_hcd
  iProduct                2 UHCI Host Controller
  iSerial                 1 0000:00:1d.0
  bNumConfigurations      1

Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 25
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 0mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 9 Hub
bInterfaceSubClass 0 Unused
bInterfaceProtocol 0 Full speed (or root) hub
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0002 1x 2 bytes
bInterval 255
Hub Descriptor:
bLength 9
bDescriptorType 41
nNbrPorts 2
wHubCharacteristic 0x000a
No power switching (usb 1.0)
Per-port overcurrent protection
bPwrOn2PwrGood 1 * 2 milli seconds
bHubContrCurrent 0 milli Ampere
DeviceRemovable 0x00
PortPwrCtrlMask 0xff
Hub Port Status:
Port 1: 0000.0103 power enable connect
Port 2: 0000.0100 power
Device Status: 0x0003
Self Powered
Remote Wakeup Enabled

#5 lore raw
In reply to Alexia Death
Quoted 11 lines · Alexia Death
Quoted 2 lines · On Monday 14 April 2008 03:45:32 you wrote:

My guess is that the problem is the way that the card is presented to the USB mass storage driver by the reader.

Yes, Ive come to a conclusion that because reader does not do anything about the speciality of the 2GB cards they wont be readable because Linux usb storage does not know about them either.

Quoted 1 line

Generally, there is no problem with 2GB SD cards,

It seems that in case of non-USB card readers, ie the ones built-in to laptops the speciality is taken care of by the reader driver...

Did you find any code in there that made you think so? Generally, the mmc layer doesn't do much about the layout of the cards but merely represents what is there.

On the contrary, the USB card readers go through a lot of effort to make the card look like a SCSI device, and many of these implementations are buggy in some way. SD cards are defined to have 512 byte sectors, while USB mass storage can theoretically have a different sector size. Of course any other size than 512 bytes is likely to break some code, which you have experienced.

Note that Linux has another driver for USB mass storage, the "ub" block driver which does not go through the SCSI software layer. It would be good if you could check whether that has the same problem. Also, it might be interesting to see if another operating system has the same problem with the combination of your card and reader.

If it works on another OS, it's probably fixable on Linux, but the effort may be significant.

Quoted 17 lines
Quoted 1 line

so it would be good if you can try a different card reader with your cards.

I have no different reader to try but I did try connecting the camera. It works.

[1249166.105850] scsi 6:0:0:0: Direct-Access     PENTAX   DIGITAL_CAMERA   
1.20 PQ: 0 ANSI: 0
[1249166.117440] sd 6:0:0:0: [sdb] 3985409 512-byte hardware sectors (2041 MB)
[1249166.122416] sd 6:0:0:0: [sdb] Write Protect is off
[1249166.122431] sd 6:0:0:0: [sdb] Mode Sense: 0a 0a 00 01
[1249166.122438] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[1249166.137400] sd 6:0:0:0: [sdb] 3985409 512-byte hardware sectors (2041 MB)
[1249166.142390] sd 6:0:0:0: [sdb] Write Protect is off
[1249166.142406] sd 6:0:0:0: [sdb] Mode Sense: 0a 0a 00 01
[1249166.142412] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[1249166.142430]  sdb: sdb1
[1249166.176608] sd 6:0:0:0: [sdb] Attached SCSI removable disk
[1249166.176735] sd 6:0:0:0: Attached scsi generic sg2 type 0
Quoted 4 lines

As you can see the camera rewrites the hw sectors description and presents it quite differently than the card presents itself. Strangely enough my cardreader/photobank itself has no problem copying from these cards but still presents the cards to the pc "as is".

The camera is just another implementation of a USB mass storage device on top of an SD card. My guess remains that this one works correctly, while your standalone reader has a quirk that prevents it from being used on Linux.

	Arnd <><
#13 lore raw
In reply to Alexia Death
Quoted 2 lines · Alexia Death

It seems this issue is a "wont fix" even tho its quite common since its a
reader problem.

There are a *LOT* of cardreaders that have a problem with larger cards. See the table on http://www.hjreggel.net/cardspeed/special-sd.html and notice the enormous amount of red colored cells (meaning failure)

Read the rest of http://www.hjreggel.net/cardspeed/ for a lot more info about cards and card readers.

Wander.

#6 lore raw
In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

On the contrary, the USB card readers go through a lot of effort to make the card look like a SCSI device, and many of these implementations are buggy in some way. SD cards are defined to have 512 byte sectors, while USB mass storage can theoretically have a different sector size. Of course any other size than 512 bytes is likely to break some code, which you have experienced.

Actually, I believe 2 GB (non-SDHC) *only* have 1024 byte sectors.

-hpa

#7 lore raw
Quoted 2 lines · H. Peter Anvin

Actually, I believe 2 GB (non-SDHC) *only* have 1024 byte sectors.

Right, I found out the same after reading the page pointed out by Wander, and the older specifications. SD 2.0 SDHC requires 512 byte sectors now, but the older standard is still used for 2GB cards.

Most USB card readers seem to translate the native sector size to 512 byte sectors internally, and we've seen that the linux SCSI disk driver together with the USB mass storage driver doesn't cope well with the device Alexia is using.

	Arnd <><
#11 lore raw
In reply to Alexia Death
Quoted 3 lines · Alexia Death

Yes, Ive come to a conclusion that because reader does not do anything about the speciality of the 2GB cards they wont be readable because Linux usb storage does not know about them either.

The reader in my wife's old laptop (Compaq R3240) would not work with 1gB or 2GB cards, but would work with 512MB and smaller. It would detect the card but have random contents displayed and certainly wouldn't read. An SD reader in a USB printer on the other hand connected to the same machine read all the cards fine. There certainly are some misdesigned SD readers out there that fail with larger cards due to having made invalid assumptions.

Sounds like that particular readers is junk and belongs in the trash. :)

Signature · 1 line
Len Sorensen
#8 lore raw
In reply to H. Peter Anvin
Quoted 11 lines · H. Peter Anvin
Quoted 8 lines · Arnd Bergmann

On the contrary, the USB card readers go through a lot of effort to make the card look like a SCSI device, and many of these implementations are buggy in some way. SD cards are defined to have 512 byte sectors, while USB mass storage can theoretically have a different sector size. Of course any other size than 512 bytes is likely to break some code, which you have experienced.

Actually, I believe 2 GB (non-SDHC) *only* have 1024 byte sectors.

The most easily available SD documentation is the SanDisk product manual (1.9) and the cards it documents only support 512-byte blocks ("The default block length is as specified in the CSD (512 bytes). A set block length of less than 512 bytes will cause a write error. The only valid set block length is 512 bytes. CMD16 is not manditory if the default is accepted.")

Somewhat unsurprisingly, not all manufacturers took into account the possibility that a card would use a different block size than what all of the cards of the time used.

-Daniel
*This .sig left intentionally blank*

#9 lore raw
Quoted 3 lines · Daniel Barkalow

Somewhat unsurprisingly, not all manufacturers took into account the possibility that a card would use a different block size than what all of the cards of the time used.

What's really kind of pathetic is that designed, in 2000, a that broke at 1 GB...

-hpa

#10 lore raw
Quoted 8 lines · H. Peter Anvin
Quoted 3 lines · Daniel Barkalow

Somewhat unsurprisingly, not all manufacturers took into account the possibility that a card would use a different block size than what all of the cards of the time used.

What's really kind of pathetic is that designed, in 2000, a that broke at 1 GB...

-hpa

I have used 2 different 2GB cards, one works with a reader that it came with, the other won't work with the reader the other card came with, I did not try the switch the other way, but it appears that the cheap readers included with the cards are not interchangeable as they cut too many corners in the testing to make them nice and cheap.

Roger