Install custom ROM KitKat on my Nexus S

Disclaimer: This guide is taken from multiple sources and for my own use
I do not write this guide.

Step by step for Kitkat ROM installation: article from AndroidGeeks
Reproduce here :
1. Download the custom ROM build. I use AOSP 4.4.3 this, taken from xda-developers

2. Download Gapps for this ROM from here.

3. Connect your Nexus S with your PC, then move both zip files on your device’s internal storage.
– disconnect the device from computer when all files are copied successfully.

4. Power off the device now.
5. Boot it in CWM Recovery Mode now. Here is another guide showing how to do so. I ended up using the 3rd method (via adb) .

6. First you need to create a full NANDROID Backup of your current ROM by selecting ‘backup and restore’ option.
– save the file on the Nexus S internal storage, then continue to the next step.

7. Now, apply the factory reset:
– select ‘wipe data/factory reset’. Confirm the process.

8. Install the custom ROM zip by selecting ‘install zip from sdcard’, then ‘choose zip from sdcard’.
– find the AOSP Android 4.4 custom ROM and confirm its installation.
=> issue encountered in the 1st run :
According to this StackOverflow thread:

In short, if you want to flash KitKat Android 4.4, you’ll have to upgrade to a version of CWM greater than v6.0.4.5. Or, use an alternate bootloader.

Mine was CWM v6.0.3.1 => need to upgrade to the latest v6.0.4.3
Download from ROM-manager, latest version at the time of writing : v6.0.4.3
Once downloaded this CWM image, copy it over to my sdk/platform-tools/ folder, and then execute this :

fastboot flash recovery clockworkmod.img

where clockworkmod.img is the filename of your image
My first attempt failed with some error in [Invalid parameters], I just re-download the image and it worked fine
Once flashing completes, from CWM, select **Recovery**, your phone should enter CWM v6.0.4.3 now.

Btw, make sure your device is connected by firing : fastboot devices
If your device is not visible to fastboot it is probably due to a few common reasons:
a. phone is not in fastboot mode -> need to reboot into fastboot mode -> for Nexus S: To enter into Bootloader/Fastboot : (while turned off) Press and hold Volume Up + Power
b. missing driver -> for Nexus S, install driver following these steps:
i. Download Google USB Driver, latest one here, or direct link
ii. Update the driver by : Device Manager -> right click and select “Update Drives Software”
2014-10-29 17_03_27-Clipboard
Browse my computer for driver software -> Let me pick from a list of device drivers on my computer -> Android Phone -> Have Disk, then browse for file android_winusb.inf (in SKD folder) -> Android ADB
Windows will prompt some warning, just proceed.

9. After the ROM is flashed, repeat step 8 actions and flash the Gapps zip too.
Note: 1st attempt fails due to insufficient space (image)
Download the micro GApps version here, or direct link

10. Return to the main custom Recovery screen when both files are flashed successfully.
11. Reboot the phone.
– note that the first boot process takes several minutes to complete, which is why you shouldn’t press any buttons until all files are loaded.

12. Enter your Google Account details when the home screen appears.

That’s it, now you need to take control over your device and start testing all the new features.

Wifi controlled Raspberry Pi robot

I will document my journey to build a wifi controlled Raspberry Pi robot here. This post will be updated as and when I have progress on the project.

Desirable features:
- controllable via wifi
- Web interface to control the robot.
- movable using 4 wheels
- has a display (16×2 LCD display is sufficient)
- has a webcam for live feed
- webcam can be rotated for capture at different angles
- run on battery

Nice to have features:
- Mobile interface to control the robot
- a speaker for robot to “talk” (text sent via the website command, then robot speaks using TTS ?)
- a microphone for interaction with human (other people speaks to the robot, and I can hear back at the website command?)
- object tracking: robot is able to track moving objects and follows that object

Hardware Components:
- Raspberry Pi, Model B
- Wifi dongle
- 16×2 LCD display – USD $5
- PCB boards
- 4 wheels DC motors – USD $16
- USB webcam / Piwebcam
- Servo motor – USD $5.15

- Breadboard
- Dupont cables
- PCB boards
- Solid core cable – US $2.95

Optional Tools
- Raspberry Pi GPIO Cobbler extension – USD $8
- Pin header – USD $1.5
- Breadboard power supply – USD $1.5

Considering power bank for Raspberry Pi

I am in need of a suitable battery pack to power my Raspberry Pi and all its peripherals. This entry is to list down any considerations made along the way :
Remember RaspPi runs at 5V, hence input power is required to provide a steady 5V stream, more and you may destroy the Pi, less and the Pi will start to behave wildly.

A Raspberry Pi needs 5V with 700 mA, meaning it has a consumption of 3.5 Watt.
Note that consumption indicates a maximum value because it can never get more power that the indicated consumption.

(1) Buy an off-the-shelf power bank. A useful article to decide on which power bank to buy : FB don’t buy power bank until you read this

(2) Use AA batteries with UBEC-Universal Battery Eliminator Circuit, which essentially is a switch mode voltage regulator .

Set up a live webcam streamer on Raspberry Pi

I used Motion as the camera live streamer. Found a great short and comprehensive guide for the setup here.

To keep long story short, these are the important commands:

  1. sudo apt-get install motion
  2. sudo nano /etc/motion/motion.conf
    => in the config file, change these values :
    Daemon = OFF to ON
    webcam_localhost = ON to OFF
    minimum_motion_frames 5 to 2999
    (changing minimum_motion_frames to avoid Motion to capture exessive screenshots whenever movement is detected. I only need the live stream camera function.
    Btw, your screen captures are stored in /tmp/motion )
  3. sudo nano /etc/default/motion
    Then change the value “start_motion_daemon=no” to “yes”
  4. sudo service motion start
  5. Access at : http://[pi ip address]:8081
    I accessed ok using Firefox. Chromes doesnot work for some reason.

Settings in my Raspberry pi /etc/network/interfaces

pi@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback

#allow-hotplug wlan0
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static

#auto eth0
#iface eth0 inet static
# Your static IP

Frequently used Unix / Raspberry Pi commands (I kinda mix them up in this single post)

ps ax | grep vnc search for process which name contains “vnc” in all running processes
cat /etc/rc.local this file defines the commands at startup
crontab -l list user’s crontab.
crontab -e edit user’s crontab. You can use crontab to define autoscript at bootup
Simply add an entry starting with @reboot
eg. @reboot sleep 180; sh ~/ #after bootup, wait for 3minutes then run
kill -9 1234 kill the running process which id is 1234
tightvncserver start tightVNC server
cat /etc/network/interfaces view network information pre-configured on raspberry pi
wpa_passphrase [yourSSID] [yourpassword] to generate an entry for your wifi ssid and password.
You then take this entry and set in /etc/wpa_supplicant/wpa_supplicant.conf
sudo shutdown -ht 0 now shutdown pi and halt after shutdown
sudo /etc/init.d/networking restart restart network, to take new settings into effect
lsusb view all connecting devices via USB
sudo service [service_name] start start a service
sudo service [service_name] stop stop a service