Upgrade Rikomagic MK902 Android MiniPC from Ubuntu

If there would be an Oscar for the WORST firmware upgrade procedure (and associated drivers, documentation and general quality of software) Rikomagic should win this by a country mile !

Rikomagic MK902

Since all the information I found on the interwebs said Linux was not supported I ended up borrowing friends notebooks (as I don’t own any Windows machinery anymore). My main Toshiba Ultrabook seemed to have issues with picking up the USB from a Windows Virtual Machine). After not being able to get the absolute crap USB drivers that come with the firmware download with any of the machines (Vista & Win7_64) I was ready to throw in the towel and put the purchase of this unit (in hindsight I would not do it again anyway) down as a total waste.

I tried a last search on upgrading using Linux it turns out there was a very recent Rockchip Linux Upgrade Tool release.

Download Upgrade Tool

http://dl.radxa.com/rock/tools/linux/Linux_Upgrade_Tool_v1.16.zip

Dependencies

If you haven’t got the Android SDK or tools yet you need to install

sudo apt-get install android-tools-adb android-tools-fastboot

USB Configuration

sudo vim /etc/udev/rules.d/51-android.rules
#add the following line
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2207", MODE="0666", GROUP="plugdev"

Restart udev
sudo udevadm control --reload-rules

vim ~/.android/adb_usb.ini
#add at the end of the file
0x2207

Restart the adb server

adb kill-server
adb start-server

You should be able to test with
adb devices

The output should be like the following:

adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
0123456789ABCDEF recovery

Please note: for adb to recognise the device it needs to be booted in recovery mode (as per the instructions in the so-called “documentation” from Rikomagic).

Boot into recovery mode

  1. Plug in USB Male-to-Male connector into the port marked “Slave” – not the other 3 hubs
  2. Press the “Reset” button using a paper-clip or similar pointy object (I used a letter opener which at times I would have loved to use on whoever came up with the crap Windows-only drivers and wasted hours of my life I will not get back… :P )
  3. After 3-5 seconds release reset button and plug the other end of the USB Male-to-Male connector into the Ubuntu box.

Upgrading

This bit took me a little while to work out. Turns out the device was in recovery mode and for the firmware upgrade process needs to be in bootloader mode.

Boot Device in Recovery Mode

Set the device into bootloader mode with adb.

adb reboot bootloader

Testing the bootloader mode

sudo ./upgrade_tool

./upgrade_tool List of rockusb connected
DevNo=1 Vid=0x2207,Pid=0x310b,LocationID=10c Loader
Found 1 rockusb,Select input DevNo,Rescan press ,Quit press :

Run the final upgrade of the downloaded image.

sudo ./upgrade_tool uf RKM_MK902_4.4.2_20140515.img

Helpful Resources

Thanks to the respective authors !

http://wiki.radxa.com/Rock/flash_the_image#Linux
http://www.cnx-software.com/2013/11/19/how-to-flash-rockchip-rk3066-rk3188-firmware-in-linux/
http://linux-rockchip.info/mw/index.php
http://www.rockchipfirmware.com/developer-tools

NOTE: If you haven’t bought this device yet and you are thinking of it – my advise is have another look somewhere else unless you have a lot of time AND are a very patient person …..

Install Google Earth on Ubuntu 14.04

Trying to install Google Earth on Ubuntu. You could just download the .deb file and run dpkg command, however I prefer to use it via a repo to make sure upgrades are installed as part of the system upgrades.

Google Earth

Google Earth Screenshot

http://www.google.com/earth/download/ge/

Google Keys

Note: this should not be necessary if you have use the GoogleTalk plugin or similar package from the Google DEB Repo

cd /tmp/
wget https://dl-ssl.google.com/linux/linux_signing_key.pub
sudo apt-key add linux_signing_key.pub
rm linux_signing_key.pub

Add Google Earth Repo

sudo vim /etc/apt/sources.list.d/google.list
#add the following line
deb http://dl.google.com/linux/earth/deb/ stable main

sudo apt-get update
sudo apt-get install google-earth-stable

NOTE: While this should be enough on 32bit versions of Ubuntu 14.04 unfortunately it turns out that there is a dependency problem with the 64bit version

Fix 64bit dependency issues

sudo apt-get install libc6:i386 lsb-core

The problem is even after the installation of the i368 libraries the .deb file from Google will still not install on 14.04 due to the missing dependency ia32-libs (which was removed). My solution was to download the 64bit .deb file from the link above and extract to a temporary folder and repackage on current system (without ia32-libs). If you find a more efficient way please let me know in the comments.

cd ~/tmp
wget http://dl.google.com/dl/earth/client/current/google-earth-stable_current_amd64.deb
mkdir google-earth-stable_current_amd64
mkdir google-earth-stable_current_amd64/DEBIAN
dpkg-deb -x google-earth-stable_current_amd64.deb google-earth-stable_current_amd64/
dpkg-deb -e google-earth-stable_current_amd64.deb google-earth-stable_current_amd64/DEBIAN
dpkg -b google-earth-stable_current_amd64
sudo dpkg -i google-earth-stable_current_amd64.deb
rm -rf google-earth-stable_current_amd64*

You should now be able to run

google-earth

Android SDK issues on Ubuntu 14.04 64bit

Since the upgrade to Ubuntu 14.04 (Trusty Tahr) I have had issues running the Android SDK Tools. For example this error:

./adb
bash: ./adb: No such file or directory

Check the multi-arch architectures installed on the system.

sudo dpkg --print-architecture

Mine only showed ‘amd64′. Turns out you need to add the i386 architecture and install libc6:i386,libncurses5:i386,libstdc++6:i386 library packages.

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
sudo ./adb

LXQt – extending the life of my trusty old EEE PC (even further)

My old Asus EEE PC 900 is the oldest piece of hardware I own. With an old Intel Atom processor and 1GB of RAM it’s never was the fastest kid on the block (in fact I never considered the Windows XP version of the same unit usable as it was very sluggish). However after owning it for nearly 7 years I am very surprised I can still use it. Granted I only use it occasionally when I am at home, but thanks to LXDE it was still usable. I recently learned that LXDE is merging with the Razor-Qt project (great idea!) to create the combined LXQT – an ultra-low resource window manager.

Warning: LXQt is still considered a work in progress. So probably not a good idea on your prime work machine.

I started with a clean re-install of LUBUNTU LTS 14.04 – to add LXQt you need to add the lubuntu-daily PPA.

sudo add-apt-repository ppa:lubuntu-dev/lubuntu-daily
sudo add-apt-repository ppa:gilir/q-project
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install lxqt-metapackage

Log out and log in back to LXQt desktop environment. Voilà !

LXQT Screenshot

LXQT Screenshot

After using it a little while it really is a joy to use and extremely responsive even on such a resource constrained old unit.

Great work !

Synology OpenVPN connection from Android

Connecting securely to your home network has always been a bit of a challenge since common home ADSL routers not normally contain any VPN Servers (those which do contain such are generally PPTP servers which I would hardly call secure these days). Which is probably a good thing as they would be horribly out of date considering the firmware release policies of retail router manufacturers. You could run/maintain your own dedicated server, but for most home networks that is overkill and out of the technical depth of most hobbyists. However NAS Appliances are becoming more useful in home networks for storage and other common tasks. I have had good experiences with Synology NAS devices over a number of years and the latest iteration also has a very useful VPN Server package available based on OpenVPN (as most Synology Apps are common Open Source components).

Server Requirements

This is a very straight forward procedure via the Synology Web UI (http://www.synology.com/en-uk/support/tutorials/459#t3.2)

Synology Openvpn

  1. Installing the VPN Server via Synology Package Manager
  2. Enabling OpenVPN Server
  3. Export the certificate using the button “Export configuration” (openvpn.zip) and extract the CA Certificate file (ca.crt)
  4. Forward UDP Port 1194 from your modem/router to the Synology NAS
  5. Make sure your Diskstation user account has OpenVPN privileges

Android Client Configuration

This part turned out a little more difficult than I expected. Initially I tried the “OpenVPN Connect” app by OpenVPN.net the makers of OpenVPN. However this seems to have no facility to edit the configuration and would not work at all from the imported config file.

The OpenVPN client that works well for me is OpenVPN for Android (https://play.google.com/store/apps/details?id=de.blinkt.openvpn)

  1. Transfer the CA Certificate (ca.crt) extracted in the previous step to the sdcard of your Android device
  2. Install the “OpenVPN for Android” app from the Google Play Store
  3. Open the “OpenVPN for Android” app, touch the + icon in the bottom left corner of the screen to add a profile
  4. Touch “Basic”
    1. Enter profile name and server address (Static IP Address or DynamicDNS of your modem/router)
    2. Touch the Select button for the CA Certificate
    3. Navigate to the file ca.crt on your sdcard and select the file
    4. Fill in the username and password of the Diskstation user with OpenVPN privileges
    5. Touch the back softkey or button of your phone
  5. Touch “IP and DNS”
    1. Check Override DNS settings by Server (Synology’s OpenVPN implementation currently does not support pushing servers)
    2. Google’s public DNS servers are the default and should work for most users)
    3. Touch the back softkey or button of your phone
  6. Touch “Authentication/Encryption”
    1. Uncheck Expect TLS server certificate
    2. Touch the back softkey or button of your phone twice to return to the app’s Profiles overview page
  7. Touch your profile’s name to connect (the icon with the sliders on the right allows to edit the profile)

Voila! Your Android device should now securely connect to your home network!

Ubuntu 14.04 – post-install enhancements for Trusty Tahr

Excellent coincidence that the release of Ubuntu 14.04 LTS (Trusty Tahr) fell into the Easter holidays. This gives me the time to install earlier than I normally have time for.

Trusty Tahr

This realease being a LTS (long-term support) release means it is a fairly conservative release. There are some nice enhancements and most importantly for me the 3.13 Kernel means finally Wacom Touch devices are supported without kernel mods.

Unfortunately some things are still not included (such as the boot-repair tools not being part of the standard repos).

Fortunately it’s relatively easy to fix most of these things.

Install core packages

One line to fix it (well – mostly …). This is a very personal & subjective list based on what I need all the time. Most things would not be relevant to casual users. Ignore at will.

sudo apt-get install -y vim chromium-browser filezilla owncloud-client gnome-gmail httrack keepass2 inkscape s3cmd putty openssh-server nfs-common fslint unoconv xsane libreoffice-base libreoffice-mysql-connector offlineimap pwgen getmail4 apache2-mpm-itk libapache2-mod-php5 mysql-client mysql-server php5 php5-mysql php5-common php5-xmlrpc php5-gd php5-common curl php5-curl php5-ldap php5-odbc php5-xsl php5-ldap php-pear libapache2-mod-wsgi python-django python-imaging python-pythonmagick python-markdown python-textile python-docutils python-mysqldb rapidsvn umit flashplugin-installer cups-pdf git gnome-schedule regexxer ubuntu-restricted-extras arduino gufw cifs-utils subversion sysinfo jobs-admin network-manager-openvpn network-manager-vpnc openjdk-7-jre openjdk-7-jdk icedtea-7-plugin bum mysql-workbench traceroute whois sublime-text bleachbit grive dia-gnome tintii calibre openscad pepperflashplugin-nonfree

NOTE: Since Chromium Flash plugin support is broken in 14.04 (due to Chromium killing Netscape Plugin API) you need to run the Pepper Flash install script to allow flash to play in Chromium.

sudo update-pepperflashplugin-nonfree --install

Adding ‘nice-to-haves’

Sublime Text

Currently my favorite text editor (even though the licensing is dodgy) – I also generally install ‘geany’ as well.

sudo add-apt-repository ppa:webupd8team/sublime-text-3

LibreCAD

sudo add-apt-repository ppa:librecad-dev/librecad-stable

Opera Browser

The main reason is that sometimes I need more than 3 browsers at the same time (don’t ask – joys of web-dev) and Opera is my 3rd choice.

sudo vim /etc/apt/sources.list
#add the following repo
deb http://deb.opera.com/opera/ stable non-free
sudo apt-get update
#get keys
sudo wget -qO - http://deb.opera.com/archive.key | sudo apt-key add -
sudo apt-get install debian-archive-keyring

VLC

Get a real video player. See this blog.

echo 'deb http://download.videolan.org/pub/debian/stable/ /' | sudo tee -a /etc/apt/sources.list.d/libdvdcss.list && echo 'deb-src http://download.videolan.org/pub/debian/stable/ /' | sudo tee -a /etc/apt/sources.list.d/libdvdcss.list && wget -O - http://download.videolan.org/pub/debian/videolan-apt.asc|sudo apt-key add -

VirtualBox

sudo echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

Note: At the time of writing this (2014-04-21) it is necessary to edit /etc/apt/sources.list.d/virtualbox.list and edit the first replacing ‘trusty’ with the ‘saucy’ repo as Oracle has not yet (and usually is very slow) updated their repo.

sudo apt-get update
sudo apt-get install -y opera vlc libdvdcss2 librecad google-talkplugin virtualbox-4.3 unity-tweak-tool gnome-tweak-tool compizconfig-settings-manager

Tweaking

All of these are personal: ‘unity-tweak-tool’ & ‘gnome-tweak-tool’ can be used to customise lots of UI aspects (I generally limit this as I don’t have time.

The main reason for installing ‘compizconfig-settings-manager’ is that I like to disable animations. Even on fast machinery it adds to speeding up the overall experience and reduce waste. I very much prefer speed over useless eye-candy. If you want to go the next step you might look ad installing a more lightweight flavour of Ubuntu (such as Xubuntu).

Adding latest stable versions

Since Ubuntu repos sometimes have quite old version of some popular projects I tend to use some PPA’s to get the latest stable versions.

These repos update the included versions of Gimp, VLC and some Gnome3 related tools (I don’t use Gnome 3 as such as I have made peace with Unity over the years and find it quite workable these days and don’t have the time to play around too much).

sudo add-apt-repository ppa:videolan/stable-daily
sudo add-apt-repository ppa:otto-kesselgulasch/gimp
sudo add-apt-repository -y ppa:gnome3-team/gnome3
sudo apt-get update
sudo apt-get install -y gimp vlc

Remove unwanted stuff

The main thing I always remove is the so-called ‘Amazon-Lense’ which includes Amazon search results in the HUD display in th UI. The easiest way I have found is to remove the ‘webapps’ feature. This is a bit of a sledgehammer approach as it removes other webapps, but I have always found these very annoying – so it suits me to remove the lot. However you can also disable the feature in the ‘System settings’ UI.

I also remove Empathy & Thunderbird as I have no use for local utils. All my mail and calendars are stored on remote servers as I use a number of devices and have no time for synchonisation hell …

sudo apt-get remove --purge unity-webapps-common evolution evolution-indicator empathy empathy-common thunderbird xul-ext-unity unity-chromium-extension
sudo update-desktop-database

Disable remote search scopes

Removes the online searches from the HUD.

gsettings set com.canonical.Unity.Lenses disabled-scopes "['more_suggestions-amazon.scope', 'more_suggestions-u1ms.scope', 'more_suggestions-populartracks.scope', 'music-musicstore.scope', 'more_suggestions-ebay.scope', 'more_suggestions-ubuntushop.scope', 'more_suggestions-skimlinks.scope']"

Normal scroll bars

gsettings set com.canonical.desktop.interface scrollbar-mode normal

Fixing UEFI Secure Boot problems on Ubuntu 14.04

Unfortunately the mess that is UEFI Secure Boot still causes issues on some hardware. In my case it’s a Toshiba Z930 Ultrabook. I have documented the procedure to get it working here.

However it turns out that there is no ‘Trusty’ release for the boot-repair utility. The fix is relatively easy.

sudo vim /etc/apt/sources.list.d/yannubuntu-boot-repair-trusty.list
#change the following line from 'trusty' to 'saucy'
sudo vim /etc/apt/sources.list.d/yannubuntu-boot-repair-trusty.list

You can then just finish with
sudo apt-get update
sudo apt-get install -y boot-repair && (boot-repair &)

Another option is to boot off a USB image (or CD) created from http://sourceforge.net/p/boot-repair-cd/home/Home/.

Apache Cordova development environment install on Ubuntu

Apache Cordova has very nice documentation, however as so many projects it is focused on the Windows/MacOS duopolies only. Fortunately it’s not too hard to work out the differences.

Apache Cordova Logo

Installing dependencies

Thanks to: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

sudo apt-get install python-software-properties python g++ make ant

Installing Android SDK

Please note: one of the problems I found was that I had some Android tools from the Ubuntu repos that were conflicting with the SDK install. It’s probably a good idea to remove them first. That might save you from a lot of headaches down the line (and time to troubleshoot).

sudo apt-get remove android-tools-adb android-tools-fastboot

Download as per http://developer.android.com/sdk/index.html

wget http://dl.google.com/android/android-sdk_r22.6.2-linux.tgz

Note: check for updated link version obviously

vim ~/.bashrc

Add the PATH variables to the top of the file

#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools

Reload bash variables without reboot / logout

source ~/.bashrc

Testing SDK

android

This command should now bring up the SDK manager.

Installing Eclipse IDE

This is obviously an optional step depending on the IDE you want to use. I have previously covered a manual Eclipse install (as opposed to the Ubuntu repositories).

Install Eclipse ADT Plugin

As per: http://developer.android.com/sdk/installing/installing-adt.html

Node.js Install

The main difficulty on Ubuntu (as with so many development tools – see Eclipse above) is that the included node.js version in the Ubuntu repositories is outdated (remove the Ubuntu version with ‘sudo apt-get remove node’).

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install python-software-properties python g++ make nodejs

Install Cordova

sudo npm install -g cordova

Check Cordova Requirements

This will check for Android SDK installation, Ant and other dependencies – saving you going through error messages later.

~/.cordova/lib/android/cordova/3.4.0/bin/check_reqs

Create Cordova Project

mkdir ~/projects/PROJECTNAME
cd ~/projects/PROJECTNAME
cordova create ~/projects/PROJECTNAME com.COMPANYNAME.PROJECTNAME PROJECTNAME
cordova -d platform add android
cordova build

Create Eclipse Project

Open Eclipse
Create New Android project from existing sources
Import ~/projects/PROJECTNAME/platforms/android
Test in emulator by right clicking the project and selecting “Run As –> Android App”

RaspberryPi real-world control with REST API

Finally found some time playing with a RaspberryPi and an attached PiFace Interface board to control some garden pumps and potentially an Aquaponics setup in the near future.

PiFace board

Requirements

Base Raspian (Debian Wheezy) Install (I prefer the clean minimal install via https://githutb.com/hifi/raspbian-ua-netins).

Configure the base system as per my previous base install.

Install Apache & PHP

sudo apt-get install apache2 php5 php5-dev php5-cli php5-mcrypt curl raspi-config

Ensure mod-rewrite is enabled

sudo a2enmod rewrite

Install PHP SPI Extension

More info: https://github.com/frak/php_spi

git clone https://github.com/frak/php_spi.git
cd php_spi
./phpize
./configure --enable--spi
make
make test
make install

Install PiFace REST API

cd /var/www/
git clone https://github.com/natefanaro/piface-rest-api
cd piface-rest-api
curl -sS https://getcomposer.org/installer | php
php composer.phar install

Thanks to Nate Fanaro for the excellent work on the API.

Make sure SPI is enabled on the RPi

raspi-config

Advanced Options –> A5 SPI –> yes

Install PiFace Modules

sudo apt-get install python3-pifacedigitalio python-pifacedigitalio
sudo usermod -a -G gpio www-data
sudo usermod -a -G spi www-data

For more info visit http://www.piface.org.uk/guides.

Apache2 API Configuration

Enable SPI extension

sudo vim /etc/php5/apache2/php.ini
#add the following extension
extension="spi.so"

Apache VHost config

sudo vim /etc/apache2/sites-available/piface

Paste the following VHost config

<Virtualhost *:80>
ServerName HOSTNAME
ServerAdmin webmaster@domain.com
DocumentRoot /usr/share/piface-rest-api/public_html
ErrorLog /var/log/apache2/piface_error.log
CustomLog /var/log/apache2/piface_access.log combined
<Directory />
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</Virtualhost>

Enable the newly created VHost

a2ensite piface
service apache2 restart

Testing

curl http://HOSTNAME/led/test/

Next up will be some modification for securing access to the PiFace REST API via some sort of API Key or digital certificate as it’s open by default at the moment.