CPU Transparency Guide

Introduction

This document describes how to set up CPU Transparency between Nokia Internet Tablet running OS2008 and host Linux machine running a Scratchbox 2 build environment.

Cross-compiling an ARMEL binary transparently on the Internet Tablet using either SSH or a CPU transparency tool called sbrsh (Scratchbox Remote Shell) has been made possible from Scratchbox. The connection to the Internet Tablet can be either via USB cable or wireless. CPU transparency is a technique where ARMEL binaries are copied over the connection from the Linux PC side to the device. The binary is then executed there natively by the Internet Tablet's own ARM CPU. Client sbrsh program connects to a remote machine running sbrshd server. After the server has authorized the connection, the client first requests it to mount a remote filesystem. When the filesystem has been mounted over the network connection, the sbrshd server executes a binary given as an argument to the sbrsh client. The sbrsh client is typically run on the Linux host where the cross-compiling takes place. The server process sbrshd runs on target hardware.

This is a handy way to compile ARMEL binaries in a native ARM CPU instead of running them in a Linux PC under the QEMU emulator, and useful when the QEMU user space emulation doesn't support some functionality properly. The current default installation in Scratchbox 2 uses QEMU user mode emulation.

Earlier versions of sbrsh used NFS network filesystem for remote mounts. The latest versions support sshfs, which is easier to implement. Most SSH servers support the protocol and there is no need for additional daemons on the host and target Linux machines. The sshfs network filesystem is based on the SSH File Transfer Protocol. It is implemented using FUSE, which provides a library and a kernel module to implement filesystems in Linux userspace. For more information, see the sshfs and FUSE project pages.

For more information on sbrsh, see the (somewhat outdated) Scratchbox Remote Shell user documentation.

Scratchbox Remote Shell is licensed under the terms of the GNU General Public License version 2.

Known limitations

The sbrsh configuration file needs fully-specified path mappings for your Scratchbox mounts (with target and rootstrap encoded), which means that you need several configurations for different rootstraps specifying different SDKs.

sbrsh communication happens over TCP/IP and is not encrypted. Use the Scratchbox remote shell only on trusted networks, such as a company's LAN or a USB network between a PC and a handheld device.

sbrsh does not support user authentication. Again, only use it on trusted networks.

How to set up CPU Transparency

Requirements

This document presupposes a Nokia N8x0 Internet Tablet target with freshly installed OS2008 image (Diablo) on the device side and maemo SDK+ installed in your host machine. You also need root access on the Internet Tablet device. See How Do I Become Root on maemo.org wiki.

Install required packages

The Linux host must have ssh and sbrsh packages installed.

On the Internet Tablet side, run maemo-sdk-tablet.install to install the required packages using the Application Manager. The following packages will be installed on Internet Tablet:

maemo-control-usb
openssh
sshfs
libfuse2
fuse-modules-rx-34
fuse-utils
sbrshd

Setup USB networking between host Linux machine and Internet Tablet

To use CPU Transparency, the host and the tablet need to be networked. If you are using a connection other than USB (e.g.., Bluetooth or WLAN), establish the connection before installing the sbrsh configuration to the tablet. If you are using a USB connection, the maemo-sdk sbrsh installation command to device takes care of the host's USB interface setup. You can also configure the USB interface in the host manually according to the instructions following below.

Tablet setup

The USB networking service is provided by the maemo-control-usb package which belongs to the maemo-sdk-tablet metapackage. The maemo-control-usb package consists of the USB Networking control panel applet for switching between USB networking and file storage mode.

When the package is installed, go to Settings > Control Panel and select USB networking in the panel. A dialog box will open and you can change the USB connection to the networking mode.

Host setup

To configure USB manually, add the following lines to the /etc/network/interfaces file:

auto usb0
allow-hotplug usb0
iface usb0 inet static
	address 192.168.2.14
	netmask 255.255.255.0

The IP address and netmask used in the above configuration example are the default ones preconfigured in the Diablo image. The default IP address for the tablet is 192.168.2.15.

For most Linux releases, after USB cable is plugged in, the USB interface will be up and configured with the address 192.168.2.14. On an Ubuntu host, you need to edit the following line in the /etc/udev/rules.d/85-ifupdown.rules file:

SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start"

Edit the line as follows:

SUBSYSTEM=="net", GOTO="net_start"

Then restart the udev daemon

# /etc/init.d/udev restart    

If the status of the USB interface is still not okay, run the following commands:

# ifdown usb0
# ifup usb0

Install the sbrsh configuration

If you are using a USB connection, first verify that the USB cable is connected and the Internet Tablet is in the USB networking mode. Then install CPU transparency to the Internet Tablet by running maemo-sdk command in your host machine:

 ~ > maemo-sdk install sbrsh 

The following text is displayed:

 0 ... exit           To exit selection
 1 ... host           Install sbrsh configuration to host
 2 ... device         Install sbrshd configuration to device

Which maemo SDK+ command you would like to execute (0..2)? 

Select 2 (device) and input the host IP and target device IP. If there is no connection to the device, the permission to set up a USB connection is asked.

To configure the sbrsh in host machine use maemo-sdk command:

 ~ > maemo-sdk install sbrsh 

Select 1 (host) and then the rootstrap. Input the host IP and target device IP.

Activate CPU transparency

To run the binary under CPU Transparency mode, set the target emulation method by the using maemo-sdk command:

 ~ > maemo-sdk set emulation-mode

Select the rootstrap and set the emulation mode to sbrsh.

Test the CPU transparency method by running an ARMEL binary in Scratchbox 2:

 ~ > sb2 ./hello_world

Debugging

Running sbrsh manually

Add the following lines to the /home/<your username>/.sbrsh file in the host machine:

sshfs-target 192.168.2.15
  ssh     you@192.168.2.14:/home/<your username>/ /home/<your username> rw,nonempty,allow_other
  bind    /tmp                            /tmp
  bind    /dev                            /dev
  bind    /dev/pts                        /dev/pts
  bind    /proc                           /proc
  bind    /sys                            /sys

To mount the directory on the host into the Internet Tablet directory /home/yourusername/a, give the following command in the Internet Tablet:

 ~ > sshfs user@192.168.2.14:/path/to/remote_dir /home/yourusername/a

To unmount the directory:

 ~ > fusermount -u /home/user/a

Activating debug logging for sbrshd

To enable the debug logging for sbrshd in the Internet Tablet, use the following command:

 ~ # /etc/init.d/sbrshd enable-debug

Log prints are stored in the file /tmp/sbrshd-1202.log.