[openfirmware] [commit] r2315 - in cpu: arm/olpc/1.75 x86/pc/olpc

repository service svn at openfirmware.info
Tue Jun 28 00:27:51 CEST 2011


Author: wmb
Date: Tue Jun 28 00:27:51 2011
New Revision: 2315
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2315

Log:
OLPC XO-1.75 - auto-reflash EC firmware if it is out of date.

Added:
   cpu/arm/olpc/1.75/ec-version.fth
   cpu/arm/olpc/1.75/ec.bth
Modified:
   cpu/arm/olpc/1.75/ecflash.fth
   cpu/arm/olpc/1.75/fw.bth
   cpu/arm/olpc/1.75/olpc.bth
   cpu/x86/pc/olpc/security.fth

Added: cpu/arm/olpc/1.75/ec-version.fth
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ cpu/arm/olpc/1.75/ec-version.fth	Tue Jun 28 00:27:51 2011	(r2315)
@@ -0,0 +1,7 @@
+\ The EC microcode
+macro: EC_VERSION 4_0_1_01
+
+\ Alternate command for getting EC microcode, for testing new versions.
+\ Temporarily uncomment the line and modify the path as necessary
+\ macro: GET_EC cp ~rsmith/olpc/ec/ec-code15/image/ecimage.bin ec.img
+\ macro: GET_EC wget -q http://dev.laptop.org/pub/ec/ec_test.img -O ec.img

Added: cpu/arm/olpc/1.75/ec.bth
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ cpu/arm/olpc/1.75/ec.bth	Tue Jun 28 00:27:51 2011	(r2315)
@@ -0,0 +1,18 @@
+purpose: Fetch the EC (Embedded Controller, i.e. KB3700) microcode
+
+command: &builder &this
+build-now
+
+fload ${BP}/cpu/arm/olpc/1.75/ec-version.fth
+
+\ If there is a GET_EC macro, use it instead of fetching the released version.
+" ${GET_EC}" expand$  nip  [if]
+   " ${GET_EC}" expand$ $sh
+[else]
+   " wget -q http://dev.laptop.org/pub/ec/cl2-${EC_VERSION}.img -O ec.img" expand$ $sh
+[then]
+
+\ This forces the creation of an ec.log file, so we don't re-fetch ec.img
+writing ec.version
+" ${EC_VERSION}"n" expand$  ofd @ fputs
+ofd @ fclose

Modified: cpu/arm/olpc/1.75/ecflash.fth
==============================================================================
--- cpu/arm/olpc/1.75/ecflash.fth	Mon Jun 27 22:49:20 2011	(r2314)
+++ cpu/arm/olpc/1.75/ecflash.fth	Tue Jun 28 00:27:51 2011	(r2315)
@@ -52,11 +52,11 @@
    abort"  Miscompare!"
    cr
 [ifndef] cl2-a1
-   ." Restarting EC and powering off" cr
-   d# 3000 ms
+   ." Restarting EC and rebooting" cr
+   d# 2000 ms
    unreset-8051
 [then]
-   reset-ec
+   ec-power-cycle
 ;
 : flash-ec  ( "filename" -- )  get-ec-file ?enough-power reflash-ec  ;
 : flash-ec! ( "filename" -- )  get-ec-file reflash-ec  ;
@@ -76,6 +76,35 @@
    load-base /ec-flash ofd @ fputs
    ofd @ fclose
 ;
+: ec-up-to-date?  ( img$ -- flag )
+   \ If the new image has an invalid length, the old one is considered up to date
+   dup /ec-flash <>  if
+      ." Invalid EC image length" cr  2drop true exit
+   then                                             ( adr len )
+   + h# 100 - cscount                               ( version&date$ )
+   \ If the new image has an invalid signature, the old one is considered up to date
+   dup d# 25 <  if  2drop true exit  then           ( version&date$ )
+   bl left-parse-string " XO-EC" $= 0=  if  2drop true exit  then  ( version&date$ )
+   bl left-parse-string " 4" $= 0=  if  2drop true exit  then      ( version&date$ )
+   bl left-parse-string 2nip                                       ( version$ )
+   ec-name$  $caps-compare  0<=                                    ( flag )
+;
+: ?update-ec-flash  ( -- )
+   " ecimage.bin" find-drop-in  if   ( adr len )
+      2dup ec-up-to-date?  if        ( adr len )
+	 free-mem                    ( )
+      else                           ( adr len )
+         2dup load-base swap move    ( adr len )
+         free-mem                    ( )
+         ['] ?enough-power catch  ?dup  if  ( error )
+            .error
+	    ." Skipping EC reflash" cr
+         else
+	    reflash-ec
+	 then
+      then
+   then
+;
 
 \ LICENSE_BEGIN
 \ Copyright (c) 2010 FirmWorks

Modified: cpu/arm/olpc/1.75/fw.bth
==============================================================================
--- cpu/arm/olpc/1.75/fw.bth	Mon Jun 27 22:49:20 2011	(r2314)
+++ cpu/arm/olpc/1.75/fw.bth	Tue Jun 28 00:27:51 2011	(r2315)
@@ -405,6 +405,8 @@
 
    read-game-keys
 
+   ?update-ec-flash
+
    factory-test?  if  text-off  then
 
    " probe-" do-drop-in

Modified: cpu/arm/olpc/1.75/olpc.bth
==============================================================================
--- cpu/arm/olpc/1.75/olpc.bth	Mon Jun 27 22:49:20 2011	(r2314)
+++ cpu/arm/olpc/1.75/olpc.bth	Tue Jun 28 00:27:51 2011	(r2315)
@@ -1,6 +1,7 @@
 purpose: Construct the Open Firmware module collection
 
 command: &builder &this
+in: ${BP}/cpu/arm/olpc/1.75/build/ec.img
 in: ${BP}/cpu/arm/olpc/1.75/build/fw.img
 in: ${BP}/cpu/arm/olpc/1.75/build/resetvec.img
 in: ${BP}/cpu/arm/olpc/1.75/build/mcastnand.bin
@@ -150,6 +151,7 @@
    " ${BP}/cpu/x86/pc/olpc/images/tux.565"       " tux.565"        $add-deflated-dropin
    " ${BP}/cpu/x86/pc/olpc/images/settings.565"  " settings.565"   $add-deflated-dropin
 [then]
+   " ec.img"                                     " ecimage.bin"    $add-deflated-dropin
 
 .( Dropin top is )  ofd @ fsize  .x cr
 

Modified: cpu/x86/pc/olpc/security.fth
==============================================================================
--- cpu/x86/pc/olpc/security.fth	Mon Jun 27 22:49:20 2011	(r2314)
+++ cpu/x86/pc/olpc/security.fth	Tue Jun 28 00:27:51 2011	(r2315)
@@ -906,16 +906,6 @@
 ;
 
 [ifdef] reflash-ec
-: ec-up-to-date?  ( img$ -- flag )
-   /ec-flash <>  if  show-x  " Invalid EC Firmware image" .security-failure  then  ( adr )
-   /ec-flash + h# 100 - cscount                     ( version&date$ )
-   \ If the new image has an invalid signature, the old one is considered up to date
-   dup d# 25 <  if  2drop true exit  then           ( version&date$ )
-   over " XO-EC 4 " comp  if  2drop true exit  then ( version&date$ )
-   bl right-split-string 2drop                      ( date$ )
-   d# 16 <>  if  2drop true exit  then              ( date-adr )
-   ec-date$  comp  0<=                              ( flag )
-;
 
 defer ec-reflash-off?  ' false to ec-reflash-off?
 : do-ec-update  ( img$ -- )



More information about the openfirmware mailing list