[openfirmware] [commit] r3304 - cpu/arm/olpc/cl4 dev/olpc/spiflash

repository service svn at openfirmware.info
Fri Sep 14 08:19:54 CEST 2012


Author: wmb
Date: Fri Sep 14 08:19:54 2012
New Revision: 3304
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3304

Log:
OLPC XO-4 - better support for different SPI FLASH sizes.

Modified:
   cpu/arm/olpc/cl4/config.fth
   dev/olpc/spiflash/spiflash.fth
   dev/olpc/spiflash/spiui.fth

Modified: cpu/arm/olpc/cl4/config.fth
==============================================================================
--- cpu/arm/olpc/cl4/config.fth	Fri Sep 14 08:18:41 2012	(r3303)
+++ cpu/arm/olpc/cl4/config.fth	Fri Sep 14 08:19:54 2012	(r3304)
@@ -13,10 +13,10 @@
 
 h# 10.0000 constant /rom           \ Total size of SPI FLASH
 
-/rom h# 1.0000 - constant mfg-data-offset     \ Offset to manufacturing data area in SPI FLASH
-/rom             constant mfg-data-end-offset \ Offset to end of manufacturing data area in SPI FLASH
-mfg-data-offset h# 30 - constant crc-offset        \ e.g. 1e.ffd0
-crc-offset      h# 10 - constant signature-offset  \ e.g. 1e.ffc0
+: mfg-data-offset  /rom h# 1.0000 - ;      \ Offset to start of manufacturing data area in SPI FLASH
+: mfg-data-end-offset  /rom  ;             \ Offset to end of manufacturing data area in SPI FLASH
+: crc-offset  mfg-data-offset h# 30 - ;    \ e.g. 1e.ffd0
+: signature-offset  crc-offset  h# 10 - ;  \ e.g. 1e.ffc0
 
 : signature$   " CL4"  ;
 : model$       " olpc,XO-CL4"  ;

Modified: dev/olpc/spiflash/spiflash.fth
==============================================================================
--- dev/olpc/spiflash/spiflash.fth	Fri Sep 14 08:18:41 2012	(r3303)
+++ dev/olpc/spiflash/spiflash.fth	Fri Sep 14 08:19:54 2012	(r3304)
@@ -297,6 +297,9 @@
 \ those commands.  The AB command seems to be supported by all
 \ of them, so it's a good starting point.
 
+: 2mb-flash  ( -- )  h# 20.0000 to /flash  ;
+: 1mb-flash  ( -- )  h# 10.0000 to /flash  ;
+
 0 value spi-id#
 : spi-identify  ( -- )
    ab-id to spi-id#
@@ -305,11 +308,11 @@
    \ a common page-write part or the SST part with its
    \ unique auto-increment address writing scheme.
    spi-id# case
-      h# 13  of  ['] common-write  endof
-      h# 34  of  ['] common-write  endof
-      h# bf  of  ['] sst-write     endof
-      h# 14  of  ['] common-write  endof
-      h# 35  of  ['] common-write  endof
+      h# 13  of  ['] common-write  1mb-flash  endof
+      h# 34  of  ['] common-write  1mb-flash  endof
+      h# bf  of  ['] sst-write     1mb-flash  endof
+      h# 14  of  ['] common-write  1mb-flash  endof
+      h# 35  of  ['] common-write  2mb-flash  endof
 \ On some old board the ID would read as 14 when it should have been something else.
 \ On CL4, 14 is the expected ID.
 \         ." The SPI FLASH ID reads as 14.  This is due to an infrequent hardware problem."  cr
@@ -335,6 +338,7 @@
          h# 13  of  ." type 13 - Spansion, Winbond, or ST"  endof
          h# 14  of  ." type 14 - 2 MB"  endof
          h# 34  of  ." type 34 - Macronyx"  endof
+         h# 35  of  ." type 35 - 2 MB"  endof
       endcase
    then
 ;
@@ -364,7 +368,7 @@
    ['] erase-spi-block         to flash-erase-block
    ['] spi-protect             to flash-protect
    use-spi-flash-read          \ Might be overridden
-   h# 10.0000  to /flash
+   [ifdef] /rom  /rom  [else] h# 10.0000  [then]  to /flash
    /spi-eblock to /flash-block
 ;
 use-spi-flash

Modified: dev/olpc/spiflash/spiui.fth
==============================================================================
--- dev/olpc/spiflash/spiui.fth	Fri Sep 14 08:18:41 2012	(r3303)
+++ dev/olpc/spiflash/spiui.fth	Fri Sep 14 08:19:54 2012	(r3304)
@@ -69,7 +69,25 @@
    r> <>  abort" Firmware image has bad internal CRC"
 ;
 
+[ifndef] 2meg  h# 20.0000 constant 2meg  [then]
+: +1m  ( offset -- offset' )  1meg +  ;
+
+\ This is for upgrading an XO-4 with a 2 MiB FLASH part from
+\ a 1 MiB installed OFW image to a 2 MiB OFW image.
+\ After flash-open, /flash is the size of the physical SPI FLASH device.
+\ On exit, /flash is the size of the image, i.e. the amount to program.
+\ /rom is the size of the image that is currently running.
+: ?upgrade-to-2mb  ( len -- len )
+   flash-open   \ Sets /flash according to the device installed
+   dup 2meg =  /rom 1meg =  and  /flash 2meg =  and  if
+      signature-offset +1m to signature-offset
+      mfg-data-offset  +1m to mfg-data-offset
+      crc-offset +1m to crc-offset
+   then
+;
+
 : ?image-valid   ( len -- )
+   flash-open   \ Sets /flash according to the device installed
    /flash <> abort" Image file is the wrong length"
 
    ." Got firmware version: "
@@ -88,7 +106,7 @@
 
 : $get-file  ( "filename" -- )
    $read-open
-   flash-buf  /flash  ifd @ fgets   ( len )
+   flash-buf  2meg  ifd @ fgets   ( len )
    ifd @ fclose
 
    ?image-valid



More information about the openfirmware mailing list