Run the Wolfram Language on an emulated Raspberry Pi on Windows

The purpose of this article is to show you the easiest way to run the Wolfram Language on a Raspberry Pi on Windows (inside the QEMU emulator). Since the Wolfram Language has only been released as a pilot for the Raspberry Pi platform, this guide tries to makes it as easy as possible to run it on Windows. Follow it very carefully so everything goes smoothly.

Maybe you recently saw the very impressive demo:

Stephen Wolfram’s Introduction to the Wolfram Language
http://www.youtube.com/watch?v=_P9HqHVPeik

It’s certainly worth watching. Knowledge-based programming. Making the world computable. 30 years in the making. 5000+ functions built-in! Totally symbolic, heavily natural, intensely knowledge-based. It enables you to create user interfaces, graphics objects, graphs, and more, programmatically. I was very impressed and I immediately wanted to try out the new language, only to find out that it’s not fully released yet, and I had to buy a Raspberry Pi to do that. Aaargh! Since I don’t have any use for a Raspberry Pi yet (I know I know there’s millions of uses for it), and wanted to try this Wolfram Language NOW, I resorted to a  Raspberry Pi emulator I found on the internet. This is how to get it up-and-running:

Get the QEMU ARM emulator for Windows

–    Go to: http://sourceforge.net/projects/rpiqemuwindows/
–    Download the qemu.zip file.
–    Unzip the zip to a directory.

You need more than 3.1 GB of free harddisk space to install QEMU and the Raspberry Pi image.

Get the latest Raspberry Pi image

–    To get the latest RaspBerry image go to: http://www.raspberrypi.org/downloads
–    Go to the section Raw Images
–    Under the Raspbian logo you’ll see a link to an image you can download. In my case that was: 2014-01-07-wheezy-raspbian.zip (780 MB). Download it.
–    Unzip the contents of the xxxx-wheezy-raspbian.zip to the subdirectory \qemu\qemu of the directory where you unzipped qemu to, the directory where the qemu-system-armw.exe is.

In this directory there is already another .img file (2012-07-15-wheezy-raspbian.img), but this is an older version of wheezy raspbian (which doesn’t contain the Wolfram stuff).

–    Remove the file 2012-07-15-wheezy-raspbian.img from the \qemu\qemu directory.

We will use the image of the newest Raspberry Pi version, because this version contains the Wolfram Language & Mathematica Pilot release for the Raspberry Pi.

Boot to root shell and fix some stuff

Before we can do a “real” boot with the Raspbian image, we need to modify some files to make it work.

–    Make a copy of the run.bat file in the \qemu\qemu folder.

–    Edit the run.bat file so it looks like this (1 line):

qemu-system-armw -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append “root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash” -hda 2014-01-07-wheezy-raspbian.img

Note: Don’t try to use more than 256MB memory within the qemu command line. The value is hard-coded in the emulated arm-chip, so you can’t change it!

At the end of the line you see the name of the raspbian image that you downloaded and unzipped.

–    Run the run.bat file.

–    At the root prompt open the file /etc/ld.so.preload with nano. Type the command:

nano /etc/ld.so.preload

A file will open. It contains exactly one line.

        /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so

–    Add a #(SHIFT+3 on german keyboard) at the beginning of the line,so it looks like this:

        #/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so

–    Now press Ctrl+O <ENTER> to write the file and then Ctrl+X to exit the editor.

–    Now just close QEMU to stop the virtual machine.

–    Edit the run.bat file again so it looks like this (1 line):

 qemu-system-armw -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -append “root=/dev/sda2 panic=1” -hda 2014-01-07-wheezy-raspbian.img

–    Start the run.bat file again. You’ll get some errors, because some devices are missing. This is expected, since we’re running a simulator and not the real hardware. After a minute or so you’ll get to the main menu of the “Raspberry Pi Software Configuration Tool (raspi-config)”.
–    Press <Tab> <Tab> to go to the Finish option.
–    Press <Enter> to select the Finish option and leave the Raspberry Pi Software Configuration Tool.

You’ll arrive at the root prompt now.

–    Type the command:

startx

If all went well, you’ll arrive at the desktop of Raspberry Pi and you can start experimenting with the Wolfram Language & Mathematica Pilot release for the Raspberry Pi.

Getting a better screen resolution

As you’ll soon discover, the emulated Raspberry Pi you have now is very basic. The screen resolution is 640 x 480, this is a quite small. If you’re fine with that, that’s OK. But if you want to change this, read on. At the moment it seems that the maximum resolution you can emulate is 800×600 with a depth of 16bit.

To be able to run X with 800×600 we need to manually create an xorg.conf file.

–    First we’ll have to leave the Raspberry Pi desktop. Go to the “Start menu” (bottom left) of the desktop. Click “Logout” (2 times).

You’ll arrive at the root prompt again.

–    Type the command:

sudo nano /etc/X11/xorg.conf

–    Write this into the file:

Section “Screen”
  Identifier “Default Screen”
    SubSection “Display”
      Depth 16
       Modes “800×600” “640×480”
    EndSubSection
EndSection

The default keyboard layout with the standard Raspberry Pi image is a British layout. It might happen that some of the characters on your keyboard don’t match with the characters you’re typing in Nano. In my case I wanted to type [“] but I had to type @ (Shift-2) instead to get a [“].

–    When you’re done press Ctrl+O <ENTER> to write the file and then Ctrl+X to exit the nano editor.

–    You can now start the X server again. Type the command:

startx

It should present you the desktop with a resolution of 800×600 pixels as shown in this image.

800x600_desktop
One important last thing:

If you shutdown the emulator and boot it again by starting the run.bat, you’ll be presented with a login box.

The login is: pi
The password is: raspberry

Getting an even better screen resolution

If you want an even better screen resolution, here’s another manual that gives you a fullscreen resolution. It depends on your own resolution, for example mine is 1680 x 1050, but even 1920×1080 is possible. This works by connecting to it with Remote Desktop from Windows.

http://forums.us.ncix.com/forums/topic.php?id=2581507

Follow this starting from the line

        now for the fun part…. Getting external network access (Not just HTML, but full network ability with a local IP Address)

The only thing that was different in my case, was the following line:

        Once it is started, double click LXTERMINAL and type in: “sudo ifconfig”

In my case, after you’re logged in, you get a prompt. After that, type “sudo ifconfig”. In the case of the author of the article, he probably had it configured so that the desktop came up automatically. In my case I have to type “startx” every time to start the desktop.

Have fun!