Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
731 lines (510 sloc) 23 KB
Debian rootfs
Step 0 - QEMU image for creating rootfs
* I used to create images straight on the device, but i dont do it anymore.
* Easiest way to create tarbal and NAND images is in qemu. You can download my
preinstalled qemu image from:
* Unpack the tarball, install qemu and run ./
* After the system is started you can use redirected port to ssh there:
ssh -p 22222 root@localhost
please note that the root password is empty.
* The system is very minimal, download more packages:
apt-get update
apt-get install multistrap cdebootstrap mtd-utils
Step 1
* We will be installing new image to /media/card:
cd ~
cat > multistrap.conf << __END__
aptsources=Grip Debian
debootstrap=Grip Debian
packages=openssh-server libts-0.0-0 udhcpc iputils-ping liblcms1 libexpat1 omhacks
packages=ifupdown net-tools procps netbase nano module-init-tools wget screen mc wpasupplicant wireless-tools iproute dosfstools fbset rsyslog psmisc iptables dash ttf-dejavu libpng12-0 libjpeg8 libxtst6 sqlite3 ntpdate libmng1 libtiff4 libvorbisfile3 libicu48 gpsd ppp rfkill libasound2 alsa-utils libcap-ng0 libcap2 libsystemd-login0 dbus libgstreamer-plugins-base0.10-0
multistrap -f multistrap.conf
Step 1.2 - modified packages
* wpa_supplicant has non upstream patch, bluez and gpsd-clients have useless
python dependencies. See step 14 and 15 below how they are built.
cd /media/card
mount -t proc none /media/card/proc
chroot /media/card
dpkg -i gpsd-clients_3.6-4+deb7u1_armel.deb
dpkg -i wpasupplicant_1.0-3_armel.deb
dpkg -i bluez_4.99-2_armel.deb
/etc/init.d/bluetooth stop
dpkg -i bluez-alsa_4.99-2_armel.deb
umount /media/card/proc
rm gpsd-clients_3.6-4+deb7u1_armel.deb
rm wpasupplicant_1.0-3_armel.deb
rm bluez_4.99-2_armel.deb
rm bluez-alsa_4.99-2_armel.deb
Step 2
* Complete installation. Copy paste below in shell:
mkdir /media/card/mnt/nfs
mkdir /media/card/mnt/p1
mkdir /media/card/mnt/p2
mkdir /media/card/mnt/p3
mkdir /media/card/media/card
echo "neo" > /media/card/etc/hostname
echo " neo" >> /media/card/etc/hosts
cat > /media/card/etc/network/interfaces <<__END__
auto lo
iface lo inet loopback
auto usb0
iface usb0 inet static
up rm /etc/resolv.conf
up echo nameserver >/etc/resolv.conf
cat > /media/card/etc/fstab << __END__
rootfs / auto defaults,errors=remount-ro,noatime 0 1
/dev/mmcblk0p1 /media/card auto defaults 0 0
/dev/mmcblk0p4 swap swap defaults 0 0
proc /proc proc defaults 0 0
#tmpfs /var/cache/apt tmpfs defaults,noatime 0 0 /mnt/nfs nfs noauto,nolock,soft,rsize=32768,wsize=32768 0 0
cat > /media/card/etc/apt/apt.conf.d/99no-install-recommends << __END__
APT::Install-Recommends "0";
sed -i 's/\(PermitEmptyPasswords\) no/\1 yes/' /media/card/etc/ssh/sshd_config
chroot /media/card /bin/sh -e <<__END_CHROOT__
echo root: root | chpasswd
sed -i 's/root:.*/root:C0XOiCyzQDtsA:14973:0:99999:7:::/' /etc/shadow
Step 3 - add more package repositories
echo "deb wheezy contrib" >> /media/card/etc/apt/sources.list
echo "deb wheezy non-free" >> /media/card/etc/apt/sources.list
echo "deb wheezy/updates main contrib non-free" >> /media/card/etc/apt/sources.list
echo "deb /" >> /media/card/etc/apt/sources.list
echo "deb /" >> /media/card/etc/apt/sources.list
echo "deb /" >> /media/card/etc/apt/sources.list
Step 4
* Device drivers modules. Most of device drivers are built in kernel, but
following drivers are exception. g_ether is module so that we can switch
between mass storage and with ppp_generic saves space so that we fit under
2MB u-boot limit.
echo g_ether > /media/card/etc/modules
echo ppp_generic >> /media/card/etc/modules
echo bq27x00_battery >> /media/card/etc/modules
echo ohci_hcd >> /media/card/etc/modules
echo ar6000 >> /media/card/etc/modules
echo btusb >> /media/card/etc/modules
echo bluetooth >> /media/card/etc/modules
echo snd-soc-neo1973-wm8753 >> /media/card/etc/modules
echo snd-soc-wm8753 >> /media/card/etc/modules
echo snd-soc-dfbmcs320 >> /media/card/etc/modules
echo snd_soc_s3c24xx >> /media/card/etc/modules
* Edit /media/card/etc/ppp/options and replace "auth" with "noauth"
nano /media/card/etc/ppp/options
* Create /media/card/etc/fb.modes
cat > /media/card/etc/fb.modes << __END__
mode "vga"
geometry 480 640 480 1280 16
timings 40816 8 16 2 16 8 2
rgba 5/11,6/5,5/0,0/0
mode "qvga"
geometry 480 640 480 1280 16
timings 100000 8 16 2 16 8 2
rgba 5/11,6/5,5/0,0/0
Calling "fbset qvga" and "echo qvga > /sys/class/lcd/jbt6k74-lcd/device/resolution"
is needed for mplayer in 320x240 with correct colors.
* Configure bluez4 for handsfreee calls, otherwise there is no sounds:
nano /media/card/etc/bluetooth/audio.conf
and uncomment SCORouting=PCM setting in [General]:
* Remove alsa-utils init scripts - we dont need them, we set correct alsa
state ourselves when qtmoko starts up:
chroot /media/card
update-rc.d -f alsa-utils remove
Step 4.5 - make it generate SSH keys on start
* SSH server keys are automatically generated during debootstrap. This can be
security problem if user does not regenerate them. So we delete old keys and
generate new ones during first boot.
rm /media/card/etc/ssh/ssh_host_*
cat > /media/card/etc/init.d/sshkeysfirstboot << __END__
# Provides: sshkeysfirstboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Generate SSH host keys on first boot
dpkg-reconfigure openssh-server
update-rc.d -f sshkeysfirstboot remove
rm -f /etc/init.d/sshkeysfirstboot
chmod +x /media/card/etc/init.d/sshkeysfirstboot
chroot /media/card
update-rc.d sshkeysfirstboot defaults
Step 4.6 - get rid of getty in inittab
* TTY's are for logging to console which is useful only if you have USB
keyboard. So tty respawning is in done in script and we can
comment it out from /etc/inittab:
nano /media/card/etc/inittab
and comment all lines with "respawn:/sbin/getty 38400 ttyX"
Step 4.7 - disable logging by defaults
* We will have syslogd and klogd disabled by default. If phone works it's not
needed and it saves flash memory from wearing off. It can be always enabled
in settings->logging or via devtools menu or with script.
chroot /media/card
update-rc.d -f rsyslog remove
Step 4.8 - fix GPRS stability
* Freerunner has problem with GPRS stability. This will limit max speed on ppp
insterface to 1000 bytes/s, with faster speed calypso crashes. For more info
cat > /media/card/etc/ppp/ip-up.d/09lindi-tc << __END__
/sbin/tc qdisc add dev ppp0 root tbf rate 7kbit latency 4500ms burst 3200
chmod +x /media/card/etc/ppp/ip-up.d/09lindi-tc
Step 5
* Set locale to get rid of apt-get warnings
echo "LANG=C" > /media/card/etc/default/locale
echo "LC_ALL=C" >> /media/card/etc/default/locale
* Fix incompatible libts version
cd /media/card/usr/lib
ln -s
* Remove .udev dir, that confuses udev. This dir is here after instalation and
causes some error/warnings during init. Not sure what's the exact problem.
cd /media/card/dev
rm -rf .udev
* Remove udev from startup scripts, we have devtmpfs in kernel and it's faster:
chroot /media/card
update-rc.d -f udev-mtab remove
update-rc.d -f udev remove
* Remove /etc/network/run and do make dir /etc/network/run
Otherwise fstab mounting will fail for this directory
rm /media/card/etc/network/run
mkdir /media/card/etc/network/run
Step 6.5 - configure gpsd
* We use gpsd and it has to be configured for Freerunner:
nano /media/card/etc/default/gpsd
* Make sure you have these values:
Step 7.5 - dash
* For faster boot (~15s) and more memory (+1MB) we use dash instead of bash.
cd /media/card/bin/
rm sh
ln -s dash sh
Step 8 - install QtMoko
* I use qemu armel host for building qtmoko package. It should be as simple as
git checkout v58
* Note that you may need to install some dependencies before building:
apt-get install libX11-dev libXext-dev libXtst-dev libasound2-dev libdbus-1-dev libts-dev libbluetooth-dev
...and checkout git submodules as it's necessary to place qt sources into qtmoko/qtopiacore/qt/:
git submodule update --init
* Please note that releases are made from translations branch so that we have
all languages.
* Now upload the package to sourceforge. In filezilla connect to sourceforge
sftp and upload it to /home/project-web/qtmoko/htdocs/debian
* Install it
chroot /media/card/
dpkg -i qtmoko-neo_58-1_armel.deb
update-rc.d qtmoko-neo defaults
rm qtmoko-neo_58-1_armel.deb
killall # recent versions start qtmoko after install, so kill it
rm -rf /media/card/home/root/* # remove all stuff created by qpe
Step 8.1 - install mokofaen theme
* Mokofaen is now default theme for qtmoko - but it's not part of qtmoko deb
package, so that user can uninstall it to save space. So install mokofaen:
cd /media/card
chroot /media/card/
dpkg -i qtmoko-theme-mokofaen_3-2_all.deb
rm qtmoko-theme-mokofaen_3-2_all.deb
Step 8.2 - some more alarm and ringtones
mkdir -p /media/card/home/root/Documents
cd /media/card/home/root/Documents
Step 9 - Linux kernel
* Sources for qtmoko are on github:
* Checkout branch for your qtmoko version:
git checkout v2.6.39-gta02-qtmoko-v58
* Create package in buildhost:
cd linux-2.6
* You should remove .git while building the package so that the tar with
sources is not that big. The package to sourceforge.
* Install kernel image:
chroot /media/card
dpkg -i linux-image-2.6.39-qtmoko-gta02_58-1_armel.deb
rm linux-image-2.6.39-qtmoko-gta02_58-1_armel.deb
* Create boot args and symlink for qi:
cd /media/card/boot
echo "console=tty0 loglevel=3 rootwait" > append-GTA02
ln -s uImage.bin uImage-GTA02.bin
Step 9.1 - Linux kernel cross compiling - not using anymore
* If you want to cross compile kernel and make uboot image on PC:
make CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- ARCH=arm gta02_defconfig
make -j8 CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- ARCH=arm uImage
make -j8 CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- ARCH=arm modules
make CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- ARCH=arm modules_install INSTALL_MOD_PATH=GTA02
Step 9.2 - import QtMoko debian repository public keys
* We use secure apt and we need keys for QtMoko repositories:
cd /media/card
chroot /media/card
apt-key add /qtmoko-pubring.gpg
rm qtmoko-pubring.gpg
Step 9.5 - remove bash history
* Remove .bash_history created during install
rm -f /media/card/root/.bash_history
Step 9.6 - setup default DNS
* So that internet works on neo, DNS used during installation is not working
e.g. when installing from qemu:
cat > /media/card/etc/resolv.conf <<__END__
Step 9.9 - enable ssh access just on usb
* SSH root access can be dangerous on wifi or on GPRS, so enable it only on usb0
echo "# Enable ssh access just on usb" >> /media/card/etc/rc.local
echo "ip6tables -A INPUT ! -i usb0 -p tcp --dport 22 -j REJECT --reject-with tcp-reset; iptables -A INPUT ! -i usb0 -p tcp --dport 22 -j REJECT --reject-with tcp-reset" >> /media/card/etc/rc.local
* Manually edit /media/card/etc/rc.local and move "exit" 0 to the end of file:
nano /media/card/etc/rc.local
Step 10 - release tarball
* Release tarbals are uploaded to sourceforge dir /home/frs/project/qtmoko/GTA02/
cd /media/card
tar -czvf ../qtmoko-debian-gta02-v58.tar.gz .
Step 11 - make ubifs images
* Delete contents of boot, because for NAND it's not needed:
rm -rf /media/card/boot/*
* Remove doc and stuff that is not needed and makes NAND image slower:
find /media/card/usr/share/locale/ -type f -exec rm -f '{}' \;
find /media/card/usr/share/doc/ -type f -exec rm -f '{}' \;
find /media/card/usr/share/doc-base/ -type f -exec rm -f '{}' \;
find /media/card/usr/share/info/ -type f -exec rm -f '{}' \;
find /media/card/usr/share/man/ -type f -exec rm -f '{}' \;
rm -rf /media/card/usr/share/sounds/alsa/*
rm -rf /media/card/usr/share/ssh/blacklist*
* We need just 3 fonts
cd /media/card/usr/share/fonts/truetype/ttf-dejavu/
mv DejaVuSansCondensed-Bold.ttf 1
mv DejaVuSansCondensed.ttf 2
mv DejaVuSansMono.ttf 3
rm *.ttf
mv 1 DejaVuSansCondensed-Bold.ttf
mv 2 DejaVuSansCondensed.ttf
mv 3 DejaVuSansMono.ttf
* Trim down midnight commander
mkdir /media/card/usr/share/mc-new
cp /media/card/usr/share/mc/mc.* /media/card/usr/share/mc-new
mkdir /media/card/usr/share/mc-new/skins
cp /media/card/usr/share/mc/skins/default.ini /media/card/usr/share/mc-new/skins
rm -rf /media/card/usr/share/mc/
mv /media/card/usr/share/mc-new /media/card/usr/share/mc
* Strip kernel modules a bit more (saves ~1MB)
find /media/card/lib/modules/2.6.39-qtmoko-v58/ -name *.ko -exec strip -R .not -R .comment --strip-unneeded {} \;
* Edit the mount for root in /media/card/etc/fstab so that it reads:
rootfs / auto defaults,no_chk_data_crc,bulk_read 0 0
* Create config for ubinize and create the resulting image:
cd /media
cat > ubinize.cfg <<__END__
mkfs.ubifs -r /media/card -o qtmoko-debian.ubifs -x zlib -m 2048 -e 126976 -c 2047
ubinize -o qtmoko-debian-gta02-v58.ubi -m 2048 -p 128KiB -s 2048 -O 2048 ubinize.cfg
rm qtmoko-debian.ubifs
Step 12 - jffs2 image (not using anymore)
* Same first 2 steps as with ubi (copy&delete /boot)
* Uncomment the /var/cache/apt mount in /media/card/etc/fstab
* Make jffs2 image:
mkfs.jffs2 --pad=0x700000 -o qtmoko-debian.jffs2 -e 0x20000 -n -d/media/card
Step 12 - qi for booting ubi image
* Standard qi from openmoko git has jffs2 hardcoded as root file system. If your
want to use ubi image you need patched qi.
git clone git://
cd qi
git checkout qtmoko-v28
make CROSS_COMPILE=/opt/toolchains/arm920t-eabi/bin/arm-linux- CPU=s3c2442
Step 13 - generate Packages.gz for debian repository
* We have debian repository at After you
upload packages there (using filezilla, host is user is
radekp,qtmoko and directory is /home/project-web/qtmoko/htdocs/debian) you
have to generate Packages.gz:
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
* For secure apt you need to generate and sign Release file:
apt-ftparchive release . > Release
gpg -abs -o Release.gpg Release
Step 14 - modified wpa_supplicant
* There is a regression in wpa_supplicant affecting Freerunner. We have to
install modified version with this patch reverted:
diff --git a/src/drivers/driver_wext.c b/src/drivers/driver_wext.c
index 9fa356b..e44aeac 100644
--- a/src/drivers/driver_wext.c
+++ b/src/drivers/driver_wext.c
@@ -1007,7 +1007,7 @@ int wpa_driver_wext_scan(void *priv, struct wpa_driver_scan_params *params)
/* Not all drivers generate "scan completed" wireless event, so try to
* read results after a timeout. */
- timeout = 5;
+ timeout = 10;
if (drv->scan_complete_events) {
* The driver seems to deliver SIOCGIWSCAN events to notify
For more info check:
* The modified package is now uploaded with others here:
Step 15 - modified bluez and gpsd-clients
* These packages in wheezy suck because they add usless python dependencies
which is ~60MB
* The tricks is that we rebuild them without dependencies:
apt-get build-dep bluez gpsd-clients
apt-get source bluez gpsd-clients
* Now edit their debian/control and manually remove dependencies and rebuild
packages with dpkg-buildpackage
* The modified packages are now uploaded here:
Boot speedup
- replacing /bin/sh with dash, speedup 15s
Ideas & TODO
- support for dumb batteries as described in mail
"Document with answers to most popular battery-related questions is ready"
from Paul Ferster
Creating debian cross compiling toolchain
* Install packages needed for toolchain. Use your phone and existing
qtmoko-debian rootfs (ideally from chroot over NFS in /root/toolchain on
your PC). (Havent found xcalibrate pkg, where is it? Is it needed?)
apt-get install libasound2-dev libbluetooth-dev libdbus-1-dev libglib2.0-dev \
libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libavcodec-dev \
libswscale-dev libxsettings-client-dev libssl-dev libts-dev \
libxcomposite-dev libxcursor-dev libxdamage-dev libxfont-dev \
libxfontcache-dev libxft-dev libxinerama-dev libxi-dev \
libxmu-dev libxmuu-dev libxp-dev libxrandr-dev libxts-dev libxtst-dev \
libxxf86dga-dev libxxf86misc-dev libxxf86vm-dev zlib1g-dev \
build-essential libc6-dev libjpeg-dev libfreetype6-dev libdjvulibre-dev
* Make directory for your toolchain and copy files from toolchain rootfs:
mkdir -p /opt/toolchains/arm920t-eabi/arm-linux-gnueabi/lib
mkdir -p /opt/toolchains/arm920t-eabi/arm-linux-gnueabi/include
cp -r /root/toolchain/lib /opt/toolchains/arm920t-eabi/arm-linux-gnueabi
cp -r /root/toolchain/usr/lib /opt/toolchains/arm920t-eabi/arm-linux-gnueabi
cp -r /root/toolchain/usr/include /opt/toolchains/arm920t-eabi/arm-linux-gnueabi
* We will use cross compiler from emdebian project. On PC add emdebian
repository to your /etc/apt/sources.list
deb lenny main
* Download needed packages
apt-get update
apt-get -d install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi gcc-4.3-arm-linux-gnueabi g++-4.3-arm-linux-gnueabi
* Unpack toolchain packages
ln -s /opt/toolchains/arm920t-eabi /opt/toolchains/arm920t-eabi/usr
rm -rf /opt/toolchains/arm920t-eabi/arm-linux-gnueabi/include/c++/4.3*
dpkg -x /var/cache/apt/archives/binutils-arm-linux-gnueabi_2.18.1~cvs20080103-7_i386.deb /opt/toolchains/arm920t-eabi/
dpkg -x /var/cache/apt/archives/cpp-4.3-arm-linux-gnueabi_4.3.2-1.1_i386.deb /opt/toolchains/arm920t-eabi/
dpkg -x /var/cache/apt/archives/gcc-4.3-arm-linux-gnueabi-base_4.3.2-1.1_i386.deb /opt/toolchains/arm920t-eabi/
dpkg -x /var/cache/apt/archives/gcc-4.3-arm-linux-gnueabi_4.3.2-1.1_i386.deb /opt/toolchains/arm920t-eabi/
dpkg -x /var/cache/apt/archives/g++-4.3-arm-linux-gnueabi_4.3.2-1.1_i386.deb /opt/toolchains/arm920t-eabi/
dpkg -x /var/cache/apt/archives/libc6-armel-cross_2.7-18_all.deb /opt/toolchains/arm920t-eabi/
dpkg -x /var/cache/apt/archives/libc6-dev-armel-cross_2.7-18_all.deb /opt/toolchains/arm920t-eabi/
dpkg -x /var/cache/apt/archives/libgcc1-armel-cross_1%3a4.3.2-1.1_all.deb /opt/toolchains/arm920t-eabi/
dpkg -x /var/cache/apt/archives/libstdc++6-armel-cross_4.3.2-1.1_all.deb /opt/toolchains/arm920t-eabi/
dpkg -x /var/cache/apt/archives/libstdc++6-4.3-dev-armel-cross_4.3.2-1.1_all.deb /opt/toolchains/arm920t-eabi/
* Symlinks
cd /opt/toolchains/arm920t-eabi/lib/gcc/arm-linux-gnueabi/4.3.2
ln -s ../../../../arm-linux-gnueabi/lib/
* Fix problems with #include_next in stddef and others
cd /opt/toolchains/arm920t-eabi/arm-linux-gnueabi/include/c++/4.3.2
find . -type f -print0 | xargs -0 sed -i 's/#include_next/#include/g'
* Fix path to toolchain in package config files:
cd /opt/toolchains/arm920t-eabi/arm-linux-gnueabi/lib/pkgconfig
sed -i 's/\/usr/\/opt\/toolchains\/arm920t-eabi\/arm-linux-gnueabi/g' *.pc
* Make paths relative in and others:
cd /opt/toolchains/arm920t-eabi/arm-linux-gnueabi/lib
sed -i 's/\/usr\/arm-linux-gnueabi\/lib\///g' *.so
* Make the toolchain compatible with our old toolchain
cd /opt/toolchains/arm920t-eabi/
ln -s arm-linux-gnueabi arm-angstrom-linux-gnueabi
cd /opt/toolchains/arm920t-eabi/bin/
ln -s arm-linux-gnueabi-gcc-4.3 arm-linux-gcc
ln -s arm-linux-gnueabi-g++-4.3 arm-linux-g++
ln -s arm-linux-gnueabi-ar arm-linux-ar
ln -s arm-linux-gnueabi-strip arm-linux-strip
ln -s arm-linux-gnueabi-ld arm-linux-ld
ln -s arm-linux-gnueabi-nm arm-linux-nm
ln -s arm-linux-gnueabi-objcopy arm-linux-objcopy
ln -s arm-linux-gnueabi-objdump arm-linux-objdump
Something went wrong with that request. Please try again.