On Saturday, October 20, 2012 5:59:23 AM UTC-4, M.R.W Wills wrote:
> The whole machine is a little gem, isn't it?!
Yes, it is.
I did some research and I found a lot of interesting links, including this special one:
Go Forth and WikiReadit
4 December 2009, by Ben
He wrote:
There’s something about a product that does one simple thing well. But what really sets the WikiReader apart is that it lasts a year on 2 AAA batteries with no charging. How? The low-power LCD screen, and the tiny microprocessor.
But what’s even cooler, at least for someone who learned to program by dabbling in Forth, is that the device has a built-in Forth interpreter for testing the hardware and running small programs.
I was pleasantly surprised – I know that Forth is good for embedded work on tiny micros, but since the main WikiReader app is written in C, I was curious why they chose Forth for testing and apps. So I asked Christopher Hall, one of the main firmware developers. His reply was very informative, and he’s kindly allowed me to copy it here:
I have written testing programs in several languages, but compiled programs always have the problem of the edit, cross compile, load, and try to debug. Sometimes the platform can run BSD or Linux, and then you can have the full suite of tools on the platform. This is okay if the person doing the initial testing can write programs, but often the test is how to toggle a particular I/O line on/off and see the effect on the rest of the circuit. Then having some kind of scripting on the platform seems the best way to achieve this.
For the initial testing, just start the interpreter REPL and you can start the initial tests. Initially I looked at TCL and Python which I have used before, but they would take far too long to port since they need a lot of Posix system calls which do not exist for this platform.
I also considered Hedgehog, Pico Lisp or perhaps some simple Scheme interpreter but the syntax would probably be too difficult for the hardware engineers to use. Forth is pretty simple syntax and RPN was probably not too difficult for them to learn. Also it was easy to build the Forth interpreter, incrementally adding features until it is now an almost ANSI standard Forth.
Since I added all the device registers the hardware engineers can use commands like the following (I used the same register names as the datasheet):
P0_P0D p? \ display value of port
1 P0_P0D p! \ set port to 1While waiting for the main application development I could build tests for items like the LCD and CTP with just a serial connection on the device itself – using cut/paste from Emacs to picocom to upload Forth words. This is much quicker than cross-compiling and swapping SD cards.
The Forth is rather slow in compiling, the dictionary search is quite slow for example, and the indirect threading adds run-time overhead so in its present form it is probably not fast enough for the main reader application, but for quick applications to try things out I find it very convenient.
Also, the first version was hand translated from a version of EForth for Linux before I migrated it to the ANSI standard. (I kept copies in samo-lib/forth/EForthOriginals subdirectory.)
Very neat. If Lisp is the secret weapon for developing web apps, maybe Forth is it for embedded apps. Both are extensible at the language level and both have real macros, but Lisp is high level and Forth is low level.
Carsten commented: "You can write and test a program using a Forth System on your PC (Linux or other OS), then you copy the source on the Micro-SD card in the Wikireader, and start executing. For debugging, you probably want to solder a serial terminal to the wikireader so that you can interactively develop and debug on thw wikireader itself (and not do cross-development, see
http://wiki.github.com/wikireader/wikireader/hardware-specifications under “debug-connector”)."
Source:
http://blog.brush.co.nz/2009/12/wikireader/
And guess what? It is easy to access Forth programs inside the WikiReader:
The software platform also comes with a FORTH interpreter that can run several small programs that are stored on the SD card. To access these programs, you hold the "random" button down while you turn on the device. It will display a menu of the FORTH programs and allow you to run one of them by tapping it on the touchscreen. The apps that are shipped on the SD card include a simple drawing program and a calculator. There are also a few diagnostic utilities for performing various kinds of tests.
Source:
http://arstechnica.com/information-technology/2009/11/hands-on-openmoko-wikireader-is-simple-appealing/
Here for your convenience some other links which I found, but not sorted:
https://github.com/wikireader/wikireader/tree/master/samo-lib/forth/
http://www.mentby.com/christopher-hall/
https://github.com/wikireader/wikireader/wiki/Building-an-image
http://www.rhinocerus.net/forum/lang-forth/606844-wikireader.html
http://gitorious.org/wikireader-ness/wikireader-ness?page=6
http://gitorious.org/wikireader-ness/wikireader-ness/commits/master?page=7
http://elm-chan.org/fsw/ff/00index_e.html
And last, but not least:
How did you learn to program?
5 June 2007, by Ben
He wrote:
I learnt to program for fun at home, and my theory is that this is the best way to learn. I started in seriously when I was about 14 (I couldn’t quite grasp the concepts before then), and began by learning 80x86 assembly language and Forth. I tried to learn C, but for some reason I grokked assembly more quickly. Plus, assembly made it easy to play with the VGA hardware and write cool graphics demos. The joy of the art was setting in.
Mostly my dad taught me, though I also learnt a lot from reading FidoNet groups and from Demoscene coders. After playing with graphics stuff and coding the first 50 lines of about five different games that were going to “change the face of computer gaming”, my first serious project was to write a Forth compiler. I bootstrapped it by writing the core in assembly, then the rest in Forth.
Speaking of which, I really rate learning Forth. It’s probably the earliest language apart from Lisp which is extensible at the language level and has real macros. But it’s much simpler than Lisp.
The only problem is that it’s so easy to write your own Forth compiler that everyone does that instead of writing good libraries or language extensions.
Source:
http://blog.brush.co.nz/2007/06/how-did-you-learn-to-program/