<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt" ><div dir="ltr" >I've added decoding of the fsr and sr and tracing and found that at some point the fsr Erase-error comes on and shortly thereafter the Program-Error comes on.  Alas, that trace didn't have the dynamic debug for read, write, and erase commands enabled, and I got busy getting what we have flushed.  Also, there was no way to send the clear-status command so I had to power cycle to try again.</div>
<div dir="ltr" > </div>
<div dir="ltr" >The biggest difference from what I can see is that fw_setenv calls erase and write on the whole env file of 32 kernel erase pages while flashcp and flash_eraseall do an ioctl one erase block at a time, and then optionally write to stdout.  The spi-nor.c library appears to loop over the approprate sized chunks, but it appears the original data is not erased.  I even did a manual wirte to ff and setenv created a good checksum (once). </div>
<div dir="ltr" > </div>
<div dir="ltr" >milton</div>
<div dir="ltr" > </div>
<div dir="ltr" > </div>
<blockquote data-history-content-modified="1" dir="ltr" style="border-left:solid #aaaaaa 2px; margin-left:5px; padding-left:5px; direction:ltr; margin-right:0px" >----- Original message -----<br>From: Benjamin Herrenschmidt <benh@au1.ibm.com><br>To: OpenBMC Patches <openbmc-patches@stwcx.xyz>, openbmc@lists.ozlabs.org<br>Cc: Milton Miller II/Austin/IBM@IBMUS<br>Subject: Re: [PATCH openbmc 7/8] Hack to make fw_setenv work<br>Date: Thu, Jan 28, 2016 6:25 PM<br> 
<div><font face="Default Monospace,Courier New,Courier,monospace" size="2" >On Thu, 2016-01-28 at 16:50 -0600, OpenBMC Patches wrote:<br>> From: "Milton D. Miller II" <miltonm@us.ibm.com><br>><br>> The fw_setenv is not working with the kernel mtd driver.  It works<br>> on a plain flat file, and flashcp which is used in /update works.<br><br>Do we know why the kernel mtd driver doesn't work ? This worries me ...<br>we should root cause this first.<br><br>> Find the u-boot-env mtd, link it in run and copy the contents to a<br>> plain file in /run during init.  In shutdown, check for the link,<br>> the file having data, no current image update for the u-boot-env,<br>> and that the content differs from the mtd via the link.  If all<br>> are true create a symlink to the file and trigger the update.<br>><br>> Along wtih changing the fw_env.config this causes the fw_setenv<br>> and fw_printenv utilities to set and update this cached file which<br>> will be synced during a normal bmc reboot.  This will allow us to<br>> set the ethaddr variable which already requires a reboot to activate.<br>><br>> Note: the links are directly in /run because the fw_{set,print}env<br>> utilities limit the env file name to 16 characters.<br>><br>> Signed-off-by: Milton Miller <miltonmm@us.ibm.com><br>> ---<br>>  .../meta-ast2400/recipes-bsp/u-<br>> boot/files/fw_env.config            | <br>> 3 ++-<br>>  .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-<br>> init.sh       | <br>> 7 +++++++<br>>  .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-<br>> shutdown.sh   | <br>> 5 +++++<br>>  3 files changed, 14 insertions(+), 1 deletion(-)<br>><br>> diff --git a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-bsp/u-<br>> boot/files/fw_env.config b/meta-openbmc-bsp/meta-aspeed/meta-<br>> ast2400/recipes-bsp/u-boot/files/fw_env.config<br>> index fe09890..978e4d6 100644<br>> --- a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-bsp/u-<br>> boot/files/fw_env.config<br>> +++ b/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-bsp/u-<br>> boot/files/fw_env.config<br>> @@ -12,7 +12,8 @@<br>>  <br>>  # MTD SPI-dataflash example<br>>  # MTD device name Device offset Env. size Flash<br>> sector size Number of sectors<br>> -/dev/mtd2 0x00000 0x20000<br>> +#/dev/mtd2 0x00000 0x20000<br>> +/run/fw_env 0x00000 0x20000<br>>  #/dev/mtd5 0x4200 0x4200<br>>  #/dev/mtd6 0x4200 0x4200<br>>  <br>> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-<br>> initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-<br>> phosphor/obmc-phosphor-initfs/files/obmc-init.sh<br>> index 431780a..0dc4c35 100644<br>> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-<br>> initfs/files/obmc-init.sh<br>> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-<br>> initfs/files/obmc-init.sh<br>> @@ -29,6 +29,13 @@ findmtd() {<br>>   echo $m<br>>  }<br>>  <br>> +env=$(findmtd u-boot-env)<br>> +if test -n $env<br>> +then<br>> + ln -s /dev/$env /run/mtd:u-boot-env<br>> + cp /run/mtd:u-boot-env /run/fw_env<br>> +fi<br>> +<br>>  rofs=$(findmtd rofs)<br>>  rwfs=$(findmtd rwfs)<br>>  <br>> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-<br>> initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-<br>> phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh<br>> index 029cd65..cc076fd 100644<br>> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-<br>> initfs/files/obmc-shutdown.sh<br>> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-<br>> initfs/files/obmc-shutdown.sh<br>> @@ -24,6 +24,11 @@ do<br>>  done<br>>  set +x<br>>  <br>> +if test -s /run/fw_env -a -c /run/mtd:u-boot-env -a ! -e /image-u-<br>> boot-env &&<br>> + ! cmp /run/mtd:u-boot-env /run/fw_env<br>> +then<br>> + ln -s /run/fw_env /image-u-boot-env<br>> +fi<br>>  <br>>  if test -x /update && ls image-* > /dev/null 2>&1<br>>  then</font></div></blockquote>
<div dir="ltr" > </div></div><BR>