HOWTO SetUpCPUTransparency FedoraCore
This is slightly changed "HOWTO: Set up CPU transparency with your device and sbrsh" document specific to Fedora Core 4.
Set Up CPU Transparency With Your Device and Sbrsh
MoinMoinWiki Macro: TableOfContents
Introduction
These instructions will set up sbrsh CPU transparency for the Scrachbox target named "ARM". Please take into note that the use of sbrsh is insecure. You should only run it on trusted networks.
Prerequisites to be able to set up CPU transparency are:
1 . Scratchbox ARM target named "ARM" with sbrsh set as the CPU transparency method
1 . Device with flashed Maemo developer rootfs
1 . Networking using static IP addresses 192.168.2.15
on the device and 192.168.2.14
on the host computer, as described in the Setting up USB networking to your device.
1 . The Scratchbox 0.9.8.5 version, which is supported by the Maemo development rootFS.
Setting up your host environment
To setup your host environment you need to run the following commands with root access.
1 . Install NFS kernel server. In Fedora Core, this is provided by nfs-utils-1.0.7-8.i386.rpm
rpm --install nfs-utils-1.0.7-8.i386.rpm
1 .#2 Edit the /etc/exports
file (lists NFS file systems being exported) and add the following line (replace "sbox_username"
, "sbox_user_uid"
and "sbox_user_gid"
with correct values):
/scratchbox/users/<sbox_username>/targets/ARM 192.168.2.15(rw,all_squash,anonuid=<sbox_user_uid>,anongid=<sbox_user_gid>,sync) /scratchbox/users/<sbox_username>/home 192.168.2.15(rw,all_squash,anonuid=<sbox_user_uid>,anongid=<sbox_user_gid>,sync)
1 .#3 Restart NFS kernel server to apply new exports:
root@host:~ # /etc/init.d/nfs 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:~ #
1 .#4 Enable usb networking beetween your host and your device . 1 .#5 Connect device to usb
Now your host system should be set up.
Setting up your ARM target in scratchbox
Now you need to setup your ARM target inside scratchbox. To do this, first start scratchbox and change to the ARM target if necessary
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 ARM Restarting Scratchbox shell... Hangup Shell restarting... [sbox-ARM: ~] >
Then edit the file .sbrsh
in Scratchbox user's home directory, adding the following lines (replace "password" with a password used for cpu transparency and replace "username" with username using the Scratchbox):
ARM 192.168.2.15 <password> nfs 192.168.2.14:/scratchbox/users/<username>/targets/ARM / rw,nolock,noac nfs 192.168.2.14:/scratchbox/users/<username>/home /home rw,nolock,noac bind /dev /dev bind /dev/pts /dev/pts bind /proc /proc bind /tmp /tmp
With these changes your ARM target should be set up accordingly.
Setting up your device
First log into your device as root
. The password is rootme
.
user@host:~$ ssh root@192.168.2.15
The authenticity of host '192.168.2.15 (192.168.2.15)' 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 '192.168.2.15' (RSA) to the list of known hosts.
root@192.168.2.15's password:
BusyBox v1.00 (Debian 2:20041102-11) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
nokia770:~#
If you are connecting on this device for the first time, the warning message "The authenticity of host..."
is expected. Just confirm by typing yes
, and proceed as usual. 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@192.168.2.15 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! 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 192.168.2.15 has changed and you have requested strict checking. Host key verification failed. novo@wakko:~$
In this case, just edit ~/.ssh/known_hosts
, and search for a line starting with "192.168.2.15"
. Finally, you must delete this line.
After this you should add a new user to the device that will use the Developer Platform. You can do this with the adduser command by giving the user name you want after it.
nokia770:~# adduser 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 nokia770:~#
Now you need to add a line to ~/.sbrshd
. In the addition provide the same password which was added under scratchbox before. The line added there is:
nokia770:~# su - username
BusyBox v1.00 (Debian 2:20041102-11) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
~ $ echo "192.168.2.14 <passwd>" > .sbrshd
~ $
Now you should exit to root shell, and restart sbrshd
, as shown below
~ $ exit nokia770:~# /etc/init.d/sbrshd restart Stopping Scratchbox Remote Shell daemon: done. Starting Scratchbox Remote Shell daemon: done. nokia770:~#
Finally, you can log out from the device.
Test the CPU Transparency
Now the CPU transparency should be set up. To test it log into scratchbox and change to the ARM target. Run the command
tar zxf /scratchbox/packages/hello-world.tar.gz
After this go to hello-world
, run autogen.sh
and make
and finally, ./hello. This should print "hello world"
on your console.
[sbox-ARM: ~] > tar xfz /scratchbox/packages/hello-world.tar.gz [sbox-ARM: ~] > cd hello-world [sbox-ARM: ~/hello-world] > ./autogen.sh + aclocal [... output from aclocal ...] + autoconf + autoheader + automake <del>add-missing </del>foreign [... output from automake ...] + ./configure [... output from ./configure ...] [sbox-ARM: ~/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-ARM: ~/hello-world] > ./hello Hello World! [sbox-ARM: ~/hello-world] >
The program is run transparently on the device though. You can verify that by the log written to /tmp/cputransp_username.log
[sbox-ARM: ~/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-ARM: ~/hello-world] >
As expected, "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.