Installing CM7 7.1.2 (2.3.7) on a Motorola Milestone

Since, I got a new phone, I decided to upgrade my old Motorola Milestone with the latest cyanogenmod. CyanogenMod 7 for Milestone A853 is not officially supported by CyanogenMod, however, since I don’t need the phone to be working, I installed it.

As my phone is already rooted, I did not need to follow these instructions.

Preparation

  • Download OpenRecovery
  • Copy the extracted files (directory OpenRecovery, file update.zip, file vulnerable_recovery.sbf) to the sdcard of your phone.
  • Reboot into recovery (Press Camera button, then press Power. Hold them both untill you see the recovery screen. Then, press Volume Up and Camera button at the same time untill you see the recovery menu)
  • Apply the update.zip -> You are now in Open Recovery
  • Download latest google apps and place them on the sdcard of your phone in the folder OpenRecovery/updates
  • Before building CM7, you should download repo from here. Once you have the file, make it executable chmod a+x repo.
  • Make sure you have installed the following dependencies (Ubuntu) bison flex g++-multilib gcc-multilib gperf lib32ncurses5-dev lib32z1-dev libc6-dev-i386 libx11-dev mesa-common-dev openjdk-6-jdk

Compiling CM7

Depending on your CPU and bandwidth, this may take some hours.

mkdir cm4mm
cd cm4mm
repo init -u git://github.com/nadlabak/android.git -b gingerbread
repo sync
vendor/cyanogen/get-rommanager
. build/envsetup.sh && brunch umts_sholes

Flashing

  • Copy the update-cm-7...-Milestone-signed.zip from out/target/product/umts_sholes to OpenRecovery/updates
  • Factory Reset / Wipe Cache Partition AND Dalvik Cache
  • Flash the Cyanogen update-cm-7...-Milestone-signed.zip file
  • Flash the Google Apps zip file
  • Reboot

Installing dropbear an a PCH-A200/A210 (NMT – Networked Media Tank)

First, install opkg by using the NMT Community Software Installer. If you are using Ubuntu, install sudo apt-get install mono-complete (which is probably more than you need) to make NMT-CSI run. Download the opkg package, then run sh "Linux Start.sh" and go to File -> Install from File -> opkg_c200_v0.1.8-nmt1.zip. Of course you need to start FTP in order to connect to your device. For more details, go here.

Once opkg is installed get the package list opkg update and install opkg install dropbear. This failed with my setup, so I had to configure it manually:

  • create keys: dropbearkey -t dss -f dropbear_dss_host_key, dropbearkey -t rsa -s 1024 -f dropbear_rsa_host_key
  • copy them to /share/.ssh and make them chmod 600
  • also copy your authorized_keys to this directory

After that, I modified /share/Apps/local/etc/init.d/51dropbear.sh in order to start dropbear (inspired by this thread).

#!/bin/sh
[ -e /share/Apps/local/etc/default/dropbear ] && . /share/Apps/local/etc/default/dropbear
if [ "$DROPBEAR_ENABLE" = "no" ]; then
    exit
fi
if [ -n "`pidof /share/Apps/local/sbin/dropbear`" ]; then
    killall /share/Apps/local/sbin/dropbear 2>/dev/null
fi
# root does not have a shell, so ssh wont work. Give the root a shell
sed -i 's#root:x:0:0:root:/root:/bin/true#root:x:0:0:root:/root:/bin/sh#g' /etc/passwd
mkdir -p /etc/dropbear
cp /share/.ssh/dropbear_dss_host_key /etc/dropbear
mkdir -p /root/.ssh
chmod 700 /root/.ssh
cp /share/.ssh/authorized_keys /root/.ssh/
chown root.root /root
# -s Disable password logins
/share/Apps/local/sbin/dropbear -s

Lets hope that the installation of an ssh server on the new Popcorn Hour A-300 is a bit easier.

Update 15.12.2011: I installed unison for doing backups on my NMT. Unfortunately, I did not find the package here. However, it turned out to be easier than I thougt. Instead of cross-compiling my own package, I tried the package from debian, and it worked by just copying the binary into the /share/Apps/local/bin/. The only problem is the CPU that slows the encrypted traffic down to around 10MBit/s.

Upload Artifacts on the Command Line

I had to patch an external library and since my project uses Maven, I wanted to upload this patched library to my Maven repository. It turned out that I had to use maven2 as maven3 handles extensions differently.

Stackoverflow provided the rest of the information I needed to upload a library to my maven repository.

/home/draft/java/apache-maven-2.2.1/bin/mvn deploy:deploy-file -Durl=scp://tomp2p.net/home/draft/maven -DrepositoryId=ssh-tomp2p -DgroupId=org.jboss.netty -DartifactId=netty -Dversion=3.2.6.Patched -Dpackaging=jar -Dfile=target/netty-3.2.6.Patched.jar

Battery Life of a HP 5103

After reading the following articles, I decided to tweak battery life on my HP 5103. Before I started, I installed the latest Linux 3.1 kernel.

The battery usage without any tweaks was 11.4W as reported by powertop. I tested the option pcie_aspm=force and the power usage went down to 10.3W. Another tweak I did was to mount the / with the option noatime to reduce disk IO. If this option is set, reading accesses won’t be written (atime) to disk. However, I did not do any measurements.

Furthermore, I disabled bluetooth and added the following lines to rc.local (found here and here)

for i in /sys/class/scsi_host/host?/link_power_management_policy; do
    echo min_power > $i
done
for i in /sys/bus/usb/devices/*/power/autosuspend; do
    echo 1 > $i
done
for i in $(find /sys/devices/pci* -wholename "/sys/devices/pci*/power/control"); 
    do if [[ "$(cat $i)" == "on" ]]; then 
         echo "auto" > $i; 
    fi; 
done;

And now I’m down to 9.5W. Further reduction can be achieved by dimming the backligth.

If you want to have this done automatically, you may want to install laptop-mode-tools. However, you need first to change the line

Look for :
	"2.6" ) ;;

And add right after on line following, which ought to allow kernel 3.0, 3.12 .. 3.9876.

3.[0-9]*) ;;

If your mouse is only working after replugging, add it to the blacklist (in /etc/laptop-mode/conf.d/usb-autosuspend.conf set AUTOSUSPEND_USBID_BLACKLIST="046d:c018"), or buy a mouse that supports autosuspend. I also had to disable the WLAN autosuspend (/etc/laptop-mode/conf.d/wireless-power.conf), as this is with brcmsmac not possible.

(X)Ubuntu 11.10

Yesterday, I installed 11.10 oneirc on my HP 5103. The HP5103 is a netbook, which is not very fast, so I was wondering how good the new Ubuntu would work. First I tried Unity. The good part ist that they included now many of the nice features that I was missing before, e.g., multiload, which is an applet to show the cpu and network load. The reason I decided not to use Unity is because the windows key is too unreliable. Since staring application with the windows key is a central part of the Unity concept, its needs to work 100% reliabel. Pressing [win]-[e][enter], must always open Firefox regardless of the CPU load or windows focus.

Then, I installed gnome-shell. The first thing I tried was if the windows key is working as expected regardless of the CPU load or windows focus. It did work as expected, good news. However, the system monitor seems to be work in progres and I could not place it on top, it stayed on the bottom. The interesting part is that those extensions are written is javascript and are using css. This makes the extensions easy to write (no gcc, no libriaries), but it needs a good development environment, something like Firebug. Another point I am concerned is speed: while the javascript extension is flexible, I am not sure if the UI remains fast and snappy. I recently read that the Firefox developers decided to replace their XUL layout engine with a native one for greater responsiveness and less memory consumption. It seems that gnome-shell is heading in the other direction.

The feature that made me finally switch back to Xubuntu is dual monitor, which was not working with Ubuntu (gnome-shell and Unity). The screen would go black, then show colored stripes. I am having a GMA 3150, which does not have the best Linux support, but at least in Xubuntu, I can attach a second monitor. Another thing I noticed is that it just feels much faster than gnome-shell and Unity.

Manually Decrypt your Encrypted Home Directory with your Login Password

The home folder encryption uses two passwords: one password, which is the login password that encrypts/decrypts the mount password. The encrypted mount password is stored in the file wrapped-passphrase. This way, if the user changes the password, only the mount password needs to be re-encrypted.

I am using Ubuntu 11.10, so depending on your distribution, the commands may be different.

  1. ecryptfs-unwrap-passphrase /home/username/.ecryptfs/wrapped-passphrase
  2. sudo ecryptfs-add-passphrase --fnek (use key from above, copy second key, that is displayed)
  3. create /tmp/username
  4. sudo mount -t ecryptfs /home/.ecryptfs/username/.Private /tmp/username
  5. select: aes, 16, n, y, and paste the second key from above

Manually Uncrypt your Ecrypted Home Directory with your Login Password

The home folder encryption uses two passwords: one password, which is the login password that encrypts/decrypts the mount password. The encrypted mount password is stored in the file wrapped-passphrase. This way, if the user changes the password, only the wrappend passphrase needs to be re-encrypted.

I am using Ubuntu 11.10, so depending on your distribution, the commands may be different.

  1. ecryptfs-unwrap-passphrase /home/username/.ecryptfs/wrapped-passphrase
  2. sudo ecryptfs-add-passphrase --fnek (use key from above, copy second key, that is displayed)
  3. create /tmp/username
  4. sudo mount -t ecryptfs /home/.ecryptfs/username/.Private /tmp/username
  5. select: aes, 16, n, y, and paste the second key from above

OpenWRT an a RouterStation Pro

OpenWrt is a Linux distribution for embedded devices. That means OpenWRT runs fine on machines with low CPU, RAM and ROM. OpenWRT can be configured to run anything you want on your embedded device, but its mostly used in router projects. I first tried OpenWRT on a NSLU2, but I changed to a more powerful machine, since the NSLU2 was too slow. In the following, I’ll describe the steps how to setup OpenWRT for a RouterStation Pro running OpenVPN, CUPS, Asterisk, UPNP, and DynDNS.

Naming Issues with broadcom-sta module

The broadcom-sta module wl will use the eth* naming pattern by default. If you are having two network interfaces, e.g. lan and wlan (I’m having a BCM43224), ifconfig will output:

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx  
          inet addr:192.168.1.249  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: xx/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3255 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2849 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2032027 (2.0 MB)  TX bytes:359760 (359.7 KB)
          Interrupt:19 
eth1      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx  
          inet addr:192.168.1.215  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: xx/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:112 errors:1 dropped:0 overruns:0 frame:11971
          TX packets:91 errors:34 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:13829 (13.8 KB)  TX bytes:15989 (15.9 KB)
          Interrupt:16 

This behavior can be changed by setting the name in the option in /etc/modprobe.d/modprobe.conf (you may need to create this file if it does not exist) by adding the option options wl name=wlan0. As an alternative, you can use the b43 kernel module (requires kernel 3.1+) or brcmsmac instead of broadcom-sta. To switch, type in console "echo "blacklist wl" >> /etc/modprobe.d/blacklist" as root and reboot (or remove the the wl kernel module).

(X)ubuntu on a HP Mini 5103

Today, I decided to install http://xubuntu.org/ on my HP Mini 5103 to replace my classic http://www.ubuntu.com/ installation. The reason for this change is that the classic Ubuntu did not feel fast and snappy enough. Although various reports (here or here) indicate that Lubuntu is more resource friendly than Xubuntu, I decided to try Xubuntu since the HP Mini 5103 has 2GB. The installation of Xubuntu is very easy and I won’t go into details here. The following sections deal with difficulties I had while installing. Other Ubuntu variants may have the same issues.