Re: [U-Boot] U-boot UBI environment

2016-05-11 Thread Heiko Schocher

Hello Kevin,

Am 11.05.2016 um 17:54 schrieb Kevin Smith:

Hi Joe and Heiko,

I tried disabling the fastmap options, and it appears to be related to
these.  With fastmap off, I am able two write without corrupting the
other volume.  It looks like it may specifically be the autoupdate
feature, but I am still testing to be sure this is the case.  I will let
you know.


Thanks for debugging into it!


Thank you for your help,


You are welcome!

bye,
Heiko

Kevin

On 05/11/2016 12:51 AM, Heiko Schocher wrote:

Hello Joe,

Am 11.05.2016 um 01:15 schrieb Joseph Hershberger:

Hi Kevin,

Am 09.05.2016 um 23:16 schrieb Kevin Smith:

Hello,

I would appreciate some UBI help/advice if you are able to provide it.
I am trying to use UBI to store my u-boot environment, but when I try
to 'saveenv', it is corrupting another volume of my UBI.  I can image
the rootfs volume and boot Linux from it without a problem. However,
the first time that I save the u-boot environment, the rootfs becomes
unreadable.  When the rootfs is corrupted, I have booted Linux from
another source and tried to attach UBI and dd out the data. It
appears as all 0xFF.  Both u-boot and Linux can read the env volume
correctly.

I do not think that there is a board in U-boot that uses UBI env, so I
do not have anything to compare to.  I have included some details of
my setup below.  Do you have any suggestion about what might be wrong?
I saw the recent patch b1d6590d35, and thought it might fix it, but am
still having the problem even with this.  Maybe there is another bug?
I am glad to provide more info as needed.
Thank you,
Kevin

DTS:
flash@d {
num-cs = <1>;
marvell,nand-keep-config;
marvell,nand-enable-arbiter;
nand-on-flash-bbt;
nand-ecc-strength = <4>;
nand-ecc-step-size = <512>;
status = "okay";

partition@0 {
label = "mvboot";
reg = <0 0x20>;
};
partition@20 {
label = "ubi";
reg = <0x20 0x1fe0>;
};
};
Config:
#define MTDIDS_DEFAULT"nand0=pxa3xx_nand-0"
#define MTDPARTS_DEFAULT "mtdparts=pxa3xx_nand-0:2m(mvboot),-(ubi)"
#define CONFIG_CMD_UBI
#define CONFIG_CMD_UBIFS



#define CONFIG_MTD_UBI_FASTMAP
#define CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT1


I don’t define these 2, not sure if it matters.


This should be no problem ... but you (Kevin) may disable
FASTMAP for a test?


#define CONFIG_ENV_IS_IN_UBI
#define CONFIG_ENV_UBI_PART"ubi"
#define CONFIG_ENV_UBI_VOLUME"u-boot-env"
#define CONFIG_ENV_SIZE(64 * 1024)


My config looks like this:

#define MTDIDS_DEFAULT "nand0=xilinx_nand"
#define MTDPARTS_DEFAULT \
 "mtdparts=xilinx_nand:" \
 "128k(fsbl)ro," \
 "11M(u-boot)ro," \
 "70M(boot-config)," \
 "-(root)"


You have 70MB for Env?


#define CONFIG_ENV_IS_IN_UBI
#define CONFIG_ENV_UBI_PART "boot-config"
#define CONFIG_ENV_UBI_VOLUME "u-boot-env1"
#define CONFIG_ENV_UBI_VOLUME_REDUND "u-boot-env2"
#define CONFIG_ENV_SIZE0x2

I create volumes like this:

 "writepartitions=" \
 "if ubi part boot-config && " \
 "ubi read $verifyaddr u-boot-env1 1 && " \
 "ubi read $verifyaddr u-boot-env2 1; " \
 "then " \
 "ubi remove bootfs && " \
 "ubi remove config; " \
 "else " \
 "nand erase.part boot-config && " \
 "ubi part boot-config && " \
 "ubi create u-boot-env1 " __stringify(CONFIG_ENV_SIZE) "
dynamic && " \
 "ubi create u-boot-env2 " __stringify(CONFIG_ENV_SIZE) "
dynamic; " \
 "fi && " \
 "ubi create bootfs " __stringify(CONFIG_BOOTFS_VOLUME_SIZE) "
dynamic && " \
 "ubi create config - dynamic && " \
 "if ubi part root && " \
 "ubi read $verifyaddr rootfs 1; " \
 "then " \
 "ubi remove rootfs; " \
 "else " \
 "nand erase.part root && " \
 "ubi part root; " \
 "fi && " \
 "ubi create rootfs - dynamic;\0" \



=> ubi info
UBI: MTD device name:"mtd=1"
UBI: MTD device size:510 MiB
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:126976 bytes
UBI: number of good PEBs:4072
UBI: number of bad PEBs: 8
UBI: smallest flash I/O unit:2048
UBI: VID header offset:  2048 (aligned 2048)
UBI: data offset:4096
UBI: max. allowed volumes:   128
UBI: wear-leveling threshold:4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 2
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 4072
UBI: number of PEBs reserved for bad PEB handling: 72
UBI: max/mean erase counter: 18/4

=> ubi info l
Volume information dump:
vol_id  0
reserved_pebs   1
alignment   1
data_pad0
vol_type3
 

Re: [U-Boot] U-boot UBI environment

2016-05-11 Thread Kevin Smith
Hi Joe and Heiko,

I tried disabling the fastmap options, and it appears to be related to 
these.  With fastmap off, I am able two write without corrupting the 
other volume.  It looks like it may specifically be the autoupdate 
feature, but I am still testing to be sure this is the case.  I will let 
you know.

Thank you for your help,
Kevin

On 05/11/2016 12:51 AM, Heiko Schocher wrote:
> Hello Joe,
>
> Am 11.05.2016 um 01:15 schrieb Joseph Hershberger:
>> Hi Kevin,
>>
>> Am 09.05.2016 um 23:16 schrieb Kevin Smith:
>>> Hello,
>>>
>>> I would appreciate some UBI help/advice if you are able to provide it.
>>> I am trying to use UBI to store my u-boot environment, but when I try
>>> to 'saveenv', it is corrupting another volume of my UBI.  I can image
>>> the rootfs volume and boot Linux from it without a problem. However,
>>> the first time that I save the u-boot environment, the rootfs becomes
>>> unreadable.  When the rootfs is corrupted, I have booted Linux from
>>> another source and tried to attach UBI and dd out the data. It
>>> appears as all 0xFF.  Both u-boot and Linux can read the env volume 
>>> correctly.
>>>
>>> I do not think that there is a board in U-boot that uses UBI env, so I
>>> do not have anything to compare to.  I have included some details of
>>> my setup below.  Do you have any suggestion about what might be wrong?
>>> I saw the recent patch b1d6590d35, and thought it might fix it, but am
>>> still having the problem even with this.  Maybe there is another bug?
>>> I am glad to provide more info as needed.
>>> Thank you,
>>> Kevin
>>>
>>> DTS:
>>> flash@d {
>>>num-cs = <1>;
>>>marvell,nand-keep-config;
>>>marvell,nand-enable-arbiter;
>>>nand-on-flash-bbt;
>>>nand-ecc-strength = <4>;
>>>nand-ecc-step-size = <512>;
>>>status = "okay";
>>>
>>>partition@0 {
>>>label = "mvboot";
>>>reg = <0 0x20>;
>>>};
>>>partition@20 {
>>>label = "ubi";
>>>reg = <0x20 0x1fe0>;
>>>};
>>> };
>>> Config:
>>> #define MTDIDS_DEFAULT"nand0=pxa3xx_nand-0"
>>> #define MTDPARTS_DEFAULT "mtdparts=pxa3xx_nand-0:2m(mvboot),-(ubi)"
>>> #define CONFIG_CMD_UBI
>>> #define CONFIG_CMD_UBIFS
>>
>>> #define CONFIG_MTD_UBI_FASTMAP
>>> #define CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT1
>>
>> I don’t define these 2, not sure if it matters.
>
> This should be no problem ... but you (Kevin) may disable
> FASTMAP for a test?
>
>>> #define CONFIG_ENV_IS_IN_UBI
>>> #define CONFIG_ENV_UBI_PART"ubi"
>>> #define CONFIG_ENV_UBI_VOLUME"u-boot-env"
>>> #define CONFIG_ENV_SIZE(64 * 1024)
>>
>> My config looks like this:
>>
>> #define MTDIDS_DEFAULT "nand0=xilinx_nand"
>> #define MTDPARTS_DEFAULT \
>> "mtdparts=xilinx_nand:" \
>> "128k(fsbl)ro," \
>> "11M(u-boot)ro," \
>> "70M(boot-config)," \
>> "-(root)"
>
> You have 70MB for Env?
>
>> #define CONFIG_ENV_IS_IN_UBI
>> #define CONFIG_ENV_UBI_PART "boot-config"
>> #define CONFIG_ENV_UBI_VOLUME "u-boot-env1"
>> #define CONFIG_ENV_UBI_VOLUME_REDUND "u-boot-env2"
>> #define CONFIG_ENV_SIZE0x2
>>
>> I create volumes like this:
>>
>> "writepartitions=" \
>> "if ubi part boot-config && " \
>> "ubi read $verifyaddr u-boot-env1 1 && " \
>> "ubi read $verifyaddr u-boot-env2 1; " \
>> "then " \
>> "ubi remove bootfs && " \
>> "ubi remove config; " \
>> "else " \
>> "nand erase.part boot-config && " \
>> "ubi part boot-config && " \
>> "ubi create u-boot-env1 " __stringify(CONFIG_ENV_SIZE) " 
>> dynamic && " \
>> "ubi create u-boot-env2 " __stringify(CONFIG_ENV_SIZE) " 
>> dynamic; " \
>> "fi && " \
>> "ubi create bootfs " __stringify(CONFIG_BOOTFS_VOLUME_SIZE) " 
>> dynamic && " \
>> "ubi create config - dynamic && " \
>> "if ubi part root && " \
>> "ubi read $verifyaddr rootfs 1; " \
>> "then " \
>> "ubi remove rootfs; " \
>> "else " \
>> "nand erase.part root && " \
>> "ubi part root; " \
>> "fi && " \
>> "ubi create rootfs - dynamic;\0" \
>>
>>
>>> => ubi info
>>> UBI: MTD device name:"mtd=1"
>>> UBI: MTD device size:510 MiB
>>> UBI: physical eraseblock size:   131072 bytes (128 KiB)
>>> UBI: logical eraseblock size:126976 bytes
>>> UBI: number of good PEBs:4072
>>> UBI: number of bad PEBs: 8
>>> UBI: smallest flash I/O unit:2048
>>> UBI: VID header offset:  2048 (aligned 2048)
>>> UBI: data offset:4096
>>> UBI: max. allowed volumes:   128
>>> UBI: wear-leveling threshold:4096
>>> UBI: number of internal volumes: 1
>>> UBI: number of user volumes: 2
>>> UBI: available PEBs: 0
>>> UBI: total number of reserved PEBs: 4072
>>> UBI: number of 

Re: [U-Boot] U-boot UBI environment

2016-05-11 Thread Joseph Hershberger
Hi Kevin,

Am 09.05.2016 um 23:16 schrieb Kevin Smith:
> Hello,
>
> I would appreciate some UBI help/advice if you are able to provide it.
> I am trying to use UBI to store my u-boot environment, but when I try 
> to 'saveenv', it is corrupting another volume of my UBI.  I can image 
> the rootfs volume and boot Linux from it without a problem.  However, 
> the first time that I save the u-boot environment, the rootfs becomes 
> unreadable.  When the rootfs is corrupted, I have booted Linux from 
> another source and tried to attach UBI and dd out the data.  It 
> appears as all 0xFF.  Both u-boot and Linux can read the env volume correctly.
>
> I do not think that there is a board in U-boot that uses UBI env, so I 
> do not have anything to compare to.  I have included some details of 
> my setup below.  Do you have any suggestion about what might be wrong?  
> I saw the recent patch b1d6590d35, and thought it might fix it, but am
> still having the problem even with this.  Maybe there is another bug?  
> I am glad to provide more info as needed.
> Thank you,
> Kevin
>
> DTS:
> flash@d {
>   num-cs = <1>;
>   marvell,nand-keep-config;
>   marvell,nand-enable-arbiter;
>   nand-on-flash-bbt;
>   nand-ecc-strength = <4>;
>   nand-ecc-step-size = <512>;
>   status = "okay";
>
>   partition@0 {
>   label = "mvboot";
>   reg = <0 0x20>;
>   };
>   partition@20 {
>   label = "ubi";
>   reg = <0x20 0x1fe0>;
>   };
> };
> Config:
> #define MTDIDS_DEFAULT"nand0=pxa3xx_nand-0"
> #define MTDPARTS_DEFAULT "mtdparts=pxa3xx_nand-0:2m(mvboot),-(ubi)"
> #define CONFIG_CMD_UBI
> #define CONFIG_CMD_UBIFS

> #define CONFIG_MTD_UBI_FASTMAP
> #define CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT1

I don’t define these 2, not sure if it matters.

> #define CONFIG_ENV_IS_IN_UBI
> #define CONFIG_ENV_UBI_PART"ubi"
> #define CONFIG_ENV_UBI_VOLUME"u-boot-env"
> #define CONFIG_ENV_SIZE(64 * 1024)

My config looks like this:

#define MTDIDS_DEFAULT "nand0=xilinx_nand"
#define MTDPARTS_DEFAULT \
"mtdparts=xilinx_nand:" \
"128k(fsbl)ro," \
"11M(u-boot)ro," \
"70M(boot-config)," \
"-(root)" 
#define CONFIG_ENV_IS_IN_UBI
#define CONFIG_ENV_UBI_PART "boot-config"
#define CONFIG_ENV_UBI_VOLUME "u-boot-env1"
#define CONFIG_ENV_UBI_VOLUME_REDUND "u-boot-env2"
#define CONFIG_ENV_SIZE 0x2

I create volumes like this:

"writepartitions=" \
"if ubi part boot-config && " \
"ubi read $verifyaddr u-boot-env1 1 && " \
"ubi read $verifyaddr u-boot-env2 1; " \
"then " \
"ubi remove bootfs && " \
"ubi remove config; " \
"else " \
"nand erase.part boot-config && " \
"ubi part boot-config && " \
"ubi create u-boot-env1 " __stringify(CONFIG_ENV_SIZE) 
" dynamic && " \
"ubi create u-boot-env2 " __stringify(CONFIG_ENV_SIZE) 
" dynamic; " \
"fi && " \
"ubi create bootfs " __stringify(CONFIG_BOOTFS_VOLUME_SIZE) " 
dynamic && " \
"ubi create config - dynamic && " \
"if ubi part root && " \
"ubi read $verifyaddr rootfs 1; " \
"then " \
"ubi remove rootfs; " \
"else " \
"nand erase.part root && " \
"ubi part root; " \
"fi && " \
"ubi create rootfs - dynamic;\0" \


> => ubi info
> UBI: MTD device name:"mtd=1"
> UBI: MTD device size:510 MiB
> UBI: physical eraseblock size:   131072 bytes (128 KiB)
> UBI: logical eraseblock size:126976 bytes
> UBI: number of good PEBs:4072
> UBI: number of bad PEBs: 8
> UBI: smallest flash I/O unit:2048
> UBI: VID header offset:  2048 (aligned 2048)
> UBI: data offset:4096
> UBI: max. allowed volumes:   128
> UBI: wear-leveling threshold:4096
> UBI: number of internal volumes: 1
> UBI: number of user volumes: 2
> UBI: available PEBs: 0
> UBI: total number of reserved PEBs: 4072
> UBI: number of PEBs reserved for bad PEB handling: 72
> UBI: max/mean erase counter: 18/4
>
> => ubi info l
> Volume information dump:
>   vol_id  0
>   reserved_pebs   1
>   alignment   1
>   data_pad0
>   vol_type3
>   name_len10
>   usable_leb_size 126976
>   used_ebs1
>   used_bytes  126976
>   last_eb_bytes   126976
>   corrupted   0
>   upd_marker  0
>   nameu-boot-env
> Volume information dump:
>   vol_id  

Re: [U-Boot] U-boot UBI environment

2016-05-10 Thread Heiko Schocher

Hello Joe,

Am 11.05.2016 um 01:15 schrieb Joseph Hershberger:

Hi Kevin,

Am 09.05.2016 um 23:16 schrieb Kevin Smith:

Hello,

I would appreciate some UBI help/advice if you are able to provide it.
I am trying to use UBI to store my u-boot environment, but when I try
to 'saveenv', it is corrupting another volume of my UBI.  I can image
the rootfs volume and boot Linux from it without a problem.  However,
the first time that I save the u-boot environment, the rootfs becomes
unreadable.  When the rootfs is corrupted, I have booted Linux from
another source and tried to attach UBI and dd out the data.  It
appears as all 0xFF.  Both u-boot and Linux can read the env volume correctly.

I do not think that there is a board in U-boot that uses UBI env, so I
do not have anything to compare to.  I have included some details of
my setup below.  Do you have any suggestion about what might be wrong?
I saw the recent patch b1d6590d35, and thought it might fix it, but am
still having the problem even with this.  Maybe there is another bug?
I am glad to provide more info as needed.
Thank you,
Kevin

DTS:
flash@d {
   num-cs = <1>;
   marvell,nand-keep-config;
   marvell,nand-enable-arbiter;
   nand-on-flash-bbt;
   nand-ecc-strength = <4>;
   nand-ecc-step-size = <512>;
   status = "okay";

   partition@0 {
   label = "mvboot";
   reg = <0 0x20>;
   };
   partition@20 {
   label = "ubi";
   reg = <0x20 0x1fe0>;
   };
};
Config:
#define MTDIDS_DEFAULT"nand0=pxa3xx_nand-0"
#define MTDPARTS_DEFAULT "mtdparts=pxa3xx_nand-0:2m(mvboot),-(ubi)"
#define CONFIG_CMD_UBI
#define CONFIG_CMD_UBIFS



#define CONFIG_MTD_UBI_FASTMAP
#define CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT1


I don’t define these 2, not sure if it matters.


This should be no problem ... but you (Kevin) may disable
FASTMAP for a test?


#define CONFIG_ENV_IS_IN_UBI
#define CONFIG_ENV_UBI_PART"ubi"
#define CONFIG_ENV_UBI_VOLUME"u-boot-env"
#define CONFIG_ENV_SIZE(64 * 1024)


My config looks like this:

#define MTDIDS_DEFAULT "nand0=xilinx_nand"
#define MTDPARTS_DEFAULT \
"mtdparts=xilinx_nand:" \
"128k(fsbl)ro," \
"11M(u-boot)ro," \
"70M(boot-config)," \
"-(root)"


You have 70MB for Env?


#define CONFIG_ENV_IS_IN_UBI
#define CONFIG_ENV_UBI_PART "boot-config"
#define CONFIG_ENV_UBI_VOLUME "u-boot-env1"
#define CONFIG_ENV_UBI_VOLUME_REDUND "u-boot-env2"
#define CONFIG_ENV_SIZE 0x2

I create volumes like this:

"writepartitions=" \
"if ubi part boot-config && " \
"ubi read $verifyaddr u-boot-env1 1 && " \
"ubi read $verifyaddr u-boot-env2 1; " \
"then " \
"ubi remove bootfs && " \
"ubi remove config; " \
"else " \
"nand erase.part boot-config && " \
"ubi part boot-config && " \
"ubi create u-boot-env1 " __stringify(CONFIG_ENV_SIZE) " dynamic 
&& " \
"ubi create u-boot-env2 " __stringify(CONFIG_ENV_SIZE) " 
dynamic; " \
"fi && " \
"ubi create bootfs " __stringify(CONFIG_BOOTFS_VOLUME_SIZE) " dynamic 
&& " \
"ubi create config - dynamic && " \
"if ubi part root && " \
"ubi read $verifyaddr rootfs 1; " \
"then " \
"ubi remove rootfs; " \
"else " \
"nand erase.part root && " \
"ubi part root; " \
"fi && " \
"ubi create rootfs - dynamic;\0" \



=> ubi info
UBI: MTD device name:"mtd=1"
UBI: MTD device size:510 MiB
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:126976 bytes
UBI: number of good PEBs:4072
UBI: number of bad PEBs: 8
UBI: smallest flash I/O unit:2048
UBI: VID header offset:  2048 (aligned 2048)
UBI: data offset:4096
UBI: max. allowed volumes:   128
UBI: wear-leveling threshold:4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 2
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 4072
UBI: number of PEBs reserved for bad PEB handling: 72
UBI: max/mean erase counter: 18/4

=> ubi info l
Volume information dump:
   vol_id  0
   reserved_pebs   1
   alignment   1
   data_pad0
   vol_type3
   name_len10
   usable_leb_size 126976
   used_ebs1
   used_bytes  126976
   last_eb_bytes   126976
   corrupted   0
   upd_marker  0
   nameu-boot-env


@Kevin: you have