From 68c7025d99dbac9ddf1a166a19efc3f9e98f1301 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 25 Jun 2018 11:19:12 +0200 Subject: [PATCH 1/3] cmd: ubi: print load size after establishing volume size When using static volumes, the file size stored in the volume is determined at runtime. Currently the ubi command prints the file size specified on the console, which leads to a rather confusing series of messages: # ubi read ${fdt_addr_r} testvol Read 0 bytes from volume testvol to 82000000 No size specified -> Using max size (179924992) Make sure to print the actual size read in any case: # ubi read ${fdt_addr_r} testvol No size specified -> Using max size (179924992) Read 179924992 bytes from volume testvol to 82000000 Signed-off-by: Stefan Agner --- cmd/ubi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/ubi.c b/cmd/ubi.c index ac9a582437d..9c3cabc262a 100644 --- a/cmd/ubi.c +++ b/cmd/ubi.c @@ -356,6 +356,8 @@ int ubi_volume_read(char *volume, char *buf, size_t size) size = vol->used_bytes; } + printf("Read %u 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) @@ -674,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); } } From 4a94e53b23031e6c1a7a03d0a863681002e06ffd Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Tue, 26 Jun 2018 08:12:32 +0200 Subject: [PATCH 2/3] cmd: ubi: Add additional message upon UBI attach error When trying to attach an UBI MTD partition via "ubi part", it may happen that the MTD partition defined in U-Boot (via mtdparts) is not big enough than the one, where the UBI device has been created on. This may lead to errors, which are not really descriptive to debug and solve this issue, like: ubi0 error: vtbl_check: too large reserved_pebs 1982, good PEBs 1020 ubi0 error: vtbl_check: volume table check failed: record 0, error 9 or: ubi0 error: init_volumes: not enough PEBs, required 1738, available 1020 ubi0 error: ubi_wl_init: no enough physical eraseblocks (-718, need 1) ubi0 error: ubi_attach_mtd_dev: failed to attach mtd1, error -12 Lets add an additional message upon attach failure, to aid the U-Boot user to solve this problem. Signed-off-by: Stefan Roese Cc: Stefano Babic Cc: Heiko Schocher --- cmd/ubi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/ubi.c b/cmd/ubi.c index 9c3cabc262a..0e935e34b8e 100644 --- a/cmd/ubi.c +++ b/cmd/ubi.c @@ -512,6 +512,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; } From 5a08cfee3967d6e8174d7de135af1daa8e4aea00 Mon Sep 17 00:00:00 2001 From: Christophe Kerello Date: Wed, 27 Jun 2018 10:06:59 +0200 Subject: [PATCH 3/3] ubifs: remove useless code By checking ubifs source code, s_instances parameter is not used anymore. So, set this parameter and the associated source code under __UBOOT__ compilation. Signed-off-by: Christophe Kerello Signed-off-by: Patrice Chotard --- fs/ubifs/super.c | 8 ++++---- fs/ubifs/ubifs.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index abdef1e6ab8..9603163d8a0 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -2360,7 +2360,9 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags) return ERR_PTR(err); } +#ifndef __UBOOT__ INIT_HLIST_NODE(&s->s_instances); +#endif INIT_LIST_HEAD(&s->s_inodes); s->s_time_gran = 1000000000; s->s_flags = flags; @@ -2429,14 +2431,12 @@ retry: #ifndef __UBOOT__ strlcpy(s->s_id, type->name, sizeof(s->s_id)); list_add_tail(&s->s_list, &super_blocks); -#else - strncpy(s->s_id, type->name, sizeof(s->s_id)); -#endif hlist_add_head(&s->s_instances, &type->fs_supers); -#ifndef __UBOOT__ spin_unlock(&sb_lock); get_filesystem(type); register_shrinker(&s->s_shrink); +#else + strncpy(s->s_id, type->name, sizeof(s->s_id)); #endif return s; } diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 78c3a68216e..512fdaa1444 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -316,8 +316,8 @@ struct super_block { struct backing_dev_info *s_bdi; #endif struct mtd_info *s_mtd; - struct hlist_node s_instances; #ifndef __UBOOT__ + struct hlist_node s_instances; struct quota_info s_dquot; /* Diskquota specific options */ #endif