]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/karo/common/mmc.c
karo: tx6: don't write u-boot image with WITH_DROP_FFS
[karo-tx-uboot.git] / board / karo / common / mmc.c
index f88e1cff82fd33fc62bd2acd610957068628115f..0048bfb4af02b9bec562ad14e54c5695cee97fe3 100644 (file)
@@ -42,6 +42,7 @@ static int find_partitions(const char *ifname, int devno, int fstype,
        int p;
        int part;
        block_dev_desc_t *dd;
+       char dev_part_str[16];
 
        dd = get_dev(ifname, devno);
        if (!dd || dd->type == DEV_TYPE_UNKNOWN) {
@@ -78,7 +79,8 @@ static int find_partitions(const char *ifname, int devno, int fstype,
                ret = -1;
                goto cleanup;
        }
-
+       snprintf(dev_part_str, sizeof(dev_part_str), "%d:%d", devno, part);
+       fs_set_blk_dev(ifname, dev_part_str, fstype);
        ret = part;
        *dev_desc = dd;
 
@@ -93,6 +95,7 @@ static int karo_mmc_find_part(struct mmc *mmc, const char *part, int devno,
        int ret;
        block_dev_desc_t *mmc_dev;
 
+#if defined(CONFIG_SYS_DTB_OFFSET) && defined(CONFIG_SYS_MMC_ENV_PART)
        if (strcmp(part, "dtb") == 0) {
                const int partnum = CONFIG_SYS_MMC_ENV_PART;
 
@@ -104,10 +107,10 @@ static int karo_mmc_find_part(struct mmc *mmc, const char *part, int devno,
                        part_info->start + part_info->size - 1);
                return partnum;
        }
-
+#endif
        ret = find_partitions("mmc", devno, FS_TYPE_FAT, &mmc_dev, part_info);
        if (ret < 0) {
-               printf("No eMMC partition found: %d\n", ret);
+               printf("No (e)MMC partition found: %d\n", ret);
                return ret;
        }
        return 0;
@@ -118,7 +121,7 @@ int karo_load_mmc_part(const char *part, void *addr, size_t len)
        int ret;
        struct mmc *mmc;
        disk_partition_t part_info;
-       int devno = CONFIG_MMC_BOOT_DEV;
+       int devno = CONFIG_SYS_MMC_ENV_DEV;
        lbaint_t blk_cnt;
        int partnum;
 
@@ -160,12 +163,18 @@ int karo_load_mmc_part(const char *part, void *addr, size_t len)
                debug("Read %u (%u) byte from partition '%s' @ offset 0x"LBAF"\n",
                        ret * mmc->read_bl_len, len, part, part_info.start);
        } else if (partnum == 0) {
-               int len_read;
-
-               printf("Reading file %s from mmc partition %d\n", part, 0);
-               len_read = fs_read(part, (ulong)addr, 0, len);
+               loff_t len_read;
+
+               debug("Reading file %s from mmc partition %d\n", part,
+                       partnum);
+               ret = fs_read(part, (ulong)addr, 0, len, &len_read);
+               if (ret < 0) {
+                       printf("Failed to read %u byte from mmc partition %d\n",
+                               len, partnum);
+                       goto out;
+               }
                if (len_read < len) {
-                       printf("Read only %u of %u bytes\n", len_read, len);
+                       printf("Read only %llu of %u bytes\n", (u64)len_read, len);
                }
        } else {
                ret = partnum;