Archive

Archive for the ‘embedded’ Category

Scratchbox + Maemo SDK 4.1.1 on Fedora 9

2008/11/11 aalonso 3 comments

My everyday working machine is based on Fedora 9 x86_64. Since Scratchbox is officially supported only by i386 archs I have been looking for an optimal solution to get it working inside of my box.

The most clean solution is to fake an i386 architecture by using setarch command, this way the checking prerequisites are satisfied and you able to install scratchbox by following the usual procedure, with some workarounds.

Scratchbox know limitations:

Qemu “mmap_min_addr” value grather than 4096

Edit /etc/sysctl.conf and add:
vm.mmap_min_addr = 4096

Scratchbox doesn’t work when VDSO support is enabled in the host’s kernel.

To disable VDSO support in x86_64 kernels you need to add the vdso32=0 options
in your kenel boot line

Edit /boot/grub/menu.lst and add vdso32=0 my kernel boot looks like:

kernel /vmlinuz-2.6.26.6-79.fc9.x86_64 ro root=/dev/VolGroup00/LogVol00 rhgb quiet vdso32=0

Reboot your machine so VDSO can be disabled.

Installing Scratchbox:

Get the installer script:
wget http://repository.maemo.org/stable/4.1.1/maemo-scratchbox-install_4.1.1.sh

Give executable permitions to the script:
chmod +x maemo-scratchbox-install_4.1.1.sh

Disable Selinux:
echo 0 > /selinux/enforce

Other wise the installer script will complain

Fake a i386 arch:

sudo setarch i386

Run installer script:

sudo ./maemo-scratchbox-install_4.1.1.sh -s <install-path> -u <your-username>

This will take a while, when it finish you will see a massage like this:

Installation was successful!
—————————-

Installing Maemo SDK:

Download SDK installer script

wget http://repository.maemo.org/stable/4.1.1/maemo-sdk-install_4.1.1.sh

Give executable permitions to the script:
chmod +x maemo-sdk-install_4.1.1.sh

Fake i386 arch:

setarch i386

Satrt sbox service:

sudo <sb-install-path>/sbin/sbox_ctl start

Run the sdk install script
sh ./maemo-sdk-install_4.1.1.sh -y -s -d <sb-install-path>

Testing scratchbox and the sdk:

Install Xephyr server to forward sb xorg-X11

sudo yum install xorg-x11-server-Xephyr

Start Xephyr server:

Xephyr :2 -host-cursor -screen 800×480x16 -dpi 96 -ac -extension Composite

Start sbox and login

sudo /opt/scratchbox/sbin/sbox_ctl start

/opt/scratchbox/login

Create a file named hello-maemo.c and add the following lines:

/*********/

#include <hildon/hildon-program.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkbutton.h>

int main(int argc, char *argv[])
{
/* Create needed variables */
HildonProgram *program;
HildonWindow *window;
GtkWidget *button;

/* Initialize the GTK. */
gtk_init(&argc, &argv);

/* Create the hildon program and setup the title */
program = HILDON_PROGRAM(hildon_program_get_instance());
g_set_application_name(“Hello maemo!”);

/* Create HildonWindow and set it to HildonProgram */
window = HILDON_WINDOW(hildon_window_new());
hildon_program_add_window(program, window);

/* Create button and add it to main view */
button = gtk_button_new_with_label(“Hello!”);
gtk_container_add(GTK_CONTAINER(window), button);

/* Connect signal to X in the upper corner */
g_signal_connect(G_OBJECT(window), “delete_event”,
G_CALLBACK(gtk_main_quit), NULL);

/* Begin the main application */
gtk_widget_show_all(GTK_WIDGET(window));
gtk_main();

/* Exit */
return 0;
}

/*********/

Compile the hello-maemo example:

gcc -o hello-maemo hello-maemo.c `pkg-config –cflags gtk+-2.0 hildon-1` -ansi -Wall `pkg-config –libs gtk+-2.0 hildon-1`

Set the DISPLAY variable to poit to the Xephyr server

export DISPLAY=:2

Start the maemo scratchbox enviroment test script:

af-sb-init.sh start

Run the hello_maemo application:

run-standalone.sh ./hello_maemo

hello_maemo

References:

http://www.progbox.co.uk/wordpress/?p=453

http://znark.com/blog/2008/09/21/maemo-sdk-on-fedora-9

Poky Anjuta plug-in

2008/05/17 aalonso 1 comment

Poky provides an plug-in for developing using Anjuta IDE, follow the next steps form building the plug-in:

Checkout the latest version

svn co http://svn.o-hand.com/repos/anjuta-poky/trunk anjuta-plugin-sdk
cd anjuta-poky-plugin-sdk
sudo ./autogen.sh
sudo make
sudo make install

Listo, now the next step is to configure the plug-in to start development with Anjuta,

In Anjuta go to Edit->Preferences

Enable the plug-in:

Anjuta-Poky Enable

Configure the toolchain path:
/usr/local/poky/eabi-glibc/arm/

Anjuta-Poky preferences

At the moment we will leave the Target options as shown in further post I will deal with this.

Close the preferences dialog; Create a New Project
File->New->Project
Select an C GTK+ type.

Run Autogenerate…
Build->Run Autogenerate…

You will see messages like:

checking for arm-poky-linux-gnueabi-strip… arm-poky-linux-gnueabi-strip
checking whether to enable maintainer-specific portions of Makefiles… yes
checking for style of include used by make… GNU
checking for arm-poky-linux-gnueabi-gcc… arm-poky-linux-gnueabi-gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… yes

If not then you are not setting correctly the toolchain root path or you misspell the toolchain prefix.

Now Build->Build Project

That would place a binary your src directory.

On my next post I will go through procedure of running the previous example on Quemu as target platform, while you can start designing and coding : )

More info at anjuta-poky-sdk-plugin