icefox
Posts: 2
Joined: Thu Apr 10, 2014 2:26 am

Baremetal Forth?

Thu Apr 10, 2014 2:29 am

I was strongly considering writing a Forth implementation designed to run bare-metal on a Raspberry Pi, ie, booting directly into Forth with no OS. I thought this might be of interest to the community both for educational reasons and probably nostalgic ones as well.

However, I feel like this is something that should have been done already. Does anyone know of anything like this that's been done already? If there's an existing project along these lines, I'd rather contribute to that than start all over.

I've also considered the Beagleboard as a target for this, so any info on projects for that would also be nice.

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Baremetal Forth?

Thu Apr 10, 2014 3:23 am

Try xace in the GUI, for forth, or gforth. For bare metal perhaps a good option would be eFORTH written as a character device driver, and a simple pipe script kernel boot sequence. For bare metal current development, what's the point of limited USB and a micro kernel? None for me.

EDIT; The issue for me is the stability of code. Random number into context ! and bare seems bad with an SD controller, and consistency issues with bombing or crashing the system. i did invent my own language hybrid with forth once, and used the "critical" cell/variable class to prevent assigning a non vocabulary to the context. (project jarvar on github, no IO and in Java). In C with some improvements in implementation it could have gotten good. Very small user base problems.
Last edited by jackokring on Thu Apr 10, 2014 6:00 am, edited 1 time in total.
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Baremetal Forth?

Thu Apr 10, 2014 3:28 am

Forth on bare metal? The Sun OBD was actually a forth interpreter.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Baremetal Forth?

Thu Apr 10, 2014 5:46 am

You might want to look at Roland's stuff.

http://www.raspberrypi.org/forums/viewt ... 72&t=37712

tgritchie
Posts: 19
Joined: Fri Jun 01, 2012 4:07 pm
Location: United Kingdom

Re: Baremetal Forth?

Fri Apr 11, 2014 7:51 pm

I would endorse the previous post regarding Roland's code. If you look at the quoted thread you will see some small contributions from me. Having studied this I am currently working on a port of Chuck Moore's colorforth. It is early days yet so I'd rather not post any code until I resolve some outstanding issues. Colorforth may not be for everyone as it is rather *quirky* when compared with more conventional approaches (see http://www.colorforth.com) but the exercise has taught me a lot about the ARM architecture and assembler as well giving me an insight in the differences between the i386 and the ARM. Not to mention the differences in hardware, graphics, keyboard, etc, etc from PC to RPi. When I do have a bootable version I'll post it to Github.

Trevor

icefox
Posts: 2
Joined: Thu Apr 10, 2014 2:26 am

Re: Baremetal Forth?

Mon Apr 14, 2014 2:10 am

Thanks to everyone for the advice; I've looked at Roland's code and it's pretty helpful. Don't hold your breath waiting for something useful to come of this, but I'll at least have fun with it. :) If I ever get anything working I'll post a link to it here.

User avatar
scidata
Posts: 90
Joined: Tue Jan 06, 2015 4:21 pm
Location: Toronto
Contact: Website

Re: Baremetal Forth?

Thu Jan 08, 2015 3:12 pm

Bare metal Forth would be even more educational than Python-on-Linux. I've listed a few of the reasons for using Forth as an educational language here: http://www.scidata.ca/?p=264
Also, early (bare metal) Forths used a simple block-based 'O/S' known as 'screens' that eliminated the need for all that file handling. I've suggested this elsewhere in the past and had people say it wouldn't work because no one would re-write all those pi device drivers in Forth. That completely misses the point. There's no need to write device drivers, libraries, or frameworks when your entire environment is one mind and one concatenative processor. Learn pure, natural computation first, then wade into the frantic and chaotic world of IT with a bit of savvy. Less chance of getting rolled by doctrine and dogma.
"Self-education is, I firmly believe, the only kind of education there is" - Isaac Asimov

User avatar
scidata
Posts: 90
Joined: Tue Jan 06, 2015 4:21 pm
Location: Toronto
Contact: Website

Re: Baremetal Forth?

Thu Feb 19, 2015 1:04 pm

Learning to program by writing programs with examples and minimal guidance is flawed, especially for beginners. It takes a much more immersive, personal, 'syntonic' approach.
Here's an argument for Forth as a learning language
http://www.scidata.ca/?p=895
"Self-education is, I firmly believe, the only kind of education there is" - Isaac Asimov

Avoncliff
Posts: 35
Joined: Fri Dec 09, 2011 5:24 pm

Re: Baremetal Forth?

Thu Feb 19, 2015 8:49 pm

I have been hacking on pijForthos https://github.com/organix/pijFORTHos.
My first attempt added a frame buffer, my second go added the lib files from https://github.com/rsta2/uspi.
Find it here https://github.com/Avoncliff/pijFORTHos
My thanks to both of these projects.
This version allows keyboard and screen output, but is far from a working system.
The joins between the two projects are messy, but allow experimenting.
But they raise some questions in my mind of what a bare metal Forth should look like.
Should it be case sensitive, with upper case predefined words?
It is at the moment, but this feels too old school compared to say gForth.
How should it save and load code?
Always as forth compiled on load, or as binary images?
As screens?
Is there a free standing Forth machine, newer than the ACE, that is a good example?
David

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Baremetal Forth?

Fri Feb 20, 2015 8:08 pm

Avoncliff wrote:Is there a free standing Forth machine, newer than the ACE, that is a good example?
Not really, as far as I know.

There's the various OpenFirmware boot roms, I suppose, that comes kinda close. Otherwise there's Chuck's various bits of ColorForth exotica, including the greenarrays stuff, and the forth.com ForthX embedded stuff but I don't think they really count as "standalone forth machines" in the same way that the Ace did.

Avoncliff
Posts: 35
Joined: Fri Dec 09, 2011 5:24 pm

Re: Baremetal Forth?

Thu Feb 26, 2015 11:52 pm

I have updated my version of pijForthos at https://github.com/Avoncliff/pijFORTHos/tree/SD.
I have added a SD library borrowed from John Cronin's rpi-boot project.
So now the Jonesforth now auto loads the jonesforth.f file to complete the install. And you can load other forth code with LOAD file.
The code is very hacky and needs a lot of cleaning, but first I am looking at the jones forth and finding it is not quite standard. But maybe it is a case of everyone has there own standard.....
So this is for comment at this stage.
David

rst
Posts: 407
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Baremetal Forth?

Fri Feb 27, 2015 11:04 am

A week ago you mentioned a performance issue when using the USPi library. Now when I could have had a look at your code I think you do not have the MMU and caches enabled in your system.

I would suggest doing this because it has a great influence on the performance. USPi will benefit from this too. I think it is possible to get a reasonable performance with USPi and MMU and caches enabled even without using multi-core on the Raspberry Pi 2.

In USPi release 0.30 I have added MMU support to the environment. It's on GitHub if you want to have a look at it.

Avoncliff
Posts: 35
Joined: Fri Dec 09, 2011 5:24 pm

Re: Baremetal Forth?

Fri Feb 27, 2015 2:23 pm

rst
Thanks for looking, as I said the performance hit was not the most urgent thing for me to look at. I could not really use it at all as free standing with out the SD card reading that is now included. And there is a lot more to investigate to get a usable forth system.
I will follow up on your suggestions.
David

robogrow
Posts: 3
Joined: Mon Feb 08, 2016 9:15 am

Re: Baremetal Forth?

Mon Feb 08, 2016 11:03 am

Anybody no what happen to isForth? That was supposed to be working and now nothing.

mob-i-l
Posts: 267
Joined: Sat Dec 29, 2012 2:45 am
Location: Lund, Skåne/Scania, Sweden
Contact: Website Facebook Google+ Twitter YouTube

Re: Baremetal Forth?

Tue Mar 01, 2016 11:12 am

tufty wrote:
Avoncliff wrote:Is there a free standing Forth machine, newer than the ACE, that is a good example?
Not really, as far as I know.

There's the various OpenFirmware boot roms, I suppose, that comes kinda close. Otherwise there's Chuck's various bits of ColorForth exotica, including the greenarrays stuff, and the forth.com ForthX embedded stuff but I don't think they really count as "standalone forth machines" in the same way that the Ace did.
On https://en.wikipedia.org/wiki/Forth_%28 ... anguage%29 I found this tutorial http://wiki.laptop.org/go/Forth_Lessons and OLPC has Open Firmware. It would be good if Open Firmware was available for Raspberry Pi and that the tutorial on Laptop.org was adapted to Raspberry Pi. Maybe the Raspberry Pi Foundation could cooperate with Laptop.org to bring out a OLPC with a built-in Raspberry Pi 3.

BTW I read the Jupiter Ace manual and did all the excercises in it, and reported about errors in it here: https://groups.google.com/d/msg/comp.sy ... QSb4ytMcAJ
Have Pi0&1A&1B&1B+&2B&3B&4B w/ Raspbian. Started w/ BASIC on ABC80&ZX81 then Forth, Z80… https://scratch.mit.edu/users/mobluse/ https://github.com/mobluse/ https://twitter.com/mobluse/ https://YouTube.com/MOBiL4u/

Return to “Bare metal, Assembly language”