Author Topic: How does Host decide if connect MSD needs formating or the data on MSD is good?  (Read 15360 times)

nvd

  • Member
  • ***
  • Posts: 42
When Host detects the MSD device connected, it does many Read operations on different sectors on FAT.
Is it sufficient to look at MBR and Direcrtory info, to decide if the Device has good data? or are there more
consistency checks need to be done?

Is there a reference which i can go through?

Thanks
Nitin

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
If by consistency checks you mean checking to see that the device is operating properly, the host shouldn't have to do that. The host just needs to request whatever information it needs to access the device.

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
The host may not do any consistancy checks, its format detection may be as simple as looking for the magic value in sector zero (of a FAT volume).

I'm also wondring why you want to know. An MSC device should be just serving up blocks and not worrying about the content of the disk. The OS formatter should be responsible for laying down the logical information.

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
The Wikipedia article on FATs has some good information. http://en.wikipedia.org/wiki/File_Allocation_Table

nvd

  • Member
  • ***
  • Posts: 42
Probably I didn't put my question in proper context.

I am working on a Embedded USB host driver now. This host is supposed to support MSD class devices with BoT.
I also need to come up with the software stack (File system-FAT16/32  and application which uses it) on top of this USB host driver which can read/write files from the connected MSD.
No OS runs on my host.

So, now i think from Jan's reply it is clear that that the USB host driver doesn't need to do any consistency check.
Driver is only supposed to correctly read/write sectors on MSD, as desired by the Host application.

The consistency check (if required) should be part of the upper layer.

I collected few logs of the MSD device detection and transfers with the Windows host using Analyzer.
The logs show that the after enumeration, the host reads many sectors on the device not limiting (I am guessing here) to only MBR or Directory information.

Now I want to know, what information is required to be checked on the connected MSD, before it is safe to start read/write operations on it.
I guess reading First few sectors to know the FS on device and the directory information is must. Is there anything else that should/must be checked?

Thanks
Nitin

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
I don't know how much this is still true, but historically there have been many flash drives that function under Windows but don't comply fully with the USB mass-storage specs. So a host that emulates what Windows does when accessing drives can have a better chance of success with off-the-shelf flash drives.

For examples of misbehaving devices, see:

http://lvr.com/device_errors.htm

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Its been a while, but I maintained a DOS file system in the past. I don't think we did any consistency checks, just checked the magic values and assumed everything was fine.

If we wanted to check the consistency of a disk, we left that to a third party utility like Chkdsk or the Norton tools.

Nothing is required to be checked, you can check as much or as little as you feel is safe.

nvd

  • Member
  • ***
  • Posts: 42
Thank Jan,Barry!
 I will keep posting as I move forward with my Host development.