cancel
Showing results for 
Search instead for 
Did you mean: 

Uboot Environment Configuration

ajava
Associate II

Hello,

i am using an stm32mp1-dk2 board.

For using fw_printenv and other uboot tools from user space one must define a "/etc/fw_env.config" file. I can see that the "/uboot.env" file is driectly saved under the root "/" and so i defined the "fw_env.config" like that:

 

# cat /etc/fw_env.config
# Device name      Device offset  Env. size      Flash sector size
/uboot.env   0x0000 0x2000

But every time i run fw_printenv i get following msg:

# fw_printenv
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

As you can it claims about "BAD CRC...".

My question is:

How should a correct "fW_env.config" looks like for a stm32mp1-dk2 board?

 

Thanks

 

 

9 REPLIES 9
Christophe Guibout
ST Employee

Hello @ajava​ ,

This issue is known and will be fixed in the next release MMDV-2.0.0.

Here is the patch in u-boot to fix the CRC error:

The output of the function mmc_offset_try_partition must be a
byte offset in mmc and not a multiple of blksz.
 
 
This function is used in mmc_offset(), called by mmc_get_env_addr()
and the offset is used in write_env(), erase_env() and read_env().
 
In these function, blk_start = offset / mmc->read_bl_len
or /write_bl_len so this offset is not a multiple of blksz.
 
Signed-off-by: Patrick Delaunay <patrick.delau...@st.com>
---
 
 env/mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
 
diff --git a/env/mmc.c b/env/mmc.c
index 902cca23ad..c24b169f3e 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -56,10 +56,10 @@ static inline int mmc_offset_try_partition(const char *str, 
s64 *val)
        }
 
        /* round up to info.blksz */
-       len = (CONFIG_ENV_SIZE + info.blksz - 1) & ~(info.blksz - 1);
+       len = DIV_ROUND_UP(CONFIG_ENV_SIZE, info.blksz);
 
        /* use the top of the partion for the environment */
-       *val = (info.start + info.size - 1) - len / info.blksz;
+       *val = (info.start + info.size - len) * info.blksz;
 
        return 0;
 }
-- 
2.17.1

BR,

Christophe

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

thanks @Christophe Guibout​  i just applied the patch, but unfortunately i still get the Bad-CRC Error! the problem is i am not realy sure if ​ my fw_env.config-setting is really ok.

    # cat /etc/fw_env.config
    # Device name      Device offset  Env. size      Flash sector size
    /uboot.env   0x0000 0x2000

But unfortunately there is alno no where documented how to setup this file for STM32mp1-boards, where the uboot.env-file os saved directly under root "/" of ext4 partition!

any suggestion is welcome!

Christophe Guibout
ST Employee

Hi @ajava​ ,

Your fw_env.config looks good.

Our new fw_env.config file would not help because in the next release, u-boot-env will move at the end of ssbl partition.

Maybe there is a dependency on the patch, like this one : https://www.mail-archive.com/u-boot@lists.denx.de/msg360710.html

The last patch shouldn't help, but I mention it for information : https://www.mail-archive.com/u-boot@lists.denx.de/msg360708.html

We use to upstream patches, so feel free to look into the following new patches related to env : https://www.mail-archive.com/search?l=u-boot%40lists.denx.de&q=%40st.com+env&x=0&y=0

Hope it will help.

BR,

Christophe

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
ajava
Associate II

@Christophe Guibout​  thanks, so i think it is better to wait till your patches are in official release.

@Christophe Guibout​ to satisfy my own curiosity, i also tried the other patches of the patch-series (1-3) you mentioned. But unfortunately i am still getting CRC-Error :(

PDELA.1
Associate II

in Open ST Linux v1.2.0 U-Boot enviromnent is saved at root (/) of bootfs (4th parttion of SD card)

normally mounted in /boot directory in Linux

Board $> mount /dev/mmcblk0p4 /boot (if not already done)

Can you try with: /boot/uboot.env

Smedi
Associate II

Hai,

I was also trying to include the fw_printenv in the user space but when I include u-boot-fw-utils in my st-image-core.bb file I was throwing the exception as below

ERROR: oe_runmake failed

| WARNING: exit code 1 from a shell command.

| ERROR: Function failed: do_compile (log file is located at yocto-stm32mp1-koan/build/tmp-glibc/work/stm32mp1_disco-openstlinux_weston-linux-gnueabi/u-boot-fw-utils/1_2018.07-r0/temp/log.do_compile.28043)

ERROR: Task (yocto-stm32mp1-koan/sources/poky/meta/recipes-bsp/u-boot/u-boot-fw-utils_2018.07.bb:do_compile) failed with exit code '1'

Can you tell me how to include the fw-utils in the build and I am working on STM32MP157C-DK2 board.

Regards

Srikanth.

ajava
Associate II

@Christophe Guibout​ 

Ok, I am now using the latest release, where "uboot-env" is saved at the end of uboot-image partition (mmcblk0p3).

This relase: https://github.com/STMicroelectronics/u-boot

Regarding the config-file, the env-settings are:

0693W000003BxfMQAS.png

So I configured the "/etc/fw_env.config":

# MTD device name    Device offset  Env. size    Flash sector size

/dev/mmcblk0p3     0x280000    0x2000     0x40000

But unfortunately it is still no working and gives "CRC"-Erorr!

What is going wrong here? Why?

Thanks and Regards

Arash

@ajava@Christophe Guibout,

Any update on this issue with latest release of OpenSTLinux, i'm still seeing the same "Warning: Bad CRC, using default environment" with STM32MP135-DK board