Sunday, March 31, 2013

Measy U2C / B12 / NX003II Linux Microphone and Audio Out

As you may already know, the Measy U2C Android stick (AFAIK same hardware as Kimdecent B12 and NX003II sticks) contains an A/V Out (right besides the HDMI connector, in the picture below) and an integrated digital microphone (MIC in the picture below).

You can insert the typical stereo headphones jack into the A/V out and listen to music from there, in case your screen doesn't have HDMI audio, like my PC monitor.





However, if you want to use the mic and headphones from Linux (i.e. Picuntu) you will need to recompile the kernel (actually quite easy) enabling the following options in the ".config" file at the kernel source's root path.

Where it says (each line is in a different part, and the last may not be there at all):
# CONFIG_MFD_RK1000 is not set
# CONFIG_SND_RK29_SOC_RK1000 is not set
# CONFIG_SND_SOC_RK1000 is not set
and make them be (add if necessary):

CONFIG_MFD_RK1000=y
CONFIG_SND_RK29_SOC_RK1000=y
CONFIG_SND_SOC_RK1000=y
Compile and flash. Once Linux boots, open a terminal and type:
alsamixer -c 0 -V capture
You should see the microphone input, make sure the volume is at an adequate level, then exit and type:
arecord -f cd -D hw:0,0 test.wav
Hit enter and speak to the MIC, hit Ctrl-C to stop it and enter:
aplay test.wav
And you should hear the mono sound you have just recorded.

From XFCE I use PulseAudio's Volume Control app to select the headphone output, instead of HDMI, try it if you don't get to hear anything.

One step closer to full Linux support!! :)


UPDATE: The command to set PulseAudio's volume to a lower level, from the command-line, is:
pacmd set-sink-volume alsa_output.platform-soc-audio.analog-stereo 0x4500
I came up with this since the volume at start-up is very loud, though I still don't know where exactly to place this command in the startup sequence so it takes effect after PulseAudio is loaded.


References:

Wednesday, March 27, 2013

BUGFIX for wrong monitor resolution in Rockchip kernels

Finally found it!


Symptoms:


You have:
- a 1080p capable monitor
- a 1080p capable stick + kernel (Picuntu Linux on a Measy U2C RK3066 in my case)

But when booting on Android or Picuntu Linux the resolution looks wrong (specially in Linux).


Spotting the problem:


Open up your monitor's OSD and find the Info tab, where it should say which resolution it is displaying.

If it is 1280x720 then you have just run into this bug.


Fix Procedure:


Apply the patch indicated in [1] to your kernel's /drivers/video/fbmon.c
Recompile the kernel (if Picuntu Linux, see [2])
Enjoy 1080p




The Discovery :)


I must say I was thinking the blame was for the rk30_hdmi driver, however the bug was in the Linux kernel's EDID parser itself!

[N.B.: EDID is the contents of a very small ROM inside every digital TV & PC monitor, it summarizes the available and possible resolutions]

I ran up and down through the drivers/video/rockchip/hdmi/ folder looking for the place where the monitor's non-CEA EDID was being ignored, finding the function hdmi_ouputmode_select (rk30_hdmi_lcdc.c), which produced a sink_info in the kernel log that did not include the 1080p resolution.

After a couple of days, the following call sequence was found to be causing this:

hdmi_sys_parse_edid (rk30_hdmi_edid.c) -> hdmi_edid_parse_base (rk30_hdmi_edid.c) -> fb_edid_to_monspecs (../../fbmon.c)
and back in hdmi_sys_parse_edid (rk30_hdmi_edid.c) that called hdmi_ouputmode_select (rk30_hdmi_lcdc.c).

Since the EDID video modes themselves were being parsed by fbmon.c, I decided to delve into it just to know which modes it reported back to the rk30_hdmi driver.

Defining DEBUG in fbmon.c resulted in the list of 13 valid video modes extracted from the monitor's EDID. Of these, two looked extremely unusual:
1280x1280
1440x1440

So I looked up the monitor's EDID in another tool and, sure enough, the missing modes were:
1280x800
1440x900

It totally looked like the reported X-Y dimensions were being modified due to some erroneous aspect ratio calculation!!!

Digging further into the fbmon.c code, I found a totally suspicious:
static int get_std_timing(unsigned char *block, struct fb_videomode *mode) {
...
switch (ratio) {
case 0:
         yres = xres;
...

So indeed there was a place modifying a reported resolution into a "square" one (like 1440x1440, or 1280x1280) due to a ratio. However this behavior is so bizarre that I was sure it had been spotted before so I Googled for "get_std_timing" and "ratio" and found the kernel patch for this bug (see [1]).

What was happening back in the rk30_hdmi is that it took 1440x1440 as the largest resolution supported by the monitor, but couldn't match it to any of its hardcoded modes, so it just discarded it.

This is one of the problems of basing a system on Linux Kernel 3.0.8 when the latest version is 3.9

Hope it helps!



References

RK3066 Measy U2C stick power consumption


Today I've done an experiment I was curious about: measuring my Measy U2C's (RK3066 CPU) real power consumption.


Setup





      My current setup is the above Measy U2C powered (to the DC-5V Micro USB) by an HTC phone's USB power adapter (rated 5V 1A) connected to the DC-5V Micro USB port, through a breakout USB cable that allows me to place a multimeter in series (for current measurement) or in parallel (voltage).


The power consumers:

- The Measy U2C RK3066 stick running Picuntu Linux 0.9 RC3 (Xubuntu 12.10 Quantal Quetzal)
- A Logitech K400 wireless keyboard+mouse with its USB dongle in the USB 2.0 port
- A TP-Link TL-WN422G 802.11g WiFi stick in the side Micro USB
- An Acer X233H FullHD monitor to the HDMI connector



The variables:

- The stick is running Linux from a Samsung 32 GB Class 10 MicroSD
- RK3066 idle means just logged in XFCE with only conky running
- At idle the CPUs run at 252 MHz all the time ("ondemand" governor)
- RK3066 load means two threads at 100% CPU usage [1]
- For some reason my stick's CPUs won't go beyond 1.2 GHz at full load
- Picuntu kernel's DDR memory frequency is set at 300 MHz (below my stick's DDR3 chips' specs)
- Internal WiFi+BT, webcam, micro, and AV Out are not working from Linux (YET!)



Raw Measurements


- Current (in Amperes):

RK3066 idle = 0.24 A
RK3066 load = 0.5 A
RK3066 idle + HDMI connected (720p) = 0.29 A
RK3066 idle + TP-Link WiFi = 0.41 A
RK3066 idle + Logitech K400 = 0.28 A
RK3066 idle + TP-Link WiFi + Logitech K400 = 0.45 A
RK3066 idle + TP-Link WiFi + HDMI connected (720p) = 0.47 A
RK3066 idle + TP-Link WiFi + Logitech K400 + HDMI connected (720p) = 0.5 A
RK3066 load + TP-Link WiFi + Logitech K400 + HDMI connected (720p) = 0.75 A
RK3066 suspend = 0.13 A

- Voltage (in Volts):

In open circuit configuration (unconnected) = 4.77V
With RK3066 idle + WiFi + K400 + HDMI = 4.58 V
With RK3066 load + WiFi + K400 + HDMI = 4.52 V

Not the best in the world, eh.


Conclusions


So basically a bare idle RK3066 stick consumes approx. 0.24 A x 4.58 V = 1.1 Watts
Whereas at full load it goes up to 0.5 A x 4.52 V = 2.26 Watts

Now, with Ubuntu running on the RK3066, this is a low power PC!



ANDROID UPDATE:
Android on and idle (no screen, wifi on but no link) is also 0.24A (1.1 Watts).

Worrying fact:
Android power-off: turning off the stick with the SW power button in the Android status bar (Bob Finless 1.4 ROM) does turn the stick off (must re-plug power to turn on), HOWEVER consumption is 0.47Amps (>2 Watts!!!!). Hence, that feature is heavily broken, likely leaving the CPU at 100% usage.
Using the power-off button on the Measy's side, consumption comes down to 0.24A (CPU on but idle, and screen off), unacceptable, but better.

Linux Picuntu power-off: (apply "XFCE Shutdown button just restarts the stick") the stick also apparently turns off, upon clicking on shutdown, and Linux kernel is brought down, HOWEVER consumption stays then at 0.28 Amps  (1.3W), likely leaving the CPU idle but on.
So the Linux situation is less bad than Android's, but it's clear the Rockchip kernel code is bugged since the RK3066 is not really turned off (TODO: skim through the PM chip's code).



References


[1] http://stackoverflow.com/questions/2925606/how-to-create-a-cpu-spike-with-a-bash-command

Tuesday, March 26, 2013

Compiling Rockchip Kernel (for Linux on RK devices)


Starting from Rockchip Linux' source code, along with several tools, we will end up with a recovery.img file. This is used to flash the recovery partition of an RK3066 device, which will then be able to boot into Ubuntu Linux.



WARNING: You DO NOT need to follow these steps unless you want to modify the kernel!
The stock kernel from Alok Sinha works fine and is very easy to install. Follow this guide:



Assuming the kernel is compiled from an x86 PC running an Ubuntu Linux:

#get the right packages for the compiler [3]
sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.8-dev build-essential zip curl libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib sharutils lzop

#start out from the user's home and create "rk" folder for all the work
cd ~
mkdir rk
cd rk

#toolchains folder is where the ARM compiler toolchain will be downloaded to [3]
git clone https://github.com/DooMLoRD/android_prebuilt_toolchains.git toolchains

#tools folder is where the mkbootimg tool (create recovery image) will be downloaded to [4]
git clone https://github.com/olegk0/tools.git

#initramfs folder is where the Picuntu kernel's .config file looks for initramfs.cpio (see CONFIG_INITRAMFS_SOURCE)
git clone https://github.com/Galland/rk30_linux_initramfs.git initramfs
cd initramfs
gzip -dc debian-3.0.8+fkubi.cpio.gz > initramfs.cpio
cd ..

#picuntu-3.0.8-alok is where we download the latest available Picuntu Linux kernel source code (0.9 RC3)
git clone https://github.com/aloksinha2001/picuntu-3.0.8-alok.git
cd picuntu-3.0.8-alok/

#rk3x_kernel_3.0.36 is where we download the latest available Picuntu Linux kernel source code
git clone https://github.com/Galland/rk3x_kernel_3.0.36.git
cd rk3x_kernel_3.0.36/

#copy Picuntu 0.9 RC3 config file (actually extracted from a running Picuntu, located at /proc/config.gz)
cp ../initramfs/config .config

#copy updated Picuntu kernel config file
cp config.galland .config

#set the target architecture and toolchain location (CHANGE the base folder if you are not using ~/rk/)
export ARCH=arm
export CROSS_COMPILE=~/rk/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi-

#launch the Kernel compilation (-j 4 indicates that 4 compiler threads run in parallel, I have a quad-core PC...)
make -j 4

#
# Kernel compilation takes some minutes...
# BTW, don't worry about the warnings while compiling
#

#last step is to generate the recovery.img to flash the recovery partition of the Android stick
cd ..
tools/mkbootimg --kernel rk3x_kernel_3.0.36/arch/arm/boot/Image --ramdisk initramfs/fakeramdisk.gz --base 60400000 --pagesize 16384 --ramdiskaddr 62000000 -o recovery.img



Now flash recovery.img into the recovery partition and boot into Linux, just like using the stock kernel!


Installing modules and firmware


In the same x86 PC as above, after the flashing step:

mkdir mod_fw
cd rk3x_kernel_3.0.36
make modules_install INSTALL_MOD_PATH=~/rk/mod_fw/


A new folder called "lib", with "modules" and "firmware" subfolders, should appear inside "mod_fw". Copy & overwrite "lib" into the Picuntu MicroSD card's root folder, start Picuntu and in a Terminal write:
sudo depmod -a
And, after a restart, everything should be ready.


REFERENCES

[1] https://docs.google.com/folder/d/0B02hgWz32NpXcC1ONVBSLWx6RHc/edit

[2] http://www.slatedroid.com/topic/41654-pre-alpha-03-ubuntu-linux-for-mk802-iii-ug802-mk808-ug007-imito-mx1/page__view__findpost__p__502961

[3] http://www.armtvtech.com/armtvtechforum/viewtopic.php?p=5072#p5072

[4] http://www.slatedroid.com/topic/41654-pre-alpha-03-ubuntu-linux-for-mk802-iii-ug802-mk808-ug007-imito-mx1/page__view__findpost__p__495617

Monday, March 18, 2013

Fixes to use boot-picuntu to dualboot Picuntu/Android

If you have parsed the [outdated] Picuntu repo, you may have found the following dir:
http://code.google.com/p/rk3066-linux/source/browse/boot-picuntu/

It contains two scripts for Android and one for Picuntu that allow you to kind of set the default OS to boot the stick into, and an easy way to boot back into the other one.

However the README file contains a couple of typos that prevent it from working.


How-to


The way this is done is taking advantage of the "init.d" functionality that custom Android ROMs usually provide (in my case thanks to Bob's Finless ROM 1.4 for Measy U2C). If you don't have the folder /etc/init.d/ (in your Android filesystem, not on Picuntu!) then you probably can't use this.

First of all install, in your rooted Android, the ES File Explorer, open it and go to its Settings to check allow root access and to mount the root system with write permission.


Android files setup


Then just download file http://rk3066-linux.googlecode.com/git/boot-picuntu/40picuntu
and store it in /etc/init.d/    (easiest way may be copying and pasting from ES File Explorer)
now open a terminal emulator in Android, and type:
su
chmod 777 /etc/init.d/40picuntu
(note that in the README file it is erroneously typed "chown", instead of "chmod"). Make sure that upon download the file was not renamed as 40picuntu.bin or something like that (or else remove the dot and extension).

Then download file http://rk3066-linux.googlecode.com/git/boot-picuntu/go-picuntu.sh
and store it in /mnt/sdcard/    (easiest way may be copying and pasting from ES File Explorer)

now open a terminal emulator in Android, and type:
su
chmod 777 /mnt/sdcard/go-picuntu.sh
(note that in the README file it is erroneously typed "chown", instead of "chmod")


Android files corrections


Next step is to edit both files and comment (prefixing with a #) the line that reads:
DEVC="/dev/block/sda1"
to
# DEVC="/dev/block/sda1"
and also change line:
# DEVC="/dev/block/mmcblk0p1"
to
DEVC="/dev/block/mmcblk0"
(IMPORTANT: note that also the trailing "p1" has been removed!)
I do it with the bad-old "vi" through the Terminal emulator (just because I know the obscure key combinations for basic "vi" file manipulation), but you may prefer to use any Android text editor.

Last step is to run go-picuntu.sh from the Terminal emulator with:
su
sh /mnt/sdcard/go-picuntu.sh
and then you'll be always booting into Picuntu by default, until you run (in Picuntu) the script go-android.sh

Sunday, March 17, 2013

Picuntu XFCE problems' fixes

I'll use this blogpost as a kind of FAQ, including all the troubles & solutions I've found while using my Measy U2C RK3066 stick as a second PC with Picuntu 0.9 RC3 installed (with Xubuntu's XFCE).


Slow system


Get a Class 10 microSD card! :)
Seriously, it feels faster than a netbook.



Changing Default Language (only English installed)


To change the XFCE language it is necessary to do the following (this examples are for Spanish language, es_ES, change it to your language of preference):
sudo apt-get install language-pack-es
sudo locale-gen es_ES
dpkg-reconfigure locales 
If you now go to XFCE's System Settings and choose Language Support, you should see and be able to drag your language of preference to the top of the list. Changes happen after logging out and back in.

To change the keyboard layout language you may have to modify the following file:
/etc/default/keyboard
which defaults to an US keyboard. I had to set:

XKBMODEL="pc105"
XKBLAYOUT="es"
XKBVARIANT="deadtilde"
XKBRULES="xorg"
Or you may have to do this: create folder /etc/X11/xorg.conf.d and then
sudo cp /usr/share/X11/xorg.conf.d/10-evdev.conf X11/xorg.conf.d/10-evdev.conf
and edit, below: Identifier "evdev keyboard catchall"
add:

        Option "XkbLayout" "es"
        Option "XkbVariant" "deadtilde"
        Option "XkbRules" "xorg"




Reference:



Getting Parole to play videos (Gstreamer backend error)


I tried to play an mp4 file but Parole (the default video player) complained saying
"Gstreamer backend error. Configured videosink video is not working"

Solve it forever by opening, once, a terminal and writing:
parole --xv false
Note the two hyphens. From now on, opening any video should work, even after rebooting.

Reference:

Additionally you will find that the Home folder is empty, whereas usual Ubuntu distros do already contain several folders to classify your digital life (Downloads, Documents, Images, Music, etc.).
Solution is to manually create your own language's folders and then edit the file:
~/.config/user-dirs.locale
change en_US for your locale (for Spanish it's es_ES)
and then edit the file
~/.config/user-dirs.dirs
to point every variable to the right folder. For instance:
XDG_DESKTOP_DIR="$HOME/Escritorio"
XDG_DOWNLOAD_DIR="$HOME/Descargas"
and so on with the eight variables. Then run the following command:
xdg-user-dirs-update
Log out and back in and you should see the desktop containing only the files/shortcuts in folder "~/Escritorio" (or however "Desktop" is said in your language) and the rest of home folders with a nice icon.

Reference:



Missing last lines after first boot (before installing XFCE/Gnome)


The Linux prompt looks the usual 80x24 size, but I am missing the bottom lines once I get past the last line shown in screen. If you want to check if you have this issue, type:
find /.
and see if you are missing the cursor when it finishes listing.

You should also check your monitor's OSD to see what resolution is being displayed. In my case it was 1280x720 (also called 720p or just HD), whereas the kernel I had installed was 1920x1080 (also 1080p or FullHD). The incomprehensible thing is that my monitor is perfectly able (and so it shows in its EDID and normal PC use) of the typical HDTV 1080p60 mode.

I am skimming through the RK HDMI kernel code but I believe it has something to do with the way the EDID's CEA timings are read (TBC), since it also happens when booting into Android.

In any case, if you want to get rid of this problem and be able to properly run the script picuntu-da-server.sh, you can fix it by typing:
fbset -move up
Another way to get past this is to flash Picuntu's 720p kernel.


UPDATE: this is indeed a kernel bug, for the patch see http://hwswbits.blogspot.com.es/2013/03/bugfix-for-wrong-monitor-resolution-in.html




Reference:



Avoid kinteractiveup error in syslog


Add to /etc/rc.local the line:
echo 0 > /proc/sys/kernel/hung_task_timeout_secs
This avoids several syslog error lines about kinteractiveup task every 120 seconds.



32bpp screen instead of 16bpp (background color stripes)


Add to /etc/rc.local the lines:
echo 32 > /sys/devices/platform/rk-fb/graphics/fb0/bits_per_pixel
fbset -rgba 8/16,8/8,8/0,8/24 -a
Works for 1080p as well as 720p kernels.



For Measy U2C permanently remove module 8188eu


To avoid the 8188eu wireless driver module from being uselessly loaded at boot time (since that's not the Wifi chip on this stick), comment out (by preceding with a #) the line "8188eu" in /etc/modules as root:
sudo leafpad /etc/modules


XFCE Shutdown button just restarts the stick


If you click on the shutdown button but the stick just restarts, instead of powering off after shutting down, this is due to the command used by ConsoleKit (the dbus way used by XFCE to restart/shutdown), to solve it you have to modify the shutdown script (I had to Google hard to find this solution!).

Open a terminal and write:
sudo leafpad /usr/lib/ConsoleKit/scripts/ck-system-stop
and in the two places where it says "shutdown -h" change for "shutdown -H" (uppercase the h). This small difference instructs the system to halt after being brought down.

Actually the lowercase "h" lets the system choose between halting or powering off; however the system currently makes the wrong choice, and that's why we have to force it to halt. Probably something that could be fixed somewhere in the kernel code.

Reference:
http://unix.stackexchange.com/questions/30726/how-to-shutdown-with-consolekit-without-sysvinit-but-with-systemd



System deadlocks upon a few apps open


This happened to me, the system was completely unresponsive, not even letting me move the mouse and was caused by lack of free RAM. After more than 10 minutes of wait I had to take the power off.

Since filling the RAM is not so difficult, and there is no swap by default, the best solution is to create a swap file into the SD card (no need for repartitioning, it's just a file).

The best guide, and also a very simple one, to quickly add a swap file into the SD card is this one:
http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/



Can not change english language in Chromium 


There is a version mismatch in the Ubuntu Software Center. It installs Chromium version 22.0.1229.94, whereas the languages pack (chromium-browser-l10n) requires Chromium version 25.something.

The solution is to install the 22.0.... language pack from launchpad's repository, here:
http://launchpadlibrarian.net/119854807/chromium-browser-l10n_22.0.1229.94~r161065-0ubuntu1_all.deb



Change default CPU governor


If you installed the useful cpufreq-utils then most probably your boot up CPU governor is ondemand. If you would like to change it, just edit the top part of its configuration files, specifically the "GOVERNOR" variable, with:

sudo leafpad /etc/init.d/cpufrequtils


Forcing system time update

If network is not initialized fast enough during boot, you may find at times that the system time is "Jan 1st" and may take a long while to get the correct date, causing problems when trying to access secure sites (certificate not yet valid!).

I made a quick script that forces an immediate update of the system time (through the NTP, network time protocol), containing these two lines:

sudo /etc/init.d/ntp stop
sudo ntpdate pool.ntp.org
Within seconds the clock at XFCE's upper right should get the correct date too.



Saturday, March 16, 2013

Picuntu 0.9 RC3 crash in XFCE (dbus)



Symptoms:


If any of these happen to you:

- Ubuntu Software Center issues a crash report when clicking an app's "Install" button (plus install doesn't start)

- Settings Manager: crashes and no window opens when clicking over any of Settings icons (like "Language Support")



Spotting the problem:


Open a terminal and enter:
sudo cat /var/log/syslog
If the last lines report issues like:
Activated service '....' failed: Failed to execute program /usr/lib/dbus-1.0/dbus-dameon-launch-helper success
Then there likely are permission problems with the above mentioned dbus daemon helper. Now enter:
cd /usr/lib/dbus-1.0/
ll
If everything were right you would get the following result:

-rwsr-xr-- 1 root messagebus 170348 Oct 3 23:18 dbus-daemon-launch-helper*

Date/time/size are unimportant. The permissions (-rwsr-xr--) and group ownership (messagebus) is what matters.

In my case I got the following result:
-rwsr-xr-- 1 root ssh 170348 Oct 3 23:18 dbus-daemon-launch-helper*

 So the group ownership is dead wrong, preventing the file from being run properly.



Fix Procedure:


Enter the following commands:
sudo chgrp messagebus dbus-daemon-launch-helper
Now, doing "ll", you may find that the group is fine, but the permissions have changed. To correct them, type:
sudo chmod u=rwxs,g=rx,o=r dbus-daemon-launch-helper
Check that "ll" returns the above expected result and, then, safely restart the stick (you don't want to corrupt the SD flash card!):
sudo shutdown -P now 

Once you get back into Picuntu, the problem should be fixed.



References:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659953


Sunday, March 3, 2013

Ubuntu Linux (Picuntu RC3) on Measy U2C (RK3066) with WiFi dongle




In this blog-post I'll explain how to install Picuntu 0.9 RC2.2, upgrade to RC3 without Internet connection, and then, using a very common WiFi USB stick connect it to the Internet, bypassing the internal WiFi chip.

In my case I will be using a TP-Link TL-WN422G USB WiFi stick, which contains an Atheros 9000 class (ath9k) WiFi chipset, supported by Picuntu 0.9 RC3.


Why?


As you may already know, the Measy U2C TV stick comes with chips Mediatek MT5931 (WiFi) and Mediatek MT6622 (Bluetooth) which are not currently (March 2013) supported in Linux.


For more up to date WiFi+BT compatibility information see Miniand's website:
http://dl.miniand.com/tecknight/RK3066Devices.html
Please note that, from the featureset, the Measy U2C stick seems to be a clone of Kimdecent's B12 (even the U2C's PCB silkscreen reads "B12_main_V1.1").






My current setup is the above MeasyU2C with:
- A phone USB power adapter (5V 1A) connected to the DC-5V Micro USB port
- A Logitech wireless keyboard+mouse with its USB dongle plugged in the USB 2.0 port
- A TP-Link TL-WN422G 802.11g WiFi USB stick into the side Micro USB port through an adapter (Micro USB to full size USB).
- An 8 GB Class 4 MicroSD card into the "TF Card slot" (helped by a small screwdriver)
- An Acer X233H FullHD monitor (with an HDMI to DVI adapter) to the HDMI connector





Now on to the installation, but first of all, a big thank you to Alok Sinha, the main developer behind Picuntu, for his great work.


1st) Rooting the Measy U2C


When your Measy U2C arrives it will contain an unrooted Android system. The first task is to unroot it by following the directions indicated in this url:

http://blog.geekbuying.com/index.php/2013/01/31/how-to-root-measy-u2c/

This is necessary to end up with an Android console that can reboot your Measy into Linux whenever you want (you keep both systems, since the Linux kernel is flashed into the recovery partition).

The rooting process requires two tools: Moborobo will get the right drivers for WinXP to talk to the RK3066 stick, and only then, the TPShark tool will be the one unrooting the stick.

It took me some time to get Moborobo to install the right drivers on my Windows XP 32 bits, so much that I can't really tell what I did besides rebooting, plugging/unplugging lots of times to get it done. I was unable to get Moborobo to install drivers correctly on a clean WinXP VM on VirtualBox.
However I must admit I heavily dislike the Moborobo tool, to me it feels like screaming "malware", so I am very cautious dealing with it.

Once Moborobo gets the right drivers installed, the TPSharky unrooting utility will be able to work (or else it'll complain that device is not detected or it's offline) and effortlessly unroot it (after three reboots).

After this, get into Android and install in the stick the utilities: SuperRoot, Busybox, and Android terminal. These will be needed to order the Android stick to reboot into Linux (that's the way it is).





2nd) Installing Picuntu Linux


This part can't be better explained than it already is in the comprehensive Miniand's website:

https://www.miniand.com/wiki/Picuntu+Linux+Step+by+Step+Installation

It's great to see a distributor taking so much care for the products it sells, by supporting customers with all this information.

When running the "prepicuntu" script (as root, to access/format the SD), from my Linux PC (in order to copy Picuntu in my 8GB MicroSD card that will go into the Measy U2C) I selected iMito MX1 as my stick (current options are UG802, MK808, MX1, and generic).

UPDATE: Install is fine when selecting "Generic" also, but even if you select USB dongle for Wifi, you'll still have to change the "interfaces" file as indicated in a step below, since the Wifi stick gets named "wlan1" anyways.

VERY IMPORTANT if by the time you are reading this the Miniand's website instructions still refer to Picuntu 0.9 RC 2.2:
Since we need the Picuntu RC3 kernel+modules to be able to use our WiFi USB stick:
- When reaching "Part 3-Flashing the PicUntu kernel as the Android recovery image" page, you MUST NOT follow this instructions
- Instead turn to "Appendix C--Using PicuntuRC3KernelInstaller to Flash your Desired RC3 kernel" and follow those instructions, to flash the RC3 recovery kernel.
Then, follow on to "Optional-Upgrading your PicUntu installation to RC3" with the modifications described next.


Since we don't have Internet in the stick yet, we can not download the required kernel modules + firmware from inside it. Hence, it has to be done from the PC with these steps:

1) Insert the Picuntu MicroSD card prepared on "Part 2-..." into your Linux PC


2) Open a terminal and type
wget http://download.g8.net/picuntu/modules-3.0.8-alok-RC3.tgz

3) Followed by:
sudo tar -xzfv modules-3.0.8-alok-RC3.tgz -C /mnt/linuxroot/lib/modules
Root is necessary or it won't allow modifiying the SD contents. Changing "/mnt/linuxroot" with the appropriate dir where the MicroSD was mounted (could be /media/user/linuxroot for Ubuntu PCs, where "user" is your username).


4) Then, as indicated in the previous Miniand's website, correct the folder name:
sudo mv /mnt/linuxroot/lib/modules/modules /mnt/linuxroot/lib/modules/3.0.8-alok+
  (Same as before: modify the linuxroot base dir to your case)


5) NEW STEP: Since a firmware file is needed for my USB Wifi stick (htc_9271.fw for mine, check out yours) to communicate with Linux, we'll copy it now. Supposing your Linux PC already has it (or else it's easy to find & download):
sudo cp /lib/firmware/htc_9271.fw /mnt/linuxroot/lib/firmware
   (Same as before: modify the linuxroot base dir to your case)


6) NEW STEP: Now you must modify the "/mnt/linuxroot/etc/network/interfaces" file in the MicroSD in order for Picuntu to use the USB WiFi stick with your Internet router, you can type:
gksu gedit /mnt/linuxroot/etc/network/interfaces
   (Same as before: modify the linuxroot base dir to your case)

And then rename every reference to wlan0 to wlan1 (the name Picuntu gives to my Wifi USB dongle at boot time, you can check yours with ifconfig if it doesn't work for you), and set your SSID + password. As an example here is my [mangled] interfaces file:
auto lo
iface lo inet loopback
auto wlan1
iface wlan1 inet dhcp
wpa-ssid MyWLANname
wpa-psk "MyWLANpassword"
Please note ssid does not have quotes, whereas the psk text password does need them.


7) Enter the "sync" command twice to write all changes, safely extract the MicroSD from the PC, and insert it into the Measy U2C stick (all terminal commands from now on are on the stick, not on the PC).


8) Boot into Android, get into the terminal, type "su" followed by "reboot recovery" (as indicated in previous Miniand's link as step 7).


9) Now the screen should show a typical Linux boot sequence and after a minute or so you'll be prompted to login (do so as root, with default password being 12qwaszx )


10) Type "depmod -a" and after it hit Ctrl-Alt-Supr to reboot, get into Android, do the Terminal+su+reboot recovery and be back into Linux


11) I have made a little init script with the following contents:

#load spanish keyboard
loadkeys es
#make sure console fits screen (or else missing bottom lines)
fbset -move up
#set to 0 or else every 120secs task kinteractiveup shows block debug warning
echo 0 > /proc/sys/kernel/hung_task_timeout_secs
#remove large module, since this Wifi chipset is not present!
modprobe -r 8188eu

    In my case I need the "fbset" line because for some reason the Linux prompt looks the usual 80x24 size, but I am missing the bottom lines once I get past the last line shown in screen. Using fbset the terminal gets the right resolution. If you want to see this issue, type (w/o quotes):  "find /." and see if you are missing the cursor when it finishes listing.

UPDATE: The "fbset" thing was due to the monitor displaying a resolution of 720p (look in the OSD), even though the monitor is capable of HDTV 1080p60 video timings, the kernel is also 1080p, and the system res is also 1080p... However, since 720p also happens when booting into Android, I'll blame it on the stick's HDMI I/F chip.


12) Try a ping to see if the WiFi dongle is connected:
ping www.google.es
If there is response, you are good to go, or else try "ifconfig" to see if the WiFi USB is detected and maybe check the Linux logs and the interfaces file to see if the correct Wifi and settings are there.



3rd) Getting a GUI into the stick


Now for this you should run as root, from the Picuntu Linux prompt, the script: picuntu-da-server.sh

This will guide you through the configuration, download & installation of the necessary packages, which may take very long (hours) depending on the Class (speed) of your MicroSD card.

In my case the GUI of choice is the very fast and lightweight XFCE. After install finishes, I can get into XFCE by typing: startxfce4

The GUI feels snappy and it's quite cool to have such a minimal computer with a real OS!! (Android who?).



UPDATE: Just arrived a Samsung 32GB MicroSD card Class 10 (UHS-1), system is much faster!

UPDATE: If you run into problems (CRASHES) when installing apps or trying to change settings in XFCE, you may be running into the same DBUS bug I did, click here for my post on how to fix it.



I hope this quick write-up helps other people get through these steps, since it's great to be able to run Linux (and a graphical one!). If you run into any problems or would like to remark something I may have missed, please don't hesitate to leave a constructive comment below.   :-)