Author: wmb Date: 2007-08-29 01:18:26 +0200 (Wed, 29 Aug 2007) New Revision: 584
Modified: cpu/x86/pc/olpc/copynand.fth cpu/x86/pc/olpc/nandstat.fth dev/olpc/cafenand/badblock.fth dev/olpc/cafenand/cafenand.fth Log: copy-nand - Check carefully for bad blocks when copying on the OS image, adding any newly-discovered ones to the bad block table.
Modified: cpu/x86/pc/olpc/copynand.fth =================================================================== --- cpu/x86/pc/olpc/copynand.fth 2007-08-28 18:45:58 UTC (rev 583) +++ cpu/x86/pc/olpc/copynand.fth 2007-08-28 23:18:26 UTC (rev 584) @@ -135,32 +135,32 @@
defer show-erasing ( #blocks -- ) : (show-erasing) ( #blocks -- ) ." Erasing " . ." blocks" cr ; -' (show-erasing) is show-erasing +' (show-erasing) to show-erasing
defer show-erased ( block# -- ) : (show-erased) ( block# -- ) (cr . ; -' (show-erased) is show-erased +' (show-erased) to show-erased
defer show-bad ( block# -- ) -' drop is show-bad +' drop to show-bad
-defer show-bbt ( block# -- ) -' drop is show-bbt +defer show-bbt-block ( block# -- ) +' drop to show-bbt-block
defer show-clean ( block# -- ) -' drop is show-clean +' drop to show-clean
defer show-cleaning ( -- ) : (show-cleaning) ( -- ) cr ." Cleanmarkers" cr ; -' (show-cleaning) is show-cleaning +' (show-cleaning) to show-cleaning
defer show-writing ( #blocks -- ) : (show-writing) ." Writing " . ." blocks" cr ; -' (show-writing) is show-writing +' (show-writing) to show-writing
defer show-written : (show-written) ( block# -- ) (cr . ; -' (show-written) is show-written +' (show-written) to show-written
: copy-nand ( "devspec" -- ) open-nand @@ -171,7 +171,7 @@ ['] noop to show-progress
#nand-pages nand-pages/block / show-erasing - ['] show-bad ['] show-erased ['] show-bbt " (wipe)" $call-nand + ['] show-bad ['] show-erased ['] show-bbt-block " (wipe)" $call-nand
#image-eblocks show-writing
@@ -307,7 +307,6 @@ : dump-nand ( "devspec" -- ) true to dump-oob? (dump-nand) ; : save-nand ( "devspec" -- ) false to dump-oob? (dump-nand) ;
- : fastcopy-nand ( "devspec" -- ) open-nand
Modified: cpu/x86/pc/olpc/nandstat.fth =================================================================== --- cpu/x86/pc/olpc/nandstat.fth 2007-08-28 18:45:58 UTC (rev 583) +++ cpu/x86/pc/olpc/nandstat.fth 2007-08-28 23:18:26 UTC (rev 584) @@ -44,10 +44,10 @@ drop ;
-: gshow-erased ( eblock# -- ) erased-color show-state ; -: gshow-bad ( eblock# -- ) bad-color show-state ; -: gshow-bbt ( eblock# -- ) bbt-color show-state ; -: gshow-clean ( eblock# -- ) clean-color show-state ; +: gshow-erased ( eblock# -- ) erased-color show-state ; +: gshow-bad ( eblock# -- ) bad-color show-state ; +: gshow-bbt-block ( eblock# -- ) bbt-color show-state ; +: gshow-clean ( eblock# -- ) clean-color show-state ;
: gshow-cleaning ( -- ) ." Cleanmarkers" cr cursor-on ;
@@ -69,14 +69,14 @@ : gshow-written ( eblock# -- ) written-color show-state ;
: gshow - ['] gshow-erasing to show-erasing - ['] gshow-erased to show-erased - ['] gshow-bad to show-bad - ['] gshow-bbt to show-bbt - ['] gshow-clean to show-clean - ['] gshow-cleaning to show-cleaning - ['] gshow-writing to show-writing - ['] gshow-written to show-written + ['] gshow-erasing to show-erasing + ['] gshow-erased to show-erased + ['] gshow-bad to show-bad + ['] gshow-bbt-block to show-bbt-block + ['] gshow-clean to show-clean + ['] gshow-cleaning to show-cleaning + ['] gshow-writing to show-writing + ['] gshow-written to show-written ;
gshow
Modified: dev/olpc/cafenand/badblock.fth =================================================================== --- dev/olpc/cafenand/badblock.fth 2007-08-28 18:45:58 UTC (rev 583) +++ dev/olpc/cafenand/badblock.fth 2007-08-28 23:18:26 UTC (rev 584) @@ -142,7 +142,9 @@ /page + ( signature$ page# adr' ) loop ( signature$ page# adr' ) drop ( signature$ page# ) - /page bb-offset + write-bytes ( ) + /page bb-offset + write-bytes if ( ) + ." Failed to write bad block table" cr + then else ( signature$ page# ) 3drop ( ) then @@ -386,21 +388,51 @@
: start-scan ( -- ) pages/eblock negate to scan-page# ;
-\ Must erase all (wipe) first +: try-copy-block ( adr page# -- okay? ) + pages/eblock bounds ?do ( adr ) + dup i write-page if ( adr ) + drop false unloop exit ( false ) + then ( adr ) + /page + ( adr' ) + loop ( adr ) + drop true ( true ) +; +: block-okay? ( adr page# -- okay? ) + pages/eblock bounds ?do ( adr ) + i get-page if ( adr ) + drop false unloop exit ( false ) + then ( adr buf-adr ) + over /page comp if ( adr ) + drop false unloop exit + then + /page + ( adr' ) + loop ( adr ) + drop true ( true ) +; +: copy&check ( adr page# -- okay? ) + 2dup try-copy-block 0= if 2drop false exit then ( adr page# ) + block-okay? +; + : copy-block ( adr -- page# error? ) - next-page# ( adr page# ) - tuck pages/eblock bounds ?do ( page# adr ) - dup i write-page if ( page# adr ) - drop true unloop exit ( page# true ) - then ( page# adr ) - /page + ( page# adr' ) - loop ( page# adr ) - drop false ( page# false ) + begin (next-page#) 0= while ( adr page# ) + 2dup copy&check if nip false exit then ( adr page# ) + \ Error; retry once + dup erase-block ( adr page# ) + 2dup copy&check if nip false exit then ( adr page# ) + mark-bad save-bbt ( adr ) + repeat ( adr ) + drop ( ) + usable-page-limit pages/eblock - true ( page# error? ) ;
: put-cleanmarker ( page# -- ) - " "(85 19 03 20 08 00 00 00)" ( page# adr len ) - rot /page /ecc + write-bytes ( ) + >r + " "(85 19 03 20 08 00 00 00)" ( adr len r: page# ) + r@ /page /ecc + write-bytes if ( r: page# ) + r@ mark-bad save-bbt ( r: page# ) + then ( r: page# ) + r> drop ; : put-cleanmarkers ( show-xt -- ) begin (next-page#) 0= while ( show-xt page# )
Modified: dev/olpc/cafenand/cafenand.fth =================================================================== --- dev/olpc/cafenand/cafenand.fth 2007-08-28 18:45:58 UTC (rev 583) +++ dev/olpc/cafenand/cafenand.fth 2007-08-28 23:18:26 UTC (rev 584) @@ -149,13 +149,12 @@ swap r> move ( ) ;
-: pio-write-raw ( adr len page# offset -- ) +: pio-write-raw ( adr len page# offset -- error? ) write-enable dma-off set-page dup datalen ( adr len ) chip h# 2000 + swap move ( ) write-cmd h# 0000.0110 cmd wait-cmd ( ) \ No Auto ECC wait-write-done ( error? ) - drop ;
: pio-write-page ( adr page# -- error? ) @@ -210,21 +209,27 @@ syndrome-buf ;
-: read-page ( adr page# -- error? ) - 0 set-page ( adr ) - /page /ecc + h# 18 cl! ( adr ) - dma-buf-pa h# 44 cl! ( adr ) - 0 h# 48 cl! ( adr ) - /page h# a000.0000 or h# 40 cl! ( adr ) - read-cmd h# 0800.0130 cmd wait-dma ( adr ) +\ Reads page into DMA buffer +: get-page ( page# -- true | adr false ) + 0 set-page ( ) + /page /ecc + h# 18 cl! ( ) + dma-buf-pa h# 44 cl! ( ) + 0 h# 48 cl! ( ) + /page h# a000.0000 or h# 40 cl! ( ) + read-cmd h# 0800.0130 cmd wait-dma ( )
- h# 3c cl@ h# 40000 and if ( adr ) \ ECC error - dma-buf-va syndrome correct-ecc ( adr uncorrectable? ) - else ( adr ) - false ( adr error? ) - then ( adr error? ) + h# 3c cl@ h# 40000 and if ( ) \ ECC error + dma-buf-va syndrome correct-ecc ( uncorrectable? ) + else ( ) + false ( error? ) + then ( error? ) + dup 0= if dma-buf-va swap then ( true | adr false ) +;
- dma-buf-va rot /page do-lmove ( error? ) +: read-page ( adr page# -- error? ) + get-page if drop true exit then ( adr dma-buf-adr ) + swap /page do-lmove ( ) + false ;
[ifdef] notdef @@ -267,7 +272,7 @@ ;
: write-page ( adr page# -- error? ) dma-write-page ; -: write-bytes ( adr len page# offset -- ) pio-write-raw ; +: write-bytes ( adr len page# offset -- error? ) pio-write-raw ;
3 value #erase-adr-bytes \ Chip dependent : erase-block ( page# -- )