Main Contents

Using Neo Free Runner as Daily Phone

August 29, 2008

I used the Om2008.8-update as the base image, then modify it for daily usage.

First of all I would like to use the illume default keyboard instead of the qtopia one because it gets a full-qwerty layout and it’s more suitable for terminal application. It also gives me access to illume configuration besides of the default ‘Settings’ application, which is not enough for advance usage. To do this, you need to switch to the testing repository.

  • backup the original /etc/opkg directory. cp -r /etc/opkg /etc/opkg.orig
  • replace all urls under /etc/opkg to the testing repository

Then remove all the illume related packages and install the new ones.

  • opkg list_installed | grep illume | awk ‘{print $1}’ | xargs opkg -force-depends remove
  • opkg update; opkg install illume-theme-asu; opkg install illume
  • opkg list_installed | grep libe | grep cvs | awk ‘{print $1}’ | xargs opkg install

Now delete the old configs and switch to the illume default profile.

  • rm -rf ~/.e
  • replace ‘asu’ by ‘illume’ in /etc/enlightenment/default_profile

Prevent the qtopia keyboard from showing up:

  • Add “export QTOPIA_NO_VIRTUAL_KEYBOARD=1″ into /etc/X11/Xsession.d/89qtopia

The second thing I did is to lower the volume of gsm handset. The original setting is so loud that everyone around me can hear the caller talking.

  • (call someone)
  • run alsamixer
  • scroll to the right end, lower the “Speaker” volume. You can do this while talking to test the value.
  • alsactl store -f /usr/share/openmoko/scenarios/gsmhandset.state
  • (hang up)

I also need Chinese font so I can read the sms messages.

  • (on host) scp <chinese_font.ttf> root@192.168.0.202:
  • mv ~/<chinese_font.ttf> /usr/share/fonts/truetype
  • vi /opt/Qtopia/etc/default/Trolltech/qpe.conf , find [Font], change FontFamily[] to the name of the ttf. (not the filename)

Change back to the default om2008.8 repository.

  • mv /etc/opkg /etc/opkg.testing
  • mv /etc/opkg.orig /etc/opkg

Reboot.

Filed under: Openmoko | Comments (5)

git clone –mirror

August 27, 2008

It seems there will be a new option for git-clone, ‘–mirror’. The command line

$ git clone --mirror $URL

is now a short-hand for

$ git clone --bare $URL
$ (cd $(basename $URL) && git remote add --mirror origin $URL)

Refer to http://kerneltrap.org/mailarchive/git/2008/8/2/2793244 about this.

This is extremely useful if you need to check the contents of different branches in different directories at the same time. Each directory will be a local git clone -l -s, and git push will use –mirror as well by default.

Filed under: scm | Comments (0)

bug in python-opengl + mesa

August 20, 2008

Since like forever, I have never succeed in executing python-opengl demos on debian lenny.  It always segfault during glutInitDisplayMode.  After some debugging, here is why.

One should be able to call glGetError at any time.  If there’s nothing wrong, it should just return something like GLNOERROR.  Any raw (native) function call in python-opengl, no matter it belongs to GL, GLU or GLUT, will always call glGetError right after each call to check for error.  I think this is wrong since functions like glutInitDisplayMode have NOTHING to do with glGetError.  With mesa 7.0.3-5 in my system, the call to glGetError without glInit will cause segfault.  I check the same thing on Ubuntu, which has an older version of mesa and python-opengl, and it does not happen.

python-opengl enabled error checking by default with OpenGL.ERROR_CHECKING, which is set to True in OpenGL/__init__.py.  This code snippet can disable it:

import OpenGL
OpenGL.ERROR_CHECKING = False
# import other stuffs such as OpenGL.GL, etc.

or you can just modify the __init__.py to disable it by default.

Given the current status of python-opengl and low level x protocol support in python, I think the best language to do 3D in FOSS world will still be pure simple C.

Filed under: OpenGL, C, python | Comments (0)

oprofile

August 5, 2008

First you have to enable oprofile in your kernel, i.e. you must have

CONFIG_PROFILING=y
CONFIG_OPROFILE=y

in your kernel config. Then you need userspace utilities to use it. I used oprofile 0.9.4. First of all you need to setup it with something like

opcontrol --init
opcontrol --no-vmlinux
opcontrol --callgraph=5

After that, here is the script I used to do profiling against a program:

john@buddha:~$ cat bin/profile
#!/bin/sh

which sudo && SUDO=sudo || SUDO=

${SUDO} opcontrol --shutdown
${SUDO} rm -rf /var/lib/oprofile/*
${SUDO} opcontrol --status
${SUDO} opcontrol --start-daemon
${SUDO} opcontrol --start
$@
${SUDO} opcontrol --stop
${SUDO} opcontrol --dump
${SUDO} opcontrol --shutdown

Use ‘profile <the name of your executable>’ to get the profile. Use ‘opreport’ to read the result. ‘opreport -l’ might be more meaningful. You can use ‘opreport <the name of your executable>’ to only get the result related to your program, but personally I prefer to check the whole system.

Filed under: system | Comments (0)

generate object methods at runtime

June 19, 2008

I have been working on a dialer button class since yesterday. It makes sense to use the command design pattern here, and I want to separate the commands and the buttons so I can change the functionality of every button at runtime.

So we are talking about something like this:

class DialerButtons:
    def __init__(self):
        self.command_table = [
            self.numpad_1, self.numpad_2, self.numpad_3,
            self.numpad_4, self.numpad_5, self.numpad_6,
            self.numpad_7, self.numpad_8, self.numpad_9,
            self.cancel, self.numpad_0, self.dial]

    def numpad_0(self):
        self.text.append('0')

    def execute(self, n):
        self.command_table[n]()

<snipped>

and you can use this class like this:

dialer = DialerButtons()
dialer.execute(0)
dialer.execute(8)
....

Now obviously define numpad_0 to numpad_9 is a boring task. What happens if you need to define numpad 0 to 99? So, I came out with this code piece:

    @classmethod
    def _numpad_commands_factory(cls):
        for n in xrange(0, 10):
            setattr(cls, 'numpad_%d' % n, lambda self: self.text.append(str(n)))
...
DialerButtons._numpad_commands_factory()

This way you initialize DialerButtons AFTER you start the program and make methods numpad_0 to 9 on the fly. At least that’s what I was trying to do. However, it didn’t come out as I expected. Every numpad method will just add ‘9′ to self.text, instead of the respective ‘0′ to ‘9′. Why?

The reason is that the context of numpad_0, for example, is actually “f(self): self.text.append(str(n)))” instead of “f(self): self.text.append(’0′)”. so, what it does here is that it refers to the variable n inside _numpad_commands_factory, and the value of n is 9 after you executed it.

The correct code piece is:

    @classmethod
    def _numpad_commands_factory(cls):
        def f(chr):
            return lambda self: self.text.append(chr)
        for n in xrange(0, 10):
            setattr(cls, 'numpad_%d' % n, f(str(n)))

This way we can evaluate the value of str(n) first, then generate the appropriate function and assign it to numpad_n.

Filed under: programming, python | Comments (0)

python-efl on ubuntu gutsy

June 14, 2008

hey if you have a extremely slow laptop (Pentium III) like me yet you still want to use python-efl on it, here is how.

first, compiling the whole e17 from scratch is not an option. it will take forever. there’s a ubuntu package repository for e17:

$ cat /etc/apt/sources.list.d/e17.list
deb http://e17.dunnewind.net/ubuntu gutsy e17
deb-src http://e17.dunnewind.net/ubuntu gutsy e17
$ sudo apt-get update
$ sudo apt-get install efl-dev libecore-imf-evas-dev

this can save a lot of time.

the other problem is that the latest cython release (0.9.8) does NOT work with python-efl. you have to install 0.9.6.14 instead. don’t forget to install python-pyrex as well.

now you’re all set, get python-efl.

cvs -d :pserver:anonymous@anoncvs.enlightenment.org:/var/cvs/e login
cvs -z3 -d :pserver:anonymous@anoncvs.enlightenment.org:/var/cvs/e co e17

it’s under e17/proto/python-efl. another funny gotcha is that the binary packages I installed were built on 20080309. so the latest python-efl will not build successfully.

cvs -z3 update -dP -D 20080309

fixs this.

the default build-all.sh under python-efl directory builds evas ecore edje emotion e_dbus epsilon. that’s too many. for me I just need evas ecore edje e_dbus.

Filed under: python | Comments (3)

Intel onboard graphic chip + compiz

June 6, 2008

it’s a really bad combination. not so long ago the driver changed default from XAA to EXA, thus my fonts disappeared. after the last update, now compiz just keeps telling me it cannot load cpp plugin and fails to start.

guess the compiz guys put this chip(8086:2992) in their blacklist for a reason. damn, I really need compiz!

Filed under: linux hardware | Comments (0)

git first, git-svn later.

June 5, 2008

the whole story is that I started a project locally and I used git as my SCM. now I’m going to put it into a svn repository with full history but I still want to use git.

normally you should make this decision at the beginning. that means you
git-svn clone http://svn.somewhere.com/myproject
first, then you use git as usual, do git-svn rebase and git-svn dcommit. you have to do this because git-svn must know where to start, namely you should have at least one git-svn-id in your git log to start with.

here is how I add svn support into an existing git repository. basically it’s easy, you just
git-svn init http://svn.somewhere.com/myproject
git-svn fetch

now git branch -r should tell you there is a branch called git-svn. you git rebase git-svn your current master. if it succeeded then you’re all set.

however, in order to do this, there must be a point back in time that these two branches are the same. if it’s not the case, you’re in trouble. you have to use git-svn set-tree to force a svn commit to be your starting point. in my case, the svn repository started out empty, so I forced the first commit in my git. after that git rebase succeeded like I expected.

Filed under: scm | Comments (1)

fonts disappeared part II

May 15, 2008

It turns out the default AccelMethod of xdriver “intel” has been changed to EXA, and it’s a known issue that EXA does not work with compiz. So I force the AccelMethod to “XAA” and compiz works again now.

Filed under: linux hardware | Comments (1)

fonts disappeared

May 12, 2008

I’m using debian testing (lenny) and after the latest update my xserver no longer display fonts. This is not totally true because I can still see the fonts on gdm, but after logging in, no fonts whatsoever. It turns out the i810 Xorg driver is messed up and I have to set NoAccel to true to avoid it.

Section "Device"
        Identifier      "Intel Corporation 82Q963/Q965 Integrated Graphics Controller"
        Driver          "i810"
        BusID           "PCI:0:2:0"
        Option          "NoAccel"       "true"
#       Option          "AccelMethod"           "EXA"
        Option          "XAANoOffscreenPixmaps"
EndSection

BTW I can use compiz without NoAccel before if I delete the device id from the blacklist in compiz start up script.

Filed under: linux hardware | Comments (0)