10 ms·
Bare metal Smalltalk-80 port to the Raspberry Pi
- salgernon 6y ago"Past" submission didn't find anything, but the author had an "Ask HN" the other day: https://news.ycombinator.com/item?id=23806323 https://news.ycombinator.com/item?id=23806323
- johndoe0815 6y agoThanks for mentioning this - I would certainly appreciate input on this. Testing software on half a dozen different Raspberry Pi models currently involves quite a bit of cable un- and replugging...
- johndoe0815 6y agoIt was actually submitted twice before, but both submissions linked to the linkedin article, not directly to the github repository.
- 7thaccount 6y agoSeems like a neat idea. I've always wanted a tiny LispOS or SmalltalkOS that I could carry around and use on a Pi. I just wish it would also have the modern necessities like web browser...etc.
- johndoe0815 6y agoOne of the inspirations for my "crosstalk" Smalltalk system was Lukas Hartmann's Lisp-based "Interim OS" bare-metal system for the Raspberry (http://interim-os.com/ http://interim-os.com/), so you might want to give this a try. 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 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...
- skissane 6y agoI really like language-based operating systems. It is cool you did this. 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.)
- johndoe0815 6y agoGreat that you like it - thanks! Some of the work of Stephen R. Kell at Kent University also covers language-based OSes and how some of their ideas might be adapted in Unix (see [1] and [2]). 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/kell19unix-personal.pdf 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/kell13operating.pdf 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.pdf 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 http://files.squeak.org/docs/OOPSLA.Squeak.html
- throwqqq 6y agoThats a problem with modern necessities though. The web has become this bloated mess of which there is basically one canonical implementation in Chrome and one second class one in Firefox. That you need js to set up css for a basic text web page is an embarrassment. If we redid things from the bottom up a lot more people would see why having standards like http3 are a bad idea.
- infinite8s 6y agoI've been eyeing the new PinePhone as a potential candidate for a reimagining of Dynabook using Smalltalk-78 (which was built for the Notetaker) in a portable form factor.
- jecel 6y agoIt is interesting that you prefer Smalltalk-78 to -80. I also see that forks of Little Smalltalk 3 (which doesn't have metaclasses) are far more common that of LST 4 (which has them).
- johndoe0815 6y agoThe PinePhone is a very interesting platform. Unfortunately, the circle library I'm using only supports Raspberry Pis so far, so porting crosstalk to the Allwinner A64 in the PinePhone (even though the processor cores are the same as in a Raspberry Pi 3) is quite an effort. 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-Smalltalk78.pdf https://www.freudenbergs.de/bert/publications/Ingalls-2014-S...
- cmrdporcupine 6y agoI wonder if there's anything neat that could be done in the Smalltalk VM that could take advantage of the BCM SOC's VPU etc. hardware ... hmm...
- johndoe0815 6y agoAccelerating the Smalltalk VM BitBlt primitives using the VPU would certainly be interesting. Currently, drawing is rather slow since lots of the functionality is implemented in interpreted bytecodes and rendering to the framebuffer is completely unoptimized.
- zackangelo 6y agoSlight tangent, but: I first encountered a function named BitBlt when using the Win32 C API a long time ago. I had no idea that it originated in Smalltalk-72 in 1975 and the function name was just carried forward into the Windows API.
- johndoe0815 6y agoBitBlt was also used as the drawing primitive for an early graphics terminal developed at Bell Labs, the appropriately named "Blit" (https://en.wikipedia.org/wiki/Blit_(computer_terminal) https://en.wikipedia.org/wiki/Blit_(computer_terminal). Hardware implementations of BitBlt were available in the Amiga and Atari ST blitter chips (that's how I learned about BitBlt in the late '80s). Btw., there's a nice paper on BitBlt by Rob Pike: https://pdos.csail.mit.edu/~rsc/pike84bitblt.pdf https://pdos.csail.mit.edu/~rsc/pike84bitblt.pdf
- pinewurst 6y agoA very long time ago, I ported Smalltalk to Windows and had to map Smalltalk BitBlt to Win32 BitBlt.
- johndoe0815 6y agoI had a quick look at the Win32 BitBlt API and it seems to be quite similar. Can you remember how much work was actually involved in mapping the Smalltalk primitives to Win32?
- johndoe0815 6y agoAuthor here - happy to answer your questions... 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.
- kabdib 6y agoThis is very cool, thank you. Smalltalk is my favorite language that I will never ship a product in. :-/
- johndoe0815 6y agoBtw., you can read a bit about the background of Smalltalk and the Raspberry port in my article: https://www.linkedin.com/pulse/relive-part-xerox-parcs-history-smalltalk-80-raspberry-michael-engel/ https://www.linkedin.com/pulse/relive-part-xerox-parcs-histo...
- wslh 6y agoI wonder why it doesn't work in Raspberry Pi 4 with 8 GB. What (you think) does it make the difference with the 4 GB?
- johndoe0815 6y agoIt seems to be a problem with the USB controller driver in circle. Startup hangs with the message "XHCI: HW reset failed". 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...
- del_operator 6y agoI just started a small 8GB RPi 4 cluster and had similar assumptions. Did you happen to try out the beta 64 bit os?
- 6y ago
- slobiwan 6y agoI love the idea of bare-metal ports to the Pi. I saw snakeware posted here not too long ago. Are there other examples? ColorForth would be interesting as well
- johndoe0815 6y agoIn addition to the Interim Lisp system I mentioned in another comment, there are a number of bare-metal applications for the Raspberry on github (mostly ports of games). I especially like this Commodore 64 emulator (also based on circle): https://github.com/randyrossi/bmc64 https://github.com/randyrossi/bmc64
- guenthert 6y agoCould someone share what one gains with such 'baremetal' ports? I see only the loss of common ground, well tested libraries and functionality. 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).
- johndoe0815 6y agoIn general, lower code complexity results in fewer bugs and security problems, less code implies lower resource usage, so you could run the system with a smaller main memory, a slower CPU or lower power/energy consumption. In addition, if you plan to target real-time applications, setting up Linux to guarantee your real-time constraints is not trivial. 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 :-).
- ekvintroj 6y agoLove this! awesome!
- esfandia 6y agoVery neat! How much work would it be to write ROS bindings so you could control robots easily with it? Googling around, I found one team that has done it with Pharo: http://car.imt-lille-douai.fr/category/software/pharos/ http://car.imt-lille-douai.fr/category/software/pharos/
- johndoe0815 6y agoRobot control would be a fascinating applications (but my students had to program our robots in C [1] ;-)). 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-labor.html https://www.hs-coburg.de/news-detailseite/roboterrennen-im-l... (sorry, in German only) [2] https://www.hpi.uni-potsdam.de/hirschfeld/projects/nxtalk/index.html 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/smalltalk%20as%20a%20programming%20language%20for%20robotics.pdf http://www.menneske.org/projects/bachelorsproject/Articles/s...
- endlessvoid94 6y agoThis is so cool. 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?
- nsomaru 6y agoThis sounds a lot like Erlang
- johndoe0815 6y agoThat idea crossed my mind, too - in fact, I have a SOPINE cluster here [1] (built by Pine64) that would be a good platform for experiments with distributed objects. The Turing Pi is a very similar product for Raspberry Pi Compute Modules [2], just a bit more expensive. Of course, this approach would work as well with a bunch of Raspberry Pis connected via an Ethernet switch. 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/ https://www.pine64.org/clusterboard/ [2] https://turingpi.com/ https://turingpi.com/ [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.4288&rep=rep1&type=pdf http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.61.... [5] http://www.transputer.net/ 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 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/ http://www.usingcsp.com/ [8] https://en.wikipedia.org/wiki/XMOS 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 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 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/retrospective.html 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)
- soapdog 6y agoAnyone got photos or screenshots of it running :-) I am quite curious.
- johndoe0815 6y agoThe screenshots are boring - it looks like any other Smalltalk-80 system :). 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-computer.html https://www.multicores.org/blog/smalltalk-on-a-small-compute... [2] https://media-exp1.licdn.com/dms/image/C4D12AQF-SUDkziblKg/article-inline_image-shrink_1000_1488/0?e=1600300800&v=beta&t=5j4PEoZA5yPI6kCTJh2FKse_Ewfn_TqsLih5rLerPJg https://media-exp1.licdn.com/dms/image/C4D12AQF-SUDkziblKg/a...
- soapdog 6y agoThanks a lot! :-) I will try to run here as well. Excited to see more people doing stuff with Smalltalk.