* how u-boot handles the environment (rpi4, fat environment)
@ 2022-09-25 16:46 marty leisner
2022-09-29 12:57 ` Tom Rini
0 siblings, 1 reply; 3+ messages in thread
From: marty leisner @ 2022-09-25 16:46 UTC (permalink / raw)
To: u-boot
I'm running ubuntu 20.04 server (which uses u-boot v2021.01 with minor
changes/enhancements)
fw_printenv doesn't seem to work -- it always comes up with a crc error (I
haven't tried fw_setenv yet).
Is there a spec of how the environment works? I haven't seen one.
Without this patch, I get:
Warning: Bad CRC, using default environment
The first environment variable has a "0x1" in front of it.
When I apply this patch, things seem to work:
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 66cb9d2a..c85b471a 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1457,8 +1457,8 @@ int fw_env_open(struct env_opts *opts)
goto open_cleanup;
}
- crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE);
-
+ crc0 = crc32(0, (uint8_t *) (environment.data + 1) , ENV_SIZE - 1);
But I'm not at the phase of doing fw_setenv (I would have used a newer
u-boot, but I'm getting resets on bootup (it works
on a vanilla 20.04 system).
marty
marty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: how u-boot handles the environment (rpi4, fat environment)
2022-09-25 16:46 how u-boot handles the environment (rpi4, fat environment) marty leisner
@ 2022-09-29 12:57 ` Tom Rini
2022-10-02 18:38 ` marty leisner
0 siblings, 1 reply; 3+ messages in thread
From: Tom Rini @ 2022-09-29 12:57 UTC (permalink / raw)
To: marty leisner; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]
On Sun, Sep 25, 2022 at 12:46:10PM -0400, marty leisner wrote:
> I'm running ubuntu 20.04 server (which uses u-boot v2021.01 with minor
> changes/enhancements)
>
> fw_printenv doesn't seem to work -- it always comes up with a crc error (I
> haven't tried fw_setenv yet).
>
> Is there a spec of how the environment works? I haven't seen one.
>
> Without this patch, I get:
> Warning: Bad CRC, using default environment
>
> The first environment variable has a "0x1" in front of it.
> When I apply this patch, things seem to work:
>
> diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
> index 66cb9d2a..c85b471a 100644
> --- a/tools/env/fw_env.c
> +++ b/tools/env/fw_env.c
> @@ -1457,8 +1457,8 @@ int fw_env_open(struct env_opts *opts)
> goto open_cleanup;
> }
>
> - crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE);
> -
> + crc0 = crc32(0, (uint8_t *) (environment.data + 1) , ENV_SIZE - 1);
>
> But I'm not at the phase of doing fw_setenv (I would have used a newer
> u-boot, but I'm getting resets on bootup (it works
> on a vanilla 20.04 system).
Please include your /etc/fw_env.config file and relevant CONFIG_ENV
settings from the U-Boot build.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: how u-boot handles the environment (rpi4, fat environment)
2022-09-29 12:57 ` Tom Rini
@ 2022-10-02 18:38 ` marty leisner
0 siblings, 0 replies; 3+ messages in thread
From: marty leisner @ 2022-10-02 18:38 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 2689 bytes --]
In order for fw_printenv/fw_setenv to work, I have to attach the attached
patch.
leisner@rpi4b:~/bin$ cat /etc/fw_env.config
/boot/firmware/uboot.env 0x0000 0x20000
leisner@rpi4b:/usr/local/src/consulting/turf-tank/u-boot-2021.01+dfsg$ grep
CONFIG_ENV .config
CONFIG_ENV_SIZE=0x20000
CONFIG_ENV_VARS_UBOOT_CONFIG=y
CONFIG_ENV_SUPPORT=y
# CONFIG_ENV_OVERWRITE is not set
# CONFIG_ENV_IS_NOWHERE is not set
# CONFIG_ENV_IS_IN_EEPROM is not set
CONFIG_ENV_IS_IN_FAT=y
# CONFIG_ENV_IS_IN_EXT4 is not set
# CONFIG_ENV_IS_IN_FLASH is not set
# CONFIG_ENV_IS_IN_MMC is not set
# CONFIG_ENV_IS_IN_NAND is not set
# CONFIG_ENV_IS_IN_NVRAM is not set
# CONFIG_ENV_IS_IN_ONENAND is not set
# CONFIG_ENV_IS_IN_REMOTE is not set
# CONFIG_ENV_IS_IN_SPI_FLASH is not set
CONFIG_ENV_FAT_INTERFACE="mmc"
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_ENV_FAT_FILE="uboot.env"
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
# CONFIG_ENV_APPEND is not set
# CONFIG_ENV_WRITEABLE_LIST is not set
# CONFIG_ENV_ACCESS_IGNORE_FORCE is not set
I still get the "1" in the printenv output of the first env variable. But
I was able to use setenv.
Without the patch, on reboot I get:
*** Warning - bad CRC, using default environment
The version string (I'm using the ubuntu source) is:
U-Boot 2021.01-gc7eed6f7-dirty (Sep 27 2022 - 20:05:05 -0400)
On Thu, Sep 29, 2022 at 8:57 AM Tom Rini <trini@konsulko.com> wrote:
> On Sun, Sep 25, 2022 at 12:46:10PM -0400, marty leisner wrote:
>
> > I'm running ubuntu 20.04 server (which uses u-boot v2021.01 with minor
> > changes/enhancements)
> >
> > fw_printenv doesn't seem to work -- it always comes up with a crc error
> (I
> > haven't tried fw_setenv yet).
> >
> > Is there a spec of how the environment works? I haven't seen one.
> >
> > Without this patch, I get:
> > Warning: Bad CRC, using default environment
> >
> > The first environment variable has a "0x1" in front of it.
> > When I apply this patch, things seem to work:
> >
> > diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
> > index 66cb9d2a..c85b471a 100644
> > --- a/tools/env/fw_env.c
> > +++ b/tools/env/fw_env.c
> > @@ -1457,8 +1457,8 @@ int fw_env_open(struct env_opts *opts)
> > goto open_cleanup;
> > }
> >
> > - crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE);
> > -
> > + crc0 = crc32(0, (uint8_t *) (environment.data + 1) , ENV_SIZE -
> 1);
> >
> > But I'm not at the phase of doing fw_setenv (I would have used a newer
> > u-boot, but I'm getting resets on bootup (it works
> > on a vanilla 20.04 system).
>
> Please include your /etc/fw_env.config file and relevant CONFIG_ENV
> settings from the U-Boot build.
>
> --
> Tom
>
[-- Attachment #2: fw_env.c.diff --]
[-- Type: text/x-patch, Size: 911 bytes --]
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 66cb9d2a..1ac413b1 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -513,7 +513,7 @@ int fw_env_flush(struct env_opts *opts)
/*
* Update CRC
*/
- *environment.crc = crc32(0, (uint8_t *) environment.data, ENV_SIZE);
+ *environment.crc = crc32(0, (uint8_t *) environment.data + 1, ENV_SIZE - 1);
/* write environment back to flash */
if (flash_io(O_RDWR)) {
@@ -1457,8 +1457,8 @@ int fw_env_open(struct env_opts *opts)
goto open_cleanup;
}
- crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE);
-
+ crc0 = crc32(0, (uint8_t *) (environment.data + 1) , ENV_SIZE - 1);
+// crc0 = crc32(0, (uint8_t *) (environment.data) , ENV_SIZE);
crc0_ok = (crc0 == *environment.crc);
if (!have_redund_env) {
if (!crc0_ok) {
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-02 18:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-25 16:46 how u-boot handles the environment (rpi4, fat environment) marty leisner
2022-09-29 12:57 ` Tom Rini
2022-10-02 18:38 ` marty leisner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.