Moving to Debian on my Neo Freerunner

12 February 2009, 20:54 UTC

My Freerunner now runs Debian, which was an educational experience - and education is always a good thing.

But there is a bit of an irony here.

I changed to Debian because of the wealth of packages available. While Open Embedded (which is the base for the FSO distro that I was using) packages lots of stuff, it doesn't package everything. In particular it didn't seem to package python-xlib which I wanted so that I could play with fakekey-like keystroke generation using python code base on pykey by the author of crikey.

So now I have Debian and python-xlib and I am happy. But a problem is that a lot of the toys that people are writing for the Freerunner (like the python EFL Sudoku or the Neon image viewer) are only being packaged as ipk files for the Open Embedded distros. So if I want them I probably have to install by hand or package them myself.

So did I increase the range of available packages by going to Debian, or decrease it?

Distro Size

One of the reasons that I hadn't tried Debian before (despite using it regularly on other computers) is that I had the impression that it was too big for the internal flash, and I really don't want to boot off the Micro-SD card. I really would like to keep a distinction of system software internally and user-data on the card.

But it turns out I was wrong. The internal flash is only 256M (246M available for the root filesystem), and a Debian distro with useful stuff is easily into the 300M range. But it still fits. This is thanks to JFFS2. I think part of the saving comes from the fact that 300M is measured on ext2 where everything is being rounded to multiples of 4K where as JFFS2 doesn't do that. But I believe a lot of it comes from the fact that JFFS2 supports compression, and there is typically lots of opportunity for compression in a lot of files stored in a standard distro.

So while df currently reports

Filesystem 1K-blocks Used Available Use% Mounted on

rootfs 252544 137284 115260 55% /

for my root filesystem, du -x -s / reports 263427. i.e. df say I have used around half of what du reports.

I discovered this by reading the wiki page which doesn't make this crystal clear, but points in that direction and gives lots of useful information about the transition to flash.


So I installed Debian on my MicroSD card as described in the main
Debian On Freerunner [url] page, made a few changes as I will describe below, and transferred it to flash with relative little difficulty.

My biggest problem was that I re-flashed the kernel at the same time with the latest from andy-tracking and it wouldn't boot. I eventually discovered I had managed to get a partial download. Once I downloaded the full file and flashed that, it booted nicely.

The install script.

The script you download from does most of the work for setting up your initial installation. There were a couple of problems with it when I ran it (e.g. it assumes tar understands -z which my busybox tar didn't) but those seem to have been fixed, which is nice.

Make sure you think through your choices for the different configuration variables and don't assume that the defaults will work for you. I'm using the Qi boot loader so I had to set that, and it would have been easier if I had set the SINGLE_PART flag as well, but it wasn't a big problem. And for me, DASH_BINSH is definitely not wanted. I'd much rather pay the extra memory cost of using bash and have real history editing available.

Adding and removing packages

I chose to remove fso-frameworkd and zhone, because my current project is to write a phone-stack myself (without using D-Bus). One problem with this is that it removed fso-config-gta02 which contained the /usr/share/openmoko/scenarios files which I am likely to need (And in the FSO distribution are packaged separately). So I made sure to take a copy of those.

Once I had removed these, apt offered to remove a whole lot of other stuff that it thought I might not need any more. I kept python-gst10.0, python-gtk, apmd and maybe a couple of others but let it remove the rest.

I then added gcc libc6-dev nfs-utils less lsof x11-utils gpsd telnet tangogps xserver-xglamo mplayer ntpdate bc iw wireless-tools wpasupplicant openvpn udhcpc udhcpd and possibly a few other -dev libraries so I could compile some things I wanted. xserver-glamo seems an odd thing to leave out of the 'standard' install - it goes much faster than the generic xserver, and supported screen rotation. The rest are just things that I like to be present.

Touchscreen calibration

Once I installed xserver-xglamo, the touchscreen stopped working! Or more accurately, it thought I was touching somewhere completely different to where I was really touching. The problem was that 'tslib' which xglamo uses needs to be calibrated, and I didn't have the calibration file installed. There is probably a program somewhere to calibrate it but I couldn't find it quickly so I just copied /etc/pointercal from my previous root filesystem (which I had carefully saved). The contents (in case you lost yours) are:

557 38667 -4654632 -51172 121 46965312 65536

tty devices

I quickly found that gpsd and [gsm0710muxd] couldn't find their devices. They were looking for files names /dev/ttySAC{0,1} and they didn't exist. Rather, I had /dev/s3c2410_serial{0,1,2} instead. This can be fixed by adding the line
KERNEL=="s3c2410_serial[0_9]", NAME="ttySAC%n" somewhere in /etc/udev/rules.d. I put it in a file called 56-ttySAC.rules though anywhere would probably do. Possibly this is something else I lost by discarding the fso-config package.

apt caches

The MovingToFlash wiki page mentioned above suggests making /var/lib/apt/lists and /var/cache/apt tmpfs mounts to save space. I definitely like the idea of not having these on my root filesystem, but I didn't want to discard them completely. So I symlinked them to a directory on /media/card where I have more space, and less concern about extra write cycles. Even after an apt-get clean there is 51 Megabytes in those two directories.

Setting the DPI for X

This is something that I don't have a happy solution for. And I'm a bit confused about.

The X server allows you to specify the screen resolution in Dots-Per-Inch, and applications can query this. The FSO distro sets this to 285 which is the actual resolution of the device. Xglamo seems to sometimes work that out itself, and sometimes fall back to a default of 75dpi (a very big difference). So I set it explicitly in /etc/init.d/nodm in the X_OPTIONS variable.

The problem with 'dpi' and that many applications, including gtk based apps and probably most things that use pango in any way, automatically scale the fonts based on the 'dpi'. And they do this with the assumption that the display is a regular computer monitor and that you want the physical size of your fonts to be appropriate for such a device. But I tend to hold my freerunner closer to my eyes than I hold my computer monitor, so the visual size is larger for the same physical size. One way to adjust for this is to reduce the 'dpi', but that is lying, and I don't like to do that.

Another confusion is that while tangogps (a gtk app) had fonts that were just the right size for a 285dpi 480x640 display on fso, the same size and dpi produces different fonts on Debian. I have no idea what is causing that! After some experimentation I found that a DPI setting of about 150 produced fonts in tangogps that looked OK. Weird.

For my own programs, I've been setting the font size in pixels where I can. But that is not always easy to do unfortunately. I really don't know what a good solution to this problem is.


And that is about it for setting up Debian.

One thing I still need to worry about is /var/log. I don't really want boring log files to be written to my valuable flash all the time, but I don't want to discard it completely yet. Just something else I have to think about.

Having done all that, I then started adding my own little toys as I am describing bit by bit else where on this blog. The device doesn't work at all as a "Phone" as yet, but I wasn't expecting that. It is certainly a fun toy to play with.