[PATCH openbmc 7/8] Hack to make fw_setenv work

Benjamin Herrenschmidt benh at au1.ibm.com
Fri Jan 29 11:20:51 AEDT 2016


On Thu, 2016-01-28 at 16:50 -0600, OpenBMC Patches wrote:
> From: "Milton D. Miller II" <miltonm at us.ibm.com>
> 
> The fw_setenv is not working with the kernel mtd driver.  It works
> on a plain flat file, and flashcp which is used in /update works.

Do we know why the kernel mtd driver doesn't work ? This worries me ...
we should root cause this first.

> Find the u-boot-env mtd, link it in run and copy the contents to a
> plain file in /run during init.  In shutdown, check for the link,
> the file having data, no current image update for the u-boot-env,
> and that the content differs from the mtd via the link.  If all
> are true create a symlink to the file and trigger the update.
> 
> Along wtih changing the fw_env.config this causes the fw_setenv
> and fw_printenv utilities to set and update this cached file which
> will be synced during a normal bmc reboot.  This will allow us to
> set the ethaddr variable which already requires a reboot to activate.
> 
> Note: the links are directly in /run because the fw_{set,print}env
> utilities limit the env file name to 16 characters.
> 
> Signed-off-by: Milton Miller <miltonmm at us.ibm.com>
> ---
>  .../meta-ast2400/recipes-bsp/u-boot/files/fw_env.config            | 
> 3 ++-
>  .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh       | 
> 7 +++++++
>  .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh   | 
> 5 +++++
>  3 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-bsp/u-
> boot/files/fw_env.config b/meta-openbmc-bsp/meta-aspeed/meta-
> ast2400/recipes-bsp/u-boot/files/fw_env.config
> index fe09890..978e4d6 100644
> --- a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-bsp/u-
> boot/files/fw_env.config
> +++ b/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-bsp/u-
> boot/files/fw_env.config
> @@ -12,7 +12,8 @@
>  
>  # MTD SPI-dataflash example
>  # MTD device name	Device offset	Env. size	Flash
> sector size	Number of sectors
> -/dev/mtd2		0x00000		0x20000
> +#/dev/mtd2		0x00000		0x20000
> +/run/fw_env		0x00000		0x20000
>  #/dev/mtd5		0x4200		0x4200
>  #/dev/mtd6		0x4200		0x4200
>  
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-
> initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-
> phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index 431780a..0dc4c35 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-
> initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-
> initfs/files/obmc-init.sh
> @@ -29,6 +29,13 @@ findmtd() {
>  	echo $m
>  }
>  
> +env=$(findmtd u-boot-env)
> +if test -n $env
> +then
> +	ln -s /dev/$env /run/mtd:u-boot-env
> +	cp /run/mtd:u-boot-env /run/fw_env
> +fi
> +
>  rofs=$(findmtd rofs)
>  rwfs=$(findmtd rwfs)
>  
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-
> initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-
> phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> index 029cd65..cc076fd 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-
> initfs/files/obmc-shutdown.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-
> initfs/files/obmc-shutdown.sh
> @@ -24,6 +24,11 @@ do
>  done
>  set +x
>  
> +if test -s /run/fw_env -a -c /run/mtd:u-boot-env -a ! -e /image-u-
> boot-env &&
> +	! cmp /run/mtd:u-boot-env /run/fw_env
> +then
> +	ln -s /run/fw_env /image-u-boot-env
> +fi
>  
>  if test -x /update && ls image-* > /dev/null 2>&1
>  then



More information about the openbmc mailing list