Bare metal Smalltalk-80 port to the Raspberry Pi
github.com
github.com
Beware, there's a bug on ARM11-based Raspberry Pis (BCM2835 on Pi 1/Zero/Zero W and CM1) that crashes the VM when executing drawing functions. I'm currently investigating the problem.
https://www.linkedin.com/pulse/relive-part-xerox-parcs-histo...
I was under the impression that the hardware of the 8GB Raspberry Pi 4 was identical to the versions with less memory except for (obviously) the memory chip and some fixes for USB-C power delivery. Maybe it's a subtle timing problem - another item on my to-do list...
In general, I think Smalltalk is not that well suited as a systems programming language since garbage collection might mess with your timing and you would also need to find a way to handle asynchronous events (such as interrupts).
Nevertheless, Smalltalk has been used for low-level control of robots, e.g. in NXTalk [2] for the Mindstorms NXT ARM7 platform. However, the VM also relied on C code (the LegOS project) for driver code.
[1] https://github.com/organix/pijFORTHos [2] https://www.hpi.uni-potsdam.de/hirschfeld/projects/nxtalk/in...
Smalltalk is my favorite language that I will never ship a product in. :-/
There also seems to be a bare metal Forth implementation, pijFORTHos [3], but I haven't played around with that one so far.
[1] http://interim-os.com/ [2] https://en.wikipedia.org/wiki/Movitz [3] https://github.com/organix/pijFORTHos
A modern Lisp machine certainly would be nice...
git filter-repo --force --name-callback 'return b"Name to use"' --email-callback 'return b"emailtouse@example.com"'
[0]: https://github.com/newren/git-filter-repoEdit: Oh, someone else asked that question
We know that smalltalk message passing was inspired by biology, and the ultimate design vision was for objects to be ephemeral machines themselves.
Would it be possible to create a farm of Pis, where some objects were on some subset of them, and some objects on another? Even a simplistic example with two Pis, with the object space split between them? Can we use the network to perform language-level message passing?
There was some research in the late '80s on building a distributed Smalltalk [3,4] which is a nice inspiration for such a project. So it's definitely possible to build a distributed Smalltalk and it would be interesting to investigate how well such a system would work given today's hardware performance and networking throughput.
Distributed Smalltalk is just one of the ideas for building distributed non-shared-memory systems from the 1980s. This was an interesting time in general, people experimented with different approaches for distributed systems hardware and software. Some examples include the inmos Transputer, which had bit-serial communication links [5] and support for CSP-based (paper [6] and book [7]) communication in the instruction set (later these ideas were picked up again by David May and his colleagues for the XMOS embedded processors [8]); on the operating system side there were systems such as Plan 9 and Inferno [9], invented by the Unix team at Bell labs, Tanenbaum's (the Minix guy) Amoeba [10] and Ousterhout's (otherwise known for tcl/tk) Sprite [11].
Some of these ideas seem to be gaining popularity again (e.g., CSP-based communication for goroutines [12]) and I hope my students here are interested in investigation these approaches to building distributed systems, e.g. as an alternative platform for IoT applications.
(edit: links reformatted)
[1] https://www.pine64.org/clusterboard/
[3] Marcel Schelvis, Eddy Bledoeg, The Implementation of a Distributed Smalltalk, ECOOP 1988 - www.lirmm.fr/~ducour/Doc-objets/ECOOP/papers/0322/03220212.pdf
[4] John K. Bennett. 1987. The design and implementation of distributed Smalltalk. SIGPLAN Not. 22, 12 - http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.61....
[5] http://www.transputer.net/
[6] Hoare, C. A. R. (1978). "Communicating sequential processes". Communications of the ACM. 21 (8): 666–677 - https://www.cs.cmu.edu/~crary/819-f09/Hoare78.pdf
[7] Hoare, C. A. R. (1985). Communicating Sequential Processes. Prentice Hall. ISBN 978-0-13-153289-2 - http://www.usingcsp.com/
[8] https://en.wikipedia.org/wiki/XMOS
[9] Pike, R.; Presotto, D.; Dorward, S.; Flandrena, B.; Thompson, K.; Trickey, H.; Winterbottom, P. "Plan 9 from Bell Labs". Bell Labs Technical Report - https://css.csail.mit.edu/6.824/2014/papers/plan9.pdf
[10] Andrew S. Tanenbaum, M. Frans Kaashoek, Robbert van Renesse and Henri E. Bal (1991). The Amoeba distributed operating system — a status report. Computer Communications 14 - https://www.cs.vu.nl/pub/amoeba/Intro.pdf
[11] Ousterhout, John (1992). "Sprite Retrospective". University of California at Berkeley - https://www2.eecs.berkeley.edu/Research/Projects/CS/sprite/r...
[12] James Whitney, Chandler Gifford and Maria Pantoja, Distributed execution of communicating sequential process-style concurrency: Golang case study, The Journal of Supercomputing volume 75, pages 1396–1409(2019)
I have the smalltalk blue book on my shelf and have always, always wondered about the possibility of bringing back some of the radical ideas from the 60s/70s/80s in a language like Ruby (being popular). Live objects and snapshots are the two that I was most enamored with way back in the day, but I'm sure there are lots of others.
This isn't terribly old (2014) but would love thoughts on it (if you have any!). It's a prototype of a smalltalk-like "System Browser" implemented in Ruby and Qt on OS X:
https://www.youtube.com/watch?v=2xC5B5t5Rq8
The idea is that in the same way that Clojure is a sort of "improved" lisp on the JVM for performance reasons, syntax enhancements, and access to the standard library of Java, I see no reason why Ruby couldn't be the same thing for Smalltalk. Access to the ruby standard library, bringing an interactive live environment to a vibrant programming community and prioritizing interoperability with the modern world (as opposed to much of the smalltalk world which still sort of sits a "world" apart)
In general, I think there are two major interesting aspects in systems like the Ruby system browser and Smalltalk. On the one hand one can discover the system - you can dig into the implementation without using a disassembler or reverse engineering - and on the other hand it is possible to change the system behavior at runtime (though this is, of course, dangerous).
I would love to see at least the discoverability aspect to be more pervasive in standard operating systems. There are already partial approaches to this, such as DTrace/systemtap and the proc filesystem, but having discoverability as a first class concept - which might fit well to Plan 9's (and to some extent Unix's) "everything is a file" approach - would be nice.
The ability to change the system at runtime is also fascinating. I already mentioned the research of Stephen Kell in another comment [1] and there's a great video of one of his talks [2] in which he shows his approach to dynamically alter a program's behavior on Unix using shared library mechanisms (you can find the code on github [3]). I worked on related ideas in my PhD thesis 15 years ago, maybe it's time to dig these out again ;-).
However, these dynamic modifications should also be safe and accessible. I'm thinking of something related to AppleScript here, which allows to automate/scripts an amazingly large number of functions on OS X. Combining this with a browser that enables a user to discover the accessible OS functionality seems to be a good idea.
The persistent image ideas might also be useful again in the context of persistent main memory systems, which are becoming available now, e.g. with Intel Crosspoint [6]. There's so much prior work in persistent object systems also on the OS side that is almost forgotten nowadays, such as the Eumel/L3 system by Jochen Liedtke [4] (the inventor of the L4 microkernel) and the BirliX OS [5]. Sounds like a good time to re-evaluate these 1980's-era approaches.
I see some more recent work, such as Ksplice [7], as interesting related technology. What is really missing is an integration of many of these ideas into a consistent system.
[1] https://www.cs.kent.ac.uk/people/staff/srk21/
[2] https://www.youtube.com/watch?v=LwicN2u6Dro
[3] https://github.com/stephenrkell/liballocs
[4] Jochen Liedtke, A Persistent System in Real Use - Experiences of the First 13 Years, Third International Workshop on Object Orientation in Operating Systems 1993 - http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.53.7112
[5] W. E. Kühnhauser, H. Härtig, O. C. Kowalski, W. Lux, Mechanisms for Persistence and Security in BirliX, International Workshop on Computer Architectures to Support Security and Persistence of Information 1990, https://link.springer.com/chapter/10.1007/978-1-4471-3178-6_22
[6] https://en.wikipedia.org/wiki/3D_XPoint
[7] Arnold, Jeff and Kaashoek, M. Frans, Ksplice: Automatic Rebootless Kernel Updates, EuroSys 2009 - https://ksplice.oracle.com/doc/ksplice.pdfI have been thinking a lot lately about HyperCard and Applescript. They represent a line of thinking that has more or less been abandoned by the commercial side of personal computing, which is really too bad. Applescript still exists, sure, but they've really let it die on the vine. Back in the late 90s I hoped they would make the whole front end of the OS in a HyperCard like system, so that everything could be manipulated by the user. Don't like how this part of the Finder works? No problem, just peel back a layer and see what's going on.
The only reason this doesn't exist is simply that nobody has decided to build it yet.
It also takes a lot of time and effort, and so needs to be funded along with minimal interference from the bureaucracy of a business. Smalltalk and Hypercard came out of precisely those kind of environments. Today the goals of businesses are much different -- much more short term and quarterly focused. I don't have much faith that FOSS can come up with it either, since so much depends on part time work of loosely connected people.
I hope I'm wrong though!
I'm really interested in these types of topics too, so I'll add some more info to this thread.
I agree that things like Smalltalk could be a great alternative platform for IoT and edge computing. [1][2]
With GPIO access [3], very cool debugging abilities [4], and some capabilities for on-device AI/ML with TensorFlow [5], Smalltalk already has some real potential in this area. I've even tried Smalltalk on Amazon AWS (ARM) and it worked really well there too [6] with the ability to make a Docker Swarm if desired [7].
Full disclosure, I work with Instantiations (the company that develops VA Smalltalk), and they have developed a really cool VM that runs on ARM. Their interpreter VM is working on both ARM 32 / ARM 64 platforms at this point, and we've been doing a lot of testing of the LLVM-based VM with JIT compiler, PICs, and everything. And yes, it works for ARM v6, v7 and v8 so far. Small runtime images (around 1MB) or even the full blown VM with full IDE/language can be run on Linux ARM platforms (not bare metal yet...but maybe at some point.)
Feel free to reach out to me for more details or discussion.
Keep up the good work!
[1] https://dev.to/martinezpeck/why-is-smalltalk-a-good-fit-for-...
[2] https://dev.to/martinezpeck/sensor-process-and-transparently...
[3] https://dev.to/martinezpeck/accessing-raspberry-pi-gpios-wit...
[4] https://dev.to/martinezpeck/it-s-2019-stop-reading-text-and-...
[5] https://dev.to/martinezpeck/getting-started-with-nvidia-jets...
[6] https://dev.to/martinezpeck/deploying-vasmalltalk-on-amazon-...
[7] https://dev.to/martinezpeck/docker-swarm-cloud-on-a-arm64-di...
With more than a million ARM9 cores and about 7 TB of distributed memory this is a bit of a different scale than a cluster of Raspberry Pis, though ;). SpiNNaker also reminds me of Dan Hillis' Connection Machine [2], but taking advantage of 40 years of progress with Moore's Law...
[1] http://apt.cs.manchester.ac.uk/projects/SpiNNaker/architectu... [2] Hillis, William Daniel, The Connection Machine, Ph.D. Thesis, MIT Dept. of Electrical Engineering and Computer Science, 1988 - https://dspace.mit.edu/handle/1721.1/14719
That's a distributed erlang setup, and I'm rather certain erlang runs on raspi. Pretty sure I even saw Erlang on Xen worked on raspi at one point, so your raspi could be a bare-metal erlang node. Not sure that's maintained / still working though, EoX seems dead.
I think Interim only runs on the Raspberry Pi 2 at the moment; porting Interim OS to use the circle library (which I use for crosstalk) should also be feasible and would help to support other Raspberry versions.
Lukas is also the creator of the MNT Reform open source notebook (using a Freescale i.MX8 quadcore ARM Cortex-A53) - see https://www.crowdsupply.com/mnt/reform for the currently running crowdfunding campaign.
Modern web browsing is, of course, more complex than the whole rest of the Smalltalk system...
My ideal though would be – it is all written in the language (Smalltalk/Lisp/whatever), with no use of other languages such as C/C++ (except possibly assembler, in which case my ideal is it comes with an assembler written in the language); and it is fully self-hosting in terms of the build process.
Of course, I realise my ideal is a lot more work than what you've done, and none of us has infinite time in which to tinker with things...
(I myself have some toy programming language interpreters I wrote, some in C, some in Java – I keep on thinking "oh, I should get rid of the C/Java, make it generate native code and then rewrite its core in itself" – but that's a lot of work and I've never had time for that.)
The Smalltalk-80 VM is specified in Smalltalk itself (in the "Blue Book" [3]) and the Squeak VM (a Smalltalk derivative) was written in a subset of Squeak itself [4].
The great thing is that it's a lot of fun to build this (at least for me) because it's actually possible to understand the whole system. I hope my students will have fun working on topics like these, too.
[1] Unix, Plan 9 and the Lurking Smalltalk. In L. de Mol and G. Primiero (eds), Reflections on Programming Systems, Philosophical Studies Series, Springer - https://www.cs.kent.ac.uk/people/staff/srk21/research/papers...
[2] The operating system: should there be one?. In Proceedings of the 7th Workshop on Programming Languages and Operating Systems, ACM, November 2013 - https://www.cs.kent.ac.uk/people/staff/srk21/research/papers...
[3] Adele Goldberg and David Robson, Smalltalk-80: The Language and its Implementation, ISBN 0-201-11371-6 - http://stephane.ducasse.free.fr/FreeBooks/BlueBook/Bluebook....
[4] Dan Ingalls, Ted Kaehler, John Maloney, Scott Wallace, and Alan Kay. “Back to The Future: The Story of Squeak, A Practical Smalltalk Written in Itself.” In Proceedings of the 12th ACM SIGPLAN Conference on Object-Oriented Programming (OOPSLA) 1997, 318–26, 1997 - http://files.squeak.org/docs/OOPSLA.Squeak.html
But the MNT reform (and the Purism Librem 5, which uses a similar SoC) is a great project and an interesting platform for bare-metal projects, since the CPU documentation is open and pretty good (I think the old Motorola heritage of Freescale shows here...) and there is also open source GPU support in the Etnaviv project [1].
So many possible projects, so little time :-).
Considering the large number of Allwinner-based systems out there (by Pine64, Olimex and many others), it might still be worth to spend some time on a port of circle. I can imagine this would make a nice project for Google's Summer of Code.
Smalltalk-78 shouldn't be significantly different to Smalltalk-80, so a bare metal version of it sounds feasible. There's already a project to run Smalltalk-78 in a JavaScript-based VM [1].
[1] https://www.freudenbergs.de/bert/publications/Ingalls-2014-S...
I am not an expert in ROS, but there have been other projects using Smalltalk for robotics, such as NXTalk [2] and a Squeak-based system [3]. A more general paper discusses the challenges in using Smalltalk for robotics applications [4].
So it should be possible to do this on the Smalltalk-80 bare-metal port. One problem that will definitely show up, though, is the limited memory space and number of objects of Smalltalk-80, since it uses a 16 bit VM. Modern robotics applications involving complex SLAM approaches, object recognition or LiDAR might be a bit challenging for this, so I think a more modern 32 bit based VM such as Squeak or Pharo is more appropriate here.
(edit: links reformatted)
[1] https://www.hs-coburg.de/news-detailseite/roboterrennen-im-l... (sorry, in German only)
[2] https://www.hpi.uni-potsdam.de/hirschfeld/projects/nxtalk/in...
[3] Joaquin Sitte, Robotics and Robotics Education with Smalltalk, AMiRE 2005
[4] LaLonde, W., Thomas, D., Johnson, K., Smalltalk as a programming language for robotics?, IEEE International Conference on Robotics and Automation, 1987 - http://www.menneske.org/projects/bachelorsproject/Articles/s...
I especially like this Commodore 64 emulator (also based on circle): https://github.com/randyrossi/bmc64
It doesn't take a lot of Linux know-how to boot you favorite interpreter from /etc/rc.local or replacing /sbin/init (losing the libraries again, but at least keeping the kernel with the filesystem, network support and all the hardware drivers).
All of this is not that relevant for running Smalltalk-80 on the Pi, since Smalltalk was running happily on 16-bit machines with one or a few MBs of RAM.
So I guess the ultimate reason for doing this is "it can be done" - for the fun of hacking :-).
Btw., there's a nice paper on BitBlt by Rob Pike: https://pdos.csail.mit.edu/~rsc/pike84bitblt.pdf
This was in the days of Windows 2 (1988 or so) and I was hacking PPS Smalltalk to support larger, non-VGA displays. I ran the VM in 386 protected mode, because it needed large memory, where it blt-ed to an upper memory frame buffer. This was sort of a "bounce buffer" which in turn was blt-ed onto a Windows canvas by my Windows app which also reflected input events up to the VM.
Bill Gates was impressed when he saw a demo (or so I was told). Of course, he didn't realize the level of hackery involved to make it happen.
I was thinking more along the lines of... I wonder if there's anything in the VPU (or other support hardware) that would be especially useful for accelerating a bytecode VM. But I can't really think of anything.
A picture of the setup to test one of my earliest versions can be found in my blog article (this needs to be updated) [1] and another more current one in my linkedin article [2] (I hope the direct link to the picture works for you). Both pictures at home using a crappy TV in Corona times, unfortunately...
[1] https://www.multicores.org/blog/smalltalk-on-a-small-compute...
[2] https://media-exp1.licdn.com/dms/image/C4D12AQF-SUDkziblKg/a...