Setting up CPU transparency with your device and sbrsh


This document provides instructions for setting up sbrsh CPU transparency for the Scrachbox target named "ARMEL". Note that the use of sbrsh is insecure. You should only run it on trusted networks.

Prerequisites for setting up CPU transparency are as follows:

  1. Scratchbox ARMEL target named "ARMEL" with sbrsh is set to the CPU transparency method.
  2. The target device is flashed with maemo developer root file system.
  3. USB networking is set up using static IP addresses for the device and for the host computer, as desribed in Setting up USB networking to your device.
  4. The Scratchbox version is, which is supported by the maemo development root file system..

Setting up your host environment

To setup your host environment, as the root user, perform the following steps:

  1. Install NFS kernel server. In Debian, this is provided by package nfs-kernel-server. Use the following command:
    apt-get install nfs-kernel-server
  2. Edit the /etc/exports file (this lists the NFS file systems that are being exported), and add the following line (replace sbox_username, sbox_user_uid and sbox_user_gid with correct values):
  3. Restart the NFS kernel server to apply new exports. The following is an example of the output:
    root@host:~ # /etc/init.d/nfs-kernel-server restart 	    
    * Stopping NFS kernel daemon...                      [ ok ]
    * Unexporting directories for NFS kernel daemon...   [ ok ] 	    
    * Exporting directories for NFS kernel daemon...     [ ok ] 	    
    * Starting NFS kernel daemon:                        [ ok ] 	    
    root@host:~ # 	     	  

Your host environment is now set up.

Setting up your ARMEL target in Scratchbox

To set up ARMEL target inside Scratchbox, perform the following steps:

  1. Start Scratchbox and switch to the ARMEL target if necessary. The following is an example of the output:

    user@host:~$ /scratchbox/login
    Welcome to *Scratchbox*, the cross-compilation SDK!
    Scratchbox is a self-contained mini-distribution that contains all the tools needed to configure and cross-compile Open Source software using GNU make and *autoconf*.
    All the software configuration, compilation	and installation is done in a sandbox environment exactly like on your target device. 
    This is achieved by using chroot to limit system visibility for configuration scripts you run from this shell, into what exists inside the Scratchbox sandbox. 
    The Scratchbox utilities are: 	
     sbox-config  - Change your compilation target 	
     ps           - List processes running inside your sandbox
    [sbox-HOST: ~] >sbox-config -st ARMEL 	
    Restarting Scratchbox shell... 	
    Hangup 	Shell restarting... 	
    [sbox-ARMEL: ~] >
  2. Edit the .sbrsh in Scratchbox user's home directory, by adding the following lines (replace password with a password used for cpu transparency and replace username with the username associated with using the Scratchbox):

    nfs  / rw,nolock,noac
    nfs /home rw,nolock,noac
    bind    /dev          /dev
    bind    /dev/pts      /dev/pts
    bind    /proc         /proc
    bind    /tmp          /tmp	

Your ARMEL target is now set up.

Setting up your device

To set up your device, perform the following steps:

  1. Log into your device as root. The password is rootme. The following is an example of the output:

    user@host:~$ ssh root@ 	
    The authenticity of host ' (' can't be established. 	
    RSA key fingerprint is 2e:7b:14:89:53:5e:e4:be:43:15:50:01:86:6c:96:66. 	
    Are you sure you want to continue connecting (yes/no)? yes 	
    Warning: Permanently added '' (RSA) to the list of known hosts. 	
    root@'s password:   	
    BusyBox v1.00 (Debian 2:20041102-11) Built-in shell (ash) 	
    Enter 'help' for a list of built-in commands.  	
  2. If you connect to this device for the first time, the warning message The authenticity of host... is displayed. Confirm this message by entering yes, and proceed. Note that if you have used maemo SDK 1.0 from this host machine, a message such as the message below may appear:

    user@host:~$ ssh root@
    Someone could be eavesdropping on you right now (man-in-the-middle attack)! 
    It is also possible that the RSA host key has just been changed. 	
    The fingerprint for the RSA key sent by the remote host is 	2e:7b:14:89:53:5e:e4:be:43:15:50:01:86:6c:96:66.
    Please contact your system administrator. 	
    Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
    Offending key in /home/user/.ssh/known_hosts:2 	
    RSA host key for has changed and you have requested strict checking.
    Host key verification failed.
  3. If this message is displayed, edit the ~/.ssh/known_hosts file, and search for a line starting with Delete this line.

  4. After first boot, you need to fix the module dependencies with the following command:

    Nokia770:~# depmod
  5. Enable cpu-transparency from maemo-dm by selecting the cpu-transparency option.

    maemo-dm dialog

    Figure 1. maemo-dm dialog

  6. If you are using maemo's version of sbrshd (which is installed by default to development root file system), you can jump to the next section. When using cpu-transparency first time, you get a pop-up dialog in your device. Select yes.

    Create user dialog

    Figure 2. Create user dialog

    The maemo version of sbrshd takes care of creating needed users and configuring itself, but if you use sbrshd coming with Scratchbox then you need the following steps.

  7. Add a new user to the device that uses the Developer Platform. You can do this with the adduser command by giving the desired user name after the command. You also need to define --shell, because default shell is bash and this version of the software does not have it installed. The following is an example of the output:

    Nokia770:~# adduser --shell /bin/sh username 
    Adding user username...
    Adding new group username (1001).
    Adding new user username (1001) with group username. 
    Creating home directory /home/username.
    Copying files from /etc/skel 
    find: !: No such file or directory
    Changing password for username 	
    Enter the new password (minimum of 5, maximum of 8 characters) 	
    Please use a combination of upper and lower case letters and numbers. 	
    New password:
    Re-enter new password:
    Password changed.
    Changing the user information for username 
    Enter the new value, or press ENTER for the default
    Full Name []:
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
    Is the information correct? [y/n] y 
  8. Add a line to ~/.sbrshd. Provide the same password which was added under Scratchbox before. The following is an example of the output:

    nokia770:~# su - username
    BusyBox v1.00 (Debian 2:20041102-11) Built-in shell (ash)
    Enter 'help' for a list of built-in commands.
    ~ $ echo " " > .sbrshd
    ~ $
  9. Exit to root shell and restart sbrshd, as shown in the following example:

    ~ $ exit
    nokia770:~# /etc/init.d/sbrshd restart
    Stopping Scratchbox Remote Shell daemon: done.
    Starting Scratchbox Remote Shell daemon: done.
  10. Log out from the device.

CPU transparency is now set up.

Test the CPU Transparency

To test the CPU transparency, perform the following steps:

  1. Log into the Scratchbox and switch to the ARMEL target by running the following command:

    tar zxf /scratchbox/packages/hello-world.tar.gz
  2. Go to the hello-world example and run, make and /hello. This prints hello world on your console. The following is an example of the output:

    [sbox-ARMEL: ~] > tar xfz /scratchbox/packages/hello-world.tar.gz
    [sbox-ARMEL: ~] > cd hello-world
    [sbox-ARMEL: ~/hello-world] > ./
    + aclocal 	[... output from aclocal ...]
    + autoconf
    + autoheader
    + automake --add-missing --foreign 	[... output from automake ...]
    + ./configure 	[... output from ./configure ...]
    [sbox-ARMEL: ~/hello-world] > make 	
    make  all-am 	
    make[1]: Entering directory `/home/username/hello-world
    'if gcc -DHAVE_CONFIG_H -I. -I/home/username/hello-world -I. -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \ 	
    then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi
    gcc  -g -O2   -o hello  main.o 	
    make[1]: Leaving directory `/home/username/hello-world'
    [sbox-ARMEL: ~/hello-world] > ./hello
    Hello World!
    [sbox-ARMEL: ~/hello-world] >

Note that the program is run transparently on the device. You can verify this from the log written to /tmp/cputransp_username.log file. The following is an example of the output:

[sbox-ARMEL: ~/hello-world] > cat /tmp/cputransp_username.log 	
[2005-10-13 17:37:26 26032] method: "sbrsh"  pwd: "/home/username/hello-world"  cmd: "/home/username/hello-world/a.out" 	
[2005-10-13 17:37:30 26032] rc: 0  time: 3.944084 	
[2005-10-13 17:37:30 26272] method: "sbrsh"  pwd: "/home/username/hello-world"  cmd: "/home/username/hello-world/conftest" 	
[2005-10-13 17:37:31 26272] rc: 0  time: 0.196024
[2005-10-13 17:37:42 26596] method: "sbrsh"  pwd: "/home/username/hello-world"  cmd: "/home/username/hello-world/hello" 	
[2005-10-13 17:37:42 26596] rc: 0  time: 0.192171

[sbox-ARMEL: ~/hello-world] >

In the example, rc contains the result of the remote running program, and time contains the total running time on the device. Any sbrsh errors are also output to this file.

Improve this page