Feb 7, 2011

How to build Clutter for Beagleboard (2)

Follow up with http://changetheworldwithyourpassion.blogspot.com/2009/09/how-to-build-clutter-for-beagleboard.html but with detail how to compile dependencies also

GLib

  • set PATH for the toolchain so that the configure can find the ARM gcc
  • Create a directory to store bin, lib, include of the builded-packages:
    • mkdir /data/opt
    • export MYPATH=/data/opt
  • Download and Extract glib-2.20.5, go to the extracted folder:
    ./configure --prefix=$MYPATH/glib --host=arm-angstrom-linux-gnueabi ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes glib_cv_stack_grows=no glib_cv_uscore=no
    make
    make install

Pixman

Download and extract pixman-0.17.8 into a folder.
./configure --prefix=$MYPATH/pixman --host=arm-angstrom-linux-gnueabi --enable-gtk=no
make
make install

Freetype

Download and extract freetype-2.3.12 into a folder
./configure --prefix=$MYPATH/freetype --host=arm-angstrom-linux-gnueabi
make
make install

Fontconfig

Download and extract fontconfig-2.8.0 into a folder
./configure --prefix=$MYPATH/fontconfig --host=arm-angstrom-linux-gnueabi --with-arch=arm --with-freetype-config=$MYPATH/freetype/bin/freetype-config PKG_CONFIG_PATH=$MYPATH/freetype/lib/pkgconfig/
make
make install

Cairo

Download and extract Cairo-1.8.10 into a folder
./configure --prefix=/$MYPATH/cairo --host=arm-angstrom-linux-gnueabi PKG_CONFIG_PATH=$MYPATH/freetype/lib/pkgconfig/:$MYPATH/fontconfig/lib/pkgconfig/:$MYPATH/pixman/lib/pkgconfig/ --enable-xlib=no --enable-directfb=no
make
make install

Pango

Build Pango-1.26.2:
./configure --prefix=$MYPATH/pango --host=arm-angstrom-linux-gnueabi PKG_CONFIG_PATH=$MYPATH/freetype/lib/pkgconfig:$MYPATH/fontconfig/lib/pkgconfig:$MYPATH/glib/lib/pkgconfig/:$MYPATH/cairo/lib/pkgconfig:$MYPATH/pixman/lib/pkgconfig/ CXX=mips-linux-c++ --with-x=no
make
make install

Clutter

Follow the http://changetheworldwithyourpassion.blogspot.com/2009/09/how-to-build-clutter-for-beagleboard.html then copy all to NFS and run the Clutter by yourself.

Have fun :-)

ClutterTexture

The ClutterTexture is a high level texture wrapper, it is a ClutterActor and can be added directly into a ClutterStage. ClutterTexture is defined with following member


struct _ClutterTexturePrivate {
gint width;
gint height;
gint max_tile_waste;
ClutterTextureQuality filter_quality;
CoglHandle texture;
gboolean no_slice;

ClutterActor *fbo_source;
CoglHandle fbo_handle;
/* Non video memory copy of image data */
guint local_data_width, local_data_height;
guint local_data_rowstride;
guint local_data_has_alpha;
guchar *local_data;

guint sync_actor_size : 1;
guint repeat_x : 1;
guint repeat_y : 1;
guint in_dispose : 1;
guint keep_aspect_ratio : 1;

};

with:

  • width: the width of the actor.
  • height: the height of the actor.
  • max_tile_waste: the number of byte that the slice texture is allowed to have wasted. It is used when no_slice is set to false.
  • filter_quality: the filter quality to apply into the texture actor.
  • texture: the internal CoglTexture handle.
  • no_slice: value indicate that the created texture is not using slicing method to prevent wasting in texture uploading. It means that the big texture will be sliced into multiple sub-texture if no_slice is set to true. When no_slice is set to true, the max_tile_waste is used to determine the number of byte that allow to be wasted for each sub-texture.
  • fbo_source: the FBO source if using FBO
  • fbo_handle: the FBO texture handle if using FBO
  • local_data_width, local_data_height: width and height of the local data buffer when saving the actor into local.
  • local_data_rowstride: rowstride of the local data buffer
  • local_data_has_alpha
  • local_data: the actual local data buffer
  • sync_actor_size:
  • repeat_x
  • repeat_y
  • in_dispose: flag used to check if the texture is in dispose state or not
  • keep_aspect_ratio

To create the texture we have following functions

  • ClutterActor * clutter_texture_new (void);
    • Create a new blank texture object
  • ClutterActor * clutter_texture_new_from_file (const gchar *filename, GError **error);
    • Create a new texture object from specified file name. The function use clutter_texture_new to create the texture object and then use clutter_texture_set_from_file to set data for the texture.
  • ClutterActor * clutter_texture_new_from_actor (ClutterActor *actor);
    • Create a new texture object from specified actor. The function is to clone the ClutterActor object into a ClutterTexture object to use as an offscreen buffer. It need the offscreen feature available in the EGL otherwise the function return NULL.

And some following functions to change the texture data

  • clutter_texture_set_from_file: set the internal texture data of the texture object from specified file
  • clutter_texture_set_from_rgb_data: set using RGB data
  • clutter_texture_set_from_yuv_data: set using YUV data
  • clutter_texture_set_area_from_rgb_data: set a sub-region using RGB data

Some notes when working with ClutterTexture

  • The no_slice property must be set before the texture attempt to load its data buffer. If we don't want to using slicing of the ClutterTexture, we SHOULD NOT use the clutter_texture_new_from_file as default ClutterTexture use slicing method to save memory. We SHOULD use clutter_texture_new, then set the disable-slice property to false then call clutter_texture_set_from_file to setup data buffer for the texture.
  • For OpenGL system that allow read/write pixel, we can have the texture memory automatically saved into system memory when the texture is not using via realize/unrealize function. And in that case, the local_data_* variable is used.
  • The FBO is much useful when we want to do transition effect without costing the GL to draw the buffer again and again, in that case the texture object is re-used to draw to onscreen.
  • ClutterTexture class know nothing about its internal texture loading/uploading, all are control under Cogl layer.

Feb 16, 2010

Add network over USB for beagleboard

Go to menuconfig, and select following things to enable network over USB for beagleboard. You won't need a wireless adapter or USB to ethernet adapter more. All will be over USB cable.

Device Driver
  -> USB Support [y]
    -> Inventra Highspeed Dual Role Controller (TI, ADI, ...) [y]
      -> Driver Mode (Both host and peripheral: USB OTG (On The Go) Device
    -> USB Gadget Support [y]
      -> USB Gadget Drivers (Ethernet Gadget (with CDC Ethernet support) [y]
      -> RNDIS support [y]

Feb 6, 2010

Pango Note

Pango
Text layout library
Supports different font technologies:
    * Classic X fonts
    * TrueType fonts (using FreeType)
    * OpenType fonts (using Xft/XRender/FreeType)
• Win32 fonts

Pango architecture
http://fishsoup.net/bib/PangoGuadec2001/slide009.html

Supported Language
    * European languages
    * Asian languages (Chinese, Japanese, Korean, ...)
    * Middle Eastern languages (Arabic, Hebrew, Farsi,...)
    * Indic languages (Devanagari, Bengali, Gujarati, Gurmukhi, Burmese)

Pango has markup language !!!

Pango GL patch http://www.mail-archive.com/pysoy-svn@pysoy.org/msg00761.html
PangoOpenGLRenderer A tale of
http://mail.gnome.org/archives/gtk-i18n-list/2006-July/msg00002.html

http://behdad.org/text/
http://software.schmorp.de/pkg/deliantra/Deliantra-Client.html

Thebes: alternative to Pango used in Mozilla
http://mxr.mozilla.org/seamonkey/source/gfx/src/thebes/
https://developer.mozilla.org/devnews/index.php/2007/12/17/aboutmozilla-beta-2-shipping-firefox-3-icon-preview-add-ons-compatibility-gfx-architecture-and-more/#gfx
http://blog.vlad1.com/2007/12/11/graphics-in-mozilla/

http://people.redhat.com/otaylor/gtk/guadec2-i18n/

Cairo vs. Qt
https://www.kitware.com/InfovisWiki/index.php/Cairo_rendering

http://kcchao.wikidot.com/gtk

Some text layouting link
• http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=CmplxRndExamples
The main characteristics of CTL language complexity are:
    * Bi-directional text, where characters may be written from either right-to-left or left-to-right direction.
    * Context-sensitive shaping (ligatures), where a character may change its shape, dependent on its location and/or the surrounding characters. For example, a character in Arabic script can have at least four different shape forms, depending on context.
    * Ordering, the displayed order of the characters is not the same as the logical order. For example, in Devanagari, which is written from left to right, the grapheme for "short i" appears to the left of ("before") the preceding consonant: in कि ki, the ि -i should render on the left, its bow reaching until above the क k- to the right.


FreeType
Performs font rasterization. Given font data (file or data in memory), it does simple (non-complex) mapping of Unicode characters to glyph indices and rendering glyphs to images.
Fontconfig
Performs font selection based on a pattern of desired font characteristics. These characteristics typically include a family name, style, weight, slant, size, as well as language. Font configuration happens by way of a set of very expressive XML rules. Fontconfig uses FreeType to inspect fonts and caches the results in an mmap()able architecture-specific binary cache.
FriBidi
GNU FriBidi is an implementation of the Unicode Bidirectional Algorithm. Pango uses FriBidi and has an internal copy of it. AbiWord is the other major user of FriBidi. Many other projects use FriBidi as the simplest route to add support for Hebrew and Arabic scripts without adding support for a full complex text rendering engine.
HarfBuzz
HarfBuzz is the meat of the modern GNU/Linux text rendering stack. With OpenType emerging as the universal font format supporting complex text rendering, HarfBuzz, as an OpenType Layout engine, is where all the magic happens. In fact it is of such importance to the stack that it deserves an entire section of its own in this document.
Pango
Pango is, for the most part, the roof of the text rendering stack. Components sitting on top of Pango (eg. GTK+) need not know about complexities of i18n text and are expected to simply use these opaque objects called PangoLayout's. Pango has been designed to satisfy GTK+'s needs for i18n text. However, Pango still provides a low-level API on which one can build their own layout engine. This is what Firefox, Webkit-GTK, etc do, but it has proved to be a cumbersome practice. We will expand on that later.


A good link on software stack - http://maemo.org/maemo_release_documentation/maemo4.1.x/node6.html

Jan 3, 2010

Setup Buildroot for Beagleboard Development

Currently, when development with Beagleboard we often use OE distribution. The OE is hard to maintain for
me, and it requires to open everything so that I use buildroot to develop on Beagleboard.

Here is how to setup one.
1) Download the buildroot from http://www.buildroot.org/
2) You might want to use external toolchain by downloading the ARM toolchain from CodeSourcery (http://www.codesourcery.com/) or build using crosstool-ng
3) You might also want to use the omap linux kernel by downloading it using git (git clone git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git)
4) Extract the buildroot into a folder and type `make menuconfig` to configure it.
   * Target Architecture: arm
   * Target Architecture Variant: generic_arm
   * Target ABI: EABI
   * For my Beagleboard, I need to configure the Target Options > Generic serial port config (y) > and change Serial port to run a getty on to (ttyS2) instead of (ttyS0)
      - If using ttyS0, the my board cannot boot and stuck at `ip: RTNETLINK answers: File exists` (http://forums.xilinx.com/xlnx/board/message?board.id=ELINUX&thread.id=1677)
   * Go to Toolchain settings
      - If you are using External Toolchain, select Toolchain type to External binary toolchain and set the External toolchain path to correct path of your toolchain (i.e. /usr/local/xtools/armunknownlinuxuclibcgnueabi. This is my crosstool-ng installed location)
      - If you are using Internal Toolchain (the toolchain built by buildroot), select  Toolchain type to Buildroot toolchain.

    * Go to Target filesystem options and select the target fs to build.
      - If you are building the u-boot, you need to enter the Das U-Boot Monitor and select
         + board name: omap3_beagle
    * Go to kernel settings
      - If you are using Internal Kernel, select Kernel type to linux (Advanced Configuration) and select the kernel version as well as the configuration file to use (in the Linux Kernel Configuration), I copied the omap3_beagle_defconfig from arch/arm/configs to a specified location and customized it.
      - If you are using External Kernel, select Kernel type to none.
5) Save the configuration and type `make` to build the system. After finished, the image is located at binaries/[project_name]/

NOTE:
   + If using external kernel, you will need to copy the kernel module into the root filesystem at project_build_arm/[project_name]/root or into the NFS root folder. (in kernel folder: make ... INSTALL_MOD_PATH=...)
   + The crosstool-ng cannot compile the uboot because of some bugs (http://old.nabble.com/-U-Boot---PATCH-2-2--ARM:-fix-build-error-with-gcc-4.4.2-about-inline-function-declared-weak-p26188857.html)

TODO:
   + The internal kernel is getting from kernel.org and doesn't contain the patches for omap platform. Need to sync with omap git repository to create the patch and put it under the target/.../ folder inside the buildroot
   + The internal toolchain is generic arm, and does not have omap specified optimization, need to sync with OE repository to create the patch and put it under the toolchain/.../ folder inside the buildroot
   + The internal kernel cannot have USB Gadget Driver, maybe missing some patch for omap
   + Add _defconfig (or board specific into the buildroot)

Sep 8, 2009

How to build Valgrind for Beagleboard

1) Get Valgrind source code from SVN using revision 9648 and 1888 for VEX
svn co -r 9648 svn://svn.valgrind.org/valgrind/trunk
cd VEX
svn update -r 1888


3) Apply the patch into the source code
cd valgrind
patch -p1 < [path to the patch]

4) Run autogen.sh to run autotools

5) Configure the source code
./configure --host=arm-angstrom-linux-gnueabi

The patch still has some bugs such as CPU instruction alignment you can 'cat /proc/cpu/alignment' to find out if the kernel is configured to fix unaligned accesses, and you can enable it by executing 'echo 2 > /proc/cpu/alignment' but it's enough to use for simple application.
Have fun with Valgrind :-)

Sep 4, 2009

How to build Clutter for Beagleboard

The Clutter need to be configured with =flavour=eglnative= so that it can work with SGX driver
The following is the configure command
./configure --with-flavour=eglnative --host=arm-angstrom-linux-gnueabi PKG_CONFIG=/data/workspace/OE/tmp/staging/i686-linux/usr/bin/pkg-config PKG_CONFIG_PATH=/data/workspace/OE/tmp/staging/armv7a-angstrom-linux-gnueabi/usr/lib/pkgconfig CFLAGS="--sysroot=/data/workspace/OE/tmp/staging/armv7a-angstrom-linux-gnueabi/ -I/data/workspace/OE/tmp/staging/armv7a-angstrom-linux-gnueabi/usr/include" --with-x=no --with-gles=1.1 --with-imagebackend=internal

with
  • --host: set the target for the build, need to be arm-angstrom-linux-gnueabi
  • PKG_CONFIG: use the pgk-config command from OE distribution
  • PKG_CONFIG_PATH: the path to search for *.pc file, need to be pointed to OE distribution
  • --with-x: not using X
  • --with-imagebackend: specific the image backend to use
  • --with-gles: specific the GLES version to use (1.1 or 2.0)
  • CFLAGS: override some C compiler flags
  • --sysroot: the root directory to search for library and header files
  • -I[include_dir]: some optional include directories to search for