April 20, 2012

Smalltalk on the BeagleBone

If you've ever struggled with (or simply tired of) the tedious code-compile-upload-boot-test-debug-code-compile... cycle of creation on the arduino, this may be the platform you were looking for.  Running Squeak smalltalk on the BeagleBone allows you to create your software and interact with your hardware while it is running.

Smalltalk is an easy to use programming environment that also happens to be very powerful.  It is used for everything from embedded devices, educational programming, and 3D Online Worlds to semiconductor manufacturingstock trading, and international shipping.

For this quick introduction, I'm going to show how to connect a photoresistor to the BeagleBone and display it's value in a real-time graph, in 11 lines of code.  To follow along you will need to have:
  •  BeagleBone
  •  breadboard
  •  photocell and 10kΩ resistor
  •  desktop or laptop computer with a network connection to the BeagleBone

Since the BeagleBone doesn't have a video output and we're going to be working in a graphical environment, we need to use an alternative. Here are a few options:
  1. Buy a DVI or LCD expansion board.
  2. Use VNC to remotely display the smalltalk environment.
  3. Use X11 to remotely display the smalltalk environment.
I'm going to use option 3 for this demo, since is easy and can be done without modification to any of the software we are using.  X11 is pre-installed on Mac OSX and Linux.  You can get X11 for Windows, but it tends to be difficult to get running and you will probably be happier with VNC. VNC adds some very useful functionality and is what I use for most of my BeagleBone development.  I'll cover VNC in my next post.

Step 1: Build the circuit

The electronics components needed for this demo consist of a photoresistor (aka photocell) and a 10kΩ resistor that I picked up from my local Radio Shack.  Of course you will also need some bits of wire ( I'm using jumper wires, which aren't a bad investment).  Using these components, we'll build a pull-down circuit.  Here is a breadboard view from Fritzing:

The BeagleBone pin connections are as follows:
  1. Header P9 Pin 32 to one end of our photocell
  2. Header P9 Pin 39 to the other side of the photocell along with one end of our resistor,
  3. Header P9 Pin 34 to the other end of the resistor.

Step 2: Configure the BeagleBone

I am using a 5V wall adapter and an ethernet cable connected directly to my Mac for this demo.  I've enabled Internet Sharing which has assigned the IP address to my BeagleBone. To use X11 forwarding on the BeagleBone we need to add the xauth package.  First, login to your BeagleBone with ssh from a terminal window:

ssh root@

Now that you have a root shell, run the following:

opkg update
opkg install xauth

Next we can install Squeak:

mkdir /opt
cd /opt
wget http://unthinkable.org/dl/squeak4.2-beaglebone.tgz
tar xvzf squeak4.2-beaglebone.tgz

Now you are ready to follow along with the video.

Step 3: Play

Here is the smalltalk code I used for this demo:

graph1 := GraphMorph new.
graph1 openInWorld.
graph1 extent: 700@500.
graph1 clear.

analog1 := FileStream readOnlyFileNamed: '/sys/devices/platform/tsc/ain1'.

[1000 timesRepeat: [
 | lightValue |
 lightValue := (analog1 contents) asInteger.
 graph1 appendValue: lightValue.
 (Delay forMilliseconds:50) wait.
]] fork.


  1. I suggest you try 'beaglebone.local' if the BeagleBone is on your local network. This works thanks to mDNS/Bonjour, unless your computer doesn't recognize mDNS/Bonjour or there is a conflict on the network.

  2. Thanks, I forgot Avahi was installed. I tried using it tonight, but the name resolution wasn't consistent. I'll have to take a closer look.

  3. Hello,
    I'm following along with your video. Here is my setup: Laptop PC running Vista. I'm using Putty to SSH into my Beaglebone and there are no issues with the connection. When I enter "/opt/squeak/bin/squeak /opt/squeak/images/Squeak4.2-10996.image I get an error: squeak: could not find any display driver

    It has been suggested from others to do this in terminal/putty:
    export DISPLAY="IP of my laptop":0.0

    When I do that, I get this error: 'Could not open the Squeak image file `/opt/squeak/images/Squeak4.2-10996.image'
    Of course, it is suggested I read the man pages....
    Question: what did I miss in the video?

    Last, I have a DVI cape that fits to my BB....I can run squeak/smalltalk right from my BB without having to use Putty or a VNC! In order to do that, what would be the procedure to get squeak/smalltalk GUI up and running on the BB dedicated lcd monitor?

    Thank you!

  4. Hi Redtank,
    Do you have an X11 server installed? If not, here is an open source package with putty integration: http://www.straightrunning.com/XmingNotes/

    1. Hello dg,
      Installed Xming, thanks for the tip! Was able to get Squeak/Small talk up and running and follow some of the video you produced showing how to create a graph. I have a few problems, perhaps you have time to suggest a work around:
      1. Running Squeak is very slow, it takes several seconds for typed characters to show up on screen.... makes for difficult communication.
      2. After entering line "graph1 := GraphMorph new.", using Ctrl-d did not produce any results under Windows Vista 64.

      My question is this: why can't I run Squeak on my Beaglebone using the DVI cape (for video), as a normal personal computer, eliminating the need for other hardware and network hassels?


    2. 1. The speed really depends on how much screen drawing is happening in the GUI. To me, typing code doesn't feel too different than local, but opening a window will create a noticeable delay (around a second). With smalltalk, you can always do the heavy development on your PC and then copy the image to the BB when it's ready for testing and usage.

      2. You can also right-click on the line or highlighted code and select "do it" from the menu. ctrl-d is just a shortcut, and windows or your VNC client may be capturing it and not passing it to Squeak.

      Sorry, I'm not sure about the DVI cape. Do you have a desktop GUI running on your LCD?

    3. Hello dg,
      Yes, I bought the DVI cape from the folks who make them in Dallas, it works very nice. I d/l'd the latest Angstrom Demo file from BB.org and it has the Gnome desktop/gui built into it; it runs fast, but I'm also using a class 10 SD card at the moment. The SD cards that ship with Beaglebone and Beagleboard are fairly slow. I used Windiskimager to write the .img file to SC card. Anyways with the DVI cape, I can eliminate some of the issues you've been able to help me with, I just don't know how to run Squeak/small talk right from the BB. Is there a binary/executable file I can invoke?

      As a side note, I'm wanting to interface a PS3 Eye camera with the Bone and be able to take .jpg's using motion detection, write the .jpg's to the SD card, and make them available to the internet by running a web server on the Bone. I've been able to do all but that using an Arduino Ethernet w/SD reader and a serial interface camera attached to the SPI of the Arduino, but memory limitations makes it all by impossible.


    4. Funny you should mention sd card performance, I have an unpublished blog post on that very topic. I'm using a SanDisk for the root fs and a usb flash for build directories.

      I'm curious about the DVI issue. If you open a terminal window in gnome and type:
      "/opt/squeak/bin/squeak /opt/squeak/images/Squeak4.2-10966.image"
      (without quotes), does it give you the image not found error?

    5. Hello dg,
      Yes, when in terminal on the BB (using the DVI cape) I get the error "Could not open the Squeak image file '/opt/squeak/images/Squeak4.2-10996.image'."
      Then it goes on to list three ways to open a Squeak image file...doesn't make a whole lot of sense; what would be the difference?

      Thanks again,

    6. Hi redtank,
      Looks like the binary path is correct. Maybe there is a permissions issue... are you executing the command as the root user? Also, what is the output of:
      "ls -al /opt/squeak/images/Squeak4.2-10996.image"
      (without quotes)

    7. Hello dg,
      Okay, while using Xterm, I log in as root and do the "ls -al /opt/squeak/images/Squeak4.2-10996.image" and get this response:
      "ls: cannot access /opt/squeak/images/Squeak4.2-10996.image: No such or directory"

      If I cd to the images directory and ls, the file is there along with .changes, SqueakDebug.log, and SqueakV41.sources

      If I try the same approach right on the BB (using DVI cape) I get the same result.... So I'm wondering if the 10996.image file is corrupt? If so, should I start a redo the process from scratch using a different image file name?


    8. In the case of a corrupt image, the VM should still start and give an error message (or possibly crash). Can you post the output of these two commands while in the directory containing the image file.
      "ls -al"

  5. That beaglebone image is not part of the Fritzing core. Is it available somewhere?

    1. I pulled them from a github repo:

      and copied the files into the Fritzing directory.

    2. Sweet. Thanks for the tip.

  6. Is the DL still available ? wget keeps timing out on http://unthinkable.org/dl/squeak4.2-beaglebone.tgz

  7. I follow along and after some tweaking... I get to where I am showing a workspace...
    I am using x11vnc on the BBB and ChickenOfTheVNC on a Mac Laptop.

    at this point I can click in the workspace window ... but I cannot type anything. I can move the workspace window around. Also the BBB terminal window is frozen in the lower right corner... I cannot enter text into it either.