Author: wmb
Date: 2007-08-01 10:25:31 +0200 (Wed, 01 Aug 2007)
New Revision: 510
Modified:
cpu/x86/pc/olpc/copynand.fth
dev/olpc/cafenand/badblock.fth
dev/olpc/cafenand/cafenand.fth
Log:
OLPC copy-nand - OLPC trac 2614. Made copy-nand abort not only on a
CRC mismatch, but also on a NAND write error.
Modified: cpu/x86/pc/olpc/copynand.fth
===================================================================
--- cpu/x86/pc/olpc/copynand.fth 2007-08-01 03:15:29 UTC (rev 509)
+++ cpu/x86/pc/olpc/copynand.fth 2007-08-01 08:25:31 UTC (rev 510)
@@ -148,7 +148,8 @@
(cr i .
read-image-block
i ?check-crc
- load-base " copy-block" nandih $call-method
+ load-base " copy-block" nandih $call-method ( error? )
+ " Error writing to NAND FLASH" ?nand-abort
loop
cr ." Filling with cleanmarkers ..."
Modified: dev/olpc/cafenand/badblock.fth
===================================================================
--- dev/olpc/cafenand/badblock.fth 2007-08-01 03:15:29 UTC (rev 509)
+++ dev/olpc/cafenand/badblock.fth 2007-08-01 08:25:31 UTC (rev 510)
@@ -132,7 +132,10 @@
dup if ( signature$ page# )
dup erase-block ( signature$ page# )
bbt over /bbt /page / bounds ?do ( signature$ page# adr )
- dup i write-page ( signature$ page# adr )
+ dup i write-page if ( signature$ page# adr )
+ ." Error writing Bad Block Table - page# " i .x cr
+ 3drop unloop exit
+ then
/page + ( signature$ page# adr' )
loop ( signature$ page# adr' )
drop ( signature$ page# )
@@ -253,13 +256,15 @@
over block-bad? if 3drop 0 exit then
then
- dup >r ( adr page# #pages r: #pages )
- bounds ?do ( adr )
- \ XXX need some error handling
- dup i write-page ( adr )
- /page + ( adr' )
- loop ( adr )
- drop r>
+ over >r dup >r ( adr page# #pages r: page# #pages )
+ bounds ?do ( adr r: page# #pages )
+ dup i write-page if ( adr r: page# #pages )
+ drop r> drop i r> - ( #written )
+ unloop exit
+ then ( adr r: page# #pages )
+ /page + ( adr' r: page# #pages )
+ loop ( adr r: page# #pages )
+ drop r> r> drop ( #pages )
;
: erase-blocks ( page# #pages -- #pages )
@@ -364,12 +369,14 @@
: start-scan ( -- ) pages/eblock negate to scan-page# ;
\ Must erase all (wipe) first
-: copy-block ( adr -- )
+: copy-block ( adr -- error? )
next-page# pages/eblock bounds ?do ( adr )
- dup i write-page ( adr )
+ dup i write-page if ( adr )
+ drop true unloop exit ( true )
+ then ( adr )
/page + ( adr' )
loop ( adr )
- drop ( )
+ drop false ( false )
;
: put-cleanmarkers ( -- )
Modified: dev/olpc/cafenand/cafenand.fth
===================================================================
--- dev/olpc/cafenand/cafenand.fth 2007-08-01 03:15:29 UTC (rev 509)
+++ dev/olpc/cafenand/cafenand.fth 2007-08-01 08:25:31 UTC (rev 510)
@@ -119,7 +119,7 @@
\ : read-id ( -- ) 0 0 set-page read-id-cmd 0 cmd wait-cmd h# 30 cl@ ;
: dma-off ( -- ) 0 h# 40 cl! ;
-: wait-write-done ( -- )
+: wait-write-done ( -- error? )
0 ( status )
begin ( status )
drop ( )
@@ -127,7 +127,8 @@
dup h# 40 and ( status flag )
until ( status )
\ If the value is completely 0 I think it means write protect
- 1 and if ." NAND write error" cr then
+ 1 and 0<> ( error? )
+ write-disable
;
\ Assumes that the range doesn't straddle a page boundary
@@ -149,18 +150,17 @@
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
- write-disable
+ wait-write-done ( error? )
+ drop
;
-: pio-write-page ( adr page# -- )
+: pio-write-page ( adr page# -- error? )
write-enable dma-off ( adr page# )
0 set-page ( adr )
/page h# e + dup datalen ( adr len )
chip h# 2000 + swap move ( )
write-cmd h# 4800.0110 cmd wait-cmd ( ) \ 4000. Auto ECC, 0800. R/S ECC
- wait-write-done
- write-disable
+ wait-write-done ( error? )
;
: read-oob ( page# -- adr )
@@ -228,22 +228,21 @@
set-page ( adr len )
dup false dma-setup ( )
write-cmd h# 110 cmd wait-cmd ( )
- wait-write-done ( )
- dma-release ( )
- write-disable ( )
+ wait-write-done ( error? )
+ dma-release ( error? )
+ drop
;
-: dma-write-page ( adr page# -- ) \ Size is fixed
+: dma-write-page ( adr page# -- error? ) \ Size is fixed
write-enable ( adr page# )
0 set-page ( adr )
h# 800 h# 80e false dma-setup ( )
write-cmd h# 4800.0110 cmd wait-cmd ( ) \ Auto-ECC, RS, write cmd
- wait-write-done ( )
+ wait-write-done ( error? )
\ dma-release
- write-disable ( )
;
-: write-page ( adr page# -- ) dma-write-page ;
+: write-page ( adr page# -- error? ) dma-write-page ;
: write-bytes ( adr len page# offset -- ) pio-write-raw ;
3 value #erase-adr-bytes \ Chip dependent
@@ -251,8 +250,8 @@
write-enable
set-erase-page
h# 20.0060 0 #erase-adr-bytes >cmd h# 1d0 cmd
- wait-write-done
- write-disable
+ wait-write-done ( error? )
+ drop
;
: read-id ( -- adr ) 8 0 0 h# c420.0090 0 generic-read ;