[U-Boot-Users] USB SUPPORT

Ken.Fuchs at bench.com Ken.Fuchs at bench.com
Wed Apr 23 00:31:24 CEST 2008


--- Introduction ---

This thread concerns possible problems with fs/fat/fat.c
(incorrect fatls output and inaccessible files via
fatload) even when recent "git" patches have been applied
to fat.c.  VFAT is enabled.

Michael Trimarchi wrote:

> Can you give an image of it?

(He is referring to the FAT32 image where "fatls usb 0:1 /"
resulted in a clearly garbled/incorrect directory listing.)

Rather than that particular image, I decided to write two
scripts that do most of the work building two other FAT32
images that trigger problems with "fatls usb 0:1 /".  Note
that one FAT32 image is made on XP/Cygwin (mkpen) and the
other on FLOSS/Linux ..err.. GNU/Linux (mklpen).  Note that
two FAT32 images they make do have exactly the same files and
file content, built in exactly the same order, but since the
filesystem code is different, the metadata will probably also
be different ... different inodes ... etc.

The attached mkpen is the XP/Cygwin build script and
u-boot-usb-bug.img.bz2 is a bzip2 compression of the
XP FAT32 image that demonstrates the problems (shown
below) when accessed by U-Boot's fatls.

The attached mklpen automates the whole process on a
Linux host, except you still need to enter the command
./mklpen and move the pen drive from host to target when
done...  It makes a slightly a different FAT32 image that
reveals the same issues with fat.c a bit faster.  The part
where it wipes out /dev/sda1 is commented out, so uncomment
at your risk and modify as needed for a SCSI host.

The middle of this message describes how the XP FAT32 image was
made.  The latter part of this message shows the list of files
via XP/Cygwin and a different list shown via U-Boot's fatls.

--- Pen drive used ---

A 128MB USB pen drive with the following partition table
is being used (only one pen drive was used in testing):

# fdisk -l /dev/sda

Disk /dev/sda: 131 MB, 131072512 bytes
8 heads, 32 sectors/track, 1000 cylinders
Units = cylinders of 256 * 512 = 131072 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1000      127984    b  W95 FAT32
#

--- XP/Cygwin FAT32 image build procedure ---

(For FLOSS/Linux host, just use the attached mklpen script.)

1) On Linux do:

# dd if=/dev/zero of=/dev/sda1 bs=`echo "32 * 512" | bc`

This is an attempt to reduce the effect of a bad "link" to
unallocated space.  There is _no_ proof that this happens.
(Only null strings and null pointers can now be found here.)

2) On MS Windows XP or similar OS, format (mkfs) partition
   1 with a FAT32 filesystem.

Alternative) On Linux: # mkdosfs -F 32 /dev/sda1

Warning: Linux mkdosfs and XP make different FAT32 images.

3) In a Cygwin bash shell, run the mkpen script with
   cd set to /cygdrive/d (or e, f, g, etc. as appropriate):

#!/bin/bash
for char in 0 1 2 3 4 5 6 7 8 9 a b c d e f g h \
            i j k l m n o p q r s t u v w x y z ; do
        file=;
        for (( index=0 ; index < 8 ; index++ )) ; do
                file=${file}${char};
        done;
        echo "${file}" > ${file}.txt
done

Alternative) On Linux, run the same script.

Warning: Linux vfat fs and XP FAT32 fs code may produce
         different FAT32 images when running this script.

--- Note about building the FAT32 image with FLOSS ---

I also tested the FAT32 image that is built exclusively
via FLOSS tools (using the Linux alternatives in steps
2 & 3 or mklpen).  The result is shown at the end of this
message.

--- ls -lU output of USB pen drive root directory ---

$ cd /pen1
$ ls -lU
total 36
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 00000000.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 11111111.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 22222222.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 33333333.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 44444444.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 55555555.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 66666666.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 77777777.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 88888888.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 99999999.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 aaaaaaaa.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 bbbbbbbb.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 cccccccc.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 dddddddd.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 eeeeeeee.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 ffffffff.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 gggggggg.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 hhhhhhhh.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 iiiiiiii.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 jjjjjjjj.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 kkkkkkkk.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 llllllll.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 mmmmmmmm.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 nnnnnnnn.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 oooooooo.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 pppppppp.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 qqqqqqqq.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 rrrrrrrr.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 ssssssss.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 tttttttt.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 uuuuuuuu.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 vvvvvvvv.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 wwwwwwww.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 xxxxxxxx.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 yyyyyyyy.txt
-rw-r--r-- 1 fuchsk mkpasswd 9 Apr 22 13:38 zzzzzzzz.txt
$

--- U-Boot fatls output of the same directory ---

Hit any key to stop autoboot: 59 0
U-Boot> usb reset
usb reset
(Re)start USB...
USB:   scanning bus for devices...
      USB device not responding, giving up (status=20)
3 USB Device(s) found
       scanning bus for storage devices... 1 Storage Device(s) found
U-Boot> fatls usb 0:1 /
fatls usb 0:1 /
        9   00000000.txt
        9   11111111.txt
        9   22222222.txt
        9   33333333.txt
        9   44444444.txt
        9   55555555.txt
        9   66666666.txt
        9   77777777.txt
        9   88888888.txt
        9   99999999.txt
        9   aaaaaaaa.txt
        9   bbbbbbbb.txt
        9   cccccccc.txt
        9   dddddddd.txt
        9   eeeeeeee.txt
        9   ffffffff.txt
        9   gggggggg.txt
        9   hhhhhhhh.txt
        9   iiiiiiii.txt
        9   jjjjjjjj.txt
        9   kkkkkkkk.txt
        9   llllllll.txt
        9   mmmmmmmm.txt
        9   nnnnnnnn.txt
        9   oooooooo.txt
        9   pppppppp.txt
        9   qqqqqqqq.txt
        9   rrrrrrrr.txt
        9   ssssssss.txt
        9   tttttttt.txt
        9   uuuuuuuu.txt
        9   vvvvvvvv.txt
        0   00000000.


33 file(s), 0 dir(s)

U-Boot> 

--- Comments ---

Notice that the last four files are not listed and "00000000."
is a non-existent file that is listed.  (There should be 36
files.)

--- U-Boot fatls output of FAT32 image built entirely on Linux ---

Hit any key to stop autoboot: 48 0
U-Boot> usb reset
usb reset
(Re)start USB...
USB:   scanning bus for devices...
      USB device not responding, giving up (status=20)
3 USB Device(s) found
       scanning bus for storage devices... 1 Storage Device(s) found
U-Boot> fatls usb 0:1 /
fatls usb 0:1 /
        9   00000000.txt
        9   11111111.txt
        9   22222222.txt
        9   33333333.txt
        9   44444444.txt
        9   55555555.txt
        9   66666666.txt
        9   77777777.txt
        0   00000000.


9 file(s), 0 dir(s)

U-Boot> 

---

Sincerely,

Ken Fuchs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mkpen
Type: application/octet-stream
Size: 228 bytes
Desc: mkpen
Url : http://lists.denx.de/pipermail/u-boot/attachments/20080422/698e53c2/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: u-boot-usb-bug.img.bz2
Type: application/octet-stream
Size: 1630 bytes
Desc: u-boot-usb-bug.img.bz2
Url : http://lists.denx.de/pipermail/u-boot/attachments/20080422/698e53c2/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mklpen
Type: application/octet-stream
Size: 485 bytes
Desc: mklpen
Url : http://lists.denx.de/pipermail/u-boot/attachments/20080422/698e53c2/attachment-0002.obj 


More information about the U-Boot mailing list