Author: wmb
Date: 2007-08-24 01:31:44 +0200 (Fri, 24 Aug 2007)
New Revision: 576
Modified:
forth/kernel/kernel.fth
Log:
Fixed a longstanding bug that caused misleading error messages when
interpreting from files. The problem is that the line buffer memory
has been freed and possibly overwritten before the undefined word name
is displayed. The solution is to copy the word name to a dedicated
buffer.
Modified: forth/kernel/kernel.fth
===================================================================
--- forth/kernel/kernel.fth 2007-08-23 23:28:07 UTC (rev 575)
+++ forth/kernel/kernel.fth 2007-08-23 23:31:44 UTC (rev 576)
@@ -995,9 +995,11 @@
then
;
headers
+0 value 'error-word
: .not-found ( adr len -- ) where type ." ?" cr ;
\ Abort after an undefined word in interpret state
: $interpret-do-undefined ( adr len -- )
+ d# 32 min 'error-word pack count
set-abort-message d# -13 throw
;
\ Compile a surrogate for an undefined word in compile state
@@ -1532,6 +1534,7 @@
init
d# 20 alloc-mem is fake-name-buf
d# 32 alloc-mem is canonical-word
+ d# 34 alloc-mem is 'error-word
;
headers
Author: wmb
Date: 2007-08-24 01:28:07 +0200 (Fri, 24 Aug 2007)
New Revision: 575
Modified:
dev/olpc/cafenand/badblock.fth
Log:
Changed the name of "scrub" to "scrub!" and made "scrub" issue a
warning message.
Modified: dev/olpc/cafenand/badblock.fth
===================================================================
--- dev/olpc/cafenand/badblock.fth 2007-08-23 16:08:37 UTC (rev 574)
+++ dev/olpc/cafenand/badblock.fth 2007-08-23 23:28:07 UTC (rev 575)
@@ -286,7 +286,7 @@
\ Completely erase the device, ignoring any existing bad-block info
\ This is fairly severe, not recommended except in exceptional situations
-: scrub ( -- )
+: scrub! ( -- )
release-bbt
total-pages 0 ?do
(cr i .
@@ -294,6 +294,11 @@
pages/eblock +loop
make-bbt
;
+: scrub ( -- )
+ ." scrub is dangerous because it discards factory bad block information." cr
+ ." That can cause bad problems with later use of the NAND FLASH device." cr
+ ." Type scrub! if you really want to do it." cr
+;
: .bn ( -- ) (cr . ;
Author: wmb
Date: 2007-08-20 21:37:58 +0200 (Mon, 20 Aug 2007)
New Revision: 570
Added:
forth/lib/tofile.fth
Log:
forth/lib/tofile.fth - Initial checkin
Added: forth/lib/tofile.fth
===================================================================
--- forth/lib/tofile.fth (rev 0)
+++ forth/lib/tofile.fth 2007-08-20 19:37:58 UTC (rev 570)
@@ -0,0 +1,97 @@
+purpose: Redirect the output stream.
+\ See license at end of file
+
+\ to-file \ filename ( -- )
+\ causes output to be temporarily diverted to the named file.
+\ The file is created if it doesn't exist, and overwritten if it does.
+\ Output is restored to the console just before Forth prompts for a
+\ new line of input.
+\ append-to-file \ filename ( -- )
+\ Similar to to-file but if the file already exists, the new stuff is
+\ tacked onto the end, rather than overwriting the file.
+
+\ We really need to make the output stream a multi-field structure, and
+\ keep a stack of output streams.
+
+only forth also hidden also definitions
+variable old-status ' noop old-status token!
+variable old-(emit ' noop old-(emit token!
+variable old-(type ' noop old-(type token!
+variable old-cr ' noop old-cr token!
+variable old-exit? ' noop old-exit? token!
+variable old-#out 0 old-#out !
+variable old-#line 0 old-#line !
+variable saved-output-valid saved-output-valid off
+
+forth definitions
+: save-output ( -- )
+ ['] status behavior old-status token!
+ ['] (emit behavior old-(emit token!
+ ['] (type behavior old-(type token!
+ ['] cr behavior old-cr token!
+ ['] exit? behavior old-exit? token!
+ #out @ old-#out !
+ #line @ old-#line !
+ saved-output-valid on
+;
+: unsave-output ( -- )
+ saved-output-valid @ if
+ old-(emit token@ is (emit
+ old-(type token@ is (type
+ old-status token@ is status
+ old-cr token@ is cr
+ old-exit? token@ is exit?
+ old-#out @ #out !
+ old-#line @ #line !
+ saved-output-valid off
+ then
+;
+hidden definitions
+: undo-file-output ( -- ) unsave-output ofd @ fclose ;
+: file-(emit ( char -- ) ofd @ fputc ;
+: file-(type ( adr len -- ) ofd @ fputs ;
+: file-cr ( adr len -- )
+ #out off 1 #line +! newline-string ofd @ fputs
+;
+forth definitions
+: file-output ( -- )
+ save-output
+ ['] undo-file-output is status
+ ['] file-(emit is (emit
+ ['] file-(type is (type
+ ['] file-cr is cr
+ ['] false is exit?
+ #out off #line off
+;
+
+: to-file \ filename ( -- )
+ writing file-output
+;
+: append-to-file \ filename ( -- )
+ appending file-output
+;
+only forth also definitions
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2007 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Author: wmb
Date: 2007-08-19 20:13:20 +0200 (Sun, 19 Aug 2007)
New Revision: 569
Modified:
dev/ne2000/ne2000.fth
Log:
ne2000 driver - fixed a typo - OVR was spelled OVER, thus possibly
causing a bug in the "overrun" routine.
Modified: dev/ne2000/ne2000.fth
===================================================================
--- dev/ne2000/ne2000.fth 2007-08-19 01:51:23 UTC (rev 568)
+++ dev/ne2000/ne2000.fth 2007-08-19 18:13:20 UTC (rev 569)
@@ -433,7 +433,7 @@
\ updated the boundary register, or determined that there really were
\ no new packets in the ring.
- OVER isr! \ Clear the overrun interrupt bit
+ OVR isr! \ Clear the overrun interrupt bit
set-tx-mode \ Take the NIC out of loopback
\ Resend any incomplete transmission
@@ -446,7 +446,7 @@
: recv-690-overrun ( -- )
false to is-overrun-690
boundary@ boundary! \ rewrite bndry with itself
- OVER isr! \ Clear overrun interrupt bit
+ OVR isr! \ Clear overrun interrupt bit
;
[then]
Author: wmb
Date: 2007-08-19 03:39:34 +0200 (Sun, 19 Aug 2007)
New Revision: 567
Modified:
dev/olpc/kb3700/ecserial.fth
dev/olpc/spiflash/recover.fth
dev/olpc/spiflash/spiui.fth
Log:
OLPC - reliability improvements in "clone" (for debricking machines).
a) Eliminate EC watchdog resets by reading the SPI FLASH slowly (c.f. Trac #2636)
b) Tell user when and how to reset the target machine.
Modified: dev/olpc/kb3700/ecserial.fth
===================================================================
--- dev/olpc/kb3700/ecserial.fth 2007-08-19 01:13:03 UTC (rev 566)
+++ dev/olpc/kb3700/ecserial.fth 2007-08-19 01:39:34 UTC (rev 567)
@@ -17,11 +17,22 @@
['] noop to spi-reprogrammed
d# 57600 baud
+
+ \ We have to reset the target here because it is probably confused by having
+ \ received other characters from our serial line
+ ." Reset the target system with a full power-cycle, then type a key to continue" cr
+ begin key? until key drop
+
h# 5a uemit ( divisor ) \ ( wait-tx )
h# 88 spicfg! ( divisor ) \ Write enable for SPICMD register
h# 45 spibaud! ( )
+
+ d# 50 ms \ Settling time
+
d# 115200 baud
+ d# 50 ms \ Settling time
+
-1 to flash-base
;
: use-serial-ec ( -- ) ['] serial-spi-start to spi-start ;
Modified: dev/olpc/spiflash/recover.fth
===================================================================
--- dev/olpc/spiflash/recover.fth 2007-08-19 01:13:03 UTC (rev 566)
+++ dev/olpc/spiflash/recover.fth 2007-08-19 01:39:34 UTC (rev 567)
@@ -28,7 +28,7 @@
: clone ( -- )
." Getting a copy of this machine's FLASH" cr
- h# fff0.0000 flash-buf /flash move
+ slow-flash-read
true to file-loaded?
(serial-flash)
Modified: dev/olpc/spiflash/spiui.fth
===================================================================
--- dev/olpc/spiflash/spiui.fth 2007-08-19 01:13:03 UTC (rev 566)
+++ dev/olpc/spiflash/spiui.fth 2007-08-19 01:39:34 UTC (rev 567)
@@ -203,6 +203,12 @@
/flash mfg-data-end-offset write-flash-range \ Write last part
;
+: .verify-msg ( -- )
+ ." Type verify if you want to verify the data just written." cr
+ ." Verification will take about 17 minutes if the host is running Linux" cr
+ ." or about 5 minutes if the host is running OFW." cr
+;
+
: reflash ( -- ) \ Flash from data already in memory
?file
spi-start
@@ -222,8 +228,7 @@
then
spi-reprogrammed
else
- ." Type verify if you want to verify the data just written." cr
- ." Verification will take about 17 minutes..." cr
+ .verify-msg
then
;
@@ -238,21 +243,26 @@
: flash ( ["filename"] -- ) get-file reflash ;
-[ifdef] dev
-dev /flash
+\ This is a slower version of "rom-va flash-buf /flash lmove"
+\ It works around the problem that continuous CPU access to the
+\ SPI FLASH starves the EC of instruction fetch cycles, often
+\ causing it to turn off the system.
0 value rom-va
-: selftest ( -- error? )
- rom-va 0= if rom-pa /flash root-map-in to rom-va then
-
- \ This is a slower version of "rom-va flash-buf /flash lmove"
- \ It works around the problem that continuous CPU access to the
- \ SPI FLASH starves the EC of instruction fetch cycles, often
- \ causing it to turn off the system.
+: slow-flash-read ( -- )
+ rom-pa /flash root-map-in to rom-va
/flash 0 do
rom-va i + flash-buf i + h# 1.0000 lmove
d# 200 ms
h# 1.0000 +loop
+ rom-va /flash root-map-out 0 to rom-va
+;
+[ifdef] dev
+dev /flash
+: selftest ( -- error? )
+
+ slow-flash-read
+
\ Replace the manufacturing data block with all FF
flash-buf mfg-data-offset + /flash-block h# ff fill
@@ -261,7 +271,6 @@
-1 swap l!
flash-buf /flash crc <>
- rom-va /flash root-map-out 0 to rom-va
;
device-end
[then]
@@ -291,8 +300,7 @@
\ Don't overwrite the EC code
flash-buf /flash /ec write-flash-range
- ." Type verify-bios if you want to verify the data just written." cr
- ." Verification will take about 17 minutes..." cr
+ .verify-msg
;
: verify-bios ( -- ) flash-buf /flash /ec verify-flash-range ;