Re: Compact flash; is it hot plugable [conclusion]
From: Alpinekid (alpinekid_at_yahoo.com)
Date: Sat, 28 Feb 2004 04:17:10 GMT
> Alpinekid wrote:
>> I just started to play with compact flash. I have a small cheap
>> reader device on the USB bus to my linux machine.
> My environment: <OS>rh8.0 that uses the linux 2.4.18 kernel</OS>
> <device>A 9-in-1 usb card reader that has the "inland" logo on it,
> sold my microcenter in San Jose, CA. The label says it is model
> UCR-V10-SV-A060-M39l. The utility, usbdevice, reports is as being
> manufactured by the ICSI_1 corporation vendor number 0dda,
> product number 0102; revision number 52.7d
> The cf module has a label with PNY on it and is 8meg big.
> In my testing I used fdisk and the mkdosfs to setup the flash.
> I mounted it and wrote to it. All of this works fine.
> I then umounted the device and after a short while, many seconds, I
> would unplug and replug the CF.
> This seems to cause bad data to be written to the CF device.
> When I leave the device alone and shutdown power off and then restart
> the whole system it seems to be fine. I haven't got to trying to
> just unplug the reader at the USB cable.
> that is todays project.
> what I have learned so far:
> The CF should be able to be hot pluggable. It has the offset power pins
> to give the device a chance to do the right thing.
> I know that I must umount the device in the OS. I know that implies it
> is not really and truly hotplugable
> in the strictest sense
> but I understand the issues involved and I'm not bothered by that
> "legal" technicality.
> I can not do the unplugging too fast. It takes time for the CF to
> complete the write and to flush it to the real persistent storage.
> I understand that a CF does some work to actually store the data after
> writing. I'm assuming that this is happening in the time frame of micro
> seconds or even mill-seconds and not seconds.
> The CF is not really designed to be plugged and unplugged a lot.
> More later,
> Thanks for your help
I have finished testing my usb-compactflash configuration.
The test scenario was:
1) completely erase the CF by using badblocks
2) Use fdisk to partition the CF into a single partition
accepting the defaults. In my case the first cylinder was 2,
I still do not know why. The last cylinder was 992
3) put a dos file system on the partition using mkdosfs
4) I then used dd to make two files of the 1st 100 blocks of the CF,
50Kbytes. I used the /dev/sda and the /dev/sda1 devices. I just wanted
to see how much overhead there was.
The partition was offset from the start of the device by 8K, one
cylinder. This must be something from the fact
that it is being treated as a scsi disk drive.
5) I then calculated a MD5 secure checksum of the files.
This setup allows me to have known contents on the device and to check
if any bytes change.
The test goal is to verify that I can hotplug the USB reader device. I
will test the CF device itself later. Right now it is easy to just
unplug the reader from the USB and then unplug the CF.
The short answer: It works .... sort-of.
I get some interesting messages in dmesg, see below.
There seems to be some instability in the system somewhere.
Most ofter after I have hotpluged the reader the first attempt to use
the device fails.
fdisk reports that it can not read the device.
sometime the second attempt will work.
Once I completely shutdown and restarted before I could read the device.
I'm sure there is an easier way to reset the USB subsystem without power
cycling. After all its not windows. I just dont know it yet.
The good news is that I have not lost any data on the CF.
I'm beginning to think that the problems I was having with hotplugging
the CF itself may have been these 1st time instabilities.
Note: I have done all this without mounting the device. I'm just
checking access and contents of the device. The mount/umount
was just confusing the issue.
I unpluged and repluged the reader from the USB
without touching the CF card itself.
when I remount the device I get the following:
[fred@butler usb]$ mount /mnt/flash
/dev/sda1: Input/output error
From dmesg I get the following messages:
usb.c: USB disconnect on device 2
hub.c: USB new device connect on bus1/1, assigned device number 4
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 4
usb-uhci.c: interrupt, status 2, frame# 1587
SCSI disk error : host 1 channel 0 id 0 lun 0 return code = 8000002
Info fld=0x0, Current sd08:01: sense key None
I/O error: dev 08:01, sector 0
The device seems to work. I can read the directory
that was stored on the CF card before I unplugged and
replugged the USB CF reader.
I wish I know what the WARNING really met. There
seems to be some issue with timing on the first access.
I do have an old kernel and distribution. Its a 2.4.18 kernel and a RH
8.0 distribution. Its so last year:-)
At any rate, thanks for letting me chat. I'll let the world know
if I find any more interesting phenomenon that confuses me.
Soon I'm going to get the nerve to use one of my big CF from the camera
and try to get a picture off it.
Even in the open world of Linux there is a lot of unspoken
facts. Its nice to have a lot of folks to help.
What do the poor folks in the windows world do for help?
The system seems to work, I just have to learn how to work it.