[openfirmware] [commit] r2192 - cpu/x86/pc/olpc/via dev/mmc/sdhci

repository service svn at openfirmware.info
Wed Apr 27 09:14:28 CEST 2011


Author: quozl
Date: Wed Apr 27 09:14:27 2011
New Revision: 2192
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2192

Log:
OLPC XO-1.5 - fs-update, add support for sparse .zd files, undo -r2186
meaning of zblocks: parameter, split card erasure to avoid card
lockup, and show progress during erasure.

SDHCI - erase blocks, wait for card to leave programming state, and
ignore spurious data timeout.

Modified:
   cpu/x86/pc/olpc/via/fsupdate.fth
   dev/mmc/sdhci/sdhci.fth

Modified: cpu/x86/pc/olpc/via/fsupdate.fth
==============================================================================
--- cpu/x86/pc/olpc/via/fsupdate.fth	Mon Apr 18 12:11:06 2011	(r2191)
+++ cpu/x86/pc/olpc/via/fsupdate.fth	Wed Apr 27 09:14:27 2011	(r2192)
@@ -8,14 +8,28 @@
    push-hex $number pop-base  " Bad number" ?nand-abort
 ;
 
-0 value #eblocks-written
+0 value min-eblock#
+0 value max-eblock#
+
+: written ( eblock# -- )
+   dup
+   max-eblock# max to max-eblock# ( eblock# )
+   min-eblock# min to min-eblock#
+;
 
 : ?all-written  ( -- )
-   #eblocks-written #image-eblocks <>  if
+   max-eblock# 1+ #image-eblocks <>  if
       cr
       red-letters
-      ." WARNING: The file specified " #image-eblocks .d
-      ." chunks but wrote only " #eblocks-written .d ." chunks" cr
+      ." WARNING: The file said highest block " #image-eblocks .d
+      ." but wrote only as high as block " max-eblock# .d cr
+      black-letters
+   then
+   min-eblock# 0 <>  if
+      cr
+      red-letters
+      ." WARNING: The file did not write a zero block, "
+      ." but wrote only as low as block " min-eblock# .d cr
       black-letters
    then
 ;
@@ -52,15 +66,35 @@
 vocabulary nand-commands
 also nand-commands definitions
 
+\ some cards do not respond in a reasonable time,
+\ some cards lock up and cause a command timeout in get-status,
+\ so split the erase into many parts.
+: erase-blocks
+   [char] ~ emit                        \ visual hint of erase delay
+   #image-eblocks /nand-block h# 200 */ ( #blocks )
+   dup d# 16 / swap                     ( /part #blocks )
+   0 do                                 ( /part )
+      i over " erase-blocks" $call-nand
+      hdd-led-toggle                    \ visual hint of progress
+   dup +loop                            ( /part )
+   drop
+   bs emit space bs emit hdd-led-off    \ visual hint remove
+;
+
+\ : erase-blocks
+\ 0 #image-eblocks /nand-block h# 200 */ " erase-blocks" $call-nand ;
+
 : zblocks:  ( "eblock-size" "#eblocks" ... -- )
    hdd-led-toggle
    ?compare-spec-line
    get-hex# to /nand-block
    get-hex# to #image-eblocks
+   #image-eblocks to min-eblock#
+   0 to max-eblock#
    " size" $call-nand  #image-eblocks /nand-block um*  d<
    " Image size is larger than output device" ?nand-abort
    #image-eblocks  show-init
-   0 #image-eblocks /nand-block h# 200 */ " erase-blocks" $call-nand
+   erase-blocks
    get-inflater
    \ Separate the two buffers by enough space for both the compressed
    \ and uncompressed copies of the data.  4x is overkill, but there
@@ -200,8 +234,8 @@
       swap-buffers                          ( eblock# )
 \  then
 
+   dup written                              ( eblock# )
    show-written                             ( )
-   #eblocks-written 1+ to #eblocks-written  ( )
    show-temperature
    hdd-led-toggle
 ;

Modified: dev/mmc/sdhci/sdhci.fth
==============================================================================
--- dev/mmc/sdhci/sdhci.fth	Mon Apr 18 12:11:06 2011	(r2191)
+++ dev/mmc/sdhci/sdhci.fth	Wed Apr 27 09:14:27 2011	(r2192)
@@ -284,7 +284,7 @@
    then                    ( isr esr )
 
    allow-timeout?  if      ( isr esr )
-      dup 1 =  if  true to timeout?  2drop exit  then
+      dup 1 =  over h# 10 = or  if  true to timeout?  2drop exit  then
    then                    ( isr esr )
 
    ." SDHCI: Error: ISR = " swap u.
@@ -489,16 +489,6 @@
 
 0 instance value writing?
 
-: erase-blocks  ( block# #blocks -- ) \ UNTESTED
-   intstat-on
-   dup  0=  if  2drop exit  then
-   1- bounds        ( last first )
-   h# 201a 0 cmd    ( last )   \ CMD32 - R1
-   h# 211a 0 cmd    ( )        \ CMD33 - R1
-   0 h# 261b 0 cmd             \ CMD38 - R1b (wait for busy)
-   intstat-off
-;
-
 \ CMD40 is MMC
 
 \ See table 4-5 in sandisk spec
@@ -1034,6 +1024,21 @@
 : detach-sdio-card  ( -- )
 ;
 
+: erase-blocks  ( block# #blocks -- )
+   intstat-on
+   dup  0=  if  2drop exit  then
+   1- bounds        ( last first )
+   h# 201a 0 cmd    ( last )   \ CMD32 - R1
+   h# 211a 0 cmd    ( )        \ CMD33 - R1
+   0 h# 261b 0 cmd             \ CMD38 - R1b (wait for busy)
+   true to writing?                  ( )
+   true to allow-timeout?
+   false to timeout?
+   wait-write-done  drop
+   false to allow-timeout?
+   intstat-off
+;
+
 \ Asynchronous poll for completion
 : r/w-blocks-end?  ( in? -- false | error? true )
    drop



More information about the openfirmware mailing list