$Id: openmoko.txt,v 1.18 2009/11/25 14:37:13 guru Exp $ How to make a phone and hackers toy of the 'brick' Openmoko Freerunner Matthias Apitz The following is based on the FR Openmoko release Om2008.9-gta02-20080916 and describes the essential changes I did in the FR software after flashing the root image and the kernel as: Om2008.9-gta02-20080916.uImage.bin Om2008.9-gta02-20080916.rootfs.jffs2 It describes how to make a phone and hackers toy of the brick. Index: 0. General 1. Install a use-able keyboard 2. USB networking 3. web browser 4. Extending the Desktop 5. Having FR's desktop on your normal desktop as a window: x11vnc 6. Configuration of Wifi networking 7. Configuration of GPRS and PPPD 8. Configuration of audio in voice calls 9. Contacts 10. NTP and setting dates to hwclock 11. Other small packages which I have installed: 12. GPS 13. Other issues solved 14. Audio for calls 15. Terminal && UTF-8 16. StarDict 17. Ringtone 0. General The version above shows up in file system as: # cat /etc/om-version Tag Name: VERSION: 21895bf33f04f36292eec686438b55a514cb715d Branch: org.openmoko.asu.stable Build Host: barbie Time Stamp: Tue, 16 Sep 2008 08:25:15 +0800 1. Install a use-able keyboard The default keyboard which comes with Om2008.9 is pretty much useless; we need another one which just works and which can also be switched to a modus to act like a real computer keyboard; we install and configure 'illume' (Raster's) keyboard for that: Get the qwerty button if not there yet # opkg install illume-config Turn off built-in qtopia keyboard add "export QTOPIA_NO_VIRTUAL_KEYBOARD=1" in /etc/X11/Xsession.d/89qtopia # opkg install illume-config-illume Purge E's cache: # rm -rf ~/.e/e/config/illume Restart X # /etc/init.d/xserver-nodm restart see also: http://wiki.openmoko.org/wiki/Illume modifying the keyboard(s): # cd /usr/lib/enlightenment/modules/illume/keyboards # mv Default.kbd Default.kbd,orig # cp Terminal.kbd Default.kbd # killall -HUP enlightenment see also: http://wiki.openmoko.org/wiki/Illume#List_of_illume_keyboards 2. USB networking the IP addr on the FR side is hard coded in /etc/network/interfaces set to 192.168.0.202/24; on the host side I run FreeBSD and his devd(8) to set IP to 192.168.0.200 if the interface comes up; the files are: /usr/local/etc/devd/cdce.conf: +------------------------------------------------------------------------+ notify 1 { match "system" "IFNET"; match "subsystem" "cdce0"; action "/usr/local/etc/devd/cdce.sh $subsystem $type"; }; +------------------------------------------------------------------------+ /usr/local/etc/devd/cdce.sh: +------------------------------------------------------------------------+ #!/bin/sh # echo `date`: $0 $* >> /tmp/devd.out case $2 in 'ATTACH') ifconfig cdce0 192.168.0.200 netmask 255.255.255.0 exit 0 ; ;; 'DETACH') exit 0 ; ;; esac exit 0 +------------------------------------------------------------------------+ 3. web browser I have installed 'minimo': # wget http://www.ginguppin.de/files/minimo.tar.bz2 # tar -xjf minimo.tar.bz2 # opkg install minimo_0.02\+cvs20070626-r0_armv4t.ipk see also: http://wiki.openmoko.org/wiki/Minimo 4. Extending the Desktop Extending the Desktop is pretty much simple; the *.desktop files are in /usr/share/applications/ and the icons (64x64 png files) are in /usr/share/pixmaps; as an example I have here Gprs-up.desktop: +------------------------------------------------------------------------+ [Desktop Entry] Encoding=UTF-8 Name=Gprs-up Comment=Bring Gprs up Exec=xterm -e "/home/root/pppUp.sh; sleep 5" Icon=gprs Terminal=false Type=Application Categories=Application;Utilities; SingleInstance=true StartupNotify=true +------------------------------------------------------------------------+ 5. Having FR's desktop on your normal desktop as a window: x11vnc Install a VNC server on the FR # opkg install x11vnc and create a desktop launcher as: +------------------------------------------------------------------------+ [Desktop Entry] Encoding=UTF-8 Name=x11vnc Comment=Bring up x11vnc Exec=xterm -e x11vnc -display :0.0 -ncache 10 Icon=x11vnc Terminal=false Type=Application Categories=Application;Utilities; SingleInstance=true StartupNotify=true +------------------------------------------------------------------------+ One can now fully control the FR from another desktop by launching $ vncviewer 192.168.0.202:0 It even accepts keyboard input, for example in the dialer, or any other control using the desktop mouse as the styler; this way it's also very easy to make screenshots for presentation, or even capture a session in a movie with: $ vnc2swf openmoko.swf 192.168.0.202:0 some examples here: http://www.unixarea.de/home.jpg http://www.unixarea.de/minimo.jpg http://www.unixarea.de/dialer.jpg Posted by Matthias Apitz on the community mailing list, 28/09/2008 Of course you may also install a vncviewer on the FR itself: vnc_3.3.7-r0_armv4t.opk 6. Configuration of Wifi networking First we need some fixes in the shell scripts in /etc/wpa_supplicant functions.sh and ifupdown.sh: substitute 'sed --quiet' by 'sed -n' in both scripts; extend the file /etc/network/interfaces like this: +------------------------------------------------------------------------+ # Wired or wireless interfaces iface eth0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf pre-up iwconfig eth0 essid off up route del default gw 192.168.0.200 down route add default gw 192.168.0.200 +------------------------------------------------------------------------+ note: the line 'wpa-conf /etc/wp....' must start with a TAB; of course we need a working file /etc/wpa_supplicant/wpa_supplicant.conf for all known AP, it is just the same as I'm using in my FreeBSD laptop; next create some desktop launcher; it seems that the Wifi stack is still a bit weak in FR and after a lot of tests I have here what's working nearly all time: Wifi-up.desktop: +------------------------------------------------------------------------+ [Desktop Entry] Encoding=UTF-8 Name=Wifi-up Comment=Bring Wifi up with ifup eth0 Exec=xterm -e "ifdown eth0 ; iwconfig eth0 txpower auto channel 1 ; killall wpa_supplicant ; killall udhcp ; ifup eth0 ; sleep 20" Icon=wifi Terminal=false Type=Application Categories=Application;Utilities; SingleInstance=true StartupNotify=true +------------------------------------------------------------------------+ Wifi-down.desktop: +------------------------------------------------------------------------+ [Desktop Entry] Encoding=UTF-8 Name=Wifi-down Comment=Bring Wifi down with ifdown eth0 Exec=xterm -e "ifdown eth0 ; sleep 5" Icon=wifiOff Terminal=false Type=Application Categories=Application;Utilities; SingleInstance=true StartupNotify=true +------------------------------------------------------------------------+ I've made my tests with: -- AccessPoint SMCWBR14-G2 EU, WEP mode, channel 7 (2442 Mhz) -- AccessPoint SMC2555W-AG, WPA mode, channel 7 and both work very reliable with the FR and the above config; 7. Configuration of GPRS and PPPD The actual configuration of GPRS and PPPD is handmade and there is no integration with the phone stack, i.e. the phone demon 'qpe' must be shutdown and later restarted after GPRS usage (and the PIN must be re-entered); later we will install a multiplexer which let us use phone and GPRS at the same time (see below); the current files are: /etc/ppp/chap-secrets: +------------------------------------------------------------------------+ "gprs" "gprs" "gprspw" +------------------------------------------------------------------------+ /etc/ppp/gprs-connect-chat: +------------------------------------------------------------------------+ #!/bin/sh -e exec chat -v -S -s\ TIMEOUT 15\ "" "\K\K\K\d+++ATH"\ OK-AT-OK ATZ\ OK ATE1\ ABORT BUSY\ ABORT DELAYED\ ABORT "NO ANSWER"\ ABORT "NO DIALTONE"\ ABORT VOICE\ ABORT ERROR\ ABORT RINGING\ TIMEOUT 60\ OK AT+CGDCONT=1,\"IP\",\"internet.t-mobile\"\ OK ATD*99***1#\ CONNECT /n/d +------------------------------------------------------------------------+ /etc/ppp/peers/gprs : +------------------------------------------------------------------------+ # Uncomment the following if you want some debug. # debug # logfile /var/volatile/log/pppd.log debug logfile /var/volatile/log/pppd.log lock /dev/ttySAC0 115200 crtscts connect /etc/ppp/gprs-connect-chat noauth name gprs ipcp-accept-remote noipdefault ipcp-max-configure 20 defaultroute novj novjccomp idle 3600 replacedefaultroute +------------------------------------------------------------------------+ and a script to stop 'qpe', launch GPRS & PPPD and later restart the 'qpe' daemon: #!/bin/sh # test -f /var/log/pppd.log || touch /var/log/pppd.log tail -f /var/log/pppd.log & killall qpe pppd debug nodetach call gprs DISPLAY=:0.0 export DISPLAY /etc/X11/Xsession.d/89qtopia killall tail XXX later perhaps we will do this via a multiplexer to not stop 'qpe' XXX while GPRS is up (not yet installed); for routing from laptop via FR's GPRS to Internet we must MASQUERADE the IP addr of the laptop behind the IP addr of the ppp0 interface (i.e. NAT must be involved) see also: http://wiki.openmoko.org/wiki/Tethering fetch from http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/ iptables_1.3.8-r4_armv4t.ipk iptables-utils_1.3.8-r4_armv4t.ipk # opkg install iptables_1.3.8-r4_armv4t.ipk iptables-utils_1.3.8-r4_armv4t.ipk note: they need as well: libgcc1_4.2.4-r3_armv4t.ipk kernel-module-ipt-masquerade kernel-module-iptable-nat are already installed the work is done by a script 'firewall.sh' as found in the above Wiki page and which I have installed as /etc/ppp/ip-up.d/09iptables so it will be executed when PPPD brings up IP; on my laptop (an Asus eeePC 900 with FreeBSD 7.0) I only have to set the default gateway to the FR with a small script ~/routeMoko.sh: #!/bin/sh # route add default 192.168.0.202 printf "domain Sisis.de\nnameserver xxx.xxx.xxx.xxx\n" > /etc/resolv.conf XXX note: actual there is no solution how to fetch the DNS entry, only known by FR's PPPD to the laptop; example here of the 1st session of the eeePC to Internet with FR as a router: http://www.unixarea.de/20081003-173025.jpg 8. Configuration of audio in voice calls Configuring the parameters for voice calls is tricky as well; actual I'm using for the file /usr/share/openmoko/scenarios/gsmhandset.state this version which has improved the quality notable: http://www.teaparty.net/technotes/openmoko-2.html#Audio-to-other-mobiles (gsmhandset.state.20081002) 200810115: From: "Marco Trevisan (Treviño)" Date: Wed, 15 Oct 2008 08:18:40 +0200 To: community@lists.openmoko.org http://downloads.tuxfamily.org/3v1deb/openmoko/libficgta01vendor-echo-cancellation.so.tar.gz # cd /opt/Qtopia/plugins/phonevendors/ # mv libficgta01vendor.so libficgta01vendor.so.orig # mv ~/libficgta01vendor.so . # /etc/init.d/xserver-nodm restart the restart is not asking for the PIN (why ?) new gsmhandset.state file from: http://lists.openmoko.org/pipermail/community/2008-October/033312.html http://danielnoethen.de/gsmhandset.state is in ~/myThings/FreeBSD/Openmoko/gsmhandset.state.DanielNoethen 9. Contacts In Om2008.[8|9] the contacts database is in /home/root/Applications/Qtopia/qtopia_db.sqlite There is no way currently to export this to vCard file, but it can be loaded like this: # DISPLAY=:0.0 export DISPLAY # addressbook path_to_vCards_file_to_import.vcf note: 1) the 'DISPLAY=:0.0 export DISPLAY' to get the OK-button on the FR's screen; 2) at the moment use vCard V3.0 format but no non-ASCII chars in the contacts; see also: http://wiki.openmoko.org/wiki/Import_Vcf_Contacts to drop all contacts we need to install 'sqlite3': # opkg install sqlite3 and a small script ~root/updContacts.sh like this: #!/bin/sh # echo "Dropping and updating all contacts from file /home/root/std.vcf" echo -n "Is this what you really want? Hit return or Ctrl-C... " read no test -f /home/root/std.vcf || { echo "file /home/root/std.vcf does not exist -- exit." exit 1 } sqlite3 /home/root/Applications/Qtopia/qtopia_db.sqlite << EOF delete from contactcategories; delete from contactaddresses; delete from contactcustom; delete from contactphonenumbers; delete from contacts; .quit EOF DISPLAY=:0.0 export DISPLAY /opt/Qtopia/bin/addressbook /home/root/std.vcf this will erase and reload all contacts, we don't care of erasing because our master contacts database is on the laptop from now in Kabc' file ~/.kde/share/apps/kabc/std.vcf 10. NTP and setting dates to hwclock install: # opkg install ntpclient the installation starts automagically the 'ntpclient', kill it and see if it really works: # ntpclient -s -h pool.ntp.org to make 'hwclock' happy we need a fix because: # hwclock --systohc hwclock: can't open '/dev/misc/rtc': No such file or directory # mkdir /dev/misc # ln -s /dev/rtc /dev/misc/rtc # hwclock --systohc hwclock: can't open '/dev/misc/rtc': Device or resource busy # opkg install lsof # lsof | grep rtc atd 1367 root 3r CHR 254,0 1700 /dev/rtc0 # /etc/init.d/atd stop Stopping at daemon: atd. # hwclock --systohc # /etc/init.d/atd start Starting at daemon: atd. see also: http://lists.openmoko.org/pipermail/community/2008-July/023833.html http://wiki.openmoko.org/wiki/Setting_Date_and_Time 11. Other small packages which I have installed: calculator: openmoko-calculator2_0.1.0+svnr3655-r0.02_armv4t.opk browser: dillo_2.0-r0_armv4t.ipk PDF: evince_2.20.0-r2_armv4t.opk 12. GPS Install the following packages: # opkg install gpsd # opkg install http://www.tangogps.org/downloads/tangogps_0.9.3-r1_armv4t.ipk # opkg install openmoko-agpsui # opkg install gpsdcontrol_0.3_all.opk The last one (gpsdcontrol) removes the starting of the 'gpsd' from the boot run-level, which is a good idea at all for saving power; you may fetch it from: http://projects.openmoko.org/projects/gpsdcontrol/ One must edit the /etc/default/gpsd to point it to the correct serial device of the GPS antenna: # vi /etc/default/gpsd GPS_DEV="/dev/ttySAC1" gpsdcontrol as well powers on the GPS antenna by writing '1' to the drivers file; you could do this as well (and you should if you don't use gpsdcontrol) in the gpsd start script /etc/init.d/gpsd in the start/stop sequence, writing '1' on start and '0' on stop; echo 1 > /sys/class/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron in any case you must correct a bug in the /etc/init.d/gpsd which tries to kill the gpsd, but kills to the running script itself; change: killall gpsd by: pgrep -x gpsd | grep -v "$$" | xargs -r kill The installed tool openmoko-agpsui allows you to check if your GPS antenna and chip work fine; some notes about this, GPS and TTFF: - openmoko-agpsui does not need the 'gpsd' to be started and it goes out of the way if some application (like tangoGPS) instructs the 'gpsd' to read the GPS chip; - the internal radio antenna of the GPS chip is in the upper part of the Freerunner, above the loudspeaker; while waiting for TTFF (Time To First Fix) use the FR in upright position (and with nothing above it, no building, no trees, no hand or other parts of your body); - I managed TTFF between 23 seconds and 400 seconds which is good enough if you keep in mind the small antenna; the Wiki explains about TTFF for cold start (and the FR do this) about ~15 minutes: http://en.wikipedia.org/wiki/Time_to_first_fix - in the 'SS' menu of the openmoko-agpsui you can check after TTFF very good the number of the satellites and the strength of their signals; any value greater then -145 dbm should be fine; I normally manage average values around -130 dbm; - I normally use openmoko-agpsui to get the First Fix and after this I start the gpsd and tangoGPS which find the GPS chip already well located on earth; - some screenshoots of openmoko-agpsui can be seen here: http://www.unixarea.de/GPS-test01.jpg http://www.unixarea.de/GPS-test02.jpg http://www.unixarea.de/GPS-test03.jpg http://www.unixarea.de/GPS-test04.jpg Some notes about tangoGPS: - my cached maps are now stored in the SD card: # mkdir /media/card/osm # rm -rf OSM # ln -s /media/card/osm OSM - I pre-fetched maps with some tool from http://www.millions.ca/~stacy/osmtiles.tgz which let me define the two points of a rectangle, generate the URL's of OpenStreetMap and fetch down the *.png files which I store below /media/card/osm where tangoGPS will pick them up; see the README of the tar-ball for more details; for example the complete city of Munich inside the Highway-Ring A99 are some 3000 files for zoom level 11-16 and occupy only ~32 MByte; - I run tangoGPS as well in my FreeBSD laptops and connect it to the 'gpsd' which runs on the Freerunner, i.e. using the Freerunner as the GPS device for my laptop; this gives you a better view to the maps with tangoGPS, of course :-) - the 'master' site of my maps is now the laptop and I'm syncing the FR with: $ rsync -rav -c --no-owner ~/Maps/OSM/* root@moko:/media/card/osm more information: Wiki: http://wiki.openmoko.org/wiki/Neo_FreeRunner_GPS 13. Other issues solved qpe consumes a lot of time after boot: qpe reads all files on SD card (where I have ~15.000 of OSM) which consumes a lot of time after boot; switch this off by changing the section in /opt/Qtopia/etc/default/Trolltech/Storage.conf to read: [MountPoint0] Name[] = SD Card Path=/dev/mmcblk0p1 Removable = 1 Applications = 0 <***** was '1' Documents = 0 <***** was '1' ContentDatabase = 0 <***** was '1' screenshots: http://gpe.linuxtogo.org/projects/gpe-scap.shtml http://wiki.openmoko.org/wiki/Gpe-scap # opkg install gpe-scap wmiconfig (still untested): # fetch http://meshy.org/~ato/debian/pool/main/w/wmiconfig/wmiconfig_0.0.18-1_armel.deb and unpack it to pull out the Debian wmiconfig tool... see also: http://wiki.openmoko.org/wiki/Wmiconfig rotate: # opkg install http://projects.openmoko.org/frs/download.php/455/accel-rotate_0.41_armv4t.ipk 14. Audio for calls now I see clear and as well wrote this small script: # cat audiostate.sh #!/bin/sh alsactl -f /tmp/current.state store for i in /usr/share/openmoko/scenarios/*.state do diff -q /tmp/current.state >/dev/null $i && echo actual alsa state: [`basename $i`] done and yes: without any call the phone is in: # ./audiostate.sh actual alsa state: [stereoout.state] I also realized that during the call in Om2008.9 there is a small pull-up menu which allows you to toggle between handset / speaker / ... (I wasn't aware of this before). This explains also why the phone was not RINGing anymore after hard loading 'gsmhandset.state'. The remaining job is to fiddle a bit the values in the gsmspeakerout.state to avoid the 'acoustic feedback' between the micro and the speaker; ... 15. Terminal && UTF-8 There is a new (better?) terminal: vala-terminal; the good stuff is that it supports as well UTF-8 after installing some local-packages too; install: vala-terminal_1.1.1-r0.2_armv4t.opk locale-base-en-gb_2.6.1-r12_armv4t.opk glibc-binary-localedata-en-gb_2.6.1-r12_armv4t.opk and change the start command in /usr/share/applications/vala-terminal.desktop to: Exec=LANG=en_GB.UTF8 vala-terminal now we have full UTF-8 support, example for Spanish tilded chars; I wrote by my own a Spanish enabled keyboard, which is mostly working; mostly means that the chars áéúíóñ... are doing a diccionary lookup, are placed on top of the keyboard and only a next touch or the next char move them to the input area; we chatted a lot about this problem in the Openmoko-list, but there is no real solution right now; and it works, at least; as well the capital chars ÁÉÍÚÓÑ... are not working for some other unknown bug in enlightement; well the keyboard file is in my CVS as Spanish.kbd and must be places in /usr/lib/enlightenment/modules/illume/keyboards (see section above about keyboards). see also: http://wiki.openmoko.org/wiki/Vala-terminal 16. StarDict I have installe the command line version of StarDict (the Gnome based version needs to much other stuff which is currently not available for the FR), install: sdcv_0.4.2-9_armel.deb libreadline5_5.2-3.1_armel.deb StarDict's sdcv is launche with this script: # cat ~/sd #!/bin/sh sdcv --utf8-output --utf8-input $* 2> /dev/null and my dictionaries are placed in the usual location ~/.stardict/dic/... (just copied over from my laptop). 17. Ringtone The (original) tone is in /opt/Qtopia/etc/SystemRingTones/phonering.wav I've fetcheched http://www.telephonesuk.co.uk/sounds/706_ring.wav and modified it as described in the Wiki $ mplayer 706_ring.wav -ao pcm -srate 44100 -af-add volume=-20 $ mv 706_ring.wav 706_ring.wav.orig $ mv audiodump.wav 706_ring.wav and placed this into the FR; see also: http://wiki.openmoko.org/wiki/Ringtones XX. Open issues -- bigger font for xterm; see also xlsfonts; -- multiplexer qpe ./. GPRS