Posted by Jim Morris
Wed, 27 Aug 2008 21:46:34 GMT
Background
I was getting bored waiting for Trolltech to release the next version
of Qtopia for the Freerunner, so I ported the xgps client from gpsd's
distribution to Qtopia.
As you may know by now, Qtopia does not have X11 so none of the
existing X11 based or GTK based GPS clients work. I was exploring GPSD
because I wanted to to be able to get a one time position for my sunset
calculator which requires your current latitude and longitude.
Although GPSD is not well suited for that (thats a whole other blog
entry), I did notice you can connect to it over the ethernet, so I was
playing with cgps and xgps that you find in the GPSD tar file, running
on my desktop, talking to gpsd running on my Freerunner.
So wanting to dust of my Qt skills (which were so ancient I barely
even recognize Qt4) I decided to port xgps to Qt.
I first did a pretty straight forward port to my Desktop Qt4/X11.
I designed the form using designer, then plugged in the code taken as
closely as I could from xgps. This was not 1:1 by any means as XLib
and Qt are not similar ;) I ended up just taking the ideas and
algorithms from the xgps program and recoding.
So that took a day or so, as I was relearning Qt as I went, I have to
say the documentation for Qt is excellent, unlike another graphics
library I could mention (I'm looking at you GTK).
I got the basics working, and as my GPS fix inside was not very good
(works about 50/50), I found you could also point any gpsd based
client at gpsd.rellim.com and always get good data from there, this is
great for testing.
So I had qtgps (for want of a better name) running on my desktop,
looking pretty much the same as xgps, with the satellite list the sky
view and of course the basic Fix data.

Now the trick to port it to FR, so I could run this on my FR.
The UI wasn't going to fit on the FR screen so I revamped the UI in
Designer, by basically dragging all the views into a tabbed frame. So
the satellite list, the sky view, the position information and the
movement information all had their own tab, this fits pretty well on a
tiny screen.

Other than that I didn't have to do much. I had to create a new
qtgps.pro file for Qtopia, as the qmake qt one is somewhat different.
I had to use the skeleton main.cpp that all Qtopia apps seem to use,
but the bulk of the code remains the same.
Sending signals from callbacks
I did have an interesting time trying to figure out how to emit a
signal from the gps callback thread to the main window, not sure if I
chose the right way to do it but it worked... I created a singleton
QObject based class, and allowed it to be called statically, then that
does the emit. This is used to signal the main display thread that new
gps data has arrived. (Note this won't work if the singleton can be
called concurrently from multiple threads, Google c++ singleton
pattern to see how to do that).
// Singleton for sending signal from a callback
class ExtSig : public QObject
{
Q_OBJECT
public:
static ExtSig *self();
void send(struct gps_data_t* p, char* buf);
signals:
void sendit(struct gps_data_t* p, char* buf);
private:
ExtSig();
};
// Singleton defns for emiting a signal from a callback
ExtSig::ExtSig(){}
ExtSig *ExtSig::self()
{
static ExtSig inst;
return &inst;
}
void ExtSig::send(struct gps_data_t* p, char* buf)
{
emit sendit(p, buf);
}
// in callbeck call...
// signal the GUI thread we have new gps data
ExtSig::self()->send(p, buf);
Howto build your own applications
Ok so how can you write your own Qtopia applications? There are at
least two ways, 1) use the VMPlayer based Toolchain that Trolltech
provide, or 2) setup your Linux workstation to use the toolkit. 1) is
easier, and just works on pretty much anything that runs VMPlayer and
has a lot of memory. 2) is faster and used less memory. I chose 2) but
I did play with 1).
I won't go into how to do 1) as it is pretty much straight forward,
just download the
iso, and
install it (either from a loopback device or from a burned CD).
The second method is not so well documented (if at all) so here is
what I did to make it work on a Ubuntu Hardy i686 32-bit workstation
with KDE installed..
Download the
toolchain
and install it into /opt/toolchains, it seems it must be there
otherwise it doesn't quite work.
Then download the latest
qtopia snapshot and put that in a
working directory and set QTOPIA_DEPOT_PATH to that directory.
Then create a build directory for the qtopia build and set the QPEDIR
environment variable to that path.
In my case I have
QTOPIA_DEPOT_PATH=/opt/QtopiaSDK/qtopia-opensource-src-4.3.2-snapshot-20080815
and
QPEDIR=/opt/QtopiaSDK/build/qtopia-4.3.2
Now we need to build the qtopia snapshot, you can use the result to
copy to /opt/Qtopia on your FR, or not, but you need to do this to get
the tools to build your own apps.
Now follow these steps to build Qtopia:-
> cd $QPEDIR
> $QTOPIA_DEPOT_PATH/configure -device ficgta01
> make
> make install
Go get some coffee or Dinner :) this will take a while.....
Now you will have a full Qtopia build in $QPEDIR/image
You can use the following script to copy this to your FR, it is
modified from Trolltechs update script. It will keep your settings.
However you will have needed to have flashed to the 0808 version of
Qtopia and kernel for this to work.
#!/bin/sh
QTOPIA_DIR=$QPEDIR/image
QTOPIA_IMAGE=qtopia.tar.gz
PHONEIP=192.168.0.200
# sudo ifconfig usb0 192.168.0.200 up
tar -C $QTOPIA_DIR czvf $QTOPIA_IMAGE
cat $QTOPIA_IMAGE | ssh "root@$PHONEIP" '(set -x;rm -f /tmp/restart-qtopia;killall qpe; mkdir -p /opt/Qtopia;rm -rf /opt/Qtopia/*; cd /opt/Qtopia;gunzip |tar xvf -;/etc/init.d/qpe start &)'
Whether you do that or just keep the Trolltech released image you are
now ready to write your own apps. I recommend you study the
Qt docs Qtopia is pretty much Qt4.3 at
the moment.
As an example you can use the
qtgps.tar.gz as an
example app or use $QTOPIA_DEPOT_PATH/examples/application
I created a build/myapps directory, and then tar xvfz qtgps.tar.gz
into that directory. Then...
> cd build/myapps/qtgps
> $QPEDIR/bin/qtopiamake
> make
This will create a qtgps excutable that you can copy to your FR and
run.
A nice trick I found is to run a GUI app from the ssh into FR you can
do this...
> ssh 192.168.0.200
> . /opt/Qtopia/qpe.env
> ./qtgps
The app will popup on the FR screen, you could also run it from the
terminal on the FR or from the file manager on the FR.
To create a new application you can do this..
> cd build/myapps/mynewapplication
> ... edit some .cpp and .h files
> $QPEDIR/bin/qtopiamake -project
> ... edit mynewapplication.pro appropriately
> $QPEDIR/bin/qtopiamake
> make
The skeleton main.cpp should look like this...
#include "mynewapp.h"
#include <qtopiaapplication.h>
QTOPIA_ADD_APPLICATION(QTOPIA_TARGET,MyNewApp)
QTOPIA_MAIN
The rest of the files are up to you. I like to create the UI using
designer...
> $QPEDIR/bin/designer mynewapp.ui
look in either example.cpp or qtgps.cpp and qtgps.h on how to
initialize a designer based UI.
There are lots of example apps on the Trolltech docs site.
Running app on the workstation
If you want to run the app locally rather than on your FR, you can use
$QPEDIR/bin/qvfb
You will need to build a native version of qtopia to do that, which
can be done by repeating the above steps but in a new build directory
do:-
> export QPEDIR=build/qtopia-native
> mkdir $QPEDIR
> cd $QPEDIR
> $QTOPIA_DEPOT_PATH/configure -device i686fb
> make
> make install
and then rebuild your app for the native machine...
> cd build/myapps/qtgps
> make clean
> $QPEDIR/bin/qtopiamake
> make
Then run the native version of your app, but you will need to do the following to make the size
correct...
> export QWS_DISPLAY=QVFb:mmWidth43:mmHeight58:0
> $QPEDIR/bin/qvfb -width 480 -height 640 &
> sleep 2
> ./qtgps -qws gpsd.rellim.com
This will run qtgps on the local workstation in a simulation of the FR
screen (without qtopia), using gps data from gpsd.rellim.com.
Packaging
UPDATED I figured out how to install.
This document
explains how to install a package so it shows up in the applications
list, here is how I actually did it.
I created a directory called feed in my work directory, and set the
path to $HTTPDIR. Then I ran a simple web server (I used boa but any
will do), that points to $HTTPDIR to serve files.
Then I built the qpk package...
> cd $WORKDIR/qtgps
> make packages
> $QPEDIR/bin/mkPackages $HTTPDIR
Then make sure the web server is running, on the FR goto the Software
Packages App, add the following server to the server lists
http://192.168.0.200:8000, this presumes you are connected via USB and
you ran the webserver at port 8000. Then click download, and you
should see qtgps in the list, select it for install, and it will get
installed. From then on you can replace the qtgps binary it installs
with any new builds. It will be under
/home/root/packages/somelongrandomstring/bin/qtgps
If you are using the vmplayer version of the SDK, then you can simply
do this...
> sdk -b
> sdk -p
> sdk -i
Where to get the source
The source code to this project is now on github
http://github.com/wolfmanjm/qtopiagps/tree/master
Installing required libraries for the toolchain
UPDATE I forgot to mention how I got the libgps stuff into the
toolchain. I found a hack, first I built gpsd-dev using mokomakefile
then I did this...
dpkg-deb -X build/tmp/deploy/glibc/ipk/armv4t/gpsd-dev_2.34-r9_armv4t.ipk /opt/QtopiaSDK/opt/toolchains/arm920t-eabi/arm-angstrom-linux-gnueabi
This worked for this case and setup the .so links correctly. You could
also copy the libgps.so from your FR.
Another user (Radek Barton) did it this way, but I haven't tested
this...
1. Download lastest gpsd source code at http://download.berlios.de/gpsd/gpsd-2.37.tar.gz and unpack it somewhere.
2. Add line #include <linux/limits.h> to gpsd.h-head file.
3. Modify line 15 of gps.h file from <limits.h> to <linux/limits.h>
4. configure with command: PATH=/opt/toolchains/arm920t-eabi/bin:$PATH ./configure --host=arm-angstrom-linux-gnueabi
5. Then make, make install, etc.
For those that cannot do that, then download this tar file to /pathtodownload/...
and...
> cd /
> tar xzvf /pathtodownload/libgps.tar.gz
This presumes that your Qtopia toolchain is in /opt/toolchains
Posted in Openmoko | Tags freerunner, gps, openmoko | 6 comments | no trackbacks
Posted by Jim Morris
Mon, 11 Aug 2008 06:09:00 GMT
I finally got around to building ruby 1.8.6 for my FR. I modified the
ruby bitbake files that I found in the Mokomakefile openembedded
directory. I am not sure how one actually is meant to do this, as the
OE site is down and the docs don't explain it. So I just replcaed the
1.8.5 ones with the 1.8.6 ones. I also managed to fix a bug in the
1.8.5 BB recipe that was causing socket to not build.
I also got the ruby dbus library to work, although I don't know what to
do with it yet :)
So until I figure out how you are meant to add a new version to OE,
I have put the ipk here.
If you want ruby 1.9 you can find it
here
To install it just ssh into your FR and type
> wget http://blog.wolfman.com/files/ruby_1.8.6-p287-r1_armv4t.ipk
> opkg install ruby_1.8.6-p287-r1_armv4t.ipk
If you want to install gem then you need to ssh into the FR and do
this...
> wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
> tar xzvf rubygems-1.2.0.tgz
> cd rubygems-1.2.0
> ruby setup.rb --no-rdoc --no-ri
I recommend you do the no doc and no ri otherwise it takes forever.
As for dbus...
> wget https://trac.luon.net/data/ruby-dbus/releases/ruby-dbus-0.2.1.tar.gz
> tar xzvf ruby-dbus-0.2.1.tar.gz
> cd ruby-dbus-0.2.1
> ruby setup.rb config
> ruby setup.rb setup
> ruby setup.rb install
look in the examples to see how to use it, I tries this...
> ruby examples/utils/listnames.rb --system
org.freedesktop.DBus
:1.3
:1.4
org.freedesktop.Avahi
:1.0
org.bluez
:1.1
:1.6
:1.2
org.freedesktop.Hal
So it seems to work.
Let me know what you do with it.
I also built jove, my favorite mini-emacs editor, this is just an
executable just copy to /usr/bin Use instead of vi or nano.
Posted in Openmoko | Tags freerunner, ruby | no comments | no trackbacks
Posted by Jim Morris
Tue, 22 Jul 2008 20:20:08 GMT
Well I have had this thing for a few weeks now, and I have burned a lot
of hours playing with it :) (Wish I could bill someone for those
hours it would have paid for the phone 4 times over!)
I started with 2007.2 the built in image, and upgraded it initially
with dfu-util, then with opkg update && opkg upgrade.
I installed a bunch of things and tweaked it to death (literally).
I got Jalimo
java installed and working, and wrote the simple SWT app which worked nicely.
The only change to the instructions are you need to add
-force-depends to the opkg command.
As reported in my
other blog article
I got WIFI/WPA2 working, and finally got GPRS working.
I have not tried to pair with a bluetooth headset yet, although got
far enough to see that the device could be seen using the scan
command.
I played with all the varieties of on screen keyboards available, but
really couldn't use any of them as they are so small, and my eyes are
not that good anymore. I have seen some promising mentions of works in
progress for keyboards, but the ones in the Qtopia distribution are
the best, plus they have handwriting recognition which is a little
fussy but looks like it can be trained.
The GPS problems were fixed by an amazing community and OpenMoko
effort, which I have never seen before. There is a S/W fix, and a H/W
fix which I suspect most people will not be able to do, soldering
surface mount components is not for the faint of heart!
I spent several hours trying to build the OpenEmbedded and
the MokoMakefile development environments, so I could start to
contribute, but have still not been able to get them to finish
building the native toolchain needed to build any of the apps.
I get several errors, some of which I found workarounds to by googling
but eventually hit dead ends in both cases which I could not solve and
have not been reported or solved by the community. I am using a stock
KUbuntu 8.08 Hardy Heron desktop, which should be pretty mainstream,
so I don't know what is wrong. The pre built toolchain OpenMoko
provides for building apps does work however, but you can't build
soft keyboards, or system components that route (at least I couldn't
find a way to do it). I'll continue to hammer away at MokoMakefile and
see if I can eventually get it going, of course I'll post my findings
to the Wiki or dev mailing list if I succeed.
If someone could provide a VMPlayer image of a working OE or
Mokomakefile environment that would help a lot of us.
(Trolltech/Qtopia do provide exactly that for their development
tools).
So after several opkg upgrades and tweaks, I finally killed my highly
customized rootfs, X would no longer boot, sound was dead etc etc.
I tried to backup the image using
these instructions,
but always got an error halfway through, I suspect my flash image of
rootfs may have been corrupted. Anyway I lost all that work :(
I tried flashing ASU, but it seems too much a work in progress more so
than 2007.8.
Then I tried
Qtopia
now this is much more to my liking. The interface is clean, intuitive
and seems to work pretty well. There are still a few rough edges which
Trolltech seem to be taking care of, but it mostly works pretty well. The
on screen input methods (which there are several of) are very good,
even the keyboard has a nice touch where it zooms into the keys you
are touching. It also has the tiny tiny QWERTY keyboard if you prefer
that style and your eyes still work.
The downside is of course you lose access to all the applications
currently under development for the GTK based 2007.2, but Qtopia does
have a growing number of applications, and of course you can write
your own.
I am going to experiment a little with trying to run GTK based apps
under Qtopia, I know I can do that on my KDE (aka QT) desktop, so why
not under Qtopia? I'll update this if I get it to work.
UPDATE Oh ok the reason you can't do that is that Qtopia is not
running X Windows, so running GTK is not an option, bummer. I suppose you
could render GTK into a QT canvas or something but that is more work
than I am prepared to do at the moment.
The current show stoppers for me, which stops me being able to use
this a phone are...
- Nasty buzzing noise on both ends of the call
- Bluetooth pairing with a headset not easily available.
I'm sure people are working on these issues, and I wait patiently for
them to get fixed so I can dump my aging Motorola V600. I'd actually
try to pitch in myself but I can't get the development environment to
work!
Oh well guess I better get back to my paying job :)
Posted in Openmoko, Linux | Tags freerunner, openmoko | 4 comments | no trackbacks
Posted by Jim Morris
Fri, 11 Jul 2008 20:53:11 GMT
OK so I just got my shiny new OpenMoko Freerunner GTA02.
This is an Open source GSM cell phone, running Linux and OpenMoko S/W stack.
This phone is really a developer release although it implies on the
website it is usable for the masses.
We will see...
Turning it on you see all this Linux boot up tiny tiny text scroll by,
ya the average Joe blo is going to love that ;)
So I followed the
startup guide
and plugged in the usb cable to my Ubuntu desktop. (If you don't have
Linux think again, maybe that $400's can go towards a tank of gas).
I followed the usb networking guide, and ssh'd into the phone, and
Holy Crap! it just worked!
First off it doesn't come with much, It can make a phone call, but no
other apps seem to be loaded.
Oh one gripe is there is nowhere to stow a stylus, it comes with a
huge pen/laser pointer/stylus, but who is going to keep that in their
pocket, and those with fat fingers are going to have a hard time doing
anything.
I actually had to RTFM to figure out how to close an application! BTW
this guide
seems to be pretty good. (You click the power button to close an app!
it really needs a close button somewhere where people expect one).
After loading most of the needed apps via the opkg app, which is slow
via USB 1.1 (whats up with that guys? its 2008! USB 2 is REQUIRED)
I found that most of them are pretty much unusable. The default
2007.2 UI is unintuitive, and most of the necessary apps simply don't
work well. Adding a contact is virtually impossible, try setting the
phone number to home instead of work for instance.
The web browser works but you can't input anything into forms, so
don't try logging into gmail.
The calendar makes no sense whatsoever.
OK so I am being harsh here, but the damn thing costs $400! and they
imply your average user could use it as a phone, so lets get over that
issue, and take it that this is a work in progress, very early stages,
and open source. It needs a good UI guide, come on we may not have a
super UI design guy, but copy the iphone or any other phone on the
market to get a clue how to make an intuitive UI. I am not a UI guy,
but even I can see this needs some work. BTW I do like the way the
scrolling works, that is very cool, you flick up or down and it
scrolls with some friction looks great, and works even better.
The platform itself has plenty of potential, built in GPS (which
doesn't work without an external antenna), accelerometers, which no one
has figured out how to use yet. A really nice VGA display, although
its invisible in bright sunlight, wifi which I was totally unable to
get to connect to a WPA/PSK station, and bluetooth, with no S/W support
for headsets.
Once all these issues are resolved I think it would make a great
primary handset.
I'll do my part and write something for it and release it as open
source, but I'm disappointed I can't use this as a phone yet.
I'll continue to RTFM if I can find one that describes the current UI
(the WIKI describes an obsolete UI). Maybe some of my issues are
simply not knowing how to use the UI, but that is a bad sign as I am a
developer and can use most UI's without RTFM'ing.
I still think this is a great (if expensive) toy for now, especially
for us Linux Geeks, and one day it may actually be a great phone too.
GPRS
UPDATE I got GPRS working, followed the instructions on the
WIKI, it is manual but it works.
My tmobile chatscript is...
# File: /etc/ppp/chatscripts/tmobile
TIMEOUT 20
ABORT BUSY
ABORT "NO ANSWER"
ABORT "NO DIALTONE"
ABORT VOICE
ABORT ERROR
ABORT RINGING
SAY 'Starting GPRS connect script\n'
"" +++
OK ATZ
OK ATE1
OK AT+CFUN=1
OK AT+COPS
SAY 'Setting APN\n'
OK AT+CGDCONT=1,"IP","wap.voicestream.com"
ABORT 'NO CARRIER'
SAY 'Dialing...\n'
OK ATD*99***1#
CONNECT /n/d
and the script
# File: /etc/ppp/peers/tmobile
#
/dev/ttySAC0
115200
crtscts
lock
hide-password
defaultroute # set the default route
usepeerdns
holdoff 3
ipcp-accept-local
lcp-echo-failure 12
lcp-echo-interval 3
noauth
noipdefault
novj
novjccomp
replacedefaultroute
persist
debug
connect "/usr/sbin/chat -v -f /etc/ppp/chatscripts/tmobile"
disconnect "/usr/sbin/chat -v -f /etc/ppp/chatscripts/tmobile-disconnect"
and a script to run it all...
/etc/init.d/gsmd stop
echo "1" > /sys/bus/platform/devices/neo1973-pm-gsm.0/power_on
chown uucp.uucp /dev/ttySAC0
stty -F /dev/ttySAC0 crtscts
pppd call tmobile
GPS
I did get a fix with the GPS using the internal antenna, however it
takes some concerted effort, see this page
for hints. NOTE without the sd card I get a fix within 1 minute.
WIFI
UPDATE Got WIFI and WPA/PSK working, again there are two sets of
instructions on the WIKI, the first set doesn't work for me, however
the second set does... adding
iface eth0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
to /etc/network/interfaces and then do ifdown usb0 and ifup eth0 of
course you need to setup /etc/wpa_supplicant/wpa_supplicant.conf
appropriately. However when I ssh into the phone via the wifi after
disconnecting the USB, it looses its connection regularly and usually
within a few minutes. Not sure why that is, my WIFI is generally very
stable with my laptop. I wonder if the bluetooth is interfering with
it?
Finally I would like to say that I love the idea of an open spurce
cell phone. I can see that these issues will probably get fixed pretty
quickly as it is open source and there are thousands of eyes on the
code, and if there is something you don't like you can fix it. Lets
see you do that on your I-Phone ;)
Posted in Openmoko, Linux | Tags freerunner, openmoko | 19 comments | no trackbacks