[OpenBIOS] r715 - dev/olpc/spiflash

svn at openbios.org svn at openbios.org
Wed Nov 7 08:34:31 CET 2007


Author: wmb
Date: 2007-11-07 08:34:31 +0100 (Wed, 07 Nov 2007)
New Revision: 715

Modified:
   dev/olpc/spiflash/spiui.fth
Log:
Added restore-mfg-data <filename> to restore manufacturing data
saved by save-mfg-data.  Also fixed a bug in save-mfg-data whereby
the wrong filename is generated for old machines where the SN tag
value doesn't have a trailing null.


Modified: dev/olpc/spiflash/spiui.fth
===================================================================
--- dev/olpc/spiflash/spiui.fth	2007-11-07 07:27:51 UTC (rev 714)
+++ dev/olpc/spiflash/spiui.fth	2007-11-07 07:34:31 UTC (rev 715)
@@ -122,7 +122,11 @@
 [ifdef] $call-method
 : make-sn-name  ( -- filename$ )
    " SN" find-tag 0=  abort" No serial number in mfg data"  ( sn$ )
-   dup  if  1-  then         ( sn$' )  \ Remove Null
+   dup  if                   ( sn$ )
+      2dup + 1- c@ 0=  if    ( sn$ )
+         1-                  ( sn$' )    \ Remove Null
+      then                   ( sn$ )
+   then                      ( sn$ )
    d# 11 over -  dup 0>  if  ( sn$' #excess )
       /string                ( sn$' )  \ Keep last 11 characters
    else                      ( sn$' #excess )
@@ -148,6 +152,23 @@
    mfg-data-range  " write" r@ $call-method   ( r: ihandle )
    r> close-dev
 ;
+: restore-mfg-data  ( "filename" -- )
+   reading
+   ifd @ fsize  dup /flash-block >  if  ( len )
+      drop  ifd @ fclose                ( )
+      true abort" File is too big"
+   then                                 ( len )
+   mfg-data-buf  swap                   ( adr len )
+   2dup ifd @ fgets drop                ( adr len )
+   ifd @ fclose
+
+   spi-start spi-identify
+   mfg-data-offset erase-spi-block      ( adr len )
+   mfg-data-end-offset over -           ( adr len offset )
+   write-spi-flash                      ( )
+   spi-reprogrammed                     ( )
+;
+
 [then]
 
 : ?move-mfg-data  ( -- )




More information about the OpenBIOS mailing list