Message ID | 20160624153307.13d1c850@crub |
---|---|
State | Deferred, archived |
Delegated to: | Richard Weinberger |
Headers | show |
Anatolij. On 24 June 2016 at 10:33, Anatolij Gustschin <agust@denx.de> wrote: [..] > > # ubiupdatevol /dev/ubi0_0 data.ubi > # echo $? > 0 > It seems you are you writing a UBI *volume*, with an image prepared for a UBI *device*. > # mount -t ubifs ubi0:data /mnt > mount: mounting ubi0:data on /mnt failed: Invalid argument > > I think that the data.ubi image is okay because after formatting the > MTD partition with this very image mounting works: > > # ubiformat /dev/mtd4 -f data.ubi > ubiformat: mtd4 (nor), size 16121856 bytes (15.4 MiB), 246 eraseblocks of 65536 bytes (64.0 KiB), min. I/O size 1 bytes > libscan: scanning eraseblock 245 -- 100 % complete > ubiformat: 246 eraseblocks have valid erase counter, mean value is 5 > ubiformat: flashing eraseblock 14 -- 100 % complete > ubiformat: formatting eraseblock 245 -- 100 % complete > If you wrote down your exact steps, then it's clear this is wrong: ubiformat /dev/mtd4 -f data.ubi ubiupdatevol /dev/ubi0_0 data.ubi You probably want "ubiupdatevol /dev/ubi0_0 data.img".
Hi Ezequiel, On Fri, 24 Jun 2016 12:36:05 -0300 Ezequiel Garcia ezequiel@vanguardiasur.com.ar wrote: >Anatolij. > >On 24 June 2016 at 10:33, Anatolij Gustschin <agust@denx.de> wrote: >[..] >> >> # ubiupdatevol /dev/ubi0_0 data.ubi >> # echo $? >> 0 >> > >It seems you are you writing a UBI *volume*, with an image >prepared for a UBI *device*. yes, now I see it. Thanks for the pointer. [...] >If you wrote down your exact steps, then it's clear this >is wrong: > >ubiformat /dev/mtd4 -f data.ubi >ubiupdatevol /dev/ubi0_0 data.ubi I extracted the commands from some old script and this script was obviously wrong. >You probably want "ubiupdatevol /dev/ubi0_0 data.img". Exactly! And that works as expected. Thanks, Anatolij
On Fri, Jun 24, 2016 at 3:33 PM, Anatolij Gustschin <agust@denx.de> wrote: > [ 108.786816] UBIFS error (ubi0:0 pid 355): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1 > [ 108.796053] Not a node, first 24 bytes: > [ 108.799799] 00000000: 55 42 49 23 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 80 UBI#...............@.... This line proves Ezequiel's thought. You flashed an UBI image into a volume. UBI# is the EC header magic.
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 69e287e2..bc8396b 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c @@ -310,6 +310,7 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node) pr_err("Not a node, first %zu bytes:", UBIFS_CH_SZ); print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 32, 1, (void *)node, UBIFS_CH_SZ, 1); + pr_err("magic 0x%08x\n", le32_to_cpu(ch->magic)); return; } diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 97be412..e2ddc55 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c @@ -984,8 +984,10 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len, ubifs_assert(type >= 0 && type < UBIFS_NODE_TYPES_CNT); err = ubifs_leb_read(c, lnum, buf, offs, len, 0); - if (err && err != -EBADMSG) + if (err && err != -EBADMSG) { + dbg_gen("ubifs_leb_read ret %d", err); return err; + } if (type != ch->node_type) { ubifs_errc(c, "bad node type (%d but expected %d)", @@ -1010,7 +1012,7 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len, out: ubifs_errc(c, "bad node at LEB %d:%d, LEB mapping status %d", lnum, offs, ubi_is_mapped(c->ubi, lnum)); - if (!c->probing) { + if (!c->probing || c->mounting) { ubifs_dump_node(c, buf); dump_stack(); } diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index 3cbb904..b96f4b7 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c @@ -493,6 +493,7 @@ struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c) err = ubifs_read_node(c, sup, UBIFS_SB_NODE, UBIFS_SB_NODE_SZ, UBIFS_SB_LNUM, 0); if (err) { + dbg_gen("ubifs_read_node err %d", err); kfree(sup); return ERR_PTR(err); } @@ -530,13 +531,16 @@ int ubifs_read_superblock(struct ubifs_info *c) if (c->empty) { err = create_default_filesystem(c); + dbg_gen("create_default_filesystem ret %d", err); if (err) return err; } sup = ubifs_read_sb_node(c); - if (IS_ERR(sup)) + if (IS_ERR(sup)) { + dbg_gen("ubifs_read_sb_node ret %ld", PTR_ERR(sup)); return PTR_ERR(sup); + } c->fmt_version = le32_to_cpu(sup->fmt_version); c->ro_compat_version = le32_to_cpu(sup->ro_compat_version); @@ -558,6 +562,7 @@ int ubifs_read_superblock(struct ubifs_info *c) err = -EROFS; } else err = -EINVAL; + dbg_gen("ubifs_assert ret %d", err); goto out; } @@ -633,6 +638,7 @@ int ubifs_read_superblock(struct ubifs_info *c) c->old_leb_cnt, c->leb_cnt); sup->leb_cnt = cpu_to_le32(c->leb_cnt); err = ubifs_write_sb_node(c, sup); + dbg_gen("ubifs_write_sb_node ret %d", err); if (err) goto out; c->old_leb_cnt = c->leb_cnt; @@ -650,6 +656,7 @@ int ubifs_read_superblock(struct ubifs_info *c) c->main_first = c->leb_cnt - c->main_lebs; err = validate_sb(c, sup); + dbg_gen("validate_sb ret %d", err); out: kfree(sup); return err; diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index ddf9f6b9..33e6948 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -1788,7 +1788,7 @@ void ubifs_warn(const struct ubifs_info *c, const char *fmt, ...); */ #define ubifs_errc(c, fmt, ...) \ do { \ - if (!(c)->probing) \ + if (!(c)->probing || (c)->mounting) \ ubifs_err(c, fmt, ##__VA_ARGS__); \ } while (0)