Testing maemo 2.1 (scirocco) in scratchbox apophis (R4)
Author: Carlos Sanmartín Domínguez <csanmartin at igalia dot com>
Overview
This little guide is intended for checking the
apophis
scratchbox version with the
scirocco (v2.1)
maemo
SDK downloadable from
maemo.org
.
How good we expect
Next is the list of points I'm going to check and I think necessary to consider the environment good enough, that is, what I'd expect for a good development on the environment. When I refer both architectures, I mean
i386 and
arm:
- compile packages (both)
- execute binaries and maemo environment (mainly
i386)
- debug (mainly
i386)
- generate packages (mainly
arm)
- install packages (mainly
arm)
First steps: Installation
Let's suppose you have already installed the
apophis scratchbox (at this moment, in its
1.0.6 version, release
4),
following the instructions given at
documentation
they have given us.
I'll check the
codesourcery next toolchains:
scratchbox-toolchain-cs2005q3.2-glibc-arm-1.0.4-i386
scratchbox-toolchain-cs2005q3.2-glibc-i386-1.0.4-i386
which are a repackaged version of the legacy ones we used with the scratchbox
0.9.8.
Well, when the scratchbox is already installed, download both rootstraps (armel and i386) from
maemo.org
to
/scratchbox/packages. Now, create two targets for the toolchains:
- one for developing in your PC with no emulation and
devkit-debian
- the other for creating packages for your internet tablet, with qemu-emulation (I've selected
qemu-arm-0.8.1-sb2) and devkit-debian support.
Tests for i386 target (stable maemo SDK)
We are ready to check this target, so let's test next packages which will allow us to:
- hello-world: compile and debug
- hello-world-gtk: check the maemo-environment
- hello-world-app: create and install a debian package
hello-world
compilation
I'll use this simple
tarball for test the compilation and the console execution firstly.
So, untar the file and begin the compilation:
[sbox-SDK_PC: ~] > tar -xzvf /scratchbox/packages/hello-world.tar.gz
[sbox-SDK_PC: ~/hello-world] > ./autogen.sh
[sbox-SDK_PC: ~/hello-world] > make
[sbox-SDK_PC: ~/hello-world] > ./hello
Hello World!
The
gcc binary used is located at:
/scratchbox/compilers/cs2005q3.2-glibc-i386/bin/sbox-i686-linux-gcc.
debugging
Let's try to debug this simple program setting a breakpoint at its main function:
[sbox-SDK_PC: ~/hello-world] > gdb ./hello
GNU gdb 6.1
[...]
This GDB was configured as "--host=i386-pc-linux-gnu --target=i686-linux"...
(gdb) break main
Breakpoint 1 at 0x8380: file main.c, line 4.
(gdb) r
Starting program: /home/csanmartin/hello-world/hello
Don't know how to run. Try "help target".
(gdb)
gdb says that it doesn't know how to run. This could be because this is a
cross-gdb,
host and
target don't match. It seems we must use
gdbserver. We can launch it using
host:port to make
gdb listen to that concrete (and available) port. We are working on localhost, so we can use
host or
localhost.
[sbox-SDK_PC: ~/hello-world] > gdbserver host:2345 ./hello
Process ./hello created; pid = 1773
Listening on port 2345
Now, launch
gdb like this:
[sbox-SDK_PC: ~/hello-world] > gdb
GNU gdb 6.1
[...]
(gdb) file ./hello
Reading symbols from hello...done.
(gdb) target remote localhost:2345
Remote debugging using localhost:2345
0xb7f3a8f0 in ?? ()
(gdb) break main
Breakpoint 1 at 0x8048366: file main.c, line 4.
(gdb) c
Continuing.
Breakpoint 1, main (argc=1, argv=0xbf94e754) at main.c:4
4 {
(gdb)
The
gdb binary used is located in
/scratchbox/compilers/cs2005q3.2-glibc-i386/arch_tools/bin/i686-linux-gdb
and
gdbserver is located in
/usr/bin/gdbserver.
hello-world-gtk
I'll use this program to test the maemo environment, like before, we first
untar it and then compile it.
[sbox-SDK_PC: ~] > tar -xzvf /scratchbox/packages/hello-world-gtk.tar.gz
[sbox-SDK_PC: ~/hello-world-gtk] > ./autogen.sh
[sbox-SDK_PC: ~/hello-world-gtk] > make
Before running it, we'll launch
Xephyr on display :2 with the next script from a shell outside the scratchbox:
#!/bin/sh -e
prefix=/scratchbox/users/${LOGNAME}/targets/SDK_PC/usr
export LD_LIBRARY_PATH=${prefix}/lib; export LD_LIBRARY_PATH
exec ${prefix}/bin/Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac
and then run the maemo-environment:
[sbox-SDK_PC: ~/hello-world-gtk] > af-sb-init.sh start
Note: For remote X connections DISPLAY should contain hostname!
Sample files present.
Starting DBUS system bus
Starting D-BUS session bus daemon
Starting Maemo Launcher: maemo-launcher.
Starting Sapwood image server
Starting Matchbox window manager
Starting clipboard-manager
sapwood-server[32039]: GLIB INFO default - server started
Starting Keyboard
maemo-launcher: invoking '/usr/bin/hildon-input-method.launch'
hildon-input-method[32071]: GLIB MESSAGE default - keyboard up and running
Starting MAEMO AF Desktop
maemo-launcher: invoking '/usr/bin/maemo_af_desktop.launch'
Usage:program_name [address][:port]TRACE LOG: status_bar_main: 1 g_new0
TRACE LOG: status_bar_main: 2 check panel ptr
TRACE LOG: status_bar_main: 3: init dock
TRACE LOG: status_bar_main: 4 add prespecified items
TRACE LOG: status_bar_main: 5 add user items
TRACE LOG: status_bar_main: 6 gtk widget show all
TRACE LOG: status_bar_main: 7 if rpc...
TRACE LOG: status_bar_main: 8, status bar initialized successfully
This is one of the most important points, having the maemo-environment up and running without problems...
[sbox-SDK_PC: ~/hello-world-gtk] > run-standalone.sh ./hello
Works without problem showing the label with the text
GTK Hello,
and the button to close the window.
hello-world-app
I'll use this package to test the creation of a debian one, and also to test once again the environment running another application. First, download the source code from the repository:
[sbox-SDK_PC: ~] > svn co https://stage.maemo.org/svn/maemo/projects/haf/trunk/hello-world-app
[...]
Checked out revision 8220.
And now we can make a simple change to show a bit different string:
Index: libhelloworld.c
===================================================================
--- libhelloworld.c (revision 8220)
+++ libhelloworld.c (working copy)
@@ -56,7 +56,7 @@
GTK_RESPONSE_OK,
NULL);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
- gtk_label_new ("Hello World!"));
+ gtk_label_new ("Hello World has changed!"));
gtk_widget_show_all (dialog);
return GTK_DIALOG (dialog);
So, make the package:
[sbox-SDK_PC: ~/hello-world-app] > ./autogen.sh
[sbox-SDK_PC: ~/hello-world-app] > fakeroot debian/rules binary
[...]
warning, `debian/hello-world-app/DEBIAN/control' contains user-defined field `Maemo-Icon-26'
dpkg-deb: building package `hello-world-app' in `../hello-world-app_0.4_i386.deb'.
dpkg-deb: ignoring 1 warnings about the control file(s)
Install it and run it inside the maemo environment:
[sbox-SDK_PC: ~/hello-world-app] > fakeroot dpkg -i ../hello-world-app_0.4_i386.deb
[sbox-SDK_PC: ~/hello-world-app] > af-sb-init.sh start
When you click on the icon this is what I get:
The locations of the binaries are:
- fakeroot:
/scratchbox/tools/bin/fakeroot-tcp
- apt-get:
/scratchbox/devkits/debian/bin/apt-get
- dpkg:
/scratchbox/devkits/debian/bin/dpkg
Tests for arm target (stable maemo SDK)
Now, I'll test the
arm target, which is mainly used to create the packages for the internet tablet. We'll take a look at the next tests:
- hello-world: compile and debug
- hello-world-gtk: check the maemo-environment
- hello-world-app: create and install a debian package
hello-world
compilation
This test is the one for the
i386, compiling and running the tarball of
hello-world.
[sbox-ARM: ~] > tar xzvf /scratchbox/packages/hello-world.tar.gz
[sbox-ARM: ~/hello-world] > ./autogen.sh
[sbox-ARM: ~/hello-world] > make
[sbox-ARM: ~/hello-world] > ./hello
Hello World!
This time, the compiler used is:
/scratchbox/compilers/cs2005q3.2-glibc-arm/bin/sbox-arm-linux-gcc,
and for running the application it'll be used the qemu emulator
/scratchbox/devkits/cputransp/bin/qemu.
debugging
Let's try to debug:
[sbox-ARM: ~/hello-world] > gdbserver host:2345 ./hello
Process ./hello created; pid = 7857
qemu: Unsupported syscall: 26
Hello World!
Child exited with retcode = 0
Listening on port 2345
qemu doesn't support all neccessary syscalls which gdb uses but it should support gdb server mode though.
You can read more
here
.
So, we can use
qemu -g option (which waits a gdb connection to port 1234).
[sbox-ARM: ~/hello-world] > qemu -g ./hello
and the client side as we saw before for i386 target:
[sbox-ARM: ~/hello-world] > gdb
GNU gdb 6.1
[...]
(gdb) file ./hello
Reading symbols from ./hello...done.
(gdb) break main
Breakpoint 1 at 0x8384: file main.c, line 5.
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x400826e0 in ?? ()
(gdb) c
Continuing.
Breakpoint 1, main (argc=1, argv=0x40080834) at main.c:5
5 printf("Hello World!\n");
(gdb)
The
gdb binary is located at
/scratchbox/compilers/cs2005q3.2-glibc-arm/arch_tools/bin/arm-linux-gdb and
the gdb server at
/usr/bin/gdbserver.
hello-world-gtk
If you try to start the maemo environment inside an
arm target, it's launched:
[sbox-ARM: ~] > af-sb-init.sh start
/usr/bin/af-sb-init.sh: line 1: export: `bus:': not a valid identifier
Note: For remote X connections DISPLAY should contain hostname!
Sample files present.
Starting DBUS system bus
Starting D-BUS session bus daemon
Starting Maemo Launcher: maemo-launcher.
maemo-defender: died my parent is not who he claims to be
maemo-launcher: error rising the oom shield for pid=9970 status=2816
Starting Sapwood image server
sapwood-server[9985]: GLIB INFO default - server started
Starting Matchbox window manager
Starting clipboard-manager
Starting Keyboard
maemo-launcher: invoking '/usr/bin/hildon-input-method.launch'
Starting MAEMO AF Desktop
maemo-launcher: invoking '/usr/bin/maemo_af_desktop.launch'
hildon-input-method[10042]: GLIB MESSAGE default - keyboard up and running
TRACE LOG: status_bar_main: 1 g_new0
TRACE LOG: status_bar_main: 2 check panel ptr
TRACE LOG: status_bar_main: 3: init dock
TRACE LOG: status_bar_main: 4 add prespecified items
TRACE LOG: status_bar_main: 5 add user items
TRACE LOG: status_bar_main: 6 gtk widget show all
TRACE LOG: status_bar_main: 7 if rpc...
TRACE LOG: status_bar_main: 8, status bar initialized successfully
[...]
but when you click over the menu or another place to launch some application, it crashes. I suppose it isn't thought to be used in this way (in a target different from your host, I mean). So, I wasn't able to run graphical applications with it. This is the message I got:
maemo-launcher: child (pid=10046) exited due to exit()=245
matchbox-wm: X error warning (0x80002a): BadWindow (opcode: 12)
matchbox-wm: X error warning (0x80002a): BadWindow (opcode: 12)
matchbox-wm: X error warning (0x80002a): BadWindow (opcode: 25)
hello-world-app
Let's follow the same steps that we did for
i386:
[sbox-ARM: ~] > svn co https://stage.maemo.org/svn/maemo/projects/haf/trunk/hello-world-app
[...]
Checked out revision 8220.
The same change in the file
libhelloworld.c (line 56):
- gtk_label_new ("Hello World!"));
+ gtk_label_new ("Hello World has changed!"));
So, make the package:
[sbox-ARM: ~/hello-world-app] > ./autogen.sh
[sbox-ARM: ~/hello-world-app] > fakeroot debian/rules binary
[...]
dpkg-deb: building package `hello-world-app' in `../hello-world-app_0.4_armel.deb'.
dpkg-deb: ignoring 1 warnings about the control file(s)
I installed it in the
770 to run it, and it works fine, getting the same result as in the
i386 target.
Tests for i386 target (sardine)
The
sardine repository contains the lastest releases of the hildon application framework (
HAF) components. It's the selected distribution for maemo developers. We can upgrade our SDK to sardine adding to the
/etc/apt/sources.list the next repository:
deb http://repository.maemo.org sardine main non-free
Make update and then upgrade.
[sbox-SDK_PC: ~] > fakeroot apt-get update
[...]
Get:17 http://repository.maemo.org sardine/main Packages [148kB]
Get:18 http://repository.maemo.org sardine/main Release [111B]
Get:19 http://repository.maemo.org sardine/non-free Packages [2803B]
Get:20 http://repository.maemo.org sardine/non-free Release [115B]
Fetched 311kB in 7s (40.4kB/s)
Reading Package Lists... Done
During the upgrade, I accept all changes in configuration files,
typing
Y and pressing
enter.
[sbox-SDK_PC: ~] > fakeroot apt-get upgrade
[...]
95 upgraded, 0 newly installed, 0 to remove and 56 not upgraded.
[...]
Now, dist-upgrade, but before, make a copy of your
sources.list, because
this process will remove it:
[sbox-SDK_PC: ~] > fakeroot apt-get dist-upgrade
[...]
91 upgraded, 25 newly installed, 1 to remove and 0 not upgraded.
[...]
and it appears to be a first problem:
[...]
Selecting previously deselected package xtrans-dev.
Unpacking xtrans-dev (from .../xtrans-dev_1.0.0-4_all.deb) ...
dpkg: error processing /var/cache/apt/archives/xtrans-dev_1.0.0-4_all.deb (--unpack):
trying to overwrite `/usr/lib/pkgconfig/xtrans.pc', which is also in package libxtrans-dev
[...]
Errors were encountered while processing:
/var/cache/apt/archives/xtrans-dev_1.0.0-4_all.deb
E: Sub-process /scratchbox/devkits/debian/bin/dpkg returned an error code (1)
[...]
One of the packages involved should overwrite the
.pc file, so I forced its installation.
[sbox-SDK_PC: ~] > fakeroot dpkg -i --force-all /var/cache/apt/archives/xtrans-dev_1.0.0-4_all.deb
Now, restore your
sources.list copy and resume the process:
[sbox-SDK_PC: ~] > fakeroot apt-get dist-upgrade
[...]
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
78 not fully installed or removed.
[...]
invoke-rc.d: initscript dbus, action "start" failed.
[...]
Errors were encountered while processing:
dbus
dbus-1-utils
osso-gwconnect
The packages
dbus-1-utils and
osso-gwconnect fail due to an unconfigured
dbus package which they depend on.
dbus doesn't set up properly, because its daemon didn't start and it's because of the next line inside
/etc/init.d/dbus script:
echo `uname -m` | grep "^armv" > /dev/null
because the target is
i686 and not
arm. There is already a reference on internet about it
here
.
Finally, the dist-upgrade ends successfully:
[sbox-SDK_PC: ~] > fakeroot apt-get dist-upgrade
[...]
3 not fully installed or removed.
[...]
In order to test the
sardine distribution, I'll made the same tests again.
hello-world
compilation
The compiler is the same, all should work... and it's true:
[sbox-SDK_PC: ~] > tar -xzvf /scratchbox/packages/hello-world.tar.gz
[sbox-SDK_PC: ~/hello-world] > ./autogen.sh
[sbox-SDK_PC: ~/hello-world] > make
[sbox-SDK_PC: ~/hello-world] > ./hello
Hello World!
debugging
Debugging works fine, in the same way we've already seen. Here I've checked it:
[sbox-SDK_PC: ~/hello-world] > gdbserver host:2345 ./hello
Process ./hello created; pid = 27905
Listening on port 2345
[sbox-SDK_PC: ~/hello-world] > gdb
GNU gdb 6.1
[...]
(gdb) file ./hello
Reading symbols from ./hello...done.
(gdb) break main
Breakpoint 1 at 0x8048366: file main.c, line 4.
(gdb) target remote localhost:2345
Remote debugging using localhost:2345
0xb7fdb8f0 in ?? ()
(gdb) c
Continuing.
Breakpoint 1, main (argc=1, argv=0xbf8f1074) at main.c:4
4 {
(gdb)
hello-world-gtk
Let's go with this test, the most important one.
[sbox-SDK_PC: ~] > tar -xzvf /scratchbox/packages/hello-world-gtk.tar.gz
[sbox-SDK_PC: ~/hello-world-gtk] > ./autogen.sh
[sbox-SDK_PC: ~/hello-world-gtk] > make
Start the maemo environment:
[sbox-SDK_PC: ~/hello-world-gtk] > af-sb-init.sh start
[...]
Starting Maemo Launcher: maemo-launcher/home/csanmartin/.osso/current-gtk-key-theme\
:1: Unable to find include file: "keybindings.rc"
[...]
/home/csanmartin/.osso/current-gtk-key-theme:1: Unable to find include file: "keybi\
ndings.rc"
[...]
maemo_af_desktop[1627]: GLIB DEBUG default - Reached EOF of `file:///usr/share/back\
grounds/bg_img_01.png', building the pixbuf
maemo_af_desktop[1627]: GLIB DEBUG default - we got the pixbuf (w:720, h:480), form\
at: png
[...]
maemo_af_desktop[4001]: GLIB WARNING ** default - Application GTK Hello did not pro\
vide valid .desktop file
maemo_af_desktop[30470]: GLIB WARNING ** default - Failed to lookup 'TitleTextColor\
' color!
maemo_af_desktop[30470]: GLIB WARNING ** default - Unable to read configuration fil\
e at `/home/csanmartin/.osso/hildon-home/hildon-home.conf': No such file or directory
maemo_af_desktop[30470]: GLIB WARNING ** default - Unable to load background from c\
ache: Failed to open file '/home/csanmartin/.osso/hildon-home/hildon_home_bg_user.\
png': No such file or directory
[...]
There are some warnings about the background and other things (like the hello-world icon) but it works, though.
I run this example without problems.
hello-world-app
Now, we'll create a package from the
hello-world-app with the already known modification (the label that changes its message):
[sbox-SDK_PC: ~] > svn co https://stage.maemo.org/svn/maemo/projects/haf/trunk/hello-world-app
[...]
Checked out revision 8220.
- gtk_label_new ("Hello World!"));
+ gtk_label_new ("Hello World has changed!"));
[sbox-SDK_PC: ~/hello-world-app] > ./autogen.sh
[sbox-SDK_PC: ~/hello-world-app] > fakeroot debian/rules binary
[...]
warning, `debian/hello-world-app/DEBIAN/control' contains user-defined field `Maemo-Icon-26'
dpkg-deb: building package `hello-world-app' in `../hello-world-app_0.4_i386.deb'.
dpkg-deb: ignoring 1 warnings about the control file(s)
After installing the package, we run it getting the desired result:
Tests for arm target (sardine)
First, as for
i386 target, we add the sardine repository:
deb http://repository.maemo.org sardine main non-free
And make update and upgrade:
[sbox-ARM: ~] > fakeroot apt-get update
[...]
[sbox-ARM: ~] > fakeroot apt-get upgrade
[...]
94 upgraded, 0 newly installed, 0 to remove and 59 not upgraded.
[...]
Again, we'll save a copy of our
sources.list, because it'll be removed. And now, start the dist-upgrade process:
[sbox-ARM: ~] > fakeroot apt-get dist-upgrade
[...]
57 upgraded, 25 newly installed, 1 to remove and 2 not upgraded.
[...]
dpkg: error processing /var/cache/apt/archives/xtrans-dev_1.0.0-4_all.deb (--unpack):
trying to overwrite `/usr/lib/pkgconfig/xtrans.pc', which is also in package libxtrans-dev
[...]
We have the same problem, and we can do the same as before, forcing the installation of the package:
[sbox-ARM: ~] > fakeroot dpkg -i --force-all /var/cache/apt/archives/xtrans-dev_1.0.0-4_all.deb
[...]
Now, we must restore our
sources.list. Then, we resume the process and it'll finish successfully.
[sbox-ARM: ~] > fakeroot apt-get dist-upgrade
[...]
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
78 not fully installed or removed.
[...]
hello-world
compilation
All should work properly...
[sbox-ARM: ~] > tar -xzvf /scratchbox/packages/hello-world.tar.gz
[sbox-ARM: ~/hello-world] > ./autogen.sh
[sbox-ARM: ~/hello-world] > make
[sbox-ARM: ~/hello-world] > ./hello
Hello World!
debugging
Like before, we try to debug:
[sbox-ARM: ~/hello-world] > qemu -g ./hello
[sbox-ARM: ~/hello-world] > gdb
GNU gdb 6.1
[...]
(gdb) file ./hello
Reading symbols from ./hello...done.
(gdb) break main
Breakpoint 1 at 0x8384: file main.c, line 5.
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x400826e0 in ?? ()
(gdb) c
Continuing.
Breakpoint 1, main (argc=1, argv=0x40080814) at main.c:5
5 printf("Hello World!\n");
(gdb)
hello-world-gtk
First, we untar the file and compile the application:
[sbox-ARM: ~] > tar -xzvf /scratchbox/packages/hello-world-gtk.tar.gz
[sbox-ARM: ~/hello-world-gtk] > ./autogen.sh
[sbox-ARM: ~/hello-world-gtk] > make
and now, it's time to launch the environment:
[sbox-ARM: ~] > af-sb-init.sh start
[...]
/usr/bin/af-sb-init.sh: line 1: export: `bus:': not a valid identifier
/etc/init.d/maemo-launcher: line 1: export: `bus:': not a valid identifier
[...]
Failed to load Pango module for id: 'BasicScriptEngineFc'matchbox-window-man\
ager[10563]: GLIB WARNING ** Pango - /usr/lib/pango/1.4.0/modules/pango-bas\
ic-fc.so: cannot open shared object file: No such file or directory
[...]
hildon-input-method[10587]: GLIB WARNING ** default - Could not initialize o\
sso from hildon-input-method
hildon-input-method[10587]: GLIB WARNING ** GConf - Client failed to connect\
to the D-BUS daemon:
Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or\
directory
[...]
hildon-input-method[10587]: GLIB CRITICAL ** Gtk - gtk_check_menu_item_set_a\
ctive: assertion `GTK_IS_CHECK_MENU_ITEM (check_menu_item)' failed
hildon-input-method[10587]: GLIB WARNING ** GLib-GObject - invalid (NULL) po\
inter instance
[...]
maemo-launcher: child (pid=10603) exited due to exit()=1
There are several problems and warnings, the environment isn't launched.
hello-world-app
[sbox-ARM: ~] > svn co https://stage.maemo.org/svn/maemo/projects/haf/trunk/hello-world-app
[...]
Checked out revision 8220.
[sbox-ARM: ~/hello-world-app] > ./autogen.sh
[sbox-ARM: ~/hello-world-app] > fakeroot debian/rules binary
[...]
warning, `debian/hello-world-app/DEBIAN/control' contains user-defined field `Maemo-Icon-26'
dpkg-deb: building package `hello-world-app' in `../hello-world-app_0.4_armel.deb'.
dpkg-deb: ignoring 1 warnings about the control file(s)
[sbox-ARM: ~/hello-world-app] >
I've installed the package in the
770 and works well, but your internet tablet
must have the sardine distribution installed. Otherwise there will be dependencies not meeted
and even forcing its installation, the application will crash.
Conclusions
After having checked the previous tests, I can say that there is enough compatibility with the maemo SDK (
scirocco in this case) and scratchbox apophis (
R4). I mean you can develop without problems inside it, both the current stable SDK and the
sardine distribution whenever we work with the toolchains above described.
Summarizing, these little tests show us the main things we can do:
- compile, debug, and run the applications in the maemo environment (this last point does not work for
arm target)
- create and install packages in both architectures
Anyway, we should also consider these are light tests with small applications.
div class="twikiTopicInfo twikiRevInfo twikiGrayText twikiMoved"<&/div>-->