uboot enviroment variable not updated.

1,013 views
Skip to first unread message

hussain ali

unread,
Jan 9, 2016, 7:30:03 AM1/9/16
to swup...@googlegroups.com
Hi Stephano,
After some effort on building image with yocto, finally I decide to build
swupdate binary manually!. I succeedded to cross compile it, but not all the components such as cfi and archive handler.
At the moment swupdate runs and updates my nand
flash partition, but it can not update uboot env correctly.
The mtdparts of nand are as follows:


device nand0 <nand.0>, # parts = 12
 #: name            size        offset        mask_flags
 0: NAND.SPL                0x00020000    0x00000000    0
 1: NAND.SPL.backup1        0x00020000    0x00020000    0
 2: NAND.SPL.backup2        0x00020000    0x00040000    0
 3: NAND.SPL.backup3        0x00020000    0x00060000    0
 4: NAND.u-boot-spl-os      0x00040000    0x00080000    0
 5: NAND.u-boot             0x00100000    0x000c0000    0
 6: NAND.u-boot-env         0x00020000    0x001c0000    0
 7: NAND.u-boot-env.backup1    0x00020000    0x001e0000    0
 8: NAND.kernel-1           0x00800000    0x00200000    0
 9: NAND.kernel-2           0x00800000    0x00a00000    0
10: NAND.rootfs-1           0x0c800000    0x01200000    0
11: NAND.rootfs-2           0x12600000    0x0da00000    0



and the description file ( for updating rootfs-2):

software =
{
        version = "0.1";

        hardware-compatibility = [ "revA" ];

        images: (
        /* single copy mode */
       
        {
                filename = "rootfs.ubifs";
                volume = "rootfs";
        }
   
            );

    uboot: (
        {
            name = "nandroot";
            value = "ubi0:rootfs rw ubi.mtd=11,512";
        }
        );
}



When I update rootfs-2, from os running on rootfs-1, logs are as follows:
(despite of some errors, updating is done and uboot env is updated)

Registered handlers:

    raw
    rawfile
    ubivol
    ubipartition
    shellscript
    preinstall
    postinstall
    uboot

[NOTIFY] : SWUPDATE running :  [extract_sw_description] : Found file:
    filename sw-description
    size 347
    checksum 0x5497 VERIFIED

Version 0.1

[NOTIFY] : SWUPDATE running :  [parse_images] : Found Image: rootfs.ubifs in volume : rootfs for handler ubivol

[NOTIFY] : SWUPDATE running :  [parse_uboot] : U-Boot var: nandroot = ubi0:rootfs rw ubi.mtd=11,512

[NOTIFY] : SWUPDATE running :  [cpio_scan] : Found file:

    filename rootfs.ubifs

    size 35610624

    REQUIRED

[  207.076748] UBI error: ubi_attach_mtd_dev: mtd10 is already attached to ubi0

ERROR corelib/mtd-interface.c : [  207.086303] UBI: default fastmap pool size: 80
scan_ubi_partiti[  207.092255] UBI: default fastmap WL pool size: 25

ons : 209 : cann[  207.098548] UBI: attaching mtd11 to ubi1

ot attach mtd10 - maybe not a NAND or raw device

[NOTIFY] : SWUPDATE failed [0] ERROR corelib/mtd-interface.c : scan_ubi_partitions : 209 : cannot attach mtd10 - maybe not a NAND or raw device

ERROR corelib/mtd-interface.c : scan_ubi_partitions : 185 : wrong MTD device /dev/mtd11

[NOTIFY] : SWUPDATE failed [0] ERROR corelib/mtd-interface.c : scan_ubi_partitions : 185 : wrong MTD device /dev/mtd11

[  207.689224] UBI: scanning is finished
[  207.702395] UBI: attached mtd11 (name "rootfs-2", size 200 MiB) to ubi1
[  207.709354] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[  207.716444] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[  207.723365] UBI: VID header offset: 512 (aligned 512), data offset: 2048
[  207.730367] UBI: good PEBs: 1600, bad PEBs: 0, corrupted PEBs: 0
[  207.736645] UBI: user volume: 1, internal volumes: 1, max. volumes count: 128
[  207.744107] UBI: max/mean erase counter: 4/1, WL threshold: 4096, image sequence number: 78718647
[  207.753372] UBI: available PEBs: 51, total reserved PEBs: 1549, PEBs reserved for bad PEB handling: 80
[  207.763416] UBI: background thread "ubi_bgt1d" started, PID 144
[NOTIFY] : SWUPDATE running :  [scan_ubi_partitions] : mtd11:    Volume found :     rootfs
[NOTIFY] : SWUPDATE running :  [install_images] : Found installer for stream rootfs.ubifs ubivol
[NOTIFY] : SWUPDATE running :  Installing image rootfs.ubifs into volume /dev/ubi1_0(rootfs)
Updating UBI : rootfs.ubifs 35610624 0

[NOTIFY] : SWUPD[  214.718556] ecc unrecoverable error

ATE running :  [[  214.722379] ecc unrecoverable error

update_uboot_env[  214.727396] ecc unrecoverable error

] : Updating U-b[  214.732426] ecc unrecoverable error

oot environment
[  214.737745] ecc unrecoverable error

[  214.742518] ecc unrecoverable error

[  214.746240] ecc unrecoverable error

[  214.749949] ecc unrecoverable error

Warning: Bad CRC, using default environment
Software updated successfully
Please reboot the device to start the new software
[NOTIFY] : SWUPDATE successful !



But when I update rootfs-1 from OS running on rootfs-2, logs are as follows ( in this case the rootfs is updated but uboot env not)
.
.
.
[  435.994249] UBI: default fastmap pool size: 80

[  435.998979] UBI: default fastmap WL pool size: 25

[  436.003917] UBI: attaching mtd10 to ubi1

[  436.592858] UBI: scanning is finished

[  436.605832] UBI: attached mtd10 (name "rootfs-1", size 200 MiB) to ubi1

[  436.612805] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes

[  436.619913] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 512

[  436.626814] UBI: VID header offset: 512 (aligned 512), data offset: 2048

[  436.633823] UBI: good PEBs: 1600, bad PEBs: 0, corrupted PEBs: 0

[  436.640100] UBI: user volume: 1, internal volumes: 1, max. volumes count: 128

[  436.647552] UBI: max/mean erase counter: 3/1, WL threshold: 4096, image sequence number: 393719481

[  436.656911] UBI: available PEBs: 51, total reserved PEBs: 1549, PEBs reserved for bad PEB handling: 80

[  436.667034] UBI: background thread "ubi_bgt1d" started, PID 149

[NOTIFY] : SWUPD[  436.676550] UBI error: ubi_attach_mtd_dev: mtd11 is already attached to ubi0

ATE running :  [scan_ubi_partitions] : mtd10:    Volume found :     rootfs

ERROR corelib/mtd-interface.c : scan_ubi_partitions : 185 : wrong MTD device /dev/mtd11

[NOTIFY] : SWUPDATE failed [0] ERROR corelib/mtd-interface.c : scan_ubi_partitions : 185 : wrong MTD device /dev/mtd11

ERROR corelib/mtd-interface.c : scan_ubi_partitions : 209 : cannot attach mtd11 - maybe not a NAND or raw device

[NOTIFY] : SWUPDATE failed [0] ERROR corelib/mtd-interface.c : scan_ubi_partitions : 209 : cannot attach mtd11 - maybe not a NAND or raw device

[NOTIFY] : SWUPDATE running :  [install_images] : Found installer for stream rootfs.ubifs ubivol

[NOTIFY] : SWUPDATE running :  Installing image rootfs.ubifs into volume /dev/ubi1_0(rootfs)

Updating UBI : rootfs.ubifs 35610624 0

[NOTIFY] : SWUPDATE running :  [update_uboot_env] : Updating U-boot environment

Software updated successfully

Please reboot the device to start the new software

[NOTIFY] : SWUPDATE successful !


#
 
there is another point.
The fw_printenv tool could not  show uboot env. The error messages are as follows:

[  185.460068] ecc unrecoverable error
[  185.463906] ecc unrecoverable error
[  185.467628] ecc unrecoverable error
[  185.471337] ecc unrecoverable error
[  185.475309] ecc unrecoverable error
[  185.479026] ecc unrecoverable error
[  185.482736] ecc unrecoverable error
[  185.486453] ecc unrecoverable error

Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200


But as soon as I update volume with swupdate, it works fine!!

This is content of the fw_env.config file:

/dev/mtd6 0x0 0x20000 0x20000


Best Regards,

Stefano Babic

unread,
Jan 10, 2016, 4:46:09 AM1/10/16
to hussain ali, swup...@googlegroups.com
Hi Hussain,

On 09/01/2016 13:30, hussain ali wrote:
> Hi Stephano,
> After some effort on building image with yocto, finally I decide to build
> swupdate binary manually!. I succeedded to cross compile it, but not all
> the components such as cfi and archive handler.

It is more difficult to build yourself as inside Yocto. Yocto takjes
care of dependencies and builds the required library. CFI and archive
require MTD headers and libarchive, that you have to build and put
yourself in your environment to succeed.

> At the moment swupdate runs and updates my nand
> flash partition, but it can not update uboot env correctly.
> The mtdparts of nand are as follows:
> /

This has nothing to do with swupdate. I think you cannot update U-Boot
environment at all, even with fw_setenv/fw_printenv provided by U-Boot.

> device nand0 <nand.0>, # parts = 12
> #: name size offset mask_flags
> 0: NAND.SPL 0x00020000 0x00000000 0
> 1: NAND.SPL.backup1 0x00020000 0x00020000 0
> 2: NAND.SPL.backup2 0x00020000 0x00040000 0
> 3: NAND.SPL.backup3 0x00020000 0x00060000 0
> 4: NAND.u-boot-spl-os 0x00040000 0x00080000 0
> 5: NAND.u-boot 0x00100000 0x000c0000 0
> 6: NAND.u-boot-env 0x00020000 0x001c0000 0
> 7: NAND.u-boot-env.backup1 0x00020000 0x001e0000 0
> 8: NAND.kernel-1 0x00800000 0x00200000 0
> 9: NAND.kernel-2 0x00800000 0x00a00000 0
> 10: NAND.rootfs-1 0x0c800000 0x01200000 0
> 11: NAND.rootfs-2 0x12600000 0x0da00000 0/
>

You miss to note which is the architecture you are using. From this
snapshot, I coul maybe wrongly think you have a TI SOC (4 copies of
SPL/MLO as TI specifies).

If this is true and you have an old SOC, do not forget that there is
hurdles between how to write into NAND. The SOC requires Hardware ECC to
load SPL, and this provides 1 bit correction. This is generally enough
for the first sector, not enough for the following ones. For this
reason, most boards using TI SOC switch to software ECC for all other
ranges outside SPL, and in U-Boot there is a command "nandecc" to allow
easy switching. By the way, it is important that the U-Boot environment
is managed by the NAND exactly as kernelr/rootfs, and I presume using
SW-ECC. The linux driver (if you have not patched or added support for
it) cannot switch between HW-ECC and SW-ECC.

>
> and the description file ( for updating rootfs-2):
>
> /software =
> {
> version = "0.1";
>
> hardware-compatibility = [ "revA" ];
>
> images: (
> /* single copy mode */
>
> {
> filename = "rootfs.ubifs";
> volume = "rootfs";
> }
>
> );
>
> uboot: (
> {
> name = "nandroot";
> value = "ubi0:rootfs rw ubi.mtd=11,512";
> }
> );
> }/
>
>
> When I update rootfs-2, from os running on rootfs-1, logs are as follows:
> (despite of some errors, updating is done and uboot env is updated)
>

I want to remark here that you are using the wrong setup if you want to
run as double copy. In this way, you need two different .swu if you
update rootfs-1 or rootfs-2, and thet is completely weird. Check for
"selections" inside documentation, you can have a single .swu without
having to know if rootfs-1 or rootfs-2 is updated.

> /Registered handlers:
ecc unrecoverable error: this comes from the kernel, that is from the
NAND driver. It has nothing to do with swupdate. Before going on, you
need to have fw_printenv/fw_setenv working. If this does not work,
swupdate cannot set the environment.

Check before: I am supposing the ECC setup is different between U-Boot
and kernel.

> Warning: Bad CRC, using default environment
> Software updated successfully
> Please reboot the device to start the new software
> [NOTIFY] : SWUPDATE successful !/
>
>
> But when I update rootfs-1 from OS running on rootfs-2, logs are as
> follows ( in this case the rootfs is updated but uboot env not)
> .
> .
> .
> /[ 435.994249] UBI: default fastmap pool size: 80
> [NOTIFY] : SWUPDATE successful ! /
>
> #
>
> there is another point.
> The fw_printenv tool could not show uboot env. The error messages are
> as follows:
>
> [/ 185.460068] ecc unrecoverable error
> [ 185.463906] ecc unrecoverable error
> [ 185.467628] ecc unrecoverable error
> [ 185.471337] ecc unrecoverable error
> [ 185.475309] ecc unrecoverable error
> [ 185.479026] ecc unrecoverable error
> [ 185.482736] ecc unrecoverable error
> [ 185.486453] ecc unrecoverable error
>

Exactly - you have to fix this, it has nothing to do with swupdate.
Until fw_printenv does not work, you have no chances to update the
environment from linux.


> Warning: Bad CRC, using default environment
> bootcmd=bootp; setenv bootargs root=/dev/nfs
> nfsroot=${serverip}:${rootpath}
> ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
> bootdelay=5
> baudrate=115200
>
>
> /
> But as soon as I update volume with swupdate, it works fine!!

The environment is shared between U-Boot and linux, volumes are updated
only by linux, I presume. By the way, you can access the volumes from
U-Boot, too (see documentation in U-Boot). Try to access the volumes
from the U-Boot's console, I guess you will get ECC (error -74) errors, too.

>
> This is content of the fw_env.config file:
>
> //dev/mtd6 0x0 0x20000 0x20000/
>

This is also wrong. If you have setup twice the environment in U-Boot
(I see NAND.u-boot-env.backup1), you have to set it as well. And is it
the environment's size really 0x20000 ? Check in your U-Boot config,
they *must* match.

Best regards,
Stefano Babic


--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=====================================================================

s...@vctlabs.com

unread,
Jan 15, 2016, 4:41:43 AM1/15/16
to swupdate, hussain...@gmail.com, sba...@denx.de

Very good advice from Stefano, but I'll add a couple points.

You didn't mention your hardware platform, but I've run accross this
situation with mismatching ECC multiple times. Sometimes a vendor will
do this inconvenient thing where u-boot and kernel have totally different
ECC schemes in the initial BSP, but by the time the board gets mainline
support in u-boot and kernel, this disagreement has been ironed out.
So if you're not already using the latest kernel & u-boot, might want to
check whether the ECC situation has improved in the latest.

About the size of the u-boot env, you might be confusing the size of the
partitions containing the env copies rather than the actual size of the
env itself. It is rare for a board to use an env big enough to fill a
whole erase block, so the rest of the mtd partition is probably just unused.

hussain ali

unread,
Jan 16, 2016, 1:51:33 AM1/16/16
to swup...@googlegroups.com

---------- Forwarded message ----------
From: hussain ali <hussain...@gmail.com>
Date: Wed, Jan 13, 2016 at 1:33 PM
Subject: Re: [swupdate] uboot enviroment variable not updated.
To: Stefano Babic <sba...@denx.de>




On Sun, Jan 10, 2016 at 1:16 PM, Stefano Babic <sba...@denx.de> wrote:

Thanks Stefano.
 
It is more difficult to build yourself as inside Yocto. Yocto takjes
care of dependencies and builds the required library. CFI and archive
require MTD headers and libarchive, that you have to build and put
yourself in your environment to succeed.

 You're right. I had many difficulties in cross compiling swupdate. But there was a way that i chose because i could not work with yocto. But I'll do it in near future, God willing.
 

You miss to note which is the architecture you are using. From this
snapshot, I coul maybe wrongly think you have a TI SOC (4 copies of
SPL/MLO as TI specifies).
I'm using uSomiQ am335x board that is a BeagleBone Black clone with added more robust SLC NAND flash. 

If this is true and you have an old SOC, do not forget that there is
hurdles between how to write into NAND. The SOC requires Hardware ECC to load SPL, and this provides 1 bit correction. This is generally enough for the first sector, not enough for the following ones. For this
reason, most boards using TI SOC switch to software ECC for all other
ranges outside SPL, and in U-Boot there is a command "nandecc" to allow
easy switching. By the way, it is important that the U-Boot environment
is managed by the NAND exactly as kernelr/rootfs, and I presume using
SW-ECC. The linux driver (if you have not patched or added support for
it) cannot switch between HW-ECC and SW-ECC.
 
 
I want to remark here that you are using the wrong setup if you want to

run as double copy. In this way, you need two different .swu if you
update rootfs-1 or rootfs-2, and thet is completely weird. Check for
"selections" inside documentation, you can have a single .swu without
having to know if rootfs-1 or rootfs-2 is updated.

Oh, really I know. It was just a example swdescription that i used for some tests.  
ecc unrecoverable error: this comes from the kernel, that is from the
NAND driver. It has nothing to do with swupdate. Before going on, you
need to have fw_printenv/fw_setenv working. If this does not work,
swupdate cannot set the environment.

Check before: I am supposing the ECC setup is different between U-Boot
and kernel.
I've checked ( but I'm not confident whether this way is true to check ECC setup or not ) the nand_ecc.c file in the kernel and uboot. Both of them contain an ECC algorithm that detects and corrects 1 bit errors in a 256 byte block of data.

This is also wrong. If you have setup twice the environment in U-Boot
(I see NAND.u-boot-env.backup1), you have to set it as well. And is it
the environment's size really 0x20000 ? Check in your U-Boot config,
they *must* match.
That's right.I've also added backup partition to config file and now I can update Uboot env successfully.
But the "ecc unrecoverable error" still exists.
When I run fw_printenv, environment variables are printed after a bunch of error messages, "ecc unrecoverable error".

Best regards,


Reply all
Reply to author
Forward
0 new messages