Ocean Mist

23 May 2008

Using CPU Transparency with Scratchbox

Posted by astromme

Configuring CPU Transparency (sbrsh) in Scratchbox

Since I’ve always had an enormous amount of difficulty in setting up a remote shell (sbrsh) in scratchbox, hopefully this guide will spare others from the frustration.
In this guide I assume:

  • You are using Scratchbox 1 (Meaning you have a /scratchbox and you don’t use ‘sb2′ to compile)
  • You are using Ubuntu (Debian will probably still work, and other distros have a good chance as well, I just haven’t confirmed anything)
  • You have a n800 with root access. This can be done either through the R&D mode or a package that lets you ‘sudo su’.
  • You are using USB networking (I’ll show you how to set it up in a bit). Without USB networking (so over wifi) I found everything to be terribly slow. Meaning on the order of tens of magnitudes slower than normal speeds. Even with usb networking it is still dog slow. But, it is true ‘emulation’ in the fact that everything is running on your tablet.


${VARIABLE_NAME} is a variable. You should replace it when you type in commands or edit configuration files.
${TABLET_HOSTNAME} – means an address that you can access your tablet from. I ended up using the ip ( by default with usb networking)
${DEVMACHINE_HOSTNAME} – means an address that you can access your development box (that has scratchbox) from. I ended up using computername.local as it worked from my tablet. Test if yours works by ssh’ing into your tablet and running ‘ssh ${DEVMACHINE_HOSTNAME}’.
${USER} – Your username.
${UID} – Your user id (type ‘id’ to find out)
${GID} – Your group id (type  ‘id’ to find out)
italicized text – indicates what you enter into a shell prompt or text file.

Configure USB Networking:

Use the maemo-pc-connectivity package. It makes USB networking dead simple. On your tablet, install maemo-pc-connectivity.install (TinyURL Link: http://tinyurl.com/5rkqx2). This provides a control panel applet USB Networking for setting up USB networking. The applet is configured to use static IP address for the tablet and for the host. I will use these addresses throughout the guide.

“By default, the USB connection provides USB mass storage access to the memory card, and it needs to be switched to USB networking. The control panel applet USB Networking allows to change to USB networking mode, but the applet has a few quirks:
When USB networking is in use, USB cable disconnections are not properly detected by Linux HAL.
Any memory card mounts are unmounted while USB cable connection is detected, also when in USB networking mode.”
“Does not integrate with Internet Connectivity Daemon, other than providing a dummy entry.
Not possible to use USB networking with Hildon applications that use Internet Connectivity, such as browser, due to missing name resoving. USB networking uses static IP address and cannot have information about DNS, except when manually configured, thus DNS name resolving doesn’t work.
Multiple default routes might appear in the routing table if many networking connections are in place.”

Prepare your N800:

Install Software:

(I’m copying this from the sdk+ page. It worked perfectly for me)

Run task-sbrshd.install (TinyURL link: http://tinyurl.com/5yhlpj) on your N8X0 to install the required packages using the Application Manager. This will install the following packages on Internet Tablet:


Create Scratchbox User:

To be able to ssh to your tablet and use sbrsh you need to have a user on your tablet with the same username as the scratchbox user on your development machine.

$ groupadd -g ${GID} ${USER}
$ useradd -u ${UID} -g ${USER} -d /home/${USER} -s /bin/sh ${USER}
$ mkdir /home/${USER}
$ chown ${USER}:${USER} /home/${USER}

Set up Paswordless Authentication:

Because sbrsh needs to mount filesystems on your tablet from your development box, all via ssh, it needs to be able to log into your development machine. On your tablet, perform the following:

su – ${USER}

ssh-keygen -t rsa

After a few moments (it may be a minute or more, the nokia tablets are quite slow compared to modern computers) it will respond with a few notices, including a line about a public key in ~/.ssh/id_rsa.pub. You need to copy the contents of this file into your the file ~/.ssh/authorized_keys on your development machine. You can test to see if it works by first logging into your tablet via ssh and then trying ‘ssh ${DEVMACHINE_HOSTNAME}’. If you get a shell (‘${USER}@~ $‘ ) you are good to go. You might have to accept the fingerprint of your development machine, that’s ok. It’s a one time process.

You will have to do this again for your dev machine, but it’s easier due to ssh-copy-id. Again create a key with ‘ssh-keygen -t rsa’ but now copy it to your tablet with ‘ssh-copy-id ${USER}@{TABLET_HOSTNAME}’. You may have needed to set up a password for the user account on your tablet so that you can log in as it directly.

Configure sbrshd on Internet Tablet:

Scratchbox remote shell is meant to be used only on trusted networks. NFS SECURITY IS ONLY BASED ON YOUR NETWORK SECURITY.

“Edit /etc/default/sbrshd on Internet Tablet to enable sbrshd. Change ENABLE option to true and MOUNT_BIN and UMOUNT_BIN to point in util-linux versions of mount and umount:


sbrshd will only accept connections from an IP listed in /etc/sbrshd.conf. Add your development machine’s IP as a trusted host to this file, one IP address per line. In my configuration, I have the following line:

Start fuse and sbrshd on Internet Tablet:

~ $ /etc/init.d/fuse start
Starting filesystem in userspace: fuse.
~ $ /etc/init.d/sbrshd start
Starting sbrshd: done.

Prepare your development computer:

Install Software:

Ensure that you have the newest release of scratchbox-devkit-cputransp. As of this writing it is 1.0.7. To get this using the debian packages I had to modify my sources.list slightly. In the file /etc/apt/sources.list.d/maemo4.0_scratchbox.list I needed

deb http://scratchbox.org/debian/ apophis main

When I used the Nokia SDK installer it used the stable repo instead of the apophis, which only had scratchbox-devkit-cputransp release 1.0.1.

To install the required packages for Scratchbox 1:

sudo apt-get install scratchbox-devkit-cputransp

Configure sbrsh:

The sbrsh configuration file lists the nfs mounts that your tablet will use to set up its transparent filesystem. The format of ~/.sbrsh file:

# Format:
# <na
me>  <hostname>[:<port>]
#     nfs|bind|sshfs  <filesystem>  <mountpoint>  [<options>]
#     …

Edit the configuration file /scratchbox/users/${USER}/targets/CHINOOK_ARMEL.sbrsh :

sshfs-target ${TABLET_HOSTNAME}
ssh     ${USER}@${DEVMACHINE_HOSTNAME}:/scratchbox/users/${USER}/targets/CHINOOK_ARMEL/ / rw,nonempty,allow_other
ssh     ${USER}@${DEVMACHINE_HOSTNAME}:/scratchbox/users/${USER}/home/${USER}/ /home/${USER} rw,nonempty,allow_other
bind    /tmp                            /tmp
bind    /dev                            /dev
bind    /dev/pts                        /dev/pts
bind    /proc                           /proc
bind    /sys                            /sys

Edit CHINOOK_ARMEL target configuration in /scratchbox/users/${USER}/targets/CHINOOK_ARMEL.config .

Enable sbrsh by commenting out the existing SBOX_CPUTRANSPARENCY_METHOD= and adding:

Test your setup:

Try running ‘sbrsh /bin/sh’ from your normal development machine. You don’t need to be in the scratchbox environment. If you get another shell, you are good to go. It will probably feel really slow (slower than a ssh connection across the internet) but it will be in an armel environment, and that’s what matters =).

If you’re having trouble….

sbrsh server: Can’t execute command: /bin/sh (Permission denied)

“In this case, the issue is likely not that there is an access error or that permissions are wrong. Instead, this may be the result of a failure to run chroot command on the target – which would happen if you’re missing a mount for root / mount is in your .sbrsh and the sandbox mode is enabled (this is the default).”

  • Fixed second set of links. There was an extraneous “(” at the beginning that made them loop.
  • Added missing info on ssh-copy-id




Tags: , ,

Subscribe to Comments

One Response to “Using CPU Transparency with Scratchbox”

  1. I just wanted to say that I love this site



Leave a Reply