User:Nukama

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (OpenWrt)
m (USB-Networking)
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==== Bicycle ====
+
= Software related =
  
Dynamo powered openmoko (and other USB-Devices/Host) using the frequency/voltage of the dynamo to gather information about speed and distance.
+
== [[Distributions]] ==
  
Wishlist for this USB-Charger:
+
=== [[OpenWrt]] ===
* 5V, 500-1500mA output (through diodes or MOSFET)
+
* Voltage, Frequency (should be dynamohub independable)
+
* USB-Device (maybe with USBprog)
+
  
nice to
+
append "arch s3c24xx 1" to /etc/opkg.conf
* 3d compass, altimeter, thermometer (with information of distance to map tunnels, dense forest, ...)
+
* buttons for turning lights (on lowpower/on highpower/off), setting waypoints/audionotes, easy navigation of openmoko (scrolling/enter)
+
  
==== A-GPS ====
+
 
agps.sh
+
Useful packages:
 +
opkg install openssh-sftp-server
 +
 
 +
 
 +
=== [[SHR]] ===
 +
 
 +
 
 +
==== Installation ====
 +
 
 +
ubi - ubinized for flashing with [[NeoTool]]
 +
 
 +
ubifs - [[UBIFS]]
 +
 
 +
 
 +
==== Problems  ====
 +
with shr-lite-eglibc-ipk--20100115-om-gta02.rootfs @ uImage-2.6.32.3-oe1+gitr1+5827b20d022fb47ce9c9731d0fb894d361e16ffe-r4-om-gta02.bin booted with qi-ubi-s3c2442-1.0.2-r0+gitr0+c38b062a609f1442e6a9e13005cfbdfd59a5ac0d.udfu
 +
 
 +
 
 +
*whitescreen(ofstarving) from resuming and dimming, sometimes the lock-screen appears
 +
 
 +
Workaround: edit /etc/phonefsod.conf
 +
                         
 +
auto_suspend = never  /maybe normal would work also...
 +
 
 +
== USB-Networking ==
 +
 
 +
=== [[FreeBSD]] ===
 +
 
 +
 
 +
==== devd ====
 +
 
 +
Figure out the ugen for your Openmoko device:
 +
<pre>dmesg | grep ugen | grep Linux</pre>
 +
Then note down idVendor and idProduct value:
 
<pre>
 
<pre>
agps-alm.py > /dev/ttySAC1
+
# usbconfig -d ugenU.A dump_device_desc | grep idVendor
 +
# usbconfig -d ugenU.A dump_device_desc | grep idProduct
 
</pre>
 
</pre>
  
agps-alm.py
+
Configure devd(8) to perform an action if a device with the appropriate vendor and product string is attached.
<pre>
+
#!/usr/bin/python
+
#
+
# ublox AssistNow Online almanac downloader for Neo FreeRunner
+
#
+
# v0.1
+
#
+
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
+
#
+
# Usage:
+
#
+
# agps-alm.py > /dev/ttySAC1
+
#
+
  
import sys
+
/etc/devd.conf
import socket
+
<pre>#Openmoko Freerunner with Linux 2.6.34+
import re
+
attach 100 {
 +
        device-name "ugen[0-9]+";
 +
        match "vendor" "0x0525";
 +
        match "product" "0xa4a2";
 +
        action "perl /usr/local/etc/neo_if.pl /dev/$device-name";
 +
};</pre>
  
user='your@mail.address'
+
This action consists of switching to network mode:
pwd='pwdfromublox'
+
<pre># usbconfig -d ugenU.A set_config 1</pre>
 +
and assigning an IP address:
 +
<pre># ifconfig ue0 192.168.0.200/24</pre>
 +
This is also done with this script:
  
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
/usr/local/etc/neo_if.pl
s.connect(('agps.u-blox.com',46434))
+
<pre>#!/usr/bin/perl
 +
my ($u, $ad) = $ARGV[0] =~ /(\d+)\.(\d+)$/;
 +
print ("usage: $0 /dev/ugen4.2\n"), exit unless (length $u and length $ad);
 +
print `usbconfig -u $u -a $ad set_config 1
 +
#ifconfig ue0 link 00:1f:11:01:71:62 # uncomment if moko reports: usb0: duplicate address detected!
 +
ifconfig ue0 192.168.0.200/24`;</pre>
  
s.send('user='+user+';pwd='+pwd+';cmd=alm;lat=0;lon=0;pacc=40000000;\n')
+
Finally restart the devd daemon with:
 +
<pre># service devd restart</pre>
  
buf = s.recv(4096)
+
If you now plug the FreeRunner into the USB port the cdce0 interface gets created and the IP address will be assigned.  
while 1:
+
        b = s.recv(4096)
+
        if not b:
+
                break
+
        buf += b
+
  
h = {}
 
  
while 1:
+
==== Routing ====
        (l,s,buf) = buf.partition('\n')
+
<pre>
        l = l.rstrip('\r\n')
+
          __________________      ____________________      ____________________
        #
+
        |                  |    |                    |    |                    |
        sys.stderr.write(l+'\n')
+
        | Router          |    | Workstation        |    | Freerunner         |
        #
+
        |                  |    |                    |    |                    |
         if (l == ""):
+
        | eth0 192.168.1.1 |-----| eth0 192.168.1.2  |    |                    |
                if h.has_key('content-length') and h['content-length'].isdigit() and h.has_key('content-type') and h['content-type'] == 'application/ubx':
+
ISP-----| ppp0 DHCP        |    | ue0  192.168.0.200 |-----| usb0 192.168.0.202 |
                        sys.stdout.write(buf[0:int(h['content-length'])])
+
        |__________________|    |____________________|    |____________________|
                sys.exit(0)
+
 
        #
+
        m = re.search('\\A(.+): (.+)\\Z',l)
+
        if m:
+
                h[m.group(1).lower()] = m.group(2).lower();
+
 
</pre>
 
</pre>
  
 +
Enable on your FreeBSD workstation ip forwarding from one interface to another:
 +
<pre># sysctl net.inet.ip.forwarding=1</pre>
  
==== Enscribi on OM2009 ====
+
For persistent forwarding enable gateway inside
  
Step 1:
+
/etc/rc.conf
opkg install http://www.opkg.org/packages/zinnia_0.04_armv4t.ipk
+
<pre>gateway_enable="YES"</pre>
opkg install http://www.opkg.org/packages/0_zinnia-tomoe-ja_0.6.0-20080911_armv4t.ipk (for Japanese support)
+
or the appropriate sysctl variable inside
opkg install http://www.opkg.org/packages/0_zinnia-tomoe-zh_0.6.0-20080911_armv4t.ipk (for Chinese support)
+
opkg install http://www.opkg.org/packages/enscribi_0.2.0_armv4t.ipk
+
  
 +
/etc/sysctl.conf
 +
<pre>net.inet.ip.forwarding=1</pre>
  
Step 2:
 
  
Create symbolic links for the old libs (tested with om2009-unstable 17-Aug-2009 17:19)
+
Add a route inside your router.
If enscribi is linked against the new libs then these symbolic links are obsolete.
+
<pre># route add -net 192.168.0.0/24 gateway 192.168.1.2</pre>
 +
or
 +
<pre># route add -host 192.168.0.202 gateway 192.168.1.2</pre>
 +
 
 +
 
 +
Adjust the firewall of your router to pass packets from your Freerunner.
 +
<pre>pass in quick on $intif inet from 192.168.0.202 to any flags S/SA keep state label "USER_RULE: Openmoko Freerunner"</pre>
 +
 
 +
If you have no control over your router use Network Address Translation.
 +
 
 +
 
 +
==== NAT ====
 +
 
 +
Load kernel modules for firewall/NAT:
 +
 
 +
/boot/loader.conf
 
<pre>
 
<pre>
ln -s /usr/lib/libecore_evas-ver-svn-02.so.0 libecore_evas-ver-pre-svn-01.so.0
+
ipfw_load="YES"
ln -s /usr/lib/libecore_fb-ver-svn-02.so.0 libecore_fb-ver-pre-svn-01.so.0
+
ipdivert_load="YES"
ln -s /usr/lib/libecore_x-ver-svn-02.so.0 libecore_x-ver-pre-svn-01.so.0
+
ln -s /usr/lib/libecore_input-ver-svn-02.so.0 libecore_input-ver-pre-svn-01.so.0
+
ln -s /usr/lib/libecore_x-ver-svn-02.so.0 libecore_txt-ver-pre-svn-01.so.0
+
ln -s /usr/lib/libedje-ver-svn-02.so.0 libedje-ver-pre-svn-01.so.0
+
ln -s /usr/lib/libembryo-ver-svn-02.so.0 libembryo-ver-pre-svn-01.so.0
+
ln -s /usr/lib/libecore_job-ver-svn-02.so.0 libecore_job-ver-pre-svn-01.so.0
+
ln -s /usr/lib/libevas-ver-svn-02.so.0 libevas-ver-pre-svn-01.so.0
+
ln -s /usr/lib/libecore-ver-svn-02.so.0 libecore-ver-pre-svn-01.so.0
+
ln -s /usr/lib/libeina-ver-svn-02.so.0 libeina-ver-pre-svn-01.so.0
+
 
</pre>
 
</pre>
  
Step 3:
 
goto "setup" --> "keyboard" --> "enscribi"
 
  
To get a Chinese/Japanese input method. Ensure, that you have Chinese/Japanes fonts installed.
+
Set default policy to accept:
  
 +
/etc/syctl.conf
 +
<pre>
 +
net.inet.ip.fw.default_to_accept=1
 +
</pre>
  
==== OpenWrt ====
 
 
append "arch s3c24xx 1" to /etc/opkg.conf
 
  
 +
Configure an alias for Freerunner, enable ip forwarding and firewall.
  
 +
Enable natd on the interface connected to the router, replace eth0 with this interface (i.e. re0, em0).
 +
Use the alias as redirect address inside your LAN.
  
 +
/etc/rc.conf
 +
<pre>
 +
ifconfig_eth0="inet 192.168.1.2/24"
 +
ipv4_addrs_eth0="192.168.1.202/32"
 +
gateway_enable="YES"
 +
firewall_enable="YES"
 +
firewall_type="OPEN"
 +
natd_enable="YES"
 +
natd_interface="eth0"
 +
natd_flags="-redirect_address 192.168.0.202 192.168.1.202"
 +
</pre>
  
==== USB-Networking ====
 
  
===== OpenWrt =====
+
=== [[OpenWrt]] ===
  
 
/etc/config/network
 
/etc/config/network
Line 120: Line 159:
 
option proto static
 
option proto static
 
option ifname eth0
 
option ifname eth0
option ipaddr 192.168.0.1
+
option ipaddr 192.168.0.202
 
option netmask 255.255.255.0
 
option netmask 255.255.255.0
option gateway 192.168.0.2
+
option gateway 192.168.0.200
 
option dns 208.67.222.222
 
option dns 208.67.222.222
 
</pre>
 
</pre>
  
===== Ubuntu 9.10 =====
+
Without modifying the /etc/config/network
 
<pre>
 
<pre>
sudo iptables -I INPUT 1 -s 192.168.0.1 -j ACCEPT
+
sudo iptables -I INPUT 1 -s 192.168.1.1 -j ACCEPT
sudo iptables -I OUTPUT 1 -s 192.168.0.2 -j ACCEPT
+
sudo iptables -I OUTPUT 1 -s 192.168.1.2 -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24
+
sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24
 
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
 
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
 
</pre>
 
</pre>
  
  
===== Ubuntu 8.10 =====
+
=== Ubuntu 9.10 ===
 
<pre>
 
<pre>
 
sudo iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT
 
sudo iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT
Line 143: Line 182:
 
</pre>
 
</pre>
  
===== Ubuntu 9.04 =====
+
== Packages ==
/etc/network/freerunner (chmod -x)
+
 
 
<pre>
 
<pre>
#!/bin/sh
+
ffalarms
#
+
dates
# configures the freerunner for internet
+
openssh-sftp-server
#
+
tangogps
#
+
navit
 +
zinnia
 +
zinnia-tomoe-zh
 +
enscribi
 +
ttf-arphic-uming
 +
elementary-sms?
 +
elementary-alarm?
 +
intone
 +
intone-video
 +
browser
 +
</pre>
  
DEVICE=usb0
+
=== Enscribi on OM2009 ===
IPADDR=192.168.0.200
+
REMOTE_IPADDR=192.168.0.202
+
NETMASK=255.255.255.0
+
  
# get first ip for dns
+
Step 1:
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)
+
opkg install http://www.opkg.org/packages/zinnia_0.04_armv4t.ipk
 +
opkg install http://www.opkg.org/packages/0_zinnia-tomoe-ja_0.6.0-20080911_armv4t.ipk (for Japanese support)
 +
opkg install http://www.opkg.org/packages/0_zinnia-tomoe-zh_0.6.0-20080911_armv4t.ipk (for Chinese support)
 +
opkg install http://www.opkg.org/packages/enscribi_0.2.0_armv4t.ipk
  
case "$1" in
 
start)
 
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR
 
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP
 
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP
 
  
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then
+
Step 2:
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward
+
echo 1 > /proc/sys/net/ipv4/ip_forward
+
fi
+
;;
+
stop)
+
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR
+
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP
+
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d  $IPADDR --dport domain -j DNAT --to-destination $DNSIP
+
  
if [ -f /var/run/openmoko.ip_forward ]; then
+
Create symbolic links for the old libs (tested with om2009-unstable 17-Aug-2009 17:19)
rm /var/run/openmoko.ip_forward
+
If enscribi is linked against the new libs then these symbolic links are obsolete.
echo 0 > /proc/sys/net/ipv4/ip_forward
+
<pre>
fi
+
ln -s /usr/lib/libecore_evas-ver-svn-02.so.0 libecore_evas-ver-pre-svn-01.so.0
;;
+
ln -s /usr/lib/libecore_fb-ver-svn-02.so.0 libecore_fb-ver-pre-svn-01.so.0
esac
+
ln -s /usr/lib/libecore_x-ver-svn-02.so.0 libecore_x-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore_input-ver-svn-02.so.0 libecore_input-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore_x-ver-svn-02.so.0 libecore_txt-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libedje-ver-svn-02.so.0 libedje-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libembryo-ver-svn-02.so.0 libembryo-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore_job-ver-svn-02.so.0 libecore_job-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libevas-ver-svn-02.so.0 libevas-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore-ver-svn-02.so.0 libecore-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libeina-ver-svn-02.so.0 libeina-ver-pre-svn-01.so.0
 +
</pre>
  
 +
Maybe link the old libs against the even older libs. But seems not to work.
 +
<pre>
 +
cd /usr/lib
 +
cp /location-of-old-libs-for-enscribi/* .
 +
ln -s /usr/lib/libecore_evas-ver-svn-02.so.0.9.9 libecore_evas-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore_fb-ver-svn-02.so.0.9.9 libecore_fb-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore_input-ver-svn-02.so.0.9.9 libecore_input-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore_job-ver-svn-02.so.0.9.9 libecore_job-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore-ver-svn-02.so.0.9.9 libecore-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore_x-ver-svn-02.so.0.9.9 libecore_x-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libecore_x-ver-svn-02.so.0.9.9 libecore_txt-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libedje-ver-svn-02.so.0.9.92 libedje-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libeina-ver-svn-02.so.0.0.2 libeina-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libembryo-ver-svn-02.so.0.9.9 libembryo-ver-pre-svn-01.so.0
 +
ln -s /usr/lib/libevas-ver-svn-02.so.0.9.9 libevas-ver-pre-svn-01.so.0
 
</pre>
 
</pre>
  
/etc/udev/rules.d/80-freerunner.rules
+
Step 3:
 +
goto "setup" --> "keyboard" --> "enscribi"
 +
 
 +
To get a Chinese/Japanese input method. Ensure, that you have Chinese/Japanes fonts installed.
 +
 
 +
  opkg install task-fonts-truetype-chinese
 +
 
 +
http://trac.shr-project.org/trac/ticket/868
 +
 
 +
 
 +
== other tricks ==
 +
=== A-GPS ===
 +
agps.sh
 
<pre>
 
<pre>
# This file causes programs to be run on device insertion.
+
agps-alm.py > /dev/ttySAC1
# See udev(7) for syntax.
+
# rule to assign a fixed mac address specified in /
+
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"
+
 
</pre>
 
</pre>
  
/usr/local/sbin/freerunner-usb-add.sh  (chmod -x)
+
agps-alm.py
 
<pre>
 
<pre>
#!/bin/sh
+
#!/usr/bin/python
(
+
#
ip address add 192.168.0.200/26 netmask dev usb0 > /dev/null
+
# ublox AssistNow Online almanac downloader for Neo FreeRunner
ip link set usb0 up > /dev/null
+
#
/etc/network/freerunner start
+
# v0.1
) &
+
#
exit 0
+
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
 +
#
 +
# Usage:
 +
#
 +
# agps-alm.py > /dev/ttySAC1
 +
#
 +
 
 +
import sys
 +
import socket
 +
import re
 +
 
 +
user='your@mail.address'
 +
pwd='pwdfromublox'
 +
 
 +
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 +
s.connect(('agps.u-blox.com',46434))
 +
 
 +
s.send('user='+user+';pwd='+pwd+';cmd=alm;lat=0;lon=0;pacc=40000000;\n')
 +
 
 +
buf = s.recv(4096)
 +
while True:
 +
        b = s.recv(4096)
 +
        if not b:
 +
                break
 +
        buf += b
 +
 
 +
h = {}
 +
 
 +
while True:
 +
        (l,s,buf) = buf.partition('\n')
 +
        l = l.rstrip('\r\n')
 +
        #
 +
        sys.stderr.write(l+'\n')
 +
        #
 +
        if l == "":
 +
                if 'content-length' in h and h['content-length'].isdigit() and 'content-type' in h and h['content-type'] == 'application/ubx':
 +
                        sys.stdout.write(buf[:int(h['content-length'])])
 +
                sys.exit(0)
 +
        #
 +
        m = re.search('\\A(.+): (.+)\\Z',l)
 +
        if m:
 +
                h[m.group(1).lower()] = m.group(2).lower();
 
</pre>
 
</pre>
 +
 +
 +
= Hardware related =
 +
== Bicycle ==
 +
 +
Dynamo powered openmoko (and other USB-Devices/Host) using the frequency/voltage of the dynamo to gather information about speed and distance.
 +
 +
Wishlist for this USB-Charger:
 +
* 5V, 500-1500mA output (through diodes or MOSFET)
 +
* Voltage, Frequency (should be dynamohub independable)
 +
* USB-Device (maybe with USBprog)
 +
 +
nice to
 +
* 3d compass, altimeter, thermometer (with information of distance to map tunnels, dense forest, ...)
 +
* buttons for turning lights (on lowpower/on highpower/off), setting waypoints/audionotes, easy navigation of openmoko (scrolling/enter)

Latest revision as of 20:15, 7 April 2011

Contents

[edit] Software related

[edit] Distributions

[edit] OpenWrt

append "arch s3c24xx 1" to /etc/opkg.conf


Useful packages:

opkg install openssh-sftp-server


[edit] SHR

[edit] Installation

ubi - ubinized for flashing with NeoTool

ubifs - UBIFS


[edit] Problems

with shr-lite-eglibc-ipk--20100115-om-gta02.rootfs @ uImage-2.6.32.3-oe1+gitr1+5827b20d022fb47ce9c9731d0fb894d361e16ffe-r4-om-gta02.bin booted with qi-ubi-s3c2442-1.0.2-r0+gitr0+c38b062a609f1442e6a9e13005cfbdfd59a5ac0d.udfu


  • whitescreen(ofstarving) from resuming and dimming, sometimes the lock-screen appears

Workaround: edit /etc/phonefsod.conf

auto_suspend = never /maybe normal would work also...

[edit] USB-Networking

[edit] FreeBSD

[edit] devd

Figure out the ugen for your Openmoko device:

dmesg | grep ugen | grep Linux

Then note down idVendor and idProduct value:

# usbconfig -d ugenU.A dump_device_desc | grep idVendor
# usbconfig -d ugenU.A dump_device_desc | grep idProduct

Configure devd(8) to perform an action if a device with the appropriate vendor and product string is attached.

/etc/devd.conf

#Openmoko Freerunner with Linux 2.6.34+
attach 100 {
        device-name "ugen[0-9]+";
        match "vendor" "0x0525";
        match "product" "0xa4a2";
        action "perl /usr/local/etc/neo_if.pl /dev/$device-name";
};

This action consists of switching to network mode:

# usbconfig -d ugenU.A set_config 1

and assigning an IP address:

# ifconfig ue0 192.168.0.200/24

This is also done with this script:

/usr/local/etc/neo_if.pl

#!/usr/bin/perl
my ($u, $ad) = $ARGV[0] =~ /(\d+)\.(\d+)$/;
print ("usage: $0 /dev/ugen4.2\n"), exit unless (length $u and length $ad);
print `usbconfig -u $u -a $ad set_config 1
#ifconfig ue0 link 00:1f:11:01:71:62 # uncomment if moko reports: usb0: duplicate address detected!
ifconfig ue0 192.168.0.200/24`;

Finally restart the devd daemon with:

# service devd restart

If you now plug the FreeRunner into the USB port the cdce0 interface gets created and the IP address will be assigned.


[edit] Routing

          __________________       ____________________       ____________________ 
         |                  |     |                    |     |                    |
         | Router           |     | Workstation        |     | Freerunner         |
         |                  |     |                    |     |                    |
         | eth0 192.168.1.1 |-----| eth0 192.168.1.2   |     |                    |
 ISP-----| ppp0 DHCP        |     | ue0  192.168.0.200 |-----| usb0 192.168.0.202 |
         |__________________|     |____________________|     |____________________|

Enable on your FreeBSD workstation ip forwarding from one interface to another:

# sysctl net.inet.ip.forwarding=1

For persistent forwarding enable gateway inside

/etc/rc.conf

gateway_enable="YES"

or the appropriate sysctl variable inside

/etc/sysctl.conf

net.inet.ip.forwarding=1


Add a route inside your router.

# route add -net 192.168.0.0/24 gateway 192.168.1.2

or

# route add -host 192.168.0.202 gateway 192.168.1.2


Adjust the firewall of your router to pass packets from your Freerunner.

pass in quick on $intif inet from 192.168.0.202 to any flags S/SA keep state label "USER_RULE: Openmoko Freerunner"

If you have no control over your router use Network Address Translation.


[edit] NAT

Load kernel modules for firewall/NAT:

/boot/loader.conf

ipfw_load="YES"
ipdivert_load="YES"


Set default policy to accept:

/etc/syctl.conf

net.inet.ip.fw.default_to_accept=1


Configure an alias for Freerunner, enable ip forwarding and firewall.

Enable natd on the interface connected to the router, replace eth0 with this interface (i.e. re0, em0). Use the alias as redirect address inside your LAN.

/etc/rc.conf

ifconfig_eth0="inet 192.168.1.2/24"
ipv4_addrs_eth0="192.168.1.202/32"
gateway_enable="YES"
firewall_enable="YES"
firewall_type="OPEN"
natd_enable="YES"
natd_interface="eth0"
natd_flags="-redirect_address 192.168.0.202 192.168.1.202"


[edit] OpenWrt

/etc/config/network

config interface lan
option proto static
option ifname eth0
option ipaddr 192.168.0.202
option netmask 255.255.255.0
option gateway 192.168.0.200
option dns 208.67.222.222

Without modifying the /etc/config/network

sudo iptables -I INPUT 1 -s 192.168.1.1 -j ACCEPT
sudo iptables -I OUTPUT 1 -s 192.168.1.2 -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.1.0/24
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'


[edit] Ubuntu 9.10

sudo iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT
sudo iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'

[edit] Packages

ffalarms
dates
openssh-sftp-server
tangogps
navit
zinnia
zinnia-tomoe-zh
enscribi
ttf-arphic-uming
elementary-sms?
elementary-alarm?
intone
intone-video
browser

[edit] Enscribi on OM2009

Step 1:

opkg install http://www.opkg.org/packages/zinnia_0.04_armv4t.ipk
opkg install http://www.opkg.org/packages/0_zinnia-tomoe-ja_0.6.0-20080911_armv4t.ipk (for Japanese support)
opkg install http://www.opkg.org/packages/0_zinnia-tomoe-zh_0.6.0-20080911_armv4t.ipk (for Chinese support)
opkg install http://www.opkg.org/packages/enscribi_0.2.0_armv4t.ipk


Step 2:

Create symbolic links for the old libs (tested with om2009-unstable 17-Aug-2009 17:19) If enscribi is linked against the new libs then these symbolic links are obsolete.

ln -s /usr/lib/libecore_evas-ver-svn-02.so.0 libecore_evas-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_fb-ver-svn-02.so.0 libecore_fb-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_x-ver-svn-02.so.0 libecore_x-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_input-ver-svn-02.so.0 libecore_input-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_x-ver-svn-02.so.0 libecore_txt-ver-pre-svn-01.so.0
ln -s /usr/lib/libedje-ver-svn-02.so.0 libedje-ver-pre-svn-01.so.0 
ln -s /usr/lib/libembryo-ver-svn-02.so.0 libembryo-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_job-ver-svn-02.so.0 libecore_job-ver-pre-svn-01.so.0
ln -s /usr/lib/libevas-ver-svn-02.so.0 libevas-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore-ver-svn-02.so.0 libecore-ver-pre-svn-01.so.0
ln -s /usr/lib/libeina-ver-svn-02.so.0 libeina-ver-pre-svn-01.so.0

Maybe link the old libs against the even older libs. But seems not to work.

cd /usr/lib
cp /location-of-old-libs-for-enscribi/* .
ln -s /usr/lib/libecore_evas-ver-svn-02.so.0.9.9 libecore_evas-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_fb-ver-svn-02.so.0.9.9 libecore_fb-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_input-ver-svn-02.so.0.9.9 libecore_input-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_job-ver-svn-02.so.0.9.9 libecore_job-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore-ver-svn-02.so.0.9.9 libecore-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_x-ver-svn-02.so.0.9.9 libecore_x-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_x-ver-svn-02.so.0.9.9 libecore_txt-ver-pre-svn-01.so.0
ln -s /usr/lib/libedje-ver-svn-02.so.0.9.92 libedje-ver-pre-svn-01.so.0 
ln -s /usr/lib/libeina-ver-svn-02.so.0.0.2 libeina-ver-pre-svn-01.so.0
ln -s /usr/lib/libembryo-ver-svn-02.so.0.9.9 libembryo-ver-pre-svn-01.so.0
ln -s /usr/lib/libevas-ver-svn-02.so.0.9.9 libevas-ver-pre-svn-01.so.0

Step 3:

goto "setup" --> "keyboard" --> "enscribi"

To get a Chinese/Japanese input method. Ensure, that you have Chinese/Japanes fonts installed.

 opkg install task-fonts-truetype-chinese

http://trac.shr-project.org/trac/ticket/868


[edit] other tricks

[edit] A-GPS

agps.sh

agps-alm.py > /dev/ttySAC1

agps-alm.py

#!/usr/bin/python
#
# ublox AssistNow Online almanac downloader for Neo FreeRunner
#
# v0.1
#
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
#
# Usage:
#
# agps-alm.py > /dev/ttySAC1
#

import sys
import socket
import re

user='your@mail.address'
pwd='pwdfromublox'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('agps.u-blox.com',46434))

s.send('user='+user+';pwd='+pwd+';cmd=alm;lat=0;lon=0;pacc=40000000;\n')

buf = s.recv(4096)
while True:
        b = s.recv(4096)
        if not b:
                break
        buf += b

h = {}

while True:
        (l,s,buf) = buf.partition('\n')
        l = l.rstrip('\r\n')
        #
        sys.stderr.write(l+'\n')
        #
        if l == "":
                if 'content-length' in h and h['content-length'].isdigit() and 'content-type' in h and h['content-type'] == 'application/ubx':
                        sys.stdout.write(buf[:int(h['content-length'])])
                sys.exit(0)
        #
        m = re.search('\\A(.+): (.+)\\Z',l)
        if m:
                h[m.group(1).lower()] = m.group(2).lower();


[edit] Hardware related

[edit] Bicycle

Dynamo powered openmoko (and other USB-Devices/Host) using the frequency/voltage of the dynamo to gather information about speed and distance.

Wishlist for this USB-Charger:

  • 5V, 500-1500mA output (through diodes or MOSFET)
  • Voltage, Frequency (should be dynamohub independable)
  • USB-Device (maybe with USBprog)

nice to

  • 3d compass, altimeter, thermometer (with information of distance to map tunnels, dense forest, ...)
  • buttons for turning lights (on lowpower/on highpower/off), setting waypoints/audionotes, easy navigation of openmoko (scrolling/enter)
Personal tools

Bicycle

Dynamo powered openmoko (and other USB-Devices/Host) using the frequency/voltage of the dynamo to gather information about speed and distance.

Wishlist for this USB-Charger:

  • 5V, 500-1500mA output (through diodes or MOSFET)
  • Voltage, Frequency (should be dynamohub independable)
  • USB-Device (maybe with USBprog)

nice to

  • 3d compass, altimeter, thermometer (with information of distance to map tunnels, dense forest, ...)
  • buttons for turning lights (on lowpower/on highpower/off), setting waypoints/audionotes, easy navigation of openmoko (scrolling/enter)

A-GPS

agps.sh

agps-alm.py > /dev/ttySAC1

agps-alm.py

#!/usr/bin/python
#
# ublox AssistNow Online almanac downloader for Neo FreeRunner
#
# v0.1
#
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
#
# Usage:
#
# agps-alm.py > /dev/ttySAC1
#

import sys
import socket
import re

user='your@mail.address'
pwd='pwdfromublox'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('agps.u-blox.com',46434))

s.send('user='+user+';pwd='+pwd+';cmd=alm;lat=0;lon=0;pacc=40000000;\n')

buf = s.recv(4096)
while 1:
        b = s.recv(4096)
        if not b:
                break
        buf += b

h = {}

while 1:
        (l,s,buf) = buf.partition('\n')
        l = l.rstrip('\r\n')
        #
        sys.stderr.write(l+'\n')
        #
        if (l == ""):
                if h.has_key('content-length') and h['content-length'].isdigit() and h.has_key('content-type') and h['content-type'] == 'application/ubx':
                        sys.stdout.write(buf[0:int(h['content-length'])])
                sys.exit(0)
        #
        m = re.search('\\A(.+): (.+)\\Z',l)
        if m:
                h[m.group(1).lower()] = m.group(2).lower();


Enscribi on OM2009

Step 1:

opkg install http://www.opkg.org/packages/zinnia_0.04_armv4t.ipk
opkg install http://www.opkg.org/packages/0_zinnia-tomoe-ja_0.6.0-20080911_armv4t.ipk (for Japanese support)
opkg install http://www.opkg.org/packages/0_zinnia-tomoe-zh_0.6.0-20080911_armv4t.ipk (for Chinese support)
opkg install http://www.opkg.org/packages/enscribi_0.2.0_armv4t.ipk


Step 2:

Create symbolic links for the old libs (tested with om2009-unstable 17-Aug-2009 17:19) If enscribi is linked against the new libs then these symbolic links are obsolete.

ln -s /usr/lib/libecore_evas-ver-svn-02.so.0 libecore_evas-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_fb-ver-svn-02.so.0 libecore_fb-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_x-ver-svn-02.so.0 libecore_x-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_input-ver-svn-02.so.0 libecore_input-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_x-ver-svn-02.so.0 libecore_txt-ver-pre-svn-01.so.0
ln -s /usr/lib/libedje-ver-svn-02.so.0 libedje-ver-pre-svn-01.so.0 
ln -s /usr/lib/libembryo-ver-svn-02.so.0 libembryo-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore_job-ver-svn-02.so.0 libecore_job-ver-pre-svn-01.so.0
ln -s /usr/lib/libevas-ver-svn-02.so.0 libevas-ver-pre-svn-01.so.0
ln -s /usr/lib/libecore-ver-svn-02.so.0 libecore-ver-pre-svn-01.so.0
ln -s /usr/lib/libeina-ver-svn-02.so.0 libeina-ver-pre-svn-01.so.0

Step 3:

goto "setup" --> "keyboard" --> "enscribi"

To get a Chinese/Japanese input method. Ensure, that you have Chinese/Japanes fonts installed.


OpenWrt

append "arch s3c24xx 1" to /etc/opkg.conf



USB-Networking

OpenWrt

/etc/config/network

config interface lan
option proto static
option ifname eth0
option ipaddr 192.168.0.1
option netmask 255.255.255.0
option gateway 192.168.0.2
option dns 208.67.222.222
Ubuntu 9.10
sudo iptables -I INPUT 1 -s 192.168.0.1 -j ACCEPT
sudo iptables -I OUTPUT 1 -s 192.168.0.2 -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'


Ubuntu 8.10
sudo iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT
sudo iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
Ubuntu 9.04

/etc/network/freerunner (chmod -x)

#!/bin/sh
#
# configures the freerunner for internet
#
#

DEVICE=usb0
IPADDR=192.168.0.200
REMOTE_IPADDR=192.168.0.202
NETMASK=255.255.255.0

# get first ip for dns
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)

case "$1" in
start)
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP

if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward
echo 1 > /proc/sys/net/ipv4/ip_forward
fi
;;
stop)
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d  $IPADDR --dport domain -j DNAT --to-destination $DNSIP

if [ -f /var/run/openmoko.ip_forward ]; then
rm /var/run/openmoko.ip_forward
echo 0 > /proc/sys/net/ipv4/ip_forward
fi
;;
esac

/etc/udev/rules.d/80-freerunner.rules

# This file causes programs to be run on device insertion.
# See udev(7) for syntax.
# rule to assign a fixed mac address specified in /
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"

/usr/local/sbin/freerunner-usb-add.sh (chmod -x)

#!/bin/sh
(
ip address add 192.168.0.200/26 netmask dev usb0 > /dev/null
ip link set usb0 up > /dev/null
/etc/network/freerunner start
) &
exit 0