Thursday, 3 December 2009

U8230 MoDaCo ROM makes ShopSavvy work on Android T-Mobile Pulse

Well, I installed the U8230 MoDaCo ROM, and it sort of worked.

Unfortunately, things (especially the front screen) kept crashing.

However, after advice from the nice MoDaCo people, I did a factory reset...
  • Use the Quick Boot app to go into recovery mode
  • Allow the root shell access when the prompt comes up
  • Choose the factory reset option
  • When the system restarts it will come up with the standard French options - go into Settings/Locale and text/Select locale and choose English.
  • I found I had to reboot the phone again to make that setting take properly.
  • Now you have to reinstall all your apps (but, if you go to Market, My downloads, they are all listed ready to install). I have installed CoPilot Live (paid for), but it downloaded and installed OK, and re-registered fine.

Because this version of the ROM has moved Google Maps into the data partition (to save space), the factory reset removed it (as it wipes the data partition). So I then had to reinstall the update again. I would advise factory resetting before installing this ROM.

There are some good things about this ROM though:

  • ShopSavvy can use the camera like it should (the old version just showed a black screen).
  • Google contacts will sync OK (even if you add people to your Favorites).

ShopSavvy doesn't work on Android T-Mobile Pulse

One of the highly recommended applications on Android is ShopSavvy. Apparently this lets you use the phone's camera to scan barcodes of products, and then tells you the best prices to buy them, both locally and on the 'Net.

Sounds good, but doesn't work on my Pulse :-(

However, the excellent Paul at MoDaCo has produced a custom rom based on the French U8230 version of this phone, which fixes the problem. (For those not wishing to root their phone, ShopSavvy have been told by the phone manufacturer that a new ROM image has been supplied to T-Mobile, so just wait patiently!)

So I'm loading it now - for full instructions see http://trumphurst.blogspot.com/2009/12/rooting-android-on-t-mobile-pulse.html - but use http://www.romraid.com/paul/pulse/update-pulse-u8230edition-1.0-core-signed.zip instead of update-pulse-1.3-core-signed.zip.

SSH into my Android T-Mobile Pulse phone

Having installed the MoDaCo Custom ROM into my rooted phone, I then tried to ssh into it. The first thing I needed was the password - the instructions weren't clear, but I eventually found it in Settings/About Phone/Setup Wizard.

I used Putty to SSH into the phone (having got its IP address from my DHCP server logs) as root (using port 2222), and it worked. Now I wanted to use my public key, so I wouldn't be asked for the password again. Instructions were a bit fragmented, and I had a few false starts, but this is what I ended up doing:
  • cd /data/dropbear
  • mkdir .ssh
  • chmod 700 .ssh
  • cd .ssh
  • echo 'my public key' >authorized_keys
  • chmod 644 authorized_keys
  • cd ..
  • mount -o rw,remount -t yaffs2 /dev/block/mtdblock1 /system
  • edit /system/bin/dropbear.sh to add
    -R /data/dropbear/.ssh/authorized_keys
    to the end of the command line.
  • mount -o ro,remount -t yaffs2 /dev/block/mtdblock1 /system
  • reboot the phone (type "reboot" at the command line, or use the Quick Boot app on the phone).

The mount commands switch the filesystem from read-only (its usual state) to read-write and back again.


Brilliant - I now have password-free root access to my phone using ssh from my PC (which has a real keyboard). Some experimentation shows I have most of the commonly-used Linux commands available to me.

Rooting Android on the T-Mobile Pulse

Being the techy that I am, I investigated getting ssh access into my phone (preferably as root). The site with the best information on this is http://android.modaco.com/content/t-mobile-pulse-pulse-modaco-com/294178/13-10-1-0-rooting-the-pulse-introducing-superboot/

I didn't find the instructions there 100% clear, so here is what I did:
  • Install the CD that came with the phone - this is necessary to install USB drivers, adb, etc., so the computer can talk to the phone.
  • Download (to my PC) the superboot root image http://content.modaco.net/dropzone/1.1-pulse-superboot.zip
  • and the recovery image http://content.modaco.net/dropzone/1.2.3-pulse-amonrarecovery.zip
  • and the MoDaCo Custom ROM http://www.romraid.com/paul/pulse/update-pulse-1.3-core-signed.zip
  • and the stock T-Mobile image (in case of emergency) http://content.modaco.net/pulse/update-pulse-stock-V100R001GBRC85B116SP01-t-mobile-signed.zip
  • Turn the phone off, and unplug the USB cable.
  • Hold the volume down and red (end call) buttons, and press the power button. This puts the phone into bootloader mode.
  • Plug in the USB cable.
  • Unzip the superboot file, copy AdbWinApi.dll from the CD that came with the phone into the 1.1-pulse-superboot folder, and run .install-superboot-windows.bat.
  • At this point I restarted the phone by removing the battery, and tried it out - the phone was rooted, but I was unable to get into recovery mode to install the MoDaCo Custom ROM. Turns out I needed to install the recovery image first, and I think I could have done that straight away while the phone was still in bootloader mode.
  • Unzip the amonrecovery zip, copy AdbWinApi.dll from the CD that came with the phone into the 1.0-pulse-amonrarecovery folder, and run ._install-recovery-windows.bat.
  • Now restart the phone by removing the battery.
  • Go into the applications list (bottom right button on the home screen), and run the "Quick Boot" application that superboot has installed. Choose Recovery, and, when you get the sudo screen asking whether to allow root access, allow it. This puts the phone into recovery mode, which I think is a kind of boot image provided by amonrecovery. It's a bit like Windows recovery mode, or booting a Windows machine with a floppy disk - you can do stuff, but the main operating system is not running.
  • The first useful thing to do is to take a backup of the entire phone, using the Nandroid Backup option on the recovery menu. This backs up a complete image of the phone's ROM to the SD card, which you can restore later. I then turned USB mass storage on (so I could get to the SD card from my computer), and backed up that image to my computer.
  • Then I renamed the MoDaCo ROM zip (update-pulse-1.3-core-signed.zip) to plain update.zip, and copied it from my computer onto the SD card.
  • I turned off USB mass storage (so the phone could see the SD card again), and ran the "Apply sdcard:update.zip" option. This installed the MoDaCo ROM image.
  • Finally I rebooted the phone (from the menu). The reboot took ages. This is to be expected.

SSH into the phone in my next post...

Android on the T-Mobile Pulse

I've always wanted a smartphone I can use anywhere to access the Internet, ssh into the servers I maintain, check my mail, etc. I was tempted by the iPhone, but put off by the enormous price, and the closed Apple-only system.

Then I found the T-Mobile Pulse, available on pay-as-you-go for under £200, which runs Android. So I bought one a couple of weeks ago.

It's a nice phone (although the camera is pretty awful). I really like the Android operating system - it does the kind of thing the iPhone does on the TV adverts, but it's open.

I installed all kinds of good software on it:

  • EStrongs File Explorer - gives me access to my Windows and Samba shares over my Wifi network.
  • Android-vnc-viewer - lets me control my desktop from the phone (in an emergency - the phone screen is a bit tiny for controlling twin 19" monitors!).
  • AndFTP - FTP/SFTP client.
  • TextEdit - does what it says on the tin.
  • ConnectBot - ssh/telnet client.
  • DynDNS - dynamic DNS client.
  • Skype Lite.
  • CoPilot Live Navigator - full turn-by-turn GPS with maps on the phone, so no Internet connection needed.

I also put on quite a few other less vital bits an pieces - e.g. a spirit level (just like the TV ad), toggle switches for turning WiFi/GPS/3G/etc. on and off (to save going through the settings menu).

Friday, 13 March 2009

ifup: network-functions: line 52: eth0: No such file or directory

The (external) power supply on my Linux box broke the other day. Tranquil PC sent me a new one, so I booted the machine up for the first time in ages. I noticed an error message as it was trying to bring up the eth0 interface (which is nicknamed "moors" on my machine):

ifup: network-functions: line 52: eth0: No such file or directory

This appeared twice every time I booted the machine.

I looked in /etc/sysconfig/network-script/network-functions, and line 52 was the (rather unhelpful):

. $CONFIG

I went through a prolonged debugging session, putting trace code in ifup and network-functions, and I found the problem was caused by line 155 of ifup:

is_available ${REALDEVICE}

REALDEVICE at this point is "eth0". is_available starts like this:

LC_ALL= LANG= ip -o link | grep -q $1
[ "$?" = "1" ] || return 0

alias=`modprobe -c | awk "/^(alias|install)[[:space:]]+$1[[:space:]]/ { print \\$3 }"`
if [ -z "$alias" -o "$alias" = "off" -o "$alias" = "/bin/true" ]; then
return 2
fi
modprobe $1 > /dev/null 2>&1 || return 1
# if it is a mainframe ccwgroup device, configure it before
# trying to rename it:
need_config ${1}

I haven't figured out what all the tests at the top do, but (for eth0 only, and only when rebooting) control comes through to the call to need_config. need_config looks like this:

CONFIG="ifcfg-${1}"
[ -f "${CONFIG}" ] && return
CONFIG="${1}"
[ -f "${CONFIG}" ] && return
local addr=`get_hwaddr ${1}`
if [ -n "$addr" ]; then
local nconfig=`get_config_by_hwaddr ${addr}`
if [ -n "$nconfig" ] ; then
CONFIG=$nconfig
[ -f "${CONFIG}" ] && return
fi
fi

So CONFIG gets changed from "ifcfg-moors" (which is what it was to start with) to "eth0" - and there is no such file (nor an ifcfg-eth0) in /etc/sysconfig/network-scripts.

I have "fixed" the problem by adding a line to the top of need_config:

[ -f "${CONFIG}" ] && return

but this is the ravings of someone who doesn't really know what is going on!

Helpful suggestions welcome.

Thursday, 5 March 2009

Adding a second Internet connection - part 2

Now I have routing working properly on my new router, I took the opportunity to move it onto eth0 (my firewalled, "dirty" interface).


First, I set up a new aliased ethernet port on the Linux box, using the Gnome System Settings/Network tool. I gave this IP address 192.168.0.1 (no default gateway).


Then I connected to the new router, and changed its IP address to 192.168.0.250. I physically moved it onto the eth0 network. Finally I telnetted to it and set up its own routes, as follows:

D-Link> ip route addrom index 1
D-Link> ip route addrom name gbit
D-Link> ip route addrom set 192.168.3.0/24 192.168.0.1 1
D-Link> ip route addrom save
ip route addrom: save ok
D-Link> ip route addrom index 2
D-Link> ip route addrom name mbit
D-Link> ip route addrom set 192.168.1.0/24 192.168.0.1 1
D-Link> ip route addrom save
ip route addrom: save ok
D-Link> ip route addrom index 3
D-Link> ip route addrom name dirty
D-Link> ip route addrom set 192.168.2.0/24 192.168.0.1 1
D-Link> ip route addrom save
ip route addrom: save ok

This set up the following static routes:

Dest FF Len Device Gateway Metric stat Timer Use RN
192.168.0.0 00 24 enet0 192.168.0.250 1 041b 0 1150
192.168.1.0 00 24 enet0 192.168.0.1 1 001b 0 0
192.168.2.0 00 24 enet0 192.168.0.1 1 001b 0 0
192.168.3.0 00 24 enet0 192.168.0.1 1 001b 0 445

Then I altered the routes on the Linux box as follows:

ip route add 192.168.2.0/24 dev eth0 src 192.168.2.1 table ISP1
ip route add default via 192.168.2.5 table ISP1

ip route add 192.168.0.0/24 dev eth0 src 192.168.0.1 table ISP2
ip route add default via 192.168.0.250 table ISP2

ip route add 192.168.2.0/24 dev eth0 src 192.168.2.1
ip route add default via 192.168.2.5

ip rule add from 192.168.2.1 table ISP1
ip rule add from 192.168.0.1 table ISP2

I also set up static routes for some IP addresses I wanted to reach via one or other ISP (e.g. their DNS servers).


That all works - I can connect in from outside via either of the two routers (I have set up identical NAT mappings on both). I can easily switch to the secondary router like this:

ip route del default
ip route add default via 192.168.0.250

I am now considering load balancing between the two routers. I think the commands to do this would be:

ip route del default
ip route add default scope global nexthop via 192.168.2.5 dev eth0 weight 6 nexthop via 192.168.0.250 dev eth0 weight 1

Thursday, 19 February 2009

Adding a second Internet connection

I have just installed a second ADSL connection, intending it to be a backup in case the first one goes down. This comes with a DSL-2640R NAT router (including firewall).


My existing network is somewhat complicated - at its heart is a CentOS 4 Linux box from Tranquil PC, with three network cards, which routes between the three networks.


  • My existing ADSL router is on eth0 (192.168.2.1) at 192.168.2.5.
  • I have a 100 Mbit network on eth1 (192.168.1.1)
  • I have a Gbit network on eth2 (192.168.3.1)

Although I want untimately to set up load sharing and automatic failover, to start with I just wanted everything to work, viz:

  • All machines on the network to have access to the Internet, and all other machines (including both ADSL routers).
  • To be able to connect to the Linux box from outside, via either Internet connection.

The first thing I did was to assign the new DSL-2640R router IP address 192.168.1.250, turn off DHCP (so it didn't conflict with the existing DHCP server) and add it to the network on eth1. I originally tried to put it on the same network as the existing router, but I don't understand how it would be possible to distinguish outside traffic coming in via the two routers unless they were on separate interfaces. It may be worth trying a virtual interface here.

Allowing the router to see the other networks


Now I could see the DSL-2640R from the Linux box, but not from either of the other networks (as the DSL-2640R did not have a setting for default gateway on its LAN side, so it couldn't find a route back to the other networks).


I first tried setting up NAT on the Linux box for the eth0 interface, by editing /etc/sysconfig/iptables as follows:

*nat
:PREROUTING ACCEPT [39:3410]
:POSTROUTING ACCEPT [33:2787]
:OUTPUT ACCEPT [10:677]
-A POSTROUTING -d 192.168.1.250 -o eth0 -j MASQUERADE
COMMIT

That enabled me to see the web interface of the DSL-2640R from anywhere on my network, but did not allow incoming traffic from the router to see the rest of my network.


I discovered that the router has a telnet interface, which shows the following help (once you have logged in and typed "help"):

Valid commands are:
sys exit ether wan
ip bridge dot1q pktqos
show set lan

Although I couldn't find any documentation for this interface, it looked remarkably familiar to the one on my ZyXel Prestige 660HW, for which I did have documentation.


I therefore set up two static routes in rom (so they survive a reboot), as follows:

D-Link> ip route addrom index 1
D-Link> ip route addrom name gbit
D-Link> ip route addrom set 192.168.3.0/24 192.168.1.1 1
D-Link> ip route addrom save
ip route addrom: save ok
D-Link> ip route addrom index 2
D-Link> ip route addrom name dirty
D-Link> ip route addrom set 192.168.2.0/24 192.168.1.1 1
D-Link> ip route addrom save
ip route addrom: save ok

That worked fine, so I reverted iptables to its original state.

Enabling incoming traffic


The next step was to enable incoming traffic from the DSL-2640R. I first opened up the necessary ports in the DSL-2640R's NAT setup, redirecting them all to the Linux box on 192.168.1.1. That allowed the incoming traffic, but the Linux box couldn't reply, because its default route back was via the original ADSL router at 192.168.2.5. Having read an article at http://lartc.org/howto/lartc.rpdb.multiple-links.html, I amended the routing tables on the Linux box. I first added two new tables to /etc/iproute2/rt_tables

200 ISP1
201 ISP2

Then added routes to these tables:

ip route add 192.168.2.0/24 dev eth0 src 192.168.2.1 table ISP1
ip route add default via 192.168.2.5 table ISP1

ip route add 192.168.1.0/24 dev eth0 src 192.168.1.1 table ISP2
ip route add default via 192.168.1.250 table ISP2

ip route add 192.168.2.0/24 dev eth0 src 192.168.2.1
ip route add default via 192.168.2.5

ip rule add from 192.168.2.1 table ISP1
ip rule add from 192.168.1.1 table ISP2


I don't fully understand how all this works (and I would be grateful if anyone explains it to me), but it does seem to.

Switching between the two Internet connections


The next step is to allow switching the default gateway between the two routers (in case the primary one goes down). This is done using a couple of scripts:

# Switch to new Internet connection
ip route del default
ip route add default via 192.168.1.250


#Switch to original Internet connection
ip route del default
ip route add default via 192.168.2.5


That works too - I may set this up to switch automatically, or to load balance, but I think I've done enough for now.