On Fri, 10 Jun 2005, Matt HAMEAU wrote:

> Everything goes fine now. But:
> On Windows XP, my AT91 board is well recognized like a
> Usb Mass Storage but i can't see the drive in "My
> Computer". Though i can see it in the "Disk
> Management" of my "Computer Management" utility
> (type=unknown)
> I built the file storage like that:
> #dd if=/dev/zero of=storage bs=1M count=8
> #mkdosfs -F32 -nMyDrive -v storage
> #insmod g_file_storage file=storage stall=0
> 
> It works fine under linux 2.6 host. Have i done
> something wrong? 

Follow the instructions in the document below.

Alan Stern


----------------------------------------------------------------------


        Preparing a backing file for use with a Windows host

Windows likes to see a partition table in USB disks.  Some versions of
Windows can work without a partition table, but overall life is easier
if you create one.

To create a partition table you can use the fdisk program.  Here's an
example showing how to do it.  It's a little tricky because fdisk
needs help when working with a file rather than an actual disk.

Let's suppose we've created a 64 MB backing file:

        $ dd if=/dev/zero bs=1M count=64 of=backing_file
        64+0 records in
        64+0 records out

Next we run fdisk on the file:

        $ fdisk backing_file
        Device contains neither a valid DOS partition table, nor Sun or SGI 
disklabel
        Building a new DOS disklabel. Changes will remain in memory only,
        until you decide to write them. After that, of course, the previous
        content won't be recoverable.

        You must set heads sectors and cylinders.
        You can do this from the extra functions menu.

As you see, fdisk says that it needs us to set the heads, sectors, and
cylinders values.  The values you use are more or less arbitrary; the
scheme shown here works okay.

First give the "x" (eXpert or eXtra) command:

        Command (m for help): x

Then set the number of sectors/track.  g_file_storage uses a sector
size of 512 bytes, so using 8 sectors/track will give us 4096 bytes per
track.  This is good because it matches the size of a memory page (on
a 32-bit processor).

        Expert command (m for help): s
        Number of sectors (1-63): 8
        Warning: setting sector offset for DOS compatiblity

Next set the number of heads.  With 4 KB per track, 16 heads will give
us a total of 64 KB per cylinder, which is convenient since the size
of the backing file is 64 MB.

        Expert command (m for help): h
        Number of heads (1-256): 16

Finally set the number of cylinders.  It's important that the total
size you specify matches the actual size of the backing file.  Since
we've got 64 KB per cylinder and 64 MB total, we need to use 1024
cylinders.

        Expert command (m for help): c
        Number of cylinders (1-131071): 1024

Now return to the normal menu (the "r" command):

        Expert command (m for help): r

Create a new primary partition ("n" for new).  Let's make it number 1.
The defaults for the starting and ending cylinder are perfect because
they will make the partition occupy the entire backing file.

        Command (m for help): n
        Command action
           e   extended
           p   primary partition (1-4)
        p
        Partition number (1-4): 1
        First cylinder (1-1024, default 1): 
        Using default value 1
        Last cylinder or +size or +sizeM or +sizeK (1-1024, default 1024): 
        Using default value 1024

Change the partition's type ("t") to FAT32 (code b); otherwise it will
be Linux by default, which doesn't work too well with a Windows host.

        Command (m for help): t
        Partition number (1-4): 1
        Hex code (type L to list codes): b
        Changed system type of partition 1 to b (Win95 FAT32)

Print out ("p") the new partition table to be sure everything's correct:

        Command (m for help): p

        Disk backing_file: 16 heads, 8 sectors, 1024 cylinders
        Units = cylinders of 128 * 512 bytes

               Device Boot    Start       End    Blocks   Id  System
        backing_file1             1      1024     65532    b  Win95 FAT32

Finally write out ("w") the partition table to the backing file:

        Command (m for help): w
        The partition table has been altered!

        Calling ioctl() to re-read partition table.
        Re-read table failed with error 25: Inappropriate ioctl for device.
        Reboot your system to ensure the partition table is updated.

        WARNING: If you have created or modified any DOS 6.x
        partitions, please see the fdisk manual page for additional
        information.
        Syncing disks.

At this point the new partition has been created but it hasn't been
formatted.  The easiest way to format it is to let the Windows host do
the work for you.  Just double-click on the drive's icon in the "My
Computer" window after loading g_file_storage and connecting the USB
cable.



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to