]> git.ipfire.org Git - thirdparty/u-boot.git/blobdiff - cmd/ubi.c
ARM: da850evm: Pinctrl for da850evm
[thirdparty/u-boot.git] / cmd / ubi.c
index efc43ffde91ec5863adfc3382087afcca5358ba9..0fa7553072a3b591cd3b0203bcc1c6a4ba40ee15 100644 (file)
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -47,8 +47,7 @@ struct selected_dev {
 static struct selected_dev ubi_dev;
 
 #ifdef CONFIG_CMD_UBIFS
-int ubifs_is_mounted(void);
-void cmd_ubifs_umount(void);
+#include <ubifs_uboot.h>
 #endif
 
 static void display_volume_info(struct ubi_device *ubi)
@@ -308,7 +307,7 @@ int ubi_volume_begin_write(char *volume, void *buf, size_t size,
                return ENODEV;
 
        rsvd_bytes = vol->reserved_pebs * (ubi->leb_size - vol->data_pad);
-       if (size < 0 || size > rsvd_bytes) {
+       if (size > rsvd_bytes) {
                printf("size > volume size! Aborting!\n");
                return EINVAL;
        }
@@ -334,6 +333,7 @@ int ubi_volume_read(char *volume, char *buf, size_t size)
        unsigned long long tmp;
        struct ubi_volume *vol;
        loff_t offp = 0;
+       size_t len_read;
 
        vol = ubi_find_volume(volume);
        if (vol == NULL)
@@ -355,6 +355,8 @@ int ubi_volume_read(char *volume, char *buf, size_t size)
                size = vol->used_bytes;
        }
 
+       printf("Read %zu bytes from volume %s to %p\n", size, volume, buf);
+
        if (vol->corrupted)
                printf("read from corrupted volume %d", vol->vol_id);
        if (offp + size > vol->used_bytes)
@@ -373,6 +375,7 @@ int ubi_volume_read(char *volume, char *buf, size_t size)
        tmp = offp;
        off = do_div(tmp, vol->usable_leb_size);
        lnum = tmp;
+       len_read = size;
        do {
                if (off + len >= vol->usable_leb_size)
                        len = vol->usable_leb_size - off;
@@ -398,6 +401,9 @@ int ubi_volume_read(char *volume, char *buf, size_t size)
                len = size > tbuf_size ? tbuf_size : size;
        } while (size);
 
+       if (!size)
+               env_set_hex("filesize", len_read);
+
        free(tbuf);
        return err;
 }
@@ -505,6 +511,7 @@ int ubi_part(char *part_name, const char *vid_header_offset)
                        vid_header_offset);
        if (err) {
                printf("UBI init error %d\n", err);
+               printf("Please check, if the correct MTD partition is used (size big enough?)\n");
                ubi_dev.selected = 0;
                return err;
        }
@@ -669,9 +676,6 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                }
 
                if (argc == 3) {
-                       printf("Read %lld bytes from volume %s to %lx\n", size,
-                              argv[3], addr);
-
                        return ubi_volume_read(argv[3], (char *)addr, size);
                }
        }