Re: [U-Boot] [fw_printenv should open device as O_SYNC]

2008-09-11 Thread Mari Ivan-AIM018
 What eactly do you mean by I switch the banks ? How exactly do you
do that? Can you please provide the exact  set of commands you are
using?

Hello Wolfgang,

We are using ATCA equipment and those boards have redundant boot banks
and they are managed by IPMI controllers.
So while you are you are running Linux, you can change the boot banks
for next restart through set boot options IPMI command.
The problem arises when we write the U-Boot env variables using
fw_setenv and immediately send the IPMI command to switch the boot bank.
In this situation the variables are not written immediately by the
fw_setenv application but buffered to be written later when the OS
decides it is the time to write them to the mtd driver. But it is too
late because the IPMI command was quickly executed and the boot bank has
changed. This could yield to a corrupted flash boot bank.

Following is the change I've made:

-sh-3.00$ diff -uprN  a/tools/env/fw_env.c b/tools/env/fw_env.c
--- a/tools/env/fw_env.c2008-09-10 17:52:17.362714000 -0200
+++ b/tools/env/fw_env.c2008-09-10 17:57:54.168238000 -0200
@@ -434,7 +434,7 @@ int fw_setenv (int argc, char *argv[])
*environment.crc = crc32 (0, (uint8_t *) environment.data,
ENV_SIZE);

/* write environment back to flash */
-   if (flash_io (O_RDWR)) {
+   if (flash_io (O_RDWR | O_SYNC)) {
fprintf (stderr, Error: can't write fw_env to
flash\n);
return -1;
}



Regards,

Ivan 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 10, 2008 5:57 PM
To: Mari Ivan-AIM018
Cc: u-boot@lists.denx.de
Subject: Re: [U-Boot] [fw_printenv should open device as O_SYNC]

Dear Ivan,

In message
[EMAIL PROTECTED] you
wrote:
 
 We have hit the following issue in a board with 2 flash banks.

 First I set some env variable in U-boot, using fw_setenv, then 
 immediately I switch the banks. But as the buffers have not yet been 
 flushed to the mtd driver, the bank switching leaves the flash in 
 corrupted state.

What eactly do you mean by I switch the banks ? How exactly do you do
that? Can you please provide the exact set of commands you are using?

 I ve modified the fw_env.c file to open the mtd O_SYNC and it works 
 fine.
  
 If it is OK I can submit a patch for this.

sure. Please submit it so we can see what you are talking about.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [EMAIL PROTECTED]
Keep your eyes wide open before marriage, half shut afterwards.
 -- Benjamin Franklin
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [fw_printenv should open device as O_SYNC]

2008-09-10 Thread Mari Ivan-AIM018
Hi all,
 
We have hit the following issue in a board with 2 flash banks.
 
First I set some env variable in U-boot, using fw_setenv, then
immediately I switch the banks. But as the buffers have not yet been
flushed to the mtd driver, the bank switching leaves the flash in
corrupted state.
 
I ve modified the fw_env.c file to open the mtd O_SYNC and it works
fine.
 
If it is OK I can submit a patch for this.
 
 
Regards,
 
Ivan
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot