TuxScreen on SourceForge TuxScreen CVS search the Wiki
Browsing -> Wiki -> Main -> [BuildingTinyXByHand]
edit, info, topics, orphans, hubs and nodes, or recent changes in the Wiki create a new user or login

How I build TinyX against uClibc for TuxScreen

by DwayneFontenot (jacques)

1) obtain and install a cross-compile toolchain

ftp://ftp.arm.linux.org.uk/pub/armlinux/toolchain/ or http://intimate.handhelds.org/jacques/xchain6-i386.tar.bz2

remember to add the path to arm-linux-gcc to your PATH

Why? we are going to cross-compile: i386 host, ARM target

2) obtain buildroot-tux

cvs -d:pserver:anonymous@cvs.tuxscreen.sourceforge.net:/cvsroot/tuxscreen login

# press enter at pasword prompt

cvs -z3 -d:pserver:anonymous@cvs.tuxscreen.sourceforge.net:/cvsroot/tuxscreen co buildroot-tux

cd buildroot-tux ; make

Why? this will build uClibc which we are going to link Xfree against as well as the gcc wrappers

3) modify buildroot-tux to build the full math library (libm)
add these lines to buildroot-tux/sources/uClibc.patch

NOTE: this sub-step is no longer required as recent buildroot-tux enables the full math lib by default.

@@ -70,7 +70,7 @@

 # Set to `true' if you want the math library to contain the full set
 # of C99 math library features.  Costs an extra 35k or so on x86.
-DO_C99_MATH = false
+DO_C99_MATH = true

 # Set this to `false' if you don't have/need "(unsigned) long long int" support.
 # Set it to `true' otherwise.

Why? the small version of the uClibc libm does not include cbrt nor hypot. Xfree can use its own cbrt but not hypot. It's possible to build a "small" version of uClibc libm with only hypot added, but I didn't bother since it's 21kB vs. 55kB.

cp /usr/local/arm/arm-linux/include/linux/h3600_ts.h buildroot-tux/staging_dir/include/linux

Why? the tinX touchscreen driver requires this file even when not building an ipaq-specific server.

4) obtain the xfree source (note ts broke in CVS on 10-11-2001) http://intimate.handhelds.org/jacques/xc-011010.tar.bz2 or


export CVSROOT=:pserver:anoncvs@anoncvs2.xfree86.org:/cvs

# password is 'anoncvs'
cvs login

cvs -z 3 co -D "October 10, 2001" xc/config
cvs -z 3 co -D "October 10, 2001" xc/util
cvs -z 3 co -D "October 10, 2001" xc/extras
cvs -z 3 co -D "October 10, 2001" xc/include
cvs -z 3 co -D "October 10, 2001" xc/lib
cvs -z 3 co -D "October 10, 2001" xc/programs
cvs -z 3 co -D "October 10, 2001" xc/nls
cvs -z 3 co -D "October 10, 2001" xc/Imakefile
cvs -z 3 co -D "October 10, 2001" xc/Makefile

Why? the cvs xfree ts driver was broken on October 11th, 2001. For a long time it would not even compile. It has recently been patched to compile but does not work AFAICT. So we use source from before the change.

5) patch xfree source KenRestivo adds: jacques confirms that you need to remove the existing #ifndefs and #ifdefs around these functions, and force them to be defined here. Also, on my sourceball, mbstowcs wasn't even there, I was adding it for the first time (not just changing the #ifdefs) lib/X11/Xlib.h

#if 1
#define wctomb(a,b)     _Xwctomb(a,b)
#define mblen(a,b)      _Xmblen(a,b)
#define mbtowc(a,b,c)   _Xmbtowc(a,b,c)
#define mbstowcs(a,b,c) _Xmbstowcs(a,b,c)


comment out the prototypes for the above functions from uClibc KenRestivo adds: jacques also notes you must define MB_CUR_MAX to be 2, and remove the prototype for __ctype_get_mb_cur_max. Why? uClibc has protos for these functions but no actual code and uClibc's protos clash with Xfree's when using Xfree's internal versions KenRestivo adds: and on uClibc-0.9.9, it looks like the wctomb, mblen, mbtowc, and mbstowcs have already been commented out by andersee. Cool.

the library in xc/lib/Xext may refuse to build if you don't have the latest X headers installed on your system because it uses an absolute path instead of relative. this is a bug in xfree source which can be fixed by changing the #include <X11/extensions/XLbx.h> in xc/include/extensions/lbxstr.h to be #include "XLbx.h"

also, somewhere you may need to add #include <sys/types.h> to fbdev.h

Why? standard xfree cvs breakage I guess

6) configure xfree

copy these files into xc/config/cf




7) build xfree

cd xc ; make World

8) manually link Xfbdev

a) the quick and dirty way: cd xc/programs/Xserver, add dix/main.o to the link line

b) the more elegant way cd to xc/programs/Xserve/dix, rm libdix.a, make -n to see what would normally be done, do th -n to see what would normally be done, do the same but removing main.o from the lib, then do the above manual link in xc/progams/Xserver.

Why? not exactly sure but the link returns "undefined function main()" unless the link is done like this. KenRestivo adds: the build of ts.c was failing, complaining about not being able to find linux/h3600_ts.h. So I had to manually go into xc/programs/Xserver/hw/kdrive/linux and execute the gcc line with the manual inclusion of -I/dir/to/buildroot/linux/include . This was an alternative to the step (3) listed above.

9) strip to taste

/foo/buildroot-tux/staging_dir/usr/bin/arm-uclibc-strip -x --strip-unneeded --remove-section=.note --remove-section=.comment Xfbdev

The End
15-1-2002 RSneekes adds: After peforming these steps I got an error during the build about __ctype_get_mb_cur_max(). I added a dummy function somewhere in uClibc that justs returns 0. After I did this the TinyX compiled (except for the linking described above). KenRestivo adds: jacques confirmed that commenting the prototype out of stdlib.h is another way to take care of this problem. When I (finnally) got Xfbdev compiled, the touchscreen didn't work for me (kernel 2.4.16-rmk2-tux1). In http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel/2001-November/006012.html I found some usefull stuff.

* I changed the TS_EVENT structures in buildroot-tux/staging-dir/include/linux/h3600_ts.h to be:

typedef struct {
         unsigned short          pressure;
         unsigned short          x;
         unsigned short          y;
         unsigned short          pad;
         struct timeval  stamp;

* In xc/programs/Xserver/hw/kdrive/linux/ts.c I changed the TsRead function in the following:

TsRead (int tsPort, void *closure)
    TS_EVENT        event;
    long            buf[3];
    int             n;
    long            pressure;
    long            x, y;
    unsigned long   flags;
    unsigned long   buttons;

    //perror("in TsReadn");
    n = Ps2ReadBytes (tsPort, (char *) &event,
                         sizeof (event), sizeof (event));
    if (n >= sizeof (event))
        //perror("in n==sizeofn");
        if (event.pressure >= 100)
           flags = KD_BUTTON_1;
           x = (930 - event.x) * 640 / (900);
           y = (930 - event.y) * 480 / (900); //event.y;
           //ErrorF("flags %d x %d y %dn",flags,event.x,event.y);
          flags = KD_MOUSE_DELTA;
          x = lastx;
          y = lasty;

        //perror("Send mouse eventn");
        KdEnqueueMouseEvent (flags, x, y);

After this I finnaly had a working TinyX, except for a couple of applications that didn't compile. I also had problems compiling against uClibc 0.9.8, but haven't looked into it yet.

SourceForge Content of these pages are owned and copyrighted by the poster. SourceForge