Author: wmb Date: 2007-08-14 21:03:40 +0200 (Tue, 14 Aug 2007) New Revision: 535
Added: cpu/x86/pc/olpc/nandstat.fth Modified: cpu/x86/pc/olpc/copynand.fth Log: OLPC copy-nand - graphic display of progress.
Modified: cpu/x86/pc/olpc/copynand.fth =================================================================== --- cpu/x86/pc/olpc/copynand.fth 2007-08-14 16:05:09 UTC (rev 534) +++ cpu/x86/pc/olpc/copynand.fth 2007-08-14 19:03:40 UTC (rev 535) @@ -17,6 +17,8 @@
: >crc ( index -- crc ) crc-buf swap la+ l@ ;
+: $call-nand ( ?? method$ -- ?? ) nandih $call-method ; + : close-nand-ihs ( -- ) fileih ?dup if 0 to fileih close-dev 0 to #image-eblocks then nandih ?dup if 0 to nandih close-dev 0 to #nand-pages then @@ -44,11 +46,11 @@ : open-nand ( -- ) " /nandflash" open-dev to nandih nandih 0= " Can't open NAND FLASH device" ?nand-abort - " erase-size" nandih $call-method to /nand-block - " block-size" nandih $call-method to /nand-page - " size" nandih $call-method /nand-page um/mod nip to #nand-pages + " erase-size" $call-nand to /nand-block + " block-size" $call-nand to /nand-page + " size" $call-nand /nand-page um/mod nip to #nand-pages /nand-block /nand-page / to nand-pages/block - " start-scan" nandih $call-method + " start-scan" $call-nand ;
h# 20 buffer: line-buf @@ -131,6 +133,34 @@ #crc-records if check-mem-crc else drop then ;
+defer show-erasing ( #blocks -- ) +: (show-erasing) ( #blocks -- ) ." Erasing " . ." blocks" cr ; +' (show-erasing) is show-erasing + +defer show-erased +: (show-erased) ( block# -- ) (cr . ; +' (show-erased) is show-erased + +defer show-bad +: (show-bad) ( block# -- ) drop ; +' (show-bad) is show-bad + +defer show-clean +: (show-clean) ( block# -- ) drop ; +' (show-clean) is show-clean + +defer show-cleaning +: (show-cleaning) ( -- ) cr ." Cleanmarkers" cr ; +' (show-cleaning) is show-cleaning + +defer show-writing ( #blocks -- ) +: (show-writing) ." Writing " . ." blocks" cr ; +' (show-writing) is show-writing + +defer show-written +: (show-written) ( block# -- ) (cr . ; +' (show-written) is show-written + : copy-nand ( "devspec" -- ) open-nand get-img-filename @@ -139,21 +169,21 @@
['] noop to show-progress
- ." Erasing..." cr - " wipe" nandih $call-method + #nand-pages nand-pages/block / show-erasing + ['] show-bad ['] show-erased " (wipe)" $call-nand
- cr ." Writing " #image-eblocks . ." blocks" cr + #image-eblocks show-writing
#image-eblocks 0 ?do - (cr i . read-image-block i ?check-crc - load-base " copy-block" nandih $call-method ( error? ) - " Error writing to NAND FLASH" ?nand-abort + load-base " copy-block" $call-nand ( page# error? ) + " Error writing to NAND FLASH" ?nand-abort ( page# ) + nand-pages/block / show-written ( ) loop
- cr ." Filling with cleanmarkers ..." - " put-cleanmarkers" nandih $call-method cr + show-cleaning + ['] show-clean " put-cleanmarkers" $call-nand
close-nand-ihs ; @@ -169,10 +199,10 @@ #image-eblocks 0 ?do (cr i . read-image-block - load-base /nand-block + " read-next-block" nandih $call-method ( ) + load-base /nand-block + " read-next-block" $call-nand ( ) load-base load-base /nand-block + /nand-block comp if ( ) cr ." Miscompare in block starting at page# " ( ) - " scan-page#" nandih $call-method .x cr ( ) + " scan-page#" $call-nand .x cr ( ) ?key-stop then ( ) repeat ( ) @@ -210,13 +240,13 @@ #crc-records 0 ?do (cr i .
- load-base " read-next-block" nandih $call-method ( ) + load-base " read-next-block" $call-nand ( )
load-base /nand-block $crc i >crc ( actual-crc expected-crc ) 2dup <> if ( actual-crc expected-crc ) cr ." CRC miscompare - expected " . ." got " . ( ) ." in NAND block starting at page " - " scan-page#" nandih $call-method . cr + " scan-page#" $call-nand . cr ?key-stop else ( actual-crc expected-crc ) 2drop ( ) @@ -255,13 +285,13 @@ \ The stack is empty at the end of each line unless otherwise noted #nand-pages 0 do (cr i . - load-base i nand-pages/block " read-blocks" nandih $call-method + load-base i nand-pages/block " read-blocks" $call-nand nand-pages/block = if load-base /nand-block written? if load-base /nand-block " write" fileih $call-method drop dump-oob? if i nand-pages/block bounds ?do - i " read-oob" nandih $call-method h# 40 ( adr len ) + i " read-oob" $call-nand h# 40 ( adr len ) " write" fileih $call-method drop i pad ! pad 4 " write" fileih $call-method drop loop @@ -284,7 +314,7 @@ fileih 0= " Can't open NAND fastboot image file" ?nand-abort
" size" fileih $call-method drop ( len ) - " start-fastcopy" nandih $call-method ( error? ) + " start-fastcopy" $call-nand ( error? ) " Not enough spare NAND space for fast copy" ?nand-abort
begin ( ) @@ -293,10 +323,10 @@ \ If the read didn't fill a complete block, zero the rest load-base /nand-block rot /string erase
- load-base " next-fastcopy" nandih $call-method ( ) + load-base " next-fastcopy" $call-nand ( ) repeat ( len ) drop ( ) - " end-fastcopy" nandih $call-method ( ) + " end-fastcopy" $call-nand ( )
close-nand-ihs ;
Added: cpu/x86/pc/olpc/nandstat.fth =================================================================== --- cpu/x86/pc/olpc/nandstat.fth (rev 0) +++ cpu/x86/pc/olpc/nandstat.fth 2007-08-14 19:03:40 UTC (rev 535) @@ -0,0 +1,75 @@ +purpose: Graphical status display of NAND FLASH updates +\ See license at end of file + +d# 24 d# 24 2value ulhc + +d# 22 constant status-line + +8 constant glyph-w +8 constant glyph-h + +9 constant grid-w +9 constant grid-h + +d# 128 value #cols +: xy* ( x y w h -- x*w y*h ) rot * >r * r> ; + +\ States: 0:erased 1:bad 2:waiting for write 3:written + +: >loc ( eblock# -- ) #cols /mod grid-w grid-h xy* ulhc d+ ; + +: show-state ( eblock# state -- ) + swap >loc glyph-w glyph-h " fill-rectangle" $call-screen +; + +dev screen : erase-screen erase-screen ; dend + +h# 80 h# 80 h# 80 rgb>565 constant bbt-color + +: gshow-erasing ( #eblocks -- ) + cursor-off " erase-screen" $call-screen 0 status-line at-xy + ." Erasing " + + " bbt0" $call-nand nand-pages/block / bbt-color show-state + " bbt1" $call-nand nand-pages/block / bbt-color show-state + + h# ff h# ff h# ff rgb>565 ( #eblocks color ) + swap 0 ?do i over show-state loop + drop +; + +: gshow-erased ( eblock# -- ) 0 0 0 rgb>565 show-state ; + +: gshow-bad ( eblock# -- ) h# ff 0 0 rgb>565 show-state ; + +: gshow-cleaning ( -- ) ." Cleanmarkers" cr cursor-on ; +: gshow-clean ( eblock# -- ) h# 0 0 ff rgb>565 show-state ; + +: gshow-writing ( #eblocks -- ) + ." Writing " + h# ff h# ff 0 rgb>565 ( #eblocks color ) + 0 rot 0 ?do ( color eblock# ) + dup nand-pages/block * " block-bad?" $call-nand 0= if ( color eblock# ) + 2dup swap show-state + 1 + else + 0 + then + swap 1+ swap + +loop + drop +; + +: gshow-written ( eblock# -- ) 0 h# ff 0 rgb>565 show-state ; + +: gshow + ['] gshow-erasing to show-erasing + ['] gshow-erased to show-erased + ['] gshow-bad to show-bad + ['] gshow-clean to show-clean + ['] gshow-cleaning to show-cleaning + ['] gshow-writing to show-writing + ['] gshow-written to show-written +; + +gshow