Flashing the neofreerunner's calypso modem

This is fourth in a series of write ups, the first, being here. It runs through instructions from start to finish, describing how to flash the modem with the moko13 release. Please see the beta firmware release announcement for reasons that you might wish to do this upgrade. The firmware is now considered to be out of beta after an admittedly short period of testing, despite which it is still expected to give a user experience no worse than earlier firmware releases, both from the old OpenMoko company and the freecalypso community. The community would welcome further reports from users.

This method assumes you have a Qtmoko version installed on your freerunner and obviates the need for an unlock cable, special sdcard distro or the installation of a build environment on your phone. It's applicable to both a NAND and sdcard installed system.

Preparation

Download the debian packaged loadtool and install in the normal way on your phone. The loadtool program was compiled and tested on version v58 of Qtmoko, but is known to also also runs on v54. Please note that this is an elderly version of loadtool. Although it remains entirely fit for purpose, you might want to consider using an up to date version. The one specific for flashing the freerunner modem is available in source form from here and the release announcement for this is in the community archives.

Download the moko13 firmware from here and copy it to your freerunner's file system. The notes at the end of this write up for connecting to the freerunner from your PC or laptop may be helpful if you downloaded the freecalypso products to one of those machines, rather than directly to the freerunner. I suggest decompressing the archive on your PC with bunzip2 and creating a moko13 directory on the freerunner's file system into which the the tar archive is copied and extracted.

Halting the graphical interface

Since the freerunners graphical interface must be shut down prior to running loadtools, its Terminal program will be inoperative and so everything from now on must be done over an ssh connection to the freerunner from your PC or laptop. See the end of this write up for help with maintaining this connection.

root@moke:~# /etc/init.d/qtmoko-neo stop

Running loadtool

You should run this command from inside the directory you created to hold the moko13 firmware.

root@moke # cd moko13
root@moke # fc-loadtool -h gta02 /dev/ttySAC0
Sending beacons to /dev/ttySAC0
Toggling /sys/devices/platform/neo1973-pm-gsm.0/power_on
Got beacon response, attempting download
< p command successful, switching to 115200 baud
Sending image payload
.................................................................
.................................................................Sending checksum
< c command successful, sending < b
< b command successful: downloaded image should now be running!

FreeCalypso loadagent running
Loaded via UART 0 (MODEM) at baud rate #0
TCXO clock input autodetected to be 26 MHz

Executing init script k5a3281.init
Script command: w16 fffffb00 00A4
Script command: w16 fffffb02 00A3
loadtool>

Backing up vital calibration data

If this is not the first time you've flashed the freerunners modem using the loadtool program, you should already have carried out this operation. It should not be skipped unless you already have taken a backup and have taken copies of it off the freerunner. Having the my-flashdump.bin file secured in your back up system is a safeguard against any possible future mishap.

loadtool> flash dump2bin my-flashdump.bin

Flashing the firmware

The relvent area of the modem's flash memory is first erased:-

loadtool> flash erase 0 0x300000

This is followed by loading the moko13 firmware:-

loadtool> flash program-m0 fwimage.m0

Once again, expect this loadtool command to last over 10 minutes.

Returning the phone to normal operation

After the flash operation completes, quit the loadtool program and simply either reboot the freerunner or restart the graphical interface:-

loadtool> quit
root@moke:~# /etc/init.d/qtmoko-neo start

You can check that the flash operation upgraded your freerunner to moko13 using Qtmoko's System Info program; the modem section should include the line Revision: GTA02BV4/FreeCalypso

Connecting to the freerunner from PC or laptop

Possibly this is just my hardware, but my experience is that a ssh connection tends to get dropped by the freerunner and that long running loadtool commands will thus fail to complete. Although this would not permanently brick the freerunner, it does mean that uncompleted operations have to be resumed from the beginning.

One solution is to install screen on the freerunner and start it with screen -R -D. You may need to run chmod 777 /var/run/screen to make it behave. If all loadtool commands are run inside the screen, they will continue even if the ssh connection is dropped. You can simply reconnect and access the screen session with another screen -R -D command.

Another work around, the one I favour, is a shell script to put the routing commands in a loop:-

#!/bin/bash

DEV=$1
#probably eth1 or eth2, formerly usb0 with Qtmoko

if [ "$DEV" == "" ]     ;then
        echo "which device?"
else
        NET=192.168.0.200/24
        GATE=192.168.0.202/32

        #shr:-
#       NET=192.168.7.1/24
#       GATE=192.168.7.2/32
        
        while [ true ]
        do
                echo "working"
                ip address add $NET dev $DEV
                ip link set dev $DEV up

                #route traffic from the phone
                /sbin/route add -host $GATE dev $#DEV
                iptables -A POSTROUTING -t nat -j MASQUERADE -s $NET
                iptables -P FORWARD ACCEPT
                sysctl -w net.ipv4.ip_forward=1

                sleep 15
        
        done

fi
exit 0  

For the later versions of Qtmoko, this script is called as follows:-

root@raylor # bin/moke.sh eth2
working
SIOCADDRT: No such device
net.ipv4.ip_forward = 1
working
SIOCADDRT: No such device
net.ipv4.ip_forward = 1

With this script continually poking the freerunner from one terminal window, you should be able to get a solid ssh connection from another. Output such as SIOCADDRT: No such device is not fatal, but something like Cannot find device "eth2" indicates that the freerunner has not brought up an interface on your PC. Try rebooting the PC with the freerunner already wired to it with the usb cable, or using eth1 as an argument to the script.