User:Jonathan

From Openmoko

Revision as of 07:23, 9 October 2009 by Jonathan (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Just some notes from playing with my Freerunner

What am I trying to do? I want to run a full Linux distro on my Freerunner, with Debian the obvious choice, AND have it work as a usable telephone at the same time.

Simple but practical fun with framework

Auto-configure USB interface

Since pretty the only use I make of the USB interface is for the host computer to act as a gateway to the Net, it makes sense to run a DHCP server on my other computers and DHCP client on the Freerunner. And along with that ifplugd to detect when the USB cable is plugged in. But since ifplugd seems not to work with the ethernet over USB, I used a simple hack to framework instead. At the same time it also disables screen blanking and suspend when the USB is plugged in. Extract from /etc/freesmartphone/oevents/rules.yaml

-
   trigger: PowerStatus()
   filters: Not(HasAttr(status, "discharging"))
   actions: 
            - Command( "dbus-send --system --dest=org.freesmartphone.odeviced --type=method_call /org/freesmartphone/Device/IdleNotifier/0 org.freesmartphone.Device.IdleNotifier.SetTimeout string:idle_prelock int32:0" )
            - Command( "dbus-send --system --dest=org.freesmartphone.odeviced --type=method_call /org/freesmartphone/Device/IdleNotifier/0 org.freesmartphone.Device.IdleNotifier.SetTimeout string:suspend int32:0" )
            - Command( "ifup usb0" )
-
   trigger: PowerStatus()
   filters: HasAttr(status, "discharging")
   actions: 
            - Command( "ifdown usb0" )
            - Command( "dbus-send --system --dest=org.freesmartphone.odeviced --type=method_call /org/freesmartphone/Device/IdleNotifier/0 org.freesmartphone.Device.IdleNotifier.SetTimeout string:idle_prelock int32:30" )
            - Command( "dbus-send --system --dest=org.freesmartphone.odeviced --type=method_call /org/freesmartphone/Device/IdleNotifier/0 org.freesmartphone.Device.IdleNotifier.SetTimeout string:suspend int32:30" )
-

Locking the screen

LXDE and friends appear to lack a simple screen lock so I figured out how to do it myself. First of all a tiny snippet of python that writes its own pid to a temporary file and grabs screen input forever, or until it gets interrupted. Call this file lock_screen:

#!/usr/bin/env python

import fcntl
import os
import time

EVIOCGRAB = 0x40044590

tmp = open("/tmp/lock_screen", "w")
tmp.write (str (os.getpid ()))
tmp.close ()
screen = os.open("/dev/input/event1", os.O_RDWR|os.O_NONBLOCK)
fcntl.ioctl(screen, EVIOCGRAB, 1)
while 1:
    time.sleep (9999999)

Second, a bit of sh to start and stop the screen locker on successive calls. Call this code lock_unlock_screen:

#!/bin/sh
#
if [ -f /tmp/lock_screen ]; then
    kill `cat /tmp/lock_screen`
    rm /tmp/lock_screen
else
    DISPLAY=:0 /home/jschultz/bin/lock_screen &
fi

Finally a bit of framework configuration that makes the AUX button call the screen locker/unlocker. From /etc/freesmartphone/oevents/rules.yaml

-
    #
    # AUX button Handling
    #
    trigger: InputEvent()
    filters:
             - HasAttr(switch, "AUX")
             - HasAttr(event, "released")
             - HasAttr(duration, 0)
    actions:
             - Command( "/home/jschultz/bin/lock_unlock_screen" )
-

Use headset button to pause/unpause MPlayer

This one is great for listening to podcasts... Step one is in /etc/frameworkd.conf and makes ovents report the headset button:

[odeviced.input]
report5 = HEADSETBUTTON,key,207,1
...

Second part is in /etc/freesmartphone/oevents/rules.yaml and does two things: 1. ALSA settings to make the sound chip detect the headset button; 2. Respond to the headset button by calling a script:

    #
    # Headset Audio Scenario Support
    #
-
    trigger: InputEvent()
    filters:
             - HasAttr(switch, "HEADSET")
             - HasAttr(event, "pressed")
    actions:
             - Command('amixer -d sset "Amp Spk" mute')
             - Command('amixer -d sset "DAPM Headset Mic" on')
             - Command('amixer -d sset "Left Mixer Sidetone Playback Sw" on')
             - Command('amixer -d sset "ALC Mixer Mic1" cap')
-
    trigger: InputEvent()
    filters:
             - HasAttr(switch, "HEADSET")
             - HasAttr(event, "released")
    actions:
             - Command('amixer -d sset "Amp Spk" unmute')
             - Command('amixer -d sset "DAPM Headset Mic" off')
             - Command('amixer -d sset "Left Mixer Sidetone Playback Sw" off')
             - Command('amixer -d sset "ALC Mixer Mic1" uncap')
-
    trigger: InputEvent()
    filters:
             - HasAttr(switch, "HEADSETBUTTON")
             - HasAttr(event, "released")
             - HasAttr(duration, 0)
    actions: 
             - Command( "/home/jschultz/bin/gnome-mplayer-pause" )
-

Finally the script itself, which does a bit of debouncing (otherwise we seem to get lots of pausing and unpausing each time I push the button) and sends the debus signal to gnome-mplayer to pause/unpause:

#!/bin/sh
#
# Avoid buttom bounce by disallowing more than 2 presses per second
if [ ! -f /tmp/gnome-mplayer-pause-timestamp ] || [ $((`date +%s%N` - `cat /tmp/gnome-mplayer-pause-timestamp`)) -gt 500000000 ] ; then
    DISPLAY=:0 sudo -u jschultz dbus-send --dest=com.gnome.mplayer / com.gnome.mplayer.Pause
    date +%s%N > /tmp/gnome-mplayer-pause-timestamp
fi

Choice of Desktop and Window Manager

I started with XFCE/matchbox, which worked pretty nicely but could be painfully slow. I just figured that came with the terrain of trying to run a full windows manager on such a small box.

Yesterday I changed to LXDE/openbox - what a difference! Much smarter, more responsive, it's almost a new machine. Never going back.

SHR telephony under Debian

Since the folks have got SHR packaged under debian, I've been running that as the best telephone app so far.

Still problems with windows being too small and occasional breaking of GSM connection (no ideas what that's about) but basically works not too badly.

As soon as I do the buzz fix I think I'll be able to call it a usable PDA/phone!

Some bugs and fixes

  • Unable to establish connection with FAM. Do you have "FAM" or "Gamin" installed and running?
  • Could not connect to wicd-s D-Bus interface. Check the wicd log for error messages. FIX: install notification-daemon (maybe? - still not working)
  • [elm_win.c:335] elm_win_add() elementary: ERROR. Cannot create window. FIX: install libevas-svn-03-engines-x

GPS Issues

No GPS with "Discarded data not UBX" errors ad infinitum in the framework log. Problem and fix are described here: http://www.mail-archive.com/smartphones-userland@linuxtogo.org/msg01613.html In short "rm /var/lib/freesmartphone/ogpsd.pickle" And the real fix is apparently here: http://git.freesmartphone.org/?p=framework.git;a=commitdiff;h=5271e445b327c2132eee6a1f43fcf58c37c67e00

Even though it seems to work now (well it got a fix once so far) it's very slow. It's much faster using other distros running from NAND. Might be the SD/GPS problem described here: http://wiki.openmoko.org/wiki/FreeRunner_GPS_Software_Fix_TTFF_Measurement_Test

Kernel Issues

Problems with ar6000 wifi. Arggghhhh!!! Now I'm getting this: http://lists.alioth.debian.org/pipermail/pkg-fso-maint/2009-March/000844.html Things OK if I disable wicd, but I need it for wifi config. Bah!

Personal tools

Just some notes from playing with my Freerunner

What am I trying to do? I want to run a full Linux distro on my Freerunner, with Debian the obvious choice, AND have it work as a usable telephone at the same time.

Simple but practical fun with framework

Auto-configure USB interface

Since pretty the only use I make of the USB interface is for the host computer to act as a gateway to the Net, it makes sense to run a DHCP server on my other computers and DHCP client on the Freerunner. And along with that ifplugd to detect when the USB cable is plugged in. But since ifplugd seems not to work with the ethernet over USB, I used a simple hack to framework instead. At the same time it also disables screen blanking and suspend when the USB is plugged in. Extract from /etc/freesmartphone/oevents/rules.yaml

-
   trigger: PowerStatus()
   filters: Not(HasAttr(status, "discharging"))
   actions: 
            - Command( "dbus-send --system --dest=org.freesmartphone.odeviced --type=method_call /org/freesmartphone/Device/IdleNotifier/0 org.freesmartphone.Device.IdleNotifier.SetTimeout string:idle_prelock int32:0" )
            - Command( "dbus-send --system --dest=org.freesmartphone.odeviced --type=method_call /org/freesmartphone/Device/IdleNotifier/0 org.freesmartphone.Device.IdleNotifier.SetTimeout string:suspend int32:0" )
            - Command( "ifup usb0" )
-
   trigger: PowerStatus()
   filters: HasAttr(status, "discharging")
   actions: 
            - Command( "ifdown usb0" )
            - Command( "dbus-send --system --dest=org.freesmartphone.odeviced --type=method_call /org/freesmartphone/Device/IdleNotifier/0 org.freesmartphone.Device.IdleNotifier.SetTimeout string:idle_prelock int32:30" )
            - Command( "dbus-send --system --dest=org.freesmartphone.odeviced --type=method_call /org/freesmartphone/Device/IdleNotifier/0 org.freesmartphone.Device.IdleNotifier.SetTimeout string:suspend int32:30" )
-

Locking the screen

LXDE and friends appear to lack a simple screen lock so I figured out how to do it myself. First of all a tiny snippet of python that writes its own pid to a temporary file and grabs screen input forever, or until it gets interrupted. Call this file lock_screen:

#!/usr/bin/env python

import fcntl
import os
import time

EVIOCGRAB = 0x40044590

tmp = open("/tmp/lock_screen", "w")
tmp.write (str (os.getpid ()))
tmp.close ()
screen = os.open("/dev/input/event1", os.O_RDWR|os.O_NONBLOCK)
fcntl.ioctl(screen, EVIOCGRAB, 1)
while 1:
    time.sleep (9999999)

Second, a bit of sh to start and stop the screen locker on successive calls. Call this code lock_unlock_screen:

#!/bin/sh
#
if [ -f /tmp/lock_screen ]; then
    kill `cat /tmp/lock_screen`
    rm /tmp/lock_screen
else
    DISPLAY=:0 /home/jschultz/bin/lock_screen &
fi

Finally a bit of framework configuration that makes the AUX button call the screen locker/unlocker. From /etc/freesmartphone/oevents/rules.yaml

-
    #
    # AUX button Handling
    #
    trigger: InputEvent()
    filters:
             - HasAttr(switch, "AUX")
             - HasAttr(event, "released")
             - HasAttr(duration, 0)
    actions:
             - Command( "/home/jschultz/bin/lock_unlock_screen" )
-

Use headset button to pause/unpause MPlayer

This one is great for listening to podcasts... Step one is in /etc/frameworkd.conf and makes ovents report the headset button:

[odeviced.input]
report5 = HEADSETBUTTON,key,207,1
...

Second part is in /etc/freesmartphone/oevents/rules.yaml and does two things: 1. ALSA settings to make the sound chip detect the headset button; 2. Respond to the headset button by calling a script:

    #
    # Headset Audio Scenario Support
    #
-
    trigger: InputEvent()
    filters:
             - HasAttr(switch, "HEADSET")
             - HasAttr(event, "pressed")
    actions:
             - Command('amixer -d sset "Amp Spk" mute')
             - Command('amixer -d sset "DAPM Headset Mic" on')
             - Command('amixer -d sset "Left Mixer Sidetone Playback Sw" on')
             - Command('amixer -d sset "ALC Mixer Mic1" cap')
-
    trigger: InputEvent()
    filters:
             - HasAttr(switch, "HEADSET")
             - HasAttr(event, "released")
    actions:
             - Command('amixer -d sset "Amp Spk" unmute')
             - Command('amixer -d sset "DAPM Headset Mic" off')
             - Command('amixer -d sset "Left Mixer Sidetone Playback Sw" off')
             - Command('amixer -d sset "ALC Mixer Mic1" uncap')
-
    trigger: InputEvent()
    filters:
             - HasAttr(switch, "HEADSETBUTTON")
             - HasAttr(event, "released")
             - HasAttr(duration, 0)
    actions: 
             - Command( "/home/jschultz/bin/gnome-mplayer-pause" )
-

Finally the script itself, which does a bit of debouncing (otherwise we seem to get lots of pausing and unpausing each time I push the button) and sends the debus signal to gnome-mplayer to pause/unpause:

#!/bin/sh
#
# Avoid buttom bounce by disallowing more than 2 presses per second
if [ ! -f /tmp/gnome-mplayer-pause-timestamp ] || [ $((`date +%s%N` - `cat /tmp/gnome-mplayer-pause-timestamp`)) -gt 500000000 ] ; then
    DISPLAY=:0 sudo -u jschultz dbus-send --dest=com.gnome.mplayer / com.gnome.mplayer.Pause
    date +%s%N > /tmp/gnome-mplayer-pause-timestamp
fi

Choice of Desktop and Window Manager

I started with XFCE/matchbox, which worked pretty nicely but could be painfully slow. I just figured that came with the terrain of trying to run a full windows manager on such a small box.

Yesterday I changed to LXDE/openbox - what a difference! Much smarter, more responsive, it's almost a new machine. Never going back.

SHR telephony under Debian

Since the folks have got SHR packaged under debian, I've been running that as the best telephone app so far.

Still problems with windows being too small and occasional breaking of GSM connection (no ideas what that's about) but basically works not too badly.

As soon as I do the buzz fix I think I'll be able to call it a usable PDA/phone!

Some bugs and fixes

  • Unable to establish connection with FAM. Do you have "FAM" or "Gamin" installed and running?
  • Could not connect to wicd-s D-Bus interface. Check the wicd log for error messages. FIX: install notification-daemon (maybe? - still not working)
  • [elm_win.c:335] elm_win_add() elementary: ERROR. Cannot create window. FIX: install libevas-svn-03-engines-x

GPS Issues

No GPS with "Discarded data not UBX" errors ad infinitum in the framework log. Problem and fix are described here: http://www.mail-archive.com/smartphones-userland@linuxtogo.org/msg01613.html In short "rm /var/lib/freesmartphone/ogpsd.pickle" And the real fix is apparently here: http://git.freesmartphone.org/?p=framework.git;a=commitdiff;h=5271e445b327c2132eee6a1f43fcf58c37c67e00

Even though it seems to work now (well it got a fix once so far) it's very slow. It's much faster using other distros running from NAND. Might be the SD/GPS problem described here: http://wiki.openmoko.org/wiki/FreeRunner_GPS_Software_Fix_TTFF_Measurement_Test

Kernel Issues

Problems with ar6000 wifi. Arggghhhh!!! Now I'm getting this: http://lists.alioth.debian.org/pipermail/pkg-fso-maint/2009-March/000844.html Things OK if I disable wicd, but I need it for wifi config. Bah!