Embedded Freaks..

November 19, 2010

Cross Compiling Disko for ARM926EJ-S SoC

Filed under: ARM9, embedded-linux — Tags: , — kunilkuda @ 9:50 pm

Disko is GUI toolkit for embedded linux devices. Here’s what they said about themselves:

Disko is an LGPL-licensed user interface (UI) application framework for the fast and simple development of flexible applications on Embedded Linux systems – with a particular focus on interactive user interfaces. It is high-performance and easy to learn, and due to its architecture is well suited to creating complex applications. Disko is a product of BerLinux Solutions GmbH.

Their website can be found here. It seems like it’s a nice GUI framework for embedded device. I’ve been trying to cross compile GTK-directFB without any luck, but Disko, along with its dependencies are very easy to be cross compiled.

To cross compile Disko, along with its dependencies, I’ve made a Makefile (to automate the compilation). Here’s the Disko cross-compile Makefile


# Disko package cross-compile for ARM926EJ-S
# ver 20101203_1050
#
# You will need extra tools (other than cross-toolchain) in your PC to run this Makefile:
# - pkg-config
# - pyhton
# - perl
# - SCons

TOP_DIR    = $(shell pwd)
BUILD_DIR  = $(TOP_DIR)/build
SOURCE_DIR = $(TOP_DIR)/source
HOST_DIR   = $(TOP_DIR)/host

KERNEL_HEADER   = $(HOST_DIR)/include

CURL_PACKAGE    = curl-7.21.1.tar.gz
DISKO_PACKAGE   = disko_1.7.0.tar.gz
FREETYPE_PACKAGE= freetype-2.4.3.tar.gz
OPENSSL_PACKAGE = openssl-1.0.0b.tar.gz
LIBSIGC_PACKAGE = libsigc++-2.2.8.tar.gz
LIBPNG_PACKAGE  = libpng-1.4.4.tar.gz
LIBXML2_PACKAGE = libxml2-sources-2.7.8.tar.gz
SQLITE_PACKAGE  = sqlite-amalgamation-3.7.3.tar.gz
ZLIB_PACKAGE    = zlib-1.2.5.tar.gz

CROSS_COMPILE ?= $(HOME)/workspace/codesourcery/bin/arm-none-linux-gnueabi-
AR             = $(CROSS_COMPILE)ar
CC             = $(CROSS_COMPILE)gcc
CXX            = $(CROSS_COMPILE)g++
LD             = $(CROSS_COMPILE)g++
NM             = $(CROSS_COMPILE)nm
RANLIB         = $(CROSS_COMPILE)ranlib
CFLAGS         = -mcpu=arm926ej-s
CXXFLAGS       = -mcpu=arm926ej-s
TAR            = /bin/tar
SCONS          = $(TOP_DIR)/bin/scons

all: freetype libsigc sqlite zlib openssl curl libpng libxml2 disko

# libcurl depends on zlib and openssl
curl:
	$(TAR) xvzf $(SOURCE_DIR)/$(CURL_PACKAGE) -C $(BUILD_DIR)
	cd $(BUILD_DIR)/$(firstword $(subst .tar., ,$(CURL_PACKAGE))) && \
	CC=$(CC) CFLAGS="$(CFLAGS)" \
	AR=$(AR) RANLIB=$(RANLIB) \
	PKG_CONFIG_PATH=$(HOST_DIR)/lib/pkgconfig \
	./configure --prefix=$(HOST_DIR) --with-gnu-ld --host=arm-none-linux-gnueabi \
	--disable-http --disable-ftp --disable-file --disable-ldap --disable-rtsp \
	--disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 \
	--disable-imap --disable-smtp --disable-sspi --disable-crypto-auth --disable-cookies \
	--without-ldap-lib --without-lber-lib --without-krb4 --without-spnego \
	--without-gssapi --with-ssl --with-zlib=$(HOST_DIR) \
	--without-gnutls --without-polarssl --without-nss --without-ca-bundle \
	--without-libssh2 --without-librtmp --without-libidn && \
	$(MAKE) && \
	$(MAKE) install

# disko depends libcurl, freetype, libpng, libsigc, libxml2, sqlite
disko:
	$(TAR) xvzf $(SOURCE_DIR)/$(DISKO_PACKAGE) -C $(BUILD_DIR)
	cd $(BUILD_DIR)/$(subst _,-,$(firstword $(subst .tar., ,$(DISKO_PACKAGE)))) && \
	CXX=$(CXX) CXXFLAGS="$(CXXFLAGS) -I$(KERNEL_HEADER)" \
	PKG_CONFIG_PATH=$(HOST_DIR)/lib/pkgconfig \
	$(SCONS) graphics=fbdev prefix=$(HOST_DIR) cross=true install

freetype:
	$(TAR) xvzf $(SOURCE_DIR)/$(FREETYPE_PACKAGE) -C $(BUILD_DIR)
	cd $(BUILD_DIR)/$(firstword $(subst .tar., ,$(FREETYPE_PACKAGE))) && \
	CC=$(CC) CFLAGS="$(CFLAGS)" \
	AR=$(AR) RANLIB=$(RANLIB) \
	./configure --prefix=$(HOST_DIR) --with-gnu-ld --host=arm-none-linux-gnueabi && \
	$(MAKE) && \
	$(MAKE) install

# OpenSSL depends on zlib
openssl:
	$(TAR) xvzf $(SOURCE_DIR)/$(OPENSSL_PACKAGE) -C $(BUILD_DIR)
	cd $(BUILD_DIR)/$(firstword $(subst .tar., ,$(OPENSSL_PACKAGE))) && \
	AR=$(AR) NM=$(NM) \
	./Configure --prefix=$(HOST_DIR) zlib-dynamic "linux-arm926ej-s":"$(CC):$(CFLAGS) -DTERMIO -O3 -Wall -I$(HOST_DIR)/include::-D_REENTRANT::-L$(HOST_DIR)/lib -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR::bn_asm.o armv4-mont.o::aes_cbc.o aes-armv4.o:::sha1-armv4-large.o sha256-armv4.o sha512-armv4.o:::::::void:dlfcn:linux-shared:-fPIC::.so.1.0.0":$(RANLIB):: && \
	$(MAKE) && \
	$(MAKE) install

# libpng depends on zlib
libpng:
	$(TAR) xvzf $(SOURCE_DIR)/$(LIBPNG_PACKAGE) -C $(BUILD_DIR)
	cd $(BUILD_DIR)/$(firstword $(subst .tar., ,$(LIBPNG_PACKAGE))) && \
	CC=$(CC) CFLAGS="$(CFLAGS) -I$(HOST_DIR)/include" \
	CPPFLAGS="-I$(HOST_DIR)/include" \
	LDFLAGS="-L$(HOST_DIR)/lib" \
	AR=$(AR) RANLIB=$(RANLIB) \
	./configure --prefix=$(HOST_DIR) --with-gnu-ld --host=arm-none-linux-gnueabi && \
	$(MAKE) && \
	$(MAKE) install

libsigc:
	$(TAR) xvzf $(SOURCE_DIR)/$(LIBSIGC_PACKAGE) -C $(BUILD_DIR)
	cd $(BUILD_DIR)/$(firstword $(subst .tar., ,$(LIBSIGC_PACKAGE))) && \
	CC=$(CC) CFLAGS="$(CFLAGS)" \
	CXX=$(CXX) CXXFLAGS="$(CXXFLAGS)" \
	AR=$(AR) RANLIB=$(RANLIB) \
	./configure --prefix=$(HOST_DIR) --with-gnu-ld --host=arm-none-linux-gnueabi && \
	$(MAKE) && \
	$(MAKE) install

#libxml2 depends on zlib
libxml2:
	$(TAR) xvzf $(SOURCE_DIR)/$(LIBXML2_PACKAGE) -C $(BUILD_DIR)
	cd $(BUILD_DIR)/$(subst -sources,,$(firstword $(subst .tar., ,$(LIBXML2_PACKAGE)))) && \
	CC=$(CC) CFLAGS="$(CFLAGS)" \
	AR=$(AR) RANLIB=$(RANLIB) \
	./configure --prefix=$(HOST_DIR) --with-gnu-ld --host=arm-none-linux-gnueabi \
	--without-python --without-readline --with-zlib=$(HOST_DIR) && \
	$(MAKE) && \
	$(MAKE) install

sqlite:
	$(TAR) xvzf $(SOURCE_DIR)/$(SQLITE_PACKAGE) -C $(BUILD_DIR)
	cd $(BUILD_DIR)/$(subst -amalgamation,,$(firstword $(subst .tar., ,$(SQLITE_PACKAGE)))) && \
	CC=$(CC) CFLAGS="$(CFLAGS)" \
	CXX=$(CXX) CXXFLAGS="$(CXXFLAGS)" \
	AR=$(AR) RANLIB=$(RANLIB) \
	./configure --prefix=$(HOST_DIR) --with-gnu-ld --host=arm-none-linux-gnueabi && \
	$(MAKE) && \
	$(MAKE) install

zlib:
	$(TAR) xvzf $(SOURCE_DIR)/$(ZLIB_PACKAGE) -C $(BUILD_DIR)
	cd $(BUILD_DIR)/$(firstword $(subst .tar., ,$(ZLIB_PACKAGE))) && \
	CC=$(CC) CFLAGS="$(CFLAGS)" \
	AR=$(AR) RANLIB=$(RANLIB) \
	./configure --prefix=$(HOST_DIR) && \
	$(MAKE) && \
	$(MAKE) install

To use the Makefile, first, install your target board’s kernel header in the $HOST_DIR. This is example for PHY3250 board.

# make ARCH=arm CROSS_COMPILE=$HOME/workspace/codesourcery/bin/arm-none-eabi- \
    INSTALL_HDR_PATH=$HOST_DIR phy3250_defconfig
# make ARCH=arm CROSS_COMPILE=$HOME/workspace/codesourcery/bin/arm-none-eabi- \
    INSTALL_HDR_PATH=$HOST_DIR headers_install

Now, if you are unlucky with the kernel, it may complains about redefinition of getline() (See the description and patch here). Hence, you need to patch it with this:

diff --git a/scripts/unifdef.c b/scripts/unifdef.c
index 552025e..977e682 100644
--- a/scripts/unifdef.c
+++ b/scripts/unifdef.c
@@ -206,7 +206,7 @@ static void             done(void);
 static void             error(const char *);
 static int              findsym(const char *);
 static void             flushline(bool);
-static Linetype         getline(void);
+static Linetype         parseline(void);
 static Linetype         ifeval(const char **);
 static void             ignoreoff(void);
 static void             ignoreon(void);
@@ -512,7 +512,7 @@ process(void)

        for (;;) {
                linenum++;
-               lineval = getline();
+               lineval = parseline();
                trans_table[ifstate[depth]][lineval]();
                debug("process %s -> %s depth %d",
                    linetype_name[lineval],
@@ -526,7 +526,7 @@ process(void)
  * help from skipcomment().
  */
 static Linetype
-getline(void)
+parseline(void)
 {
        const char *cp;
        int cursym;

Save the patch as getline.patch, and patch the kernel, before running the headers_install.

# patch -p1 < getline.patch
# make ARCH=arm CROSS_COMPILE=$HOME/workspace/codesourcery/bin/arm-none-eabi- \
    INSTALL_HDR_PATH=$HOST_DIR phy3250_defconfig
# make ARCH=arm CROSS_COMPILE=$HOME/workspace/codesourcery/bin/arm-none-eabi- \
    INSTALL_HDR_PATH=$HOST_DIR headers_install

Then, build the directory structures, and put the Makefile in the top directory

# mkdir convick convict/host convict/source convict/build
# vi convick/Makefile
---->insert the Makefile above

Then download the source code files into ‘source’ directory:

  • curl-7.21.1.tar.gz
  • disko_1.7.0.tar.gz
  • freetype-2.4.3.tar.gz
  • openssl-1.0.0b.tar.gz
  • libsigc++-2.2.8.tar.gz
  • libpng-1.4.4.tar.gz
  • libxml2-sources-2.7.8.tar.gz
  • sqlite-amalgamation-3.7.3.tar.gz
  • zlib-1.2.5.tar.gz

Then just type ‘make’ to compile everything

# make -C convict

The header files and libraries will be put into ‘convict/host’ directory. Note that the Disko will be based on kernel’s framebuffer (make sure your kernel supports framebuffer device as well). Also, the libcurl is, well, almost non-functional since I don’t need network capability for my project.

The next step is combine it with the bootloader, kernel, and busybox to create most simplest GUI-based embedded linux that’s available.

Will keep this post updated till then.

Advertisements

5 Comments »

  1. […] I forgot to put OpenSSL into my Disko cross compilation (here). Hence, I need to download the latest OpenSSL and cross compile it […]

    Pingback by Cross Compiling OpenSSL-1.0.0b for ARM926EJ-S « Embedded Freaks.. — November 23, 2010 @ 10:30 pm

  2. 23-Nov-2010 Fix added in Makefile: Add OpenSSL in package

    Comment by kunilkuda — November 24, 2010 @ 6:56 pm

  3. 24-Nov-2010
    – Fix libxml zlib config
    – Update the cross compilation environment variables

    Comment by kunilkuda — November 24, 2010 @ 8:41 pm

  4. […] The first thing is compile the libraries and Disko framework (here). […]

    Pingback by Testing ‘Disko-Demos’ in LPC3250 « Embedded Freaks.. — November 26, 2010 @ 4:48 pm

  5. 3-Dec-2010
    – Add kernel headers to Makefile
    – Add instructions to install kernel headers

    Comment by kunilkuda — December 3, 2010 @ 11:11 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: