[U-Boot] mtdparts not agreeing wiht fw_printenv

John Stile john at stilen.com
Fri Mar 8 03:00:29 CET 2013


Dear Wolfgang Denk ,
On Thu, 2013-03-07 at 07:52 +0100, Wolfgang Denk wrote:
> Dear John Stile,
> 
> In message <1362532855.20183.135.camel at genx> you wrote:
> > I am quite confused about partitions in my NAND flash.
> > 
> > Linux can mount my rootfs, so partitions make sense to the kernel, but
> > from the shell fw_printenv can't read the uboot environment, not matter
> > what I use in /etc/fw_env.config.
> 
> That means that all settings were incorrect.

All settings where not incorrect.

> 
> > dev:    size   erasesize  name
> > mtd0: 00020000 00020000 "bootstrap1"
> > mtd1: 00040000 00020000 "uboot1"
> > mtd2: 001a0000 00020000 "env1"
> ^^^^^^ mtd2
> > mtd3: 00200000 00020000 "linux1"
> > mtd4: 07c00000 00020000 "rootfs1"
> > mtd5: 00020000 00020000 "bootstrap2"
> > mtd6: 00040000 00020000 "uboot2"
> > mtd7: 001a0000 00020000 "env2"
> ^^^^^^ mtd7
> > mtd8: 00200000 00020000 "linux2"
> > mtd9: 07c00000 00020000 "rootfs2"
> > mtd10: 00004200 00000420 "bootstrap3"
> > mtd11: 00004200 00000420 "env3"
> ^^^^^^ mtd11
> > mtd12: 00039c00 00000420 "uboot3"
> > mtd13: 00252000 00000420 "linux3"
> > mtd14: 005ac000 00000420 "rootfs3"
> > 
> What's that? This makes no sense to me - either you have a single copy
> of the environment, or two (in case of redudant env).  Three copies is
> not a supported configuration.
> 
> > I purposefully created more /dev/mtd devices than mtdparts would
> > require, in order to find which partitions actually contain the uboot
> > env.
> 
> mtdparts does not "require" anything.  You configure your systems as
> needed, and then set mtdparts to match that setting.  SO the setting
> comes first (starting in your head or - probably better - on a sheet
> of paper), and then you set mtdparts as needed.
> 

Right.  Even without the /dev/mtd character device files, the system
boots.
This post comes way after a lot of work on paper.

> > /dev/mtd4 and /dev/mtd5 create binary equivalent dumps of env1
> > /dev/mtd14 and /dev/mtd15 create binary equivalent dumps of env2.
> 
> The names and use of your partitions is in serious mismatch.  Fix this
> first!

The problem turned out to be due to my /dev/mtd character device files
had sequential minor numbers.

> > /etc/fw_env.config does not like either of those, saying the crc does
> > not checkout.
> > 
> > /etc/fw_env.config:
> > /dev/mtd2              0x0          0x20000          0x20000
> > /dev/mtd2              0x20000      0x20000          0x20000
> 
> Well, if you find the environment in /dev/mtd4 and /dev/mtd5, then you
> should use these in the fw_env.config
> 
> Best regards,
> 
> Wolfgang Denk
> 
Like I said, I think, even those did not work.
When I created my /dev/mtd character device files to use even minor
numbers, I was able to see my env in /dev/mtd2 /dev/mtd7  using od:
od -t xz /dev/mtd2
od -t xz /dev/mtd7
And fw_printenv also worked.

One site said read-write device will have even minor numbers.

Since I am using a 2.6.30 kernel, without tmpdevfs, I rely on
buildroot's target/generic/device_table_dev.txt to generate my devices,
and it was there I had not set the proper values:
# MTD stuff
# <name>	<type>	<mode>	<uid>	<gid>	<major>	<minor>	<start>	<inc>	<count>
/dev/mtd	    c	640	0	0	90	0	0	2	20

Thank you for your help.



More information about the U-Boot mailing list