Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

611 lines (422 sloc) 19.437 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 cdebootstrap mtd-utils
Step 1
* We will be installing new image to /media/card:
cdebootstrap --flavour=minimal --include=ifupdown,procps,netbase,nano,module-init-tools,wget,openssh-server,screen,mc,libts-0.0-0,libasound2,alsa-utils,ppp,udhcpc,wpasupplicant,wireless-tools,iputils-ping,iproute,bluez,bluez-alsa,dosfstools,fbset,klogd,psmisc,iptables,dash,ttf-dejavu,timeout,libpng12-0,libjpeg62,libxtst6 squeeze /media/card/
* Minimal rootfs for gta01 jffs2:
cdebootstrap --flavour=minimal --include=ifupdown,udev,procps,netbase,nano,module-init-tools,openssh-server,libts-0.0-0,libasound2,linux-sound-base,ppp,iputils-ping,bluez-utils,dosfstools,fbset,klogd,psmisc,dash stable /media/card/
* You need to set correct date and time if you get this error:
E: Couldn't validate Release!
* For bluetooth headset bluez-audio package is needed. But because of stupid
dependencies on gstreamer it takes 4MB. With this package and some tweaks you
can have mplayer working with btluethooth headset.
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
apt-get --yes --purge remove cdebootstrap-helper-rc.d
Step 3 - add more package repositories
echo "deb squeeze contrib" >> /media/card/etc/apt/sources.list
echo "deb squeeze non-free" >> /media/card/etc/apt/sources.list
echo "deb squeeze/updates main contrib non-free" >> /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:
echo g_ether > /media/card/etc/modules
echo ppp_generic >> /media/card/etc/modules
echo joydev >> /media/card/etc/modules
* Unpack alsa scenarios to /usr/share/openmoko - you can find these files
in any openmoko distro.
* Edit /media/card/etc/ppp/options and replace "auth" with "noauth"
* 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]:
Step 4.1 - DHCP server - not using now
* DHCP server will arrange USB networking with PC out-of-the-box for
distributions using NetworkManager.
* Not using now - the problem is that e.g. my notebook prefers usb0 over wifi
and internet does not work then.
* You need install package dhcp3-server in step1.
cat > /media/card/etc/dhcp3/dhcpd.conf <<__END__
subnet netmask {
option routers;
option domain-name-servers,;
pool {
max-lease-time 7200;
allow unknown clients;
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 klogd remove
update-rc.d -f sysklogd 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
* Create dir for atd jobs:
mkdir /media/card/var/spool/at
Step 6 - qpe bootscript
* not using now - it's in debian package already
Step 6.5 - omhacks
* omhacks is used for controlling neo hardware, the version in squeeze is old
and can't be used with > 2.6.34 kernels, so install from sid:
chroot /media/card
dpkg -i libomhacks0_0.15-1_armel.deb
dpkg -i omhacks_0.15-1_armel.deb
rm libomhacks0_0.15-1_armel.deb
rm omhacks_0.15-1_armel.deb
Step 7 - logread utility
* Used for displaying log in settings. It's not presented in debian. Instead we
provide simple bash script:
cat > /media/card/sbin/logread <<__END__
tail -n 100 /var/log/messages
chmod +x /media/card/sbin/logread
Step 7.4 - wpa_supplicant
* Qtopia by default expects wpa_supplicant in /usr/sbin while debian installs
it to /sbin. We fix this with symlink
cd /media/card/usr/sbin
ln -s ../../sbin/wpa_supplicant wpa_supplicant
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 v33
* 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_34-1_armel.deb
update-rc.d qtmoko defaults
rm qtmoko_34-1_armel.deb
Step 9 - Linux kernel
* Sources for qtmoko are on github:
* Checkout branch for your qtmoko version:
git checkout remotes/origin/qtmoko-v26 -b qtmoko-v26
* Create package in buildhost:
* Remove unused fonts. We need just DejaVuSansCondensed-Bold.ttf and
cd /media/card/usr/share/fonts/truetype/ttf-dejavu/
mv DejaVuSansCondensed.ttf DejaVuSansCondensed.ttf.keep
mv DejaVuSansCondensed-Bold.ttf DejaVuSansCondensed-Bold.ttf.keep
mv DejaVuSansMono.ttf DejaVuSansMono.ttf.keep
rm *.ttf
mv DejaVuSansCondensed.ttf.keep DejaVuSansCondensed.ttf
mv DejaVuSansCondensed-Bold.ttf.keep DejaVuSansCondensed-Bold.ttf
mv DejaVuSansMono.ttf.keep DejaVuSansMono.ttf
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.34-qtmoko-gta02_v34-1_armel.deb
rm linux-image-2.6.34-qtmoko-gta02_v34-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=/opt/toolchains/arm920t-eabi/bin/arm-linux- ARCH=arm
make CROSS_COMPILE=/opt/toolchains/arm920t-eabi/bin/arm-linux- ARCH=arm modules_install INSTALL_MOD_PATH=GTA02
find GTA02/lib/modules -name *.ko -exec /opt/toolchains/arm920t-eabi/bin/arm-linux-strip -R .not -R .comment --strip-unneeded {} \;
/opt/toolchains/arm920t-eabi/bin/arm-linux-objcopy -O binary -R .note -R .comment -S arch/arm/boot/compressed/vmlinux linux.bin
mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008000 -n "qtmoko-v28" -d linux.bin uImage-GTA02.bin
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 10 - release tarball
cd /media/card
tar -czvf ../qtmoko-debian.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
* Edit the mount for root in /media/card/etc/fstab so that it reads:
rootfs / auto defaults,no_chk_data_crc,bulk_read 0 1
* Create config for ubinize and create the resulting image:
cd /root
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.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
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
Jump to Line
Something went wrong with that request. Please try again.