[U-Boot] fs/fat: device not booting since conversion to dir iterators

Patrick BrĂ¼nn P.Bruenn at beckhoff.com
Thu Nov 30 11:22:14 UTC 2017


Since commit 8eafae209c35932d9a6560809c55ee4641534236
my mx53cx9020_defconfig stopped booting.
I could "fix" that commit with this patch:
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index bbba7947ee..b99ec85097 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1035,6 +1035,9 @@ int file_fat_ls(const char *dir)
        int files = 0, dirs = 0;
        int ret;

+       //fix_fat
+       disk_read(0, PREFETCH_BLOCKS, do_fat_read_at_block);
+
        ret = fat_itr_root(itr, &fsdata);
        if (ret)
                return ret;

Since then file_fat_ls() has been moved/replaced with
fs_ls_generic(). So I had to adjust that workaround.
And added the dummy disk_read() into fs_opendir() callback:
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 7fe78439cf..be6eaeb68e 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1155,6 +1155,7 @@ int fat_opendir(const char *filename, struct fs_dir_stream **dirsp)
        if (!dir)
                return -ENOMEM;

+       disk_read(0, PREFETCH_BLOCKS, do_fat_read_at_block);
        ret = fat_itr_root(&dir->itr, &dir->fsdata);
        if (ret)
                goto fail_free_dir;

It seems important to read into do_fat_read_at_block. If I
allocate a temporary buffer and read into that one, I still
can't boot. That seems strange to me as, I couldn't find
any uninitialized access to do_fat_read_at_block anywhere.

Another workaround is to disable CMD_FAT:
diff --git a/configs/mx53cx9020_defconfig b/configs/mx53cx9020_defconfig
index b704f32fbf..2d560aabc1 100644
--- a/configs/mx53cx9020_defconfig
+++ b/configs/mx53cx9020_defconfig
@@ -15,7 +15,7 @@ CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
-CONFIG_CMD_FAT=y
+CONFIG_DOS_PARTITION=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_IS_IN_MMC=y


My device is powered by an i.MX53 and configured to
load u-boot from sdcard. That sdcard doesn't have any
FAT partition on it:
Disk /dev/mmcblk0: 471 MiB, 493879296 bytes, 964608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xbbd9d8f6

Device         Boot Start    End Sectors  Size Id Type
/dev/mmcblk0p1 *     2048 489471  487424  238M 83 Linux

Maybe my sdcard layout is broken, too. If you need any
additional info or have any idea whatelse I could try,
please let me know.

Thanks in advance,
Patrick
Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075





More information about the U-Boot mailing list