Debian rootfs ============= Use instructions from http://wiki.openmoko.org/wiki/Manual_Debian I am installing to NFS dir, so that i can make tarbal on my PC. Mount your NFS dir to /media/card for simplicity. To mount NFS you need this line in /etc/fstab: 192.168.0.200:/ /mnt/nfs nfs noauto,nolock,soft,rsize=32768,wsize=32768 0 0 and you need apt-get install nfs-common modprobe nfs Always use ext3 on SD cards - ext2 often gets corrupted during reboots. If you install from debian you need cdebootstrap: apt-get install cdebootstrap Step 1 ====== cdebootstrap --flavour=minimal --include=ifupdown,procps,netbase,nano,module-init-tools,wget,dropbear,screen,mc,libts-0.0-0,libasound2,pciutils,linux-sound-base,ppp,udhcpc,wpasupplicant,wireless-tools,iputils-ping,bluez-utils,dosfstools,fbset,klogd,psmisc,iptables,dash,xfonts-base,x11-xserver-utils,xterm,timeout stable /media/card/ http://ftp.de.debian.org/debian/ * 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 "127.0.0.1 neo" >> /media/card/etc/hosts cat > /media/card/etc/network/interfaces <<__END__ auto lo iface lo inet loopback auto usb0 iface usb0 inet static address 192.168.0.202 netmask 255.255.255.0 network 192.168.0.0 gateway 192.168.0.200 up rm /etc/resolv.conf up echo nameserver 208.67.222.222 >/etc/resolv.conf __END__ 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 192.168.0.200:/ /mnt/nfs nfs noauto,nolock,soft,rsize=32768,wsize=32768 0 0 __END__ cat > /media/card/etc/apt/apt.conf.d/99no-install-recommends << __END__ APT::Install-Recommends "0"; __END__ sed -i 's/\(PermitEmptyPasswords\) no/\1 yes/' /media/card/etc/ssh/sshd_config chroot /media/card /bin/sh -e <<__END_CHROOT__ echo root: | chpasswd apt-get --yes --purge remove cdebootstrap-helper-rc.d __END_CHROOT__ Step 3 - add more package repositories ======================================== echo "deb http://ftp.de.debian.org/debian lenny contrib" >> /media/card/etc/apt/sources.list echo "deb http://ftp.de.debian.org/debian lenny non-free" >> /media/card/etc/apt/sources.list echo "deb http://pkg-fso.alioth.debian.org/debian unstable main" >> /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 * 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 endmode 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 endmode __END__ Calling "fbset qvga" and "echo qvga-normal > /sys/bus/spi/devices/spi2.0/state" is needed for mplayer in 320x240 with correct colors. 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 192.168.0.0 netmask 255.255.255.0 { option routers 192.168.0.202; option domain-name-servers 208.67.222.222, 208.67.220.220; pool { max-lease-time 7200; range 192.168.0.200 192.168.0.201; allow unknown clients; } } __END__ Step 4.5 - alsa utils without python dependency =============================================== * To avoid python and save precious space, we will intall customized alsa-utils package which does not have python as dependency. chroot /media/card wget http://activationrecord.net/radekp/pub/alsa-utils_1.0.16-2_armel.deb dpkg -i alsa-utils_1.0.16-2_armel.deb rm alsa-utils_1.0.16-2_armel.deb exit * If you wonder how to build customized alsa-utils then just edit the source package and remove python dependency from the control files. Step 4.6 - pkg-fso-keyring ========================== chroot /media/card wget http://pkg-fso.alioth.debian.org/debian/pool/main/p/pkg-fso-keyring/pkg-fso-keyring_2009.09.12_all.deb dpkg -i pkg-fso-keyring_2009.09.12_all.deb rm pkg-fso-keyring_2009.09.12_all.deb exit 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 logging_enable.sh script. chroot /media/card update-rc.d -f klogd remove update-rc.d -f sysklogd remove exit 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 libts-0.0.so.0 libts-1.0.so.0 * 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 /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 ======================= * Create qpe init script and link in runlevel 2 nano /media/card/etc/init.d/qpe.sh #!/bin/sh . /opt/qtmoko/qpe.env case "$1" in start) if [ ! -d /dev/pts ]; then # running on devtmpfs mkdir -p /dev/pts mount -t devpts none /dev/pts modprobe joydev fi rm -f /dev/input/mice echo '1' > /proc/sys/kernel/printk echo 1 > /sys/devices/platform/gta02-pm-bt.0/power_on echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink rm -rf /var/run/ppp mkdir /var/run/ppp mkdir -p /var/cache/apt/archives/partial atd /var/spool/at /etc/init.d/qpe.sh & ;; stop) rm -f /tmp/restart-qtopia killall -q qpe atd quicklauncher mediaserver mediaplayer sipagent ;; restart) /etc/init.d/qpe.sh stop /etc/init.d/qpe.sh start ;; *) touch /tmp/restart-qtopia while [ -e /tmp/restart-qtopia ]; do qpe 2>&1 | logger -t 'Qtopia' if [ -e /tmp/restart-qtopia-qvga ]; then rm -rf /tmp/restart-qtopia-qvga export QWS_SIZE="240x320+0+0" export POINTERCAL_FILE=/etc/pointercal_qvga fbset qvga echo qvga > /sys/bus/spi/devices/spi2.0/resolution #qcop service send Launcher "execute(QString)" "calibrate" fi done ;; esac exit 0 chmod +x /media/card/etc/init.d/qpe.sh cd /media/card/etc/rc2.d/ ln -s ../init.d/qpe.sh S09qpe Step 7 - logread utility ======================== * Used for displaying log in settings. It's not presented in debian. Instead we provide simple bash script: nano /media/card/sbin/logread #!/bin/sh tail -n 100 /var/log/messages chmod +x /media/card/sbin/logread Step 7.3 - xterm desktop file ============================= * Xterm does not have .desktop file by default, but we want to launch it easily from QX: mkdir -p /media/card/usr/share/applications cat > /media/card/usr/share/applications/xterm.desktop << __END__ [Desktop Entry] Name=xterm Comment=x terminal emulator Exec=xterm Type=Application Icon=xterm-color_48x48.xpm Categories=System;TerminalEmulator __END__ 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 7.6 ======== * Install xserver-xglamo - download it from alioth repo and install it manually chroot /media/card wget http://pkg-fso.alioth.debian.org/debian/pool/main/x/xglamo/xserver-xglamo_1.3.0.0+git20080807-3_armel.deb dpkg -i xserver-xglamo_1.3.0.0+git20080807-3_armel.deb rm xserver-xglamo_1.3.0.0+git20080807-3_armel.deb exit * Create xorg.conf and configure it for Xglamo nano /media/card/etc/X11/xorg.conf # xorg.conf (X.Org X Window System server configuration file) # # This file was generated by dexconf, the Debian X Configuration tool, using # values from the debconf database. # # Edit this file with caution, and see the xorg.conf manual page. # (Type "man xorg.conf" at the shell prompt.) # # This file is automatically updated on xserver-xorg package upgrades *only* # if it has not been modified since the last upgrade of the xserver-xorg # package. # # If you have edited this file but would like it to be automatically updated # again, run the following command: # sudo dpkg-reconfigure -phigh xserver-xorg Section "InputDevice" Identifier "Generic Keyboard" Driver "kbd" Option "XkbRules" "xorg" Option "XkbModel" "pc104" Option "XkbLayout" "us" EndSection Section "InputDevice" Identifier "Configured Mouse" Driver "mouse" EndSection Section "Device" Identifier "Configured Video Device" Driver "Xglamo" # Driver "fbdev" EndSection Section "Monitor" Identifier "Configured Monitor" EndSection Section "Screen" Identifier "Default Screen" Monitor "Configured Monitor" EndSection Step 7.7 ======== * Remove all doc - we dont have space for it 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 Step 8 - compile Qtopia ======================= * Download and unpack toolchain cd / sudo wget http://sourceforge.net/projects/qtmoko/files/qtmoko-debian-toolchain-armv4t-eabi.tar.gz/download sudo tar xzvpf arm920t-eabi.tgz * Build QtMoko mkdir build cd build ../qtmoko/configure -device neo -force-build-qt make make install * Tar build * Unpack QtMoko to target image cd /media/card tar xzvpf qtopia-update.tar.gz * Translations - you need to checkout QtMoko translation git branch git checkout translations and tell configure (in build dir) which languages you want ../qtmoko/configure -device neo -force-build-qt -languages cs_CZ,en_US,it_IT,ru_RU,de_DE,es_ES,pl_PL and rebuild all make clean make make install Step 8.5 - Fonts ================ * We will use truetype fonts installed with X. They have several benefits: bigger size, international characters, fixed size font (good for terminal). cd /media/card/opt/qtmoko/lib rm -rf fonts ln -s ../../../usr/share/fonts/truetype/ttf-dejavu/ fonts Step 9 - Linux kernel ===================== * Sources for qtmoko are on github: http://github.com/radekp/linux-2.6/ * Checkout branch for your qtmoko version: git checkout remotes/origin/qtmoko-v26 -b qtmoko-v26 * Compile kernel and make uboot image: 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 * Copy kernel to /media/card/boot cd /media/card/boot echo "console=tty0 loglevel=3 rootwait" > append-GTA02 scp /home/radek/linux-2.6/GTA02/uImage-GTA02.bin root@192.168.0.202:/media/card/boot/uImage-GTA02.bin Step 9.5 - remove bash history ============================== * Remove .bash_history created during install rm -f /media/card/root/.bash_history Step 10 ======= * Unmount nfs on Neo sync umount /media/card * Pack it all on your desktop cd /media/card tar -czvf ../qtmoko-debian.tar.gz . Step 11 - make jffs2 and ubifs images ===================================== * Copy your rootfs dir to /tmp/qtmoko-debian * Delete contents of boot, because for NAND it's not needed: rm -rf /tmp/qtmoko-debian/boot/* * Uncomment the /var/cache/apt mount in /tmp/qtmoko-debian/etc/fstab * Make jffs2 image: mkfs.jffs2 --pad=0x700000 -o qtmoko-debian.jffs2 -e 0x20000 -n -d/tmp/qtmoko-debian * Ubifs image: * Comment back the /var/cache/apt mount in /tmp/qtmoko-debian/etc/fstab * Edit the mount for root in /tmp/qtmoko-debian/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: cat > ubinize.cfg <<__END__ [ubifs] mode=ubi image=qtmoko-debian.ubifs vol_id=0 vol_size=230MiB vol_type=dynamic vol_name=om-gta02-rootfs vol_flags=autoresize __END__ mkfs.ubifs -r /tmp/qtmoko-debian -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 - 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://github.com/radekp/qi.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" http://wiki.openmoko.org/wiki/Battery_Questions_and_Answers#So.2C_how_do_i_use_.22dumb.22_batteries_with_my_freerunner.3F 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 http://www.emdebian.org/debian/ 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 rm libgcc_s.so ln -s ../../../../arm-linux-gnueabi/lib/libgcc_s.so.1 libgcc_s.so * 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 libc.so 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