It's been more than 2.5 years since my last try of CyanogenMod 10.2 on Xiaomi Mi2S in December 2013. Due to unacceptable power drainage issue - about 15% battery drop overnight without Wi-Fi and 3G-data enabled), CM 10.2 was a no-go for my Mi2S. Recently, my Mi2S suffers from disk space shortage and the apps could be installed is very limited, thus I decided to resize the partitions and at the same time give CM 12.1 a try. (Per relnotes in CM 12, the battery drain issue is improved.)
Software and images used:
- GNU Parted 1.8.8.1.179 - Disk partitioning utility
- TWRP-3.0.2-0-aries - The recovery image
- CM-12.1-20150730-UNOFFICIAL-aries - CM 12.1 ROM for Mi2S
Four key partitions were resized from:
Number Start End Size File system Name Flags
21 336MB 1409MB 1074MB ext4 system
22 1409MB 1812MB 403MB ext4 cache
23 1812MB 5570MB 3758MB ext4 userdata
24 5570MB 31.3GB 25.7GB ext4 storage
to:
Number Start End Size File system Name Flags
21 336MB 1836MB 1500MB ext4 system
22 1836MB 2238MB 403MB ext4 cache
23 2238MB 8238MB 6000MB ext4 userdata
24 8238MB 31.3GB 23.0GB ext4 storage
My observation shows the overnight battery drop is still around 15%, and it's really frustrating. Too bad that CM 12.1 is still a no-go.
Jul 17, 2016
Sep 20, 2013
Raspberry Pi As A Wi-Fi Access Point
Hey guys, happy Mid-Autumn Festival. Tired of BBQ and mooncakes? Let's have a quick project by turning a Raspberry Pi into a Wi-Fi access point. The first Pi image I tried was OpenWrt 12.09 (Attitude Adjustment), which is a very small Linux distro for embedded systems. But turned out the image just doesn't work out of the box at the 1st boot. A few boot files seem to be outdated and should be replaced by those from other distros like OpenELEC. Really frustrated indeed :(. So I fell back again to my home router with Raspbian installed. There are lots of write-ups regarding making Pi a Wi-Fi AP already, but none of them worked for me tho :(. After trying a few things out, I made my own steps.
Buffalo WLI-UC-GNM W-Fi dongle was used in the test. See http://elinux.org/RPi_USB_Wi-Fi_Adapters for more hardware info.
$ lsusb | grep -i wireless
Bus 001 Device 004: ID 0411:01a2 BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNM Wireless LAN Adapter [Ralink RT8070]
We need a few more packages to complete the task:
$ apt-get install hostapd isc-dhcp-server
It took me some time to figure out a link detection daemon called ifplugd is bad for us to do the following configuration:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
hwaddress ether 00:90:de:ad:be:ef
auto wlan0
iface wlan0 inet static
address 10.8.8.254
netmask 255.255.255.0
Quoted from the hostapd manpage, hostapd is an IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator. For brevity most of the comments in the configuration files are removed, but you can easily look them up on the net.
$ more /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=Pi-Fi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=MySecret
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
The values in bold above can be changed to fit your needs.
$ more /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
An IP addresses pool will be defined, along with some TCP/IP configuration to be dispatched to the clients.
$ more /etc/dhcp/dhcpd.conf
authoritative;
ddns-update-style none;
ignore client-updates;
subnet 10.8.8.0 netmask 255.255.255.0 {
option routers 10.8.8.254;
option subnet-mask 255.255.255.0;
option domain-name "home.tw";
option domain-name-servers 8.8.8.8;
range 10.8.8.130 10.8.8.169;
default-lease-time 86400;
}
We just listen on the interface wlan0:
$ more /etc/default/isc-dhcp-server
INTERFACES="wlan0"
Add the following lines to the file /etc/rc.local:
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
That's it. Let's make some services start on boot, then reboot.
$ sudo update-rc.d hostapd enable
$ sudo update-rc.d isc-dhcp-server enable
$ sudo reboot
After the reboot, if everything goes well our Wi-Fi SSID will be broadcasted in the air like a normal AP does. Interfaces info follow:
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:90:de:ad:be:ef
inet addr:192.168.111.193 Bcast:192.168.11.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:104189 errors:0 dropped:0 overruns:0 frame:0
TX packets:84076 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:105045101 (100.1 MiB) TX bytes:17906110 (17.0 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
mon.wlan0 Link encap:UNSPEC HWaddr 4C-E6-76-D5-92-37-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32587 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3042110 (2.9 MiB) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 4c:e6:76:d5:92:37
inet addr:10.8.8.254 Bcast:10.8.8.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:85472 errors:0 dropped:0 overruns:0 frame:0
TX packets:104367 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17480008 (16.6 MiB) TX bytes:108515924 (103.4 MiB)
Notice the IP address of wlan0 should be correctly assigned, and an extra interface mon.wlan0 will be brought up by hostapd as well. In my test, three devices could get on the Internet simultaneously via this hotspot without any problem.
References:
Wi-Fi dongles
Buffalo WLI-UC-GNM W-Fi dongle was used in the test. See http://elinux.org/RPi_USB_Wi-Fi_Adapters for more hardware info.
$ lsusb | grep -i wireless
Bus 001 Device 004: ID 0411:01a2 BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNM Wireless LAN Adapter [Ralink RT8070]
Package Installation
We need a few more packages to complete the task:
$ apt-get install hostapd isc-dhcp-server
Package Removal
It took me some time to figure out a link detection daemon called ifplugd is bad for us to do the following configuration:
- MAC address modification for interface eth0. Yes, in my scenario the MAC address of the interface to the Internet is locked to a specific value. This is not required for you guys I think.
- Static IP address assignment for interface wlan0. This is essential for further routing and forwarding configuration
Topology and Interface Configuration
- WAN: eth0, Ethernet connected to the Internet. IP address is DHCP assigned.
- LAN: wlan0, wireless interface for the hotspot. IP address is statically assigned to 10.8.8.254
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
hwaddress ether 00:90:de:ad:be:ef
auto wlan0
iface wlan0 inet static
address 10.8.8.254
netmask 255.255.255.0
HostAPd Configuration
Quoted from the hostapd manpage, hostapd is an IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator. For brevity most of the comments in the configuration files are removed, but you can easily look them up on the net.
$ more /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=Pi-Fi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=MySecret
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
The values in bold above can be changed to fit your needs.
$ more /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
DHCP Server Configuration
An IP addresses pool will be defined, along with some TCP/IP configuration to be dispatched to the clients.
$ more /etc/dhcp/dhcpd.conf
authoritative;
ddns-update-style none;
ignore client-updates;
subnet 10.8.8.0 netmask 255.255.255.0 {
option routers 10.8.8.254;
option subnet-mask 255.255.255.0;
option domain-name "home.tw";
option domain-name-servers 8.8.8.8;
range 10.8.8.130 10.8.8.169;
default-lease-time 86400;
}
We just listen on the interface wlan0:
$ more /etc/default/isc-dhcp-server
INTERFACES="wlan0"
Routing and NAT Configuration
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
That's it. Let's make some services start on boot, then reboot.
$ sudo update-rc.d hostapd enable
$ sudo update-rc.d isc-dhcp-server enable
$ sudo reboot
After the reboot, if everything goes well our Wi-Fi SSID will be broadcasted in the air like a normal AP does. Interfaces info follow:
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:90:de:ad:be:ef
inet addr:192.168.111.193 Bcast:192.168.11.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:104189 errors:0 dropped:0 overruns:0 frame:0
TX packets:84076 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:105045101 (100.1 MiB) TX bytes:17906110 (17.0 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
mon.wlan0 Link encap:UNSPEC HWaddr 4C-E6-76-D5-92-37-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32587 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3042110 (2.9 MiB) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 4c:e6:76:d5:92:37
inet addr:10.8.8.254 Bcast:10.8.8.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:85472 errors:0 dropped:0 overruns:0 frame:0
TX packets:104367 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17480008 (16.6 MiB) TX bytes:108515924 (103.4 MiB)
Notice the IP address of wlan0 should be correctly assigned, and an extra interface mon.wlan0 will be brought up by hostapd as well. In my test, three devices could get on the Internet simultaneously via this hotspot without any problem.
References:
- http://www.howtogeek.com/167425/how-to-setup-wi-fi-on-your-raspberry-pi-via-the-command-line/. But I didn't try the WPA supplicant part.
- http://elinux.org/RPI-Wireless-Hotspot. Does not work for me. :(
Jun 12, 2013
Guten Morgen - Raspberry Pi As A Morning Alarm
Since my home router is in my kids' bedroom, I think it'd be great if an alarm feature can be added to the Raspberry Pi to kick their asses up in the morning. Other than a RPi we're gonna need these peripherals:
Install the audio file player and motion detection software:
$ sudo apt-get install omxplayer motion
The morning call is triggered via crontab (6:39 AM, Monday to Friday)
$ crontab -l
39 6 * * 1-5 cd guten-morgen; ./guten-morgen.sh
Once the audio file is being played, the motion detection starts and if a motion event was triggered, the omxplayer process will be killed to silence the speaker.
Screenshots:
Thank David Su for donating an engineering sample of webcam component designed for laptops. Before that I've tried some webcams but with no avail. Check the RPi Verified Peripherals page to see if your accessories work on RPi.
Live demo:
- a speaker with 3.5mm audio jack for audio playback
- a motion sensor as a switch to stop the alarm
Install the audio file player and motion detection software:
$ sudo apt-get install omxplayer motion
The morning call is triggered via crontab (6:39 AM, Monday to Friday)
$ crontab -l
39 6 * * 1-5 cd guten-morgen; ./guten-morgen.sh
Once the audio file is being played, the motion detection starts and if a motion event was triggered, the omxplayer process will be killed to silence the speaker.
Screenshots:
| Raspberry Pi as a morning alarm (w/ USB powered speaker and a USB webcam component on top of RPi) |
| Close-up of the webcam component (as a motion sensor) |
May 25, 2013
Raspberry Pi Overdose
More Pi's arrived. One of them will be used to replace my current home router, which is an old laptop running Ubuntu. (See this blog for details)
The OS to be installed is Raspbian “wheezy”, but Raspbian is too heavy for me thus by running the following command, GUI stuff or large packages could be easily found. After removing the unnecessary packages, the disk space occupied is reduced to 1.1 GB, which makes it fit very well in a 2 GB SD card.
List the packages by installed size:
$ dpkg-query -W -f='${Installed-Size} ${Package}\n' | sort -n
For more entertainment the case is hand-made using cardboard, check the Punnet project for details.
The OS to be installed is Raspbian “wheezy”, but Raspbian is too heavy for me thus by running the following command, GUI stuff or large packages could be easily found. After removing the unnecessary packages, the disk space occupied is reduced to 1.1 GB, which makes it fit very well in a 2 GB SD card.
List the packages by installed size:
$ dpkg-query -W -f='${Installed-Size} ${Package}\n' | sort -n
For more entertainment the case is hand-made using cardboard, check the Punnet project for details.
Mar 31, 2013
HTPC Comes True With Raspberry Pi
Today we're going to install a light-weighted Linux distribution - OpenELEC, to make a home theater PC (HTPC) with the Raspberry Pi. OpenELEC is designed to be simple and fast by running XBMC in standalone mode to turn your PC into a media center. Current latest version of OpenELEC is 3.0.0 as of this writing and the OS image could be downloaded HERE. The installation takes less than 10 minutes with very small disk space footprints (less than 250 MB). SSH server was enabled by default and you could login as root (password: openelec), but there's no passwd command available to change the password in a traditional way. Poor security design!
openelec:~ # df -h
Filesystem Size Used Available Use% Mounted on
none 185.1M 87.4M 97.6M 47% /dev
/dev/mmcblk0p1 124.7M 96.1M 28.7M 77% /flash
/dev/mmcblk0p2 1.7G 61.2M 1.6G 4% /storage
/dev/loop0 87.4M 87.4M 0 100% /
none 186.5M 0 186.5M 0% /dev/shm
/dev/sda1 916.9G 727.4G 142.9G 84% /var/media/cove
openelec:~ # passwd
-sh: passwd: command not found
Although the CPU in Raspberry Pi is an ARM 700 MHz processor (could be over-clocked up to 1 GHz), but the GPU (Broadcom VideoCore IV) is fast enough for 1080p video playback, which is the key to an HTPC. Since controlling an HTPC with a keyboard and mouse is way too geeky, we'll dump them and use an IR remote instead (shown below).
With the Raspberry enclosed in the black case, the composition looks less ugly tho.
Port usage in the USB hub (from left to right):
While playing 1080p video, the CPU temperature is like 62 °C (144 °F) , guess it could go up to 70 °C (158 °F) in summer, and the power consumption is less than 8W with peripherals attached shown above.
The last thing to do is enabling the AirPlay feature in XBMC. Go to System -> Settings -> Services -> AirPlay to enable it, then your iOS devices could either play the music or display the photos to the XBMC screen (mirroring not feasible due to hardware limitation).
Note that the iOS device and the XBMC must be within the same local network (or subnet to be specific) for the service to be broadcasted correctly. (no configuration is needed on iOS devices.) Click the AirPlay icon while browsing the photo to airplay it to the remote screen.
[Updated on Apr. 4, 2013]
Additional notes regarding the remote control, since the Raspberry Pi is CEC-enabled, which is a feature in HDMI specification that allows the user to operate multiple devices with one remote control, if your TV set is also CEC-enabled, you can just use your TV remote to control XMBC. Pretty cool, huh?
Luckily the TV (Sharp LC-52GX30T) I used is CEC-enabled. To check if your TV supports HDMI-CEC or not, login to the OpenELEC and type "cec-client":
openelec:~ # cec-client
No device type given. Using 'recording device'
CEC Parser created - libCEC version 2.1.1
no serial port given. trying autodetect:
path: Raspberry Pi
com port: RPI
opening a connection to the CEC adapter...
DEBUG: [ 108] unregistering all CEC clients
DEBUG: [ 111] Broadcast (F): osd name set to 'Broadcast'
DEBUG: [ 117] InitHostCEC - vchiq_initialise succeeded
DEBUG: [ 118] InitHostCEC - vchi_initialise succeeded
DEBUG: [ 120] InitHostCEC - vchi_connect succeeded
DEBUG: [ 124] logical address changed to Broadcast (f)
DEBUG: [ 125] RegisterLogicalAddress - registering address e
DEBUG: [ 306] logical address changed to Recorder 1 (1)
DEBUG: [ 307] logical address changed to Free use (e)
DEBUG: [ 307] Open - vc_cec initialised
NOTICE: [ 308] connection opened
DEBUG: [ 314] << Broadcast (F) -> TV (0): POLL
DEBUG: [ 314] initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
TRAFFIC: [ 314] << e0
DEBUG: [ 316] processor thread started
DEBUG: [ 346] >> POLL sent
DEBUG: [ 346] TV (0): device status changed into 'present'
DEBUG: [ 346] << requesting vendor ID of 'TV' (0)
TRAFFIC: [ 346] << e0:8c
TRAFFIC: [ 538] >> 0f:87:08:00:1f
DEBUG: [ 538] >> TV (0) -> Broadcast (F): device vendor id (87)
DEBUG: [ 538] TV (0): vendor = Sharp (08001f)
DEBUG: [ 539] expected response received (87: device vendor id)
NOTICE: [ 539] registering new CEC client - v2.1.1
DEBUG: [ 539] detecting logical address for type 'recording device'
Or take a look at the lower-right corner after XBMC boots, a pop-up message will be shown (see image below) if a CEC-enabled device is connected.
Here's a quick test results on CEC features against my TV:
| Booting OpenELEC |
openelec:~ # df -h
Filesystem Size Used Available Use% Mounted on
none 185.1M 87.4M 97.6M 47% /dev
/dev/mmcblk0p1 124.7M 96.1M 28.7M 77% /flash
/dev/mmcblk0p2 1.7G 61.2M 1.6G 4% /storage
/dev/loop0 87.4M 87.4M 0 100% /
none 186.5M 0 186.5M 0% /dev/shm
/dev/sda1 916.9G 727.4G 142.9G 84% /var/media/cove
openelec:~ # passwd
-sh: passwd: command not found
Although the CPU in Raspberry Pi is an ARM 700 MHz processor (could be over-clocked up to 1 GHz), but the GPU (Broadcom VideoCore IV) is fast enough for 1080p video playback, which is the key to an HTPC. Since controlling an HTPC with a keyboard and mouse is way too geeky, we'll dump them and use an IR remote instead (shown below).
With the Raspberry enclosed in the black case, the composition looks less ugly tho.
Port usage in the USB hub (from left to right):
- Power supply for the Pi
- IR remote receiver
- USB external hard disk
While playing 1080p video, the CPU temperature is like 62 °C (144 °F) , guess it could go up to 70 °C (158 °F) in summer, and the power consumption is less than 8W with peripherals attached shown above.
| Hardware info of the Raspberry Pi |
The last thing to do is enabling the AirPlay feature in XBMC. Go to System -> Settings -> Services -> AirPlay to enable it, then your iOS devices could either play the music or display the photos to the XBMC screen (mirroring not feasible due to hardware limitation).
![]() | |||
| AirPlay feature in XBMC |
Note that the iOS device and the XBMC must be within the same local network (or subnet to be specific) for the service to be broadcasted correctly. (no configuration is needed on iOS devices.) Click the AirPlay icon while browsing the photo to airplay it to the remote screen.
| AirPlay icon on iOS |
| Photo on iPad airplayed to the remote XBMC screen |
[Updated on Apr. 4, 2013]
Additional notes regarding the remote control, since the Raspberry Pi is CEC-enabled, which is a feature in HDMI specification that allows the user to operate multiple devices with one remote control, if your TV set is also CEC-enabled, you can just use your TV remote to control XMBC. Pretty cool, huh?
Luckily the TV (Sharp LC-52GX30T) I used is CEC-enabled. To check if your TV supports HDMI-CEC or not, login to the OpenELEC and type "cec-client":
openelec:~ # cec-client
No device type given. Using 'recording device'
CEC Parser created - libCEC version 2.1.1
no serial port given. trying autodetect:
path: Raspberry Pi
com port: RPI
opening a connection to the CEC adapter...
DEBUG: [ 108] unregistering all CEC clients
DEBUG: [ 111] Broadcast (F): osd name set to 'Broadcast'
DEBUG: [ 117] InitHostCEC - vchiq_initialise succeeded
DEBUG: [ 118] InitHostCEC - vchi_initialise succeeded
DEBUG: [ 120] InitHostCEC - vchi_connect succeeded
DEBUG: [ 124] logical address changed to Broadcast (f)
DEBUG: [ 125] RegisterLogicalAddress - registering address e
DEBUG: [ 306] logical address changed to Recorder 1 (1)
DEBUG: [ 307] logical address changed to Free use (e)
DEBUG: [ 307] Open - vc_cec initialised
NOTICE: [ 308] connection opened
DEBUG: [ 314] << Broadcast (F) -> TV (0): POLL
DEBUG: [ 314] initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
TRAFFIC: [ 314] << e0
DEBUG: [ 316] processor thread started
DEBUG: [ 346] >> POLL sent
DEBUG: [ 346] TV (0): device status changed into 'present'
DEBUG: [ 346] << requesting vendor ID of 'TV' (0)
TRAFFIC: [ 346] << e0:8c
TRAFFIC: [ 538] >> 0f:87:08:00:1f
DEBUG: [ 538] >> TV (0) -> Broadcast (F): device vendor id (87)
DEBUG: [ 538] TV (0): vendor = Sharp (08001f)
DEBUG: [ 539] expected response received (87: device vendor id)
NOTICE: [ 539] registering new CEC client - v2.1.1
DEBUG: [ 539] detecting logical address for type 'recording device'
Or take a look at the lower-right corner after XBMC boots, a pop-up message will be shown (see image below) if a CEC-enabled device is connected.
| Message shows this TV is CEC-enabled |
Here's a quick test results on CEC features against my TV:
- Use the TV remote to control XBMC - PASS
- Shutdown XBMC and the TV will be turned off automatically - PASS
- While TV is on, turn on the Pi and the TV video source will be switched to the XBMC automatically - PASS
- While TV is off, turn on the Pi and the TV will be turned on automatically - FAIL
Mar 30, 2013
Hungry? Grab a Byte of Raspberry Pi
Yeah! New gadgets arrived. A quick intro if you have no idea what it is. Raspberry Pi is a credit-card-sized computer developed in the UK for educational purpose. If you need a power-up-and-ready-to-go computer this is definitely NOT what you want. This one was ordered directly from the RS Components website, with a black case and plus the shipping fee, the total cost is USD $49.49 (TWD $1480). Still pretty affordable.
Since the Raspberry Pi was designed for educational purpose, we need to get the essential accessories and put them altogether to make it work. Required items are:
Optional but highly recommended items:
Next, we need an OS for the Pi to boot. We'll be using Raspbian "wheezy" as it's the recommended Linux distro from the official site. You can download it HERE, and follow the instructions on that page to dump the OS image to the SD card to make it bootable. Once everything is ready, plug in the micro USB power supply and have fun.
| Shipped from the UK |
| Raspberry Pi and the black case |
| The Raspberry Pi (model B) |
Since the Raspberry Pi was designed for educational purpose, we need to get the essential accessories and put them altogether to make it work. Required items are:
- 5V micro USB power supply
- The standard USB to micro USB cable (the black cable shown below) is an accessory of an old Nokia 5310 mobile phone
- AC to USB converter is an accessory of iPhones (the white one shown below)
- An SD card (2GB or more recommended)
- A USB keyboard and mouse (not needed if remote login is enabled after configuration)
- TV or monitor with HDMI input (not shown below)
| Required accessories |
Optional but highly recommended items:
- A USB hub, at least 4 ports, with external power source
- An external USB hard drive
- Internet connectivity
- Will be used by software update and time sync via NTP protocol as there is no real-time clock integrated in the Raspberry Pi to keep the cost down.
| Optional but highly recommended stuff |
- By default, login as pi, with password raspberry
- Type "startx" for the X Window, the graphical UI
| Dinner is served ;) |
| Raspbian "wheezy" up and running |
How to Update Flash Player Add-on on Linux Mint
It's been like a week or so the Firefox browser on Linux Mint (13, Maya) keeps deactivating the Adobe Flash Player, which is pretty annoying. Here's a quick fix for this - remove the old package shipped by Linux Mint and get the one from Ubuntu Update Repo.
Type the following commands:
$ sudo apt-get remove mint-flashplugin-11
$ sudo apt-get install flashplugin-installer
Re-start your Firefox and you're good to go.
Type the following commands:
$ sudo apt-get remove mint-flashplugin-11
$ sudo apt-get install flashplugin-installer
Re-start your Firefox and you're good to go.
![]() |
| Outdated plug-ins got deactivated by Firefox |
![]() |
| Before the update (original version) |
![]() |
| After the update |
Mar 25, 2013
ZyXEL P-6101C as Home Router and Wi-Fi Access Point
If you're using HiNet as your ISP in Taiwan, the ADSL modem they lent you could do much more than you think with a little more configuration. Today we're going to turn our ZyXEL P-6101C ADSL modem into a home router, and a Wi-Fi AP. Here's a list of services that we need to configure in this box:
Go to Setup -> LAN, and make a reasonable IP address pool.
On the same page, DNS server could also be configured.
Go to Wireless -> Basic to configure the SSID of your access point.
Setup auth type, encryption, and the passphrase.
Go to Quick Setup page, fill in your PPPoE username and password, and don't forget to enable the WLAN entry we previously configured.
If everything goes well, you'll see the new SSID in the AP list. Happy surfing!
- DHCP server
- PPPoE auto dial-up
- Wireless service
DHCP server
Go to Setup -> LAN, and make a reasonable IP address pool.
On the same page, DNS server could also be configured.
Wireless service
Go to Wireless -> Basic to configure the SSID of your access point.
Setup auth type, encryption, and the passphrase.
PPPoE dial-up
Go to Quick Setup page, fill in your PPPoE username and password, and don't forget to enable the WLAN entry we previously configured.
If everything goes well, you'll see the new SSID in the AP list. Happy surfing!
Dec 23, 2012
自宅竊案 歹徒作案手法分析
12/18 接到鄰居電話告知家裏遭竊,除了在第一時間報警之外,事後對於歹徒作案方式做了一些追蹤,順更收集更多的資訊供警方參考。
- 13:50 - 13:51 歹徒開車由民族路(新屋->中壢方向)近某蛋塔店的路囗右轉進入新X路,並利用監視器的死角,將車停在 P1 處。
- 13:51 - 14:05 歹徒下車步行,由 R1 路徑到案發現場以按電鈴方式確認無人在家,原路返回並將車開往前方200公尺 P2 處停放。
- 14:05 - 14:22 歹徒由 R2 路線步行到現場,破壞氣密窗內鎖後進入行竊,由於當天天冷且下著小雨,路上人車不多,電視就被歹徒沿 R2 原路搬到車上。(除了電視還有其他財物…)
![]() | |||||
| 監視器攝影死角 |
![]() |
| 停車點 P1 |
![]() |
| 停車點 P2 |
![]() |
| 行竊路徑圖 |
![]() |
| 歹徒 |
![]() |
| 歹徒 |
![]() | |||||
| 歹徒搬電視離開 |
![]() |
| 歹徒搬電視離開 |
| 氣密窗被破壞,因嚴重變形,是自己請人拆下送修的 |
Nov 6, 2012
Realtek RTL2832U DVB-T on Ubuntu 12.10 (Quantal)
Some of you might notice the kernel 3.5.x in Ubuntu 12.10 breaks the driver codes of RTL2832U that works on Ubuntu 12.04. Tried several alternatives found on the net but all came back in no avail. Luckily I found the driver for USB ID 1d19:1101 was in kernel 3.7-rc4. With minor code modification, my DVB-T dongle works again!
$ lsusb -v | grep "ID.*DVB"
Bus 002 Device 004: ID 1d19:1102 Dexatek Technology Ltd. DK mini DVB-T Dongle
Where 0x1d19 is the vendor ID, and 0x1102 is the product ID.
Download and extract the kernel source:
$ wget http://www.kernel.org/pub/linux/kernel/v3.0/testing/linux-3.7-rc4.tar.bz2
$ tar xfj linux-3.7-rc4.tar.bz2
Replace the URL and the filename above if newer version is available by visiting kernel.org.
Change the source code at drivers/media/usb/dvb-usb-v2/r tl28xxu.c with our product ID (0x1102 in this case).
from
{ DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101,
to
{ DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1102,
To compile the kernel, a kernel configuration file is needed. Download mine at http://dl.dropbox.com/u/76023930/kernel-3.7.0-rc4.config and save as .config in the top-level folder of the kernel source.
Recompile and install the kernel, then reboot the machine. (The kernel compilation takes like 80 minutes on my i5 2.3GHz CPU.)
$ make
$ sudo make modules_install
$ sudo make install
$ sudo reboot
dmesg output:
$ dmesg|grep DVB
[ 6.310132] usb 2-1.1: Product: Rtl2832UDVB
[ 31.747812] usb 2-1.1: dvb_usb_v2: found a 'Dexatek DK DVB-T Dongle' in warm state
[ 31.795283] DVB: registering new adapter (Dexatek DK DVB-T Dongle)
[ 32.321089] usb 2-1.1: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...
[ 32.630126] input: Dexatek DK DVB-T Dongle as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/rc/rc0/input7
[ 32.630182] rc0: Dexatek DK DVB-T Dongle as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/rc/rc0
[ 32.641710] usb 2-1.1: dvb_usb_v2: 'Dexatek DK DVB-T Dongle' successfully initialized and connected
$ uname -a
Linux buffalo 3.7.0-rc4 #2 SMP Mon Nov 5 23:03:56 CST 2012 i686 i686 i686 GNU/Linux
$ lsusb -v | grep "ID.*DVB"
Bus 002 Device 004: ID 1d19:1102 Dexatek Technology Ltd. DK mini DVB-T Dongle
Where 0x1d19 is the vendor ID, and 0x1102 is the product ID.
Download and extract the kernel source:
$ wget http://www.kernel.org/pub/linux/kernel/v3.0/testing/linux-3.7-rc4.tar.bz2
$ tar xfj linux-3.7-rc4.tar.bz2
Replace the URL and the filename above if newer version is available by visiting kernel.org.
Change the source code at drivers/media/usb/dvb-usb-v2/r
from
{ DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101,
to
{ DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1102,
To compile the kernel, a kernel configuration file is needed. Download mine at http://dl.dropbox.com/u/76023930/kernel-3.7.0-rc4.config and save as .config in the top-level folder of the kernel source.
Recompile and install the kernel, then reboot the machine. (The kernel compilation takes like 80 minutes on my i5 2.3GHz CPU.)
$ make
$ sudo make modules_install
$ sudo make install
$ sudo reboot
dmesg output:
$ dmesg|grep DVB
[ 6.310132] usb 2-1.1: Product: Rtl2832UDVB
[ 31.747812] usb 2-1.1: dvb_usb_v2: found a 'Dexatek DK DVB-T Dongle' in warm state
[ 31.795283] DVB: registering new adapter (Dexatek DK DVB-T Dongle)
[ 32.321089] usb 2-1.1: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...
[ 32.630126] input: Dexatek DK DVB-T Dongle as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/rc/rc0/input7
[ 32.630182] rc0: Dexatek DK DVB-T Dongle as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/rc/rc0
[ 32.641710] usb 2-1.1: dvb_usb_v2: 'Dexatek DK DVB-T Dongle' successfully initialized and connected
$ uname -a
Linux buffalo 3.7.0-rc4 #2 SMP Mon Nov 5 23:03:56 CST 2012 i686 i686 i686 GNU/Linux
Watching HDTV on Ubuntu 12.10
Sep 8, 2012
Decepticon Invading Travian Villages
This script was written in 2007 to automate the tedious resource fields and buildings upgrade in Travian 3. Travian is a multi-player strategy game you can play on web browsers. For beginners it looks like SimCity, but if you play it just that way then you're fcuked as battles are inevitable. With minor regex tuning, the script works well on Travian version 4. It's for experiment and scripting practice hence no alliance was joined to keep the game fair played. Travian Team implemented Bot Detection System back in 2006 but we're good while testing the script. They modify the HTML and Javascript code from time to time to keep the script kiddies away though.
Autobots, rev your engine!
Script output:
Screenshots:
Autobots, rev your engine!
Script output:
Travianer v1.11
Server: tsX.travian.com.XX
---------- [villageName] Resources ----------
Lumber: 11644/25900 (862/17)
Clay: 7034/25900 (800/25)
Iron: 5672/25900 (878/29)
Crop: 3347/21400 (401/27)
Crop consumption: 1165/ 1566
Hungry for: Iron
---------- [villageName] Fields ----------
Site 1: Woodcutter Level 10
Site 2: Cropland Level 10
Site 3: Woodcutter Level 10
Site 4: Iron Mine Level 10
Site 5: Clay Pit Level 10
Site 6: Clay Pit Level 10
Site 7: Iron Mine Level 10
Site 8: Cropland Level 10
Site 9: Cropland Level 10
Site 10: Iron Mine Level 9
Site 11: Iron Mine Level 9
Site 12: Cropland Level 10
Site 13: Cropland Level 10
Site 14: Woodcutter Level 9
Site 15: Cropland Level 10
Site 16: Clay Pit Level 10
Site 17: Woodcutter Level 9
Site 18: Clay Pit Level 10
---------- [villageName] Buildings ----------
Site 19: Marketplace Level 14
Site 20: Grain Mill Level 5
Site 21: Warehouse Level 14
Site 22: Granary Level 13
Site 23: Hero's Mansion Level 10
Site 24: Iron Foundry Level 4
Site 25: Embassy Level 3
Site 26: Main Building Level 20
Site 27: Cranny Level 10 (capa: 1000)
Site 28: Cranny Level 10 (capa: 1000)
Site 29: Barracks Level 15
Site 30: Stonemason Level 19
Site 31: Bakery Level 1
Site 32: Cranny Level 10 (capa: 1000)
Site 33: Smithy Level 11
Site 34: Cranny Level 10 (capa: 1000)
Site 35: Cranny Level 10 (capa: 1000)
Site 36: Cranny Level 10 (capa: 1000)
Site 37: Cranny Level 10 (capa: 1000)
Site 38: Cranny Level 10 (capa: 1000)
Site 39: Rally Point Level 1
Site 40: City Wall Level 19
Total cranny capa: 8000
Upgrading Iron Foundry Level 4 (site 24)...
Server: tsX.travian.com.XX
---------- [villageName] Resources ----------
Lumber: 11644/25900 (862/17)
Clay: 7034/25900 (800/25)
Iron: 5672/25900 (878/29)
Crop: 3347/21400 (401/27)
Crop consumption: 1165/ 1566
Hungry for: Iron
---------- [villageName] Fields ----------
Site 1: Woodcutter Level 10
Site 2: Cropland Level 10
Site 3: Woodcutter Level 10
Site 4: Iron Mine Level 10
Site 5: Clay Pit Level 10
Site 6: Clay Pit Level 10
Site 7: Iron Mine Level 10
Site 8: Cropland Level 10
Site 9: Cropland Level 10
Site 10: Iron Mine Level 9
Site 11: Iron Mine Level 9
Site 12: Cropland Level 10
Site 13: Cropland Level 10
Site 14: Woodcutter Level 9
Site 15: Cropland Level 10
Site 16: Clay Pit Level 10
Site 17: Woodcutter Level 9
Site 18: Clay Pit Level 10
---------- [villageName] Buildings ----------
Site 19: Marketplace Level 14
Site 20: Grain Mill Level 5
Site 21: Warehouse Level 14
Site 22: Granary Level 13
Site 23: Hero's Mansion Level 10
Site 24: Iron Foundry Level 4
Site 25: Embassy Level 3
Site 26: Main Building Level 20
Site 27: Cranny Level 10 (capa: 1000)
Site 28: Cranny Level 10 (capa: 1000)
Site 29: Barracks Level 15
Site 30: Stonemason Level 19
Site 31: Bakery Level 1
Site 32: Cranny Level 10 (capa: 1000)
Site 33: Smithy Level 11
Site 34: Cranny Level 10 (capa: 1000)
Site 35: Cranny Level 10 (capa: 1000)
Site 36: Cranny Level 10 (capa: 1000)
Site 37: Cranny Level 10 (capa: 1000)
Site 38: Cranny Level 10 (capa: 1000)
Site 39: Rally Point Level 1
Site 40: City Wall Level 19
Total cranny capa: 8000
Upgrading Iron Foundry Level 4 (site 24)...
Screenshots:
Resource fields view in Travian 4
Buildings view in Travian 4
Sep 2, 2012
Minus'es in Google Plus
Regressions in Picasa and Google+ integration:
- Album and photo geotags not shown
- Album descriptions not shown
- Photo descriptions now shown in slideshow and thumbnails
- Takes longer time rendering album list (guess for the fancy visual effects)
- Fancy album list
- Better screen asset usage in photo browse UI
- Photo resolution < 2048px does not count in disk usage
May 20, 2012
Realtek RTL2832U DVB-T on Ubuntu 12.04 (Precise) and Linux Mint 13 (Maya)
Ubuntu (Desktop) 12.04 (codenamed Precise Pangolin) was released earlier this May, which has 5-years Long Term Support (LTS) from Canonical. Let's check it out how my DVB-T USB stick works on Linux kernel 3.2. Unfortunately, Realtek RTL2832U driver did not make it in the kernel main stream, and the instructions mentioned in the post "HD DVB on Ubuntu 10.04 (Lucid)" posted a year ago did not work for me either. Luckily, I followed the instructions at https://github.com/ambrosa/DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0 ,and everything goes well. Here's the recap:
Install required packages:
Check out a copy of the driver source code patched by ambrosa:
Makefile configuration and driver compilation/installation:
dmesg shown after module insertion:
Double confirm with lsmod listing:
The VLC player and the ALSA sound driver were in good shape, thus no extra update was required.
Additional information:
[Updated May 26, 2012]
Linux Mint 13 (Maya), which was based on Ubuntu 12.04, was released few days ago. The steps mentioned above work as well on Mint. Have fun!
Install required packages:
$ sudo apt-get install build-essential git
Check out a copy of the driver source code patched by ambrosa:
$ git clone https://github.com/ambrosa/DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0
Makefile configuration and driver compilation/installation:
$ cd DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0/RTL2832-2.2.2_kernel-3.0.0/
$ vi Makefile (to make sure variable INCLUDE_EXTRA_DVB matches your kernel version)
$ make clean
$ make
$ sudo make install
$ sudo modprobe dvb_usb_rtl2832u
dmesg shown after module insertion:
[ 927.960738] IR NEC protocol handler initialized
[ 927.963676] dvb-usb: found a 'DK DONGLE' in warm state.
[ 927.963680] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[ 927.965156] IR RC5(x) protocol handler initialized
[ 927.965302] DVB: registering new adapter (DK DONGLE)
[ 927.966515] IR RC6 protocol handler initialized
[ 927.968948] IR JVC protocol handler initialized
[ 927.971631] IR Sony protocol handler initialized
[ 927.972945] IR MCE Keyboard/mouse protocol handler initialized
[ 927.974271] lirc_dev: IR Remote Control driver registered, major 250
[ 927.974493] IR LIRC bridge handler initialized
[ 927.980540] RTL2832U usb_init_bulk_setting : USB2.0 HIGH SPEED (480Mb/s)
[ 928.116808] RTL2832U check_tuner_type : FC2580 tuner on board...
[ 928.709405] DVB: registering adapter 0 frontend 0 (Realtek DVB-T RTL2832)...
[ 928.709781] input: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/input/input12
[ 928.709916] dvb-usb: schedule remote query interval to 287 msecs.
[ 928.709924] dvb-usb: DK DONGLE successfully initialized and connected.
[ 928.709997] usbcore: registered new interface driver dvb_usb_rtl2832u
Double confirm with lsmod listing:
$ lsmod | grep rtl28
dvb_usb_rtl2832u 345365 0
dvb_usb 23826 1 dvb_usb_rtl2832u
The VLC player and the ALSA sound driver were in good shape, thus no extra update was required.
HDTV playback
Additional information:
$ lsusb | grep DVB
Bus 002 Device 003: ID 1d19:1102 Dexatek Technology Ltd. DK mini DVB-T Dongle
$ uname -a
Linux cheetah 3.2.0-24-generic-pae #37-Ubuntu SMP Wed Apr 25 10:47:59 UTC 2012 i686 i686 i386 GNU/Linux
$ vlc --version
VLC media player 2.0.1 Twoflower (revision 2.0.1-0-gf432547)
VLC version 2.0.1 Twoflower (2.0.1-0-gf432547)
$ more /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.24.
$ vlc --version
VLC media player 2.0.1 Twoflower (revision 2.0.1-0-gf432547)
VLC version 2.0.1 Twoflower (2.0.1-0-gf432547)
$ more /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.24.
[Updated May 26, 2012]
Linux Mint 13 (Maya), which was based on Ubuntu 12.04, was released few days ago. The steps mentioned above work as well on Mint. Have fun!
HDTV playback on Linux Mint 13
May 18, 2012
Searching for ET in a Green Way (best practice wanted)
As a cloud computing contributor for over 12 years since joining the SETI@home (search for extraterrestrial intelligence at home) in Y2K, the carbon footprint has not been seriously considered. The picture below showed the relationship of the thermal sensor readings and the % of CPU time consumed by SETI client on my home server, which is a 12-year old Pentium III 500 MHz laptop, in six CPU usage threshold profiles ranging from 100%, 80%, 60%, 40%, 20% and finally to 0%. In summer the temperature can go as high as 75°C (167°F) running SETI in full throttle, while as low as 44°C (111°F) when idling. Given the global warming issue, the soaring electricity fee, and being a not-so-serious contributor, I think 40% might be a good choice for my home server. If you have a better equation (in scientific way) for best practice please let me know. ;)
May 13, 2012
FlyVision FDV-606 Carcam Password Protection Security Bypass
One of the features FDV-606 boasted is the password protection on the video records to prevent unauthorized access. Tests showed the password we set does not apply to the video data for encryption but just a checkpoint in the application layer of the built-in video player. Thus we can totally bypass this crappy security feature with the video files extraction method aforementioned.
EDM captured from the official website. The translation for the highlighted is "you can set passwords to prevent unauthorized access".
Password input dialog
In the built-in video player, a correct password is required to access the video files if they're password protected.
小瑪莉 - A DOS Game Written Two Decades Ago! (1992)
Really don't know how to say it in English. The slot machine? It's the first decent program I wrote for fun and for C language practice in the freshman year.
Screenshots:
Screenshots:
The literally translated name, Small Mary, is so ...
Subscribe to:
Posts (Atom)































