Forums

FAT16 boot record error

Started by johsey November 16, 2011
Hello,

I'm developing a "USB card reader" which must read a 512 bytes non-writable
memory and display it as a file.

Since the 512 bytes memory contains only data which have to be stored in
the file, I have to define in firmware the entire FAT as a big array. Thus,
no possibility to format the media using for example Windows.

I'm encountering problems when I connect my device to the host PC: Windows
7 asks if I want to format the removable device. As I understood and as I
saw with my USB analyzer, the OS doesn't seem to understand the FAT boot
sector. I based on the USB Mass Storage book from Jan Axelson.

Do someone have some ideas about what fields in the boot sector can
generate such an error? Do you know where I can find some documentation on
how Windows set the boot sector?

Thank you,
Johann	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
On 2011-11-16 10:17, johsey wrote:
> Hello, > > I'm developing a "USB card reader" which must read a 512 bytes non-writable > memory and display it as a file. > > Since the 512 bytes memory contains only data which have to be stored in > the file, I have to define in firmware the entire FAT as a big array. Thus, > no possibility to format the media using for example Windows. > > I'm encountering problems when I connect my device to the host PC: Windows > 7 asks if I want to format the removable device. As I understood and as I > saw with my USB analyzer, the OS doesn't seem to understand the FAT boot > sector. I based on the USB Mass Storage book from Jan Axelson. > > Do someone have some ideas about what fields in the boot sector can > generate such an error? Do you know where I can find some documentation on > how Windows set the boot sector?
Windows 7 requires that a FAT block device contains at least 8 sectors. Define your device as having 8 sectors and return contant value (0s) whenever Windows attempts to read any sector above the implmented ones.
Bernard wrote:
> On 2011-11-16 10:17, johsey wrote: >> I'm encountering problems when I connect my device to the host PC: >> Windows >> 7 asks if I want to format the removable device. As I understood and as I >> saw with my USB analyzer, the OS doesn't seem to understand the FAT boot >> sector. I based on the USB Mass Storage book from Jan Axelson.
[...]
> Windows 7 requires that a FAT block device contains at least 8 sectors. > Define your device as having 8 sectors and return contant value (0s) > whenever Windows attempts to read any sector above the implmented ones.
Actually, FAT16 requires the device to have at least 4096 clusters (otherwise it'd be FAT12), so the device better had a few more sectors than that (boot record, FAT, root directory, plus data clusters). Stefan
On Wed, 16 Nov 2011 19:34:41 +0100, Stefan Reuther
<stefan.news@arcor.de> wrote:

>Bernard wrote: >> On 2011-11-16 10:17, johsey wrote: >>> I'm encountering problems when I connect my device to the host PC: >>> Windows >>> 7 asks if I want to format the removable device. As I understood and as I >>> saw with my USB analyzer, the OS doesn't seem to understand the FAT boot >>> sector. I based on the USB Mass Storage book from Jan Axelson. >[...] >> Windows 7 requires that a FAT block device contains at least 8 sectors. >> Define your device as having 8 sectors and return contant value (0s) >> whenever Windows attempts to read any sector above the implmented ones. > >Actually, FAT16 requires the device to have at least 4096 clusters >(otherwise it'd be FAT12), so the device better had a few more sectors >than that (boot record, FAT, root directory, plus data clusters).
Actually the boundary between FAT12 and FAT16 is 4085* clusters - 4085 and fewer must be formatted FAT12, 4086 and higher must be FAT16 (until you get to 65526 clusters, at which point it's FAT32). In any event, given the vast number of incorrect implementations, you should avoid formatting any volume with a number of clusters within about 16 of the above limits, either by adjusting the reserved area size or the cluster size. Anyway, the definitive reference for FAT: http://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx * *not* 4095/4096
On Wed, 16 Nov 2011 19:34:41 +0100, Stefan Reuther
<stefan.news@arcor.de> wrote:

>Bernard wrote: >> On 2011-11-16 10:17, johsey wrote: >>> I'm encountering problems when I connect my device to the host PC: >>> Windows >>> 7 asks if I want to format the removable device. As I understood and as I >>> saw with my USB analyzer, the OS doesn't seem to understand the FAT boot >>> sector. I based on the USB Mass Storage book from Jan Axelson. >[...] >> Windows 7 requires that a FAT block device contains at least 8 sectors. >> Define your device as having 8 sectors and return contant value (0s) >> whenever Windows attempts to read any sector above the implmented ones. > >Actually, FAT16 requires the device to have at least 4096 clusters >(otherwise it'd be FAT12), so the device better had a few more sectors >than that (boot record, FAT, root directory, plus data clusters).
Actually the boundary between FAT12 and FAT16 is 4085* clusters - 4085 and fewer must be formatted FAT12, 4086 and higher must be FAT16 (until you get to 65526 clusters, at which point it's FAT32). In any event, given the vast number of incorrect implementations, you should avoid formatting any volume with a number of clusters within about 16 of the above limits, either by adjusting the reserved area size or the cluster size. Anyway, the definitive reference for FAT: http://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx * *not* 4095/4096
On Wed, 16 Nov 2011 19:34:41 +0100, Stefan Reuther
<stefan.news@arcor.de> wrote:

>Bernard wrote: >> On 2011-11-16 10:17, johsey wrote: >>> I'm encountering problems when I connect my device to the host PC: >>> Windows >>> 7 asks if I want to format the removable device. As I understood and as I >>> saw with my USB analyzer, the OS doesn't seem to understand the FAT boot >>> sector. I based on the USB Mass Storage book from Jan Axelson. >[...] >> Windows 7 requires that a FAT block device contains at least 8 sectors. >> Define your device as having 8 sectors and return contant value (0s) >> whenever Windows attempts to read any sector above the implmented ones. > >Actually, FAT16 requires the device to have at least 4096 clusters >(otherwise it'd be FAT12), so the device better had a few more sectors >than that (boot record, FAT, root directory, plus data clusters).
(apologies if this is a double post - newsreader was being weird) Actually the boundary between FAT12 and FAT16 is 4085* clusters - 4085 and fewer must be formatted FAT12, 4086 and higher must be FAT16 (until you get to 65526 clusters, at which point it's FAT32). In any event, given the vast number of incorrect implementations, you should avoid formatting any volume with a number of clusters within about 16 of the above limits, either by adjusting the reserved area size or the cluster size. Anyway, the definitive reference for FAT: http://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx * *not* 4095/4096
Thank you for your answers.

I will try to put more clusters in order to be pretty much higher than the
FAT16 low limits and I will have a look at the linked document.

I will come back if I still have problems with my device being recognized
by Windows.

Regards,
Johann	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
In comp.arch.embedded,
johsey <johann.seydoux@n_o_s_p_a_m.pnnmedical.ch> wrote:
> Hello, > > I'm developing a "USB card reader" which must read a 512 bytes non-writable > memory and display it as a file. > > Since the 512 bytes memory contains only data which have to be stored in > the file, I have to define in firmware the entire FAT as a big array. Thus, > no possibility to format the media using for example Windows. > > I'm encountering problems when I connect my device to the host PC: Windows > 7 asks if I want to format the removable device. As I understood and as I > saw with my USB analyzer, the OS doesn't seem to understand the FAT boot > sector. I based on the USB Mass Storage book from Jan Axelson. > > Do someone have some ideas about what fields in the boot sector can > generate such an error? Do you know where I can find some documentation on > how Windows set the boot sector?
How big is the "disk" pretending to be? Small disks can only be FAT12, you can not create an arbitrary sized FAT16 disk. There are set rules in cluster count for each FAT type as the number of clusters is the only way to determine the FAT type, see: http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/fatgen103.doc -- Stef (remove caps, dashes and .invalid from e-mail address to reply by mail) Rule of the Great: When people you greatly admire appear to be thinking deep thoughts, they probably are thinking about lunch.