Getting OpenMoko working on host with Xephyr

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(catspec)
Line 165: Line 165:
  
 
[[Category:Developer software]]
 
[[Category:Developer software]]
 +
 +
[[Category:Guides]]

Revision as of 15:42, 28 July 2007

The goal of this page is to show you how to run an OpenMoko development image on your host x86 development machine in a chrooted environment.

Contents

What is Xephyr

Xephyr is a modern X Server in a window which can be used to simulate small displays in a desktop development enviroment. It is maintained on the OpenedHand projects page. Please note that even though it will render OpenMoko pixel for pixel, it will likely display almost 4 times larger than the actual device since portable devices tend to have smaller pixels than computer monitors.

Build an OpenMoko Image

First, you'll need to build an openmoko-devel-image. You'll need to edit your local.conf file during build process (before step 5).

You should use Building OpenMoko using the MokoMakefile to build an openmoko-devel-image for your host architecture (x86 in our case). Make sure you put the moko makefile in /home/moko/Makefile .

Prior to that, edit your build/conf/local.conf to make it look like this:

MACHINE = "x86"
DISTRO = "openmoko"
BUILD_ARCH = "i686"
INHERIT += " devshell"
SRCDATE_eds-dbus = "now"

Once you have built the image, you can start working toward running the image.

(User:Flerchjj) I also had to add the following line to "build/conf/local.conf" to get "make openmoko-devel-image" to complete.

TARGET_FPU = ""

Setup the image filesystem

Please see the included help script at the bottom of this article. It should make your life much easier.

The filesystem of the image can be found at /home/moko/build/tmp/rootfs . It is that image that we want to run in a chrooted environment.

We will copy that that rootfs directory somewhere so that subsquent builds (using the MokoMakefile for instance) don't overwrite it.

Make sure you have root privileges:

su -

Copy the rootf into a directory called MokoBox. From now on, we will call the chrooted environment a MokoBox.

cp -r /home/moko/build/tmp/rootfs /home/moko/mokobox

make sure /dev and /proc of the host machine are visible from within mokobox

mount --bind /dev /home/moko/mokobox/dev
mount -t proc none /home/moko/mokobox/proc

Start/Move into the protected mokobox environment

chroot /home/moko/mokobox /bin/sh

In chroot'ed environment

set environment variables

DISPLAY=:1
LANG=C
HOME=/home/root
export DISPLAY LANG HOME

Create pango.modules file

pango-querymodules > /etc/pango/pango.modules

Create gdk-pixbuf.loaders file

gdk-pixbuf-query-loaders > /etc/gtk-2.0/gdk-pixbuf.loaders

Remove touch screen calibrator. Since touch screen hardware is not present, the touch screen calibration prevents X start-up on PC.

rm /etc/X11/Xsession.d/30xTs_Calibrate

Starting the nested X server

Supplying fonts

You might need to install fonts supplied by OpenMoko to your host system. The easiest way to do is in Gnome is to go Preferences -> Font - > Details -> Go to font folder and then drag and drop TTF font files from build/tmp/rootfs/usr/share/fonts/ in Nautilus. Using Xubuntu (no Gnome) I found copying the ttf folder into /usr/X11R6/lib/X11/fonts worked.

Launching Xephyr

In another terminal (not related to mokobox), start Xephyr

Xephyr :1 -ac -2button -host-cursor -screen 480x640

Start X Client

Now, back in chroo'ted environment, start X client:

eval $(dbus-launch)
/etc/X11/Xsession

You should see OpenMoko booting in the Xephyr window.

Xephyr.png

A sample script

The following script sets up the most of root fs environment automatically

#!/bin/bash
#
# Set-up x86 OpenMoko root jail. This script must be run as root.
#
# Root jail is an environment, where the file system root has been
# changed to the OpenMoko root file system folder. Please don't
# use the build/rootfs, but make a copy of it, since build/rootfs
# gets overwritten each time you build openmoko-devel-image
#
# You need to set-up another X server (nested preferably) to 
# act as a OpenMoko screen. Otherwise chrooted applications are executed
# as is on the host hardware and the kernel.
#
# See: 
#
# http://wiki.openmoko.org/wiki/Getting_OpenMoko_working_on_host_with_Xephyr
# 
#
# 2007 Mikko Ohtamaa - Red Innovation Ltd.
# <mikko@redinnovation.com>
#
# Do anything you wish with this script
#
#
#

# Setup required environment variables

# Xephyr must listen to this DISPLAY
DISPLAY=:1

# If we don't have locale, applications refuse to launch
LANG=C

# We are running as root in our chrooted environment

HOME=/home/root
export DISPLAY LANG HOME

# Update pango modules
pango-querymodules > /etc/pango/pango.modules

# Update icon images
gdk-pixbuf-query-loaders > /etc/gtk-2.0/gdk-pixbuf.loaders

# Mount /dev and /proc file systems
mount --bind /dev ./dev
mount -t proc none ./proc

# Remove touch screen calibration start up app
# It doesn't launch on x86 and prevents X booting
if [ -e /etc/X11/Xsession.d/30xTs_Calibrate ] ; then
        rm /etc/X11/Xsession.d/30xTs_Calibrate
fi

# Use host name server information so that
# web browsing works
cp /etc/resolv.conf etc/resolv.conf

# Enter into chroot jail
chroot . /bin/sh

Improving Display Realism - Extending Xephyr with Xoo

Xoo further extends Xephyr as to provide a poor mans device emulator. It is intended for embedded developers that want to simulate a target device (with an accurate display size, working hardware buttons, themed display, etc) on a desktop machine.

See Getting Openmoko working on host with Xoo for more information.

Personal tools

The goal of this page is to show you how to run an OpenMoko development image on your host x86 development machine in a chrooted environment.

What is Xephyr

Xephyr is a modern X Server in a window which can be used to simulate small displays in a desktop development enviroment. It is maintained on the OpenedHand projects page. Please note that even though it will render OpenMoko pixel for pixel, it will likely display almost 4 times larger than the actual device since portable devices tend to have smaller pixels than computer monitors.

Build an OpenMoko Image

First, you'll need to build an openmoko-devel-image. You'll need to edit your local.conf file during build process (before step 5).

You should use Building OpenMoko using the MokoMakefile to build an openmoko-devel-image for your host architecture (x86 in our case). Make sure you put the moko makefile in /home/moko/Makefile .

Prior to that, edit your build/conf/local.conf to make it look like this:

MACHINE = "x86"
DISTRO = "openmoko"
BUILD_ARCH = "i686"
INHERIT += " devshell"
SRCDATE_eds-dbus = "now"

Once you have built the image, you can start working toward running the image.

(User:Flerchjj) I also had to add the following line to "build/conf/local.conf" to get "make openmoko-devel-image" to complete.

TARGET_FPU = ""

Setup the image filesystem

Please see the included help script at the bottom of this article. It should make your life much easier.

The filesystem of the image can be found at /home/moko/build/tmp/rootfs . It is that image that we want to run in a chrooted environment.

We will copy that that rootfs directory somewhere so that subsquent builds (using the MokoMakefile for instance) don't overwrite it.

Make sure you have root privileges:

su -

Copy the rootf into a directory called MokoBox. From now on, we will call the chrooted environment a MokoBox.

cp -r /home/moko/build/tmp/rootfs /home/moko/mokobox

make sure /dev and /proc of the host machine are visible from within mokobox

mount --bind /dev /home/moko/mokobox/dev
mount -t proc none /home/moko/mokobox/proc

Start/Move into the protected mokobox environment

chroot /home/moko/mokobox /bin/sh

In chroot'ed environment

set environment variables

DISPLAY=:1
LANG=C
HOME=/home/root
export DISPLAY LANG HOME

Create pango.modules file

pango-querymodules > /etc/pango/pango.modules

Create gdk-pixbuf.loaders file

gdk-pixbuf-query-loaders > /etc/gtk-2.0/gdk-pixbuf.loaders

Remove touch screen calibrator. Since touch screen hardware is not present, the touch screen calibration prevents X start-up on PC.

rm /etc/X11/Xsession.d/30xTs_Calibrate

Starting the nested X server

Supplying fonts

You might need to install fonts supplied by OpenMoko to your host system. The easiest way to do is in Gnome is to go Preferences -> Font - > Details -> Go to font folder and then drag and drop TTF font files from build/tmp/rootfs/usr/share/fonts/ in Nautilus. Using Xubuntu (no Gnome) I found copying the ttf folder into /usr/X11R6/lib/X11/fonts worked.

Launching Xephyr

In another terminal (not related to mokobox), start Xephyr

Xephyr :1 -ac -2button -host-cursor -screen 480x640

Start X Client

Now, back in chroo'ted environment, start X client:

eval $(dbus-launch)
/etc/X11/Xsession

You should see OpenMoko booting in the Xephyr window.

Xephyr.png

A sample script

The following script sets up the most of root fs environment automatically

#!/bin/bash
#
# Set-up x86 OpenMoko root jail. This script must be run as root.
#
# Root jail is an environment, where the file system root has been
# changed to the OpenMoko root file system folder. Please don't
# use the build/rootfs, but make a copy of it, since build/rootfs
# gets overwritten each time you build openmoko-devel-image
#
# You need to set-up another X server (nested preferably) to 
# act as a OpenMoko screen. Otherwise chrooted applications are executed
# as is on the host hardware and the kernel.
#
# See: 
#
# http://wiki.openmoko.org/wiki/Getting_OpenMoko_working_on_host_with_Xephyr
# 
#
# 2007 Mikko Ohtamaa - Red Innovation Ltd.
# <mikko@redinnovation.com>
#
# Do anything you wish with this script
#
#
#

# Setup required environment variables

# Xephyr must listen to this DISPLAY
DISPLAY=:1

# If we don't have locale, applications refuse to launch
LANG=C

# We are running as root in our chrooted environment

HOME=/home/root
export DISPLAY LANG HOME

# Update pango modules
pango-querymodules > /etc/pango/pango.modules

# Update icon images
gdk-pixbuf-query-loaders > /etc/gtk-2.0/gdk-pixbuf.loaders

# Mount /dev and /proc file systems
mount --bind /dev ./dev
mount -t proc none ./proc

# Remove touch screen calibration start up app
# It doesn't launch on x86 and prevents X booting
if [ -e /etc/X11/Xsession.d/30xTs_Calibrate ] ; then
        rm /etc/X11/Xsession.d/30xTs_Calibrate
fi

# Use host name server information so that
# web browsing works
cp /etc/resolv.conf etc/resolv.conf

# Enter into chroot jail
chroot . /bin/sh

Improving Display Realism - Extending Xephyr with Xoo

Xoo further extends Xephyr as to provide a poor mans device emulator. It is intended for embedded developers that want to simulate a target device (with an accurate display size, working hardware buttons, themed display, etc) on a desktop machine.

See Getting Openmoko working on host with Xoo for more information.