[U-Boot] [PATCH] tools/fw_env: use fsync to ensure that data is physically stored

Michael Heimpold mhei at heimpold.de
Tue May 21 19:34:06 CEST 2013


Hi Wolfgang Denx,

> > Closing a file descriptor does not guarantee that the data has been
> > successfully saved to disk, as the kernel might defer the write.
> 
> What is the exact problem you are trying to fix?
> 
> I mean, when exactly does adding the sync play a role?

I'm using fw_setenv during system update process. The sequence
of such a shell script is something like (much simplified):

...
fw_setenv state=2
dd if=... of=/dev/mmcblk0...
fw_setenv state=1
...
reboot

The (redundant) environment is stored in a eMMC flash.
The env var 'state' gives a hint to U-Boot whether/where the process
was interrupted.

So my intension is to be absolutely sure, that when fw_setenv returns,
the environment is written out to disk.

Best regards,
Michael



More information about the U-Boot mailing list