If you’ve ever compiled the Linux kernel, you’ll know make menuconfig is the command line used to unset/set options, disable/enable modules in order to match your hardware and requirements. I used to simply browse in the menu to find the option, and just remember the correct path. Sometimes I just looked at .config to locate the option I needed, and the possible path in make menuconfig. The first time you use a new option it can be time consuming. But I’ve just found there is a better way via Google+.
“/” is actually available in make menuconfig, just like it is in vi/vim. If you want to enable NFS server in your kernel, press “/”, and search for NFSD.
It will show the list of results with “NFSD” strings. NFS server support is right at the top, and the path is shown to be File Systems->Network File Systems. The neat thing is you don’t have to remember or note the path, as you can just press the number between parenthesis on the left of the option location, in this case (1), and it will take you directly there.
But what if you’re searching for a string with lots of results such as PCI. The actual CONFIG_PCI is just buried in the search results. The solution is to use regular expressions. If you just want to find “CONFIG_PCI”, press “/” for a search, and “^PCI$” to find the exact match.
Great! Press “1″ to go to the option, and enable PCI in your kernel. You can use other regexps as well.
I’ve just received a mini PC powered by AllWinner A31, and I had to (re-)install the firmware, so I’ll explain the steps I followed in this post. The procedure is for CS868 mini PC, but it should be similar for all Android HDMI TV dongles, and media players based on AllWinner A20 or A31.The procedure below only works in Windows, and has been tested in Windows XP. I’ll mention a possible method in Linux at the end of the post.
Download the latest CS868 firmware and tools, and extract “cs868 firmware and update tool 20130507.rar” file
Download PhoenixUSBPro tool in English, and extract This is optional as the Chinese version is included in rar file above.
Double-click on PhoenixUSBPro/PhoenixUSBPro.exe to start the program
Click on Update to upgrade the tool to the latest version if need be.
Click on Key to to load the key file (AW_LCTOOLS.key), on Image to load the firmware file (sun6i_android_fiber-onda809q9_20130507_V2.0_media_ck_288.img), and click on Start.
Now connect the microUSB to USB cable to the OTG port of your device, use a paper clip or tweezers to press the recovery button, and connect the other end of the USB cable to your Windows PC. Release the recovery button once you hear Windows has detected a new device.
Do not let Windows search for a driver online, but instead set the search path to PhoenixUSBPro/USBDriver, as shown below.
Click on Next, let the driver installation complete, and the firmware update should start.
Wait a few minutes until the firmware upgrade completes. It took 3 minutes 38 seconds to upgrade my device.
At the beginning I had issues in Windows, because, as I found out later, my Windows file system was encrypted, so I also gave it a try in Linux using Livesuit, but unsuccessfully. Livesuit Linux refuses to load the img file provided. The most likely reason is that Livesuit and PhoenixUSBPro file formats are different (and Livesuit did not need to key file), or the current version of Livesuit may only work with AllWinner A10 or Cubieboard. I’m sure somebody will correct me on that.
Google I/O started yesterday, and Google released an early access preview version of Android Studio, a new IDE based on IntelliJ IDEA with drag-and-drop GUI layout editor, Gradle-based build system, Lint tools, the ability to preview how apps look on different screen sizes, and more. This may eventually replace the Eclipse + ADT Plugin combination currently used, so I’ve decided to give it a try in Ubuntu 13.04 64-bit, but it’s also available for Windows and Mac OS X.
First, head over to Android Studio Installation instructions, and download Android Studio for you operating system via your Browser (You’ll have to accept an EULA), then open a terminal to extra it:
tar xzvf ~/Downloads/android-studio-bundle-130.677228-linux.tgz
Now let’s start Android Studio:
cd android-studio/bin/
./studio.sh
OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-1ubuntu1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
WARNING: You are launching the IDE using OpenJDK Java runtime.
ITS KNOWN TO HAVE PERFORMANCE AND GRAPHICS ISSUES!
SWITCH TO THE ORACLE(SUN) JDK BEFORE REPORTING PROBLEMS!
NOTE: If you have both Oracle (Sun) JDK and OpenJDK installed
please validate either STUDIO_JDK, JDK_HOME, or JAVA_HOME environment variable points to valid Oracle (Sun) JDK installation.
See http://ow.ly/6TuKQ for more info on switching default JDK.
Press Enter to continue.
I did press enter to continue, but Android Studio complained about JAVA_HOME no being defined. Let’s just install Sun Oracle JAVA JDK since this is the recommended method. I’ve used the instructions provided on Mark Loiseau blog to do so.
This should be it, let’s confirm we’re using the right version:
java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
I also had to install some extra dependencies to workaround issues with adb when running the application:
apt-get install lib32ncurses5 ia32-libs
Let’s start Android Studio again with ./studio.sh
Success! If you already have project based on Eclipse, Google Provides instructions to migrate your Eclipse apps to Android Studio, but today, let’s just start a New Project.
You’ll just need to provide an application name (e.g. Hello_World), and change the Package Name (replace com.example by your own) to remove a warning, and click on Next. There are several options in the wizard, but I’ve just clicked on Next several times to complete the creation of the new project. The first time will take some time since Android Studio will download, install and configure Gradle build system.
Now just open the “MainActivity” as shown below to see the source code.
Edit the code as follows (Changes highlighted in green):
package com.cnxsoft.hello_world;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
I’ll use the emulator for this hello world example, so we need to configure Android Studio to use it. Click on Run->Edit Configuration, select emulator, and create a Android Virtual Device by clicking on … (e.g. Nexus 4), and click OK.
Time to run the application by pressing the Run icon (green triangle) or pressing Shift+F10. Now be a little patient, and after a while, you should see “Hello, Android” displayed in the Emulator.
Android mini PCs ( HDMI TV dongles) are great to make your TV smart, and you may expect to be able to play Android games on your TV easily. The reality is that the keyboard and mouse, or remote controls used with those devices, are not suitable for games, and most games do not play at all. Of course, OUYA and GameStick projects will take care of this, as well as the recently available Project SHIELD ($349) , but if you already have one of those mini PCs, you may not want to spend the money for another device. Luckily there’s a solution, and with some efforts, you can play many games, but not all, with a PS3 Bluetooth controller connected to your Android mini PC or Set-Top Box.
I received the controller in the package below, which was *almost* not damaged…
Goigame Doubleshock III Package (Click to Enlarge)
The wireless controller comes with a silicon case, and nothing else, so you’ll also need to find a mini USB to USB cable to charge the device.
It does indeed look like a PS3 Dualshock III controller, but for some details such as the “P3″ key. I can’t compare the build quality to an original controller since I’ve never used one. The model number at the back is CECHZC2U.
I’ve also partially disassembled the thing for those of you who want to see its guts.
Click to Enlarge
(Click to Enlarge)
Playing Android Games with PS3 Wireless Controller
At the beginning, I though my controller was damaged because I failed to see it in the list of Bluetooth devices in both Linux computers and Android devices. But apparently, this BT device does not work that way, and won’t be detected at all in the list of devices.
The first thing to do in Android is to download Sixaxis Compatibility Checker, a utility that checks if your Android device and your controller are compatible, before you buy Sixaxis Controller app (~$2.50 US).
Launch Sixasis Compatibility Checker, and click on Start. This is check if your Android device is compatible, and if it is successful show the message below with the master address. The message tells you to use SiaxisPairTool in Windows or sixpair in Linux, but since all mini PCs run Android 4.x, we can just connect our PS3 controller to the mini PC via USB for the next step.
If you don’t get the message above, your device firmware is not compatible, you need to investigate, and possibly re-build the Linux kernel and/or required drivers in as explained in that post.
After having connected the controller to the USB port, click on Pair, make sure the master address is correct (the one detected previously), and click OK.
Disconnect the USB cable, click on Start again in the app, and click on the PS3 Button (original controller) or P3 Button (Clone). LED 1 should be on, and the other 3 off, and the following message should show up in Sixaxis Compatibility Checker.
Click OK, and if you play around with the analog joystick and buttons of your controller, debug messages should be displayed in the app:
Client 0: DOWN - 19
Client 0: UP - 19
Client 0: DOWN - 19
Client 0: UP - 19
Client 0: DOWN - 20
Client 0: UP - 20
With the number changing depending on the key pressed.
Now go over Google Play, buy and install Sixaxis Controller app to be able to play games.
The user interface is very similar to the free checker, just follow the same instructions to pair your controller. You can then click on “Change IME”, and select Sixaxis Controller.
Now let’s try to setup the system to play Dead Trigger. Still in Sixaxis Controller, click on Preferences->GamePad Settings’, and Enable Gamepad as shown below.
I’ve also changed the “Analog Poll Rate” to the maximum, but I’ve not sure it affects playability at all.
You may also want to enable “Mouse Emulation”, or you’ll have to use your mouse to control the menu in the game instead of your controller. I’ve done that, and selected the “START” key to toggle mouse, set the left stick to control the mouse, and assigned L1 and R1 as the left and right mouse buttons.
There’s also a “Touch Emulation”, which will be necessary in many games such as ShadowGun, but not in Dead Trigger, so I’ve skipped this part, which appears to be more complex as I understand you have to setup profiles for each games. Some people also mention the need to use Droidmote to be able to play more games on devices such as MK808.
Let’s start Dead Trigger. Press “START” once to toggle mouse emulation, and go to the setup menu to change the control scheme to “Free Move Pad”, and for my controller, I had to set the aim sensitivity for the game to be playable when turning left or right.
Finally click on Customize Gamepad to define the buttons used for firing, reloading, aiming, and more.. That’s it, start the game, press the “START” button on the controller again to disable mouse emulation, and kill’em all!
Sometimes, the analog sticks would just stop to work for a short, and/or appear to be stuck in position (which they weren’t). I don’t know the root cause of the issue. It could be a controller issue, a firmware bug, or Sixaxis Controller app bug.
PS3 Controller in Linux (Ubuntu)
Instructions to use the controller in Ubuntu are available in help.ubuntu.com.
and after connecting the controller via USB run the following command:
sudo sixpair
But the next step, where you disconnect USB, and run
sixad --start
would be unable to detect the device as I pressed P3 key. There seems to be issue with Ubuntu and my Bluetooth dongle, as Bluetooth often gets disabled.
USB mode however works perfectly, and after installing the packages below:
I could control the mouse pointer with the controller, and play SuperTuxKart without issues in Ubuntu 13.04. It did not work with Ubuntu 12.04 and an earlier version of the game.
About one year after showing the first image from the camera module prototype, the Raspberry Pi Foundation announced the Camera board is now available for purchase on RS Component or Element14. Navigating either of these sites is a nightmare, but, if you’re lucky, you should eventually find the camera board for around $25 before taxes and shipping.
“Raspicam” features the following hardware specifications:
Omnivision 5647 sensor in a fixed-focus module
5MPixel sensor
Still picture resolution: 2592 x 1944
Max video resolution: 1080p
Max frame rate: 30fps
Size: 20 x 25 x 10mm
Connection by flat ribbon cable to 15-pin MIPI Camera Serial Interface (CSI) connector S5 on Raspberry Pi computer board
The first thing you’ll have to do with the camera is to connect it to the CSI connector on your Raspberry Pi, just behind the Ethernet connector on model B. James explains it very clearly in the video below.
]
Now that the camera is connected, you’ll need to update your Raspbian installation. Login to your pi, and run those commands:
sudo apt-get update
sudo apt-get upgrade
This may take a little while. After completion, run
sudo raspi-config
and enable the camera module, as shown below.
Save the settings, and reboot.
Two command lines applications called raspivid and raspstill are available respectively to capture video and still images.
Some example s:
Capture an image in jpeg format:
raspistill -o image.jpg
Capture a 5s video in h264 format:
raspivid -o video.h264
Capture a 10s video:
raspivid -o video.h264 -t 10000
You can use the arrow keys to scroll, and type q to exit. Read here for further details.
It’s also possible to stream the Feed to a Linux, Mac OS X, or Windows computer:
Linux PC Install dependencies:
sudo apt-get install mplayer netcat-openbsd
and run the following command:
nc -l 5001 | mplayer -fps 31 -cache 1024 -
Windows PC
Download MPlayer and Netcat.
Start a command promt, and type the following type:
[Path to nc.exe]\nc.exe -L -p 5001 | [Path to mplayer.exe]\mplayer.exe -fps 31 -cache 1024 -
Mac OS X Download MPlayer.
Run the following command in Terminal to view the feed using MPlayer:
nc -l 5001 | mplayer -fps 31 -cache 1024 -
You may also want to view the feed directly from the Raspberry Pi:
If some cases you may want to know if a library or binary built for the ARM architecture is using hard-float (armhf) or soft-float (armel). You can analyze ELF binary using readefl utility, so let’s have a try.
First let’s install some armel and armhf files on a computer running Ubuntu by install gcc/g++ toolchain for armel and armhf:
We now have armhf and armel libraries installed in /usr/arm-linux-gnueabihf/lib and /usr/arm-linux-gnueabi/lib respectively. Let’s check the output of readelf filtered with “FP” string for libm.so.6 for armel:
readelf -a /usr/arm-linux-gnueabi/lib/libm.so.6 | grep FP
Tag_FP_arch: VFPv3-D16
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_HardFP_use: SP and DP
Great, so there’s an extra line for armhf (Tag_ABI_VFP_args) that seems to confirm the library is hard-float.
With readelf compiled from elftoolchain-0.6.1 (source code), the extra line will be a bit different: “Tag_ABI_VFP_args: AAPCS (VFP variant)
AAPCS stands for ARM Architecture Procedure Call Standard. You can read more details on ARM website. There are also two other possible values for Tag_ABI_VFP_args: “AAPCS (base variant)” and “toolchain-specific”, but I’m not sure in which case they may be returned.
“-a” will just dump everything, but readelf also allows you to only select architecture depend information with “-A”. So beside floating point type, you can also find out about the architecture, thumb, whether it’s build with NEON support and more:
You may have heard about libhybris, a library that cleverly loads Android HW adaptations and convert calls from bionic to glibc. One of the greatest achievement of this library is to allow Android GPU drivers to be used with Linux, and is notably used by Canonical, although they did not write it, for Ubuntu 14.04 which will be compatible with any recent Android smartphones or tablets.
One way to get started with libhybris is to port a device to Ubuntu Touch, but this may take a while. However, I’ve found a faster and easier way to play with libhybris thanks to Martin Brook (vgrade) who wrote a tutorial on how to use libhybris with Mer on the Cubieboard. Mer is an open source mobile Linux distribution powered by Qt/QML and HTML5, that’s born from the ashes of Meego, and is now used in the upcoming Sailfish OS.
Qt5 Cinematic Experienced Rendered at 25 fps in Cubieboard via Android GPU Drivers in Linux Thanks to libhybris
You’ll need to follow 4 main steps:
Build Android
Build a minimal Mer image
Install Libhybris
Run demos
I’ll skip the Mer image build since Martin has provided a binary image. I’ll use a build machine running Ubuntu 12.04.2 LTS. You should make sure the build environment is setup correctly, you’ve installed repo, and that it’s in your path. I’ll use the Cubieboard (1GB RAM), but you may want to try other hardware platform, or Linux distribution as the instructions should be similar.
Build Android for the Cubieboard
This is basically following the instructions provided here. First let’s code Android Jelly Bean (CyanogenMod) source code:
repo sync may take quite a while depending on your Internet connection. It took 10 hours, after several attempts over three days… Once this is done, we’ll need to configure the build for the Cubieboard:
source build/envsetup.sh
lunch
Select Cubieboard (#4), and start the build:
make -j10
The build initially failed with this error:
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.txt by executing the following command:
make update-api
^^^^^^^^^^^^^^^^^^
NO. NO. STOP BEING LAZY. SERIOUSLY.
DO NOT DO THIS in CM. THIS IS A LIE. IF YOU DO THIS I WILL HATE YOU.
USE OPTION #1.
-Koush
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
So I shamelessly typed “make update-api” to automatically update current.txt, and continued the build with “make -j10″. The build may also take quite a while depending on your computer performance and available RAM. This step was much faster than repo sync in my case, as it just took about 45 minutes in total.
The Android build is now completed, but we need still to patch Bionic library, and rebuild:
cd bionic
wget http://pastie.org/pastes/7649385/download -O bionic_libhybris.patch
patch -p1 < bionic_libhybris.patch
cd ..
make -j10
Now let’s tar Android’s system directory as we’ll need to copy the will have the patched bionic library plus all the android libs (EGL, GLESv2, RIL etc):
pushd out/target/product/cubieboard/system/
tar cjvf ../../../../../cubie_android_system.tar.bz2 .
popd
Installing and Running Mer
Since we don’t build the image ourself, this step is rather easy, as we just need to download the image, and dump it to a micro SD card.
Where you need to replace <sd_device> by your actual SD card device such as “sdc”.
My 4GB microSD is slightly smaller than the image provided, so dd failed at the very end. But you can usually run the following 2 commands on the last partition (in this case ext4) in order to resize the partition, and fix any potential boot problems:
e2fsck -y /dev/sdc2
resize2fs /dev/sdc2 +3300K
Interestingly, this time those commands failed, but I still inserted the microSD in my Cubieboard, and I was able to login successfully into Mer via the serial console as root (password: mer). You should also have access a terminal on the HDMI monitor.
We don’t want X to start anymore, so let’s disable it and restart the Cubieboard:
zypper rm uxlauncher
reboot
If you’re using HDMI console, switch to VT2 (Ctrl+Alt+F2) before running the command.
Installing libhybris and Android system folder
Let’s log-in again via the serial console, or via VT2 on the HDMI monitor if this works for you, and install libhybris:
zypper ar http://repo.merproject.org/obs/home:/sage:/libhybris/latest_armv7hl/home:sage:libhybris.repo
zypper in libhybris
zypper in libhybris-tests
You may want to enlarge your terminal for the steps above, as the text goes over the window, and you have to answer some questions for the installation. The next step is to install Android’s system files to /system in the Cubieboard. Copy the files from the Linux PC to the Cubieboard:
After a reboot, Cubieboard decided to boot Android from flash, so I tried to remove and re-insert the micro SD, and noooooooooo! The micro SD socket let me down and refuses to lock the card in place, so I’ll have to replace the slot which will take me few weeks since I have to order the thing.
So I count on you to let me know what has gone wrong. Thanks
Let’s carry on as if everything worked just fine, and run the next demo:
test_glesv2
This should display a white diamond shape filled with an animated Catherine wheel.
Martin also has instructions for several other demos, but the most interesting one (we have a video), is Qt5 Cinematic Experience that you can install in the board as follows:
zypper in qt5-plugin-imageformat-jpeg
zypper in qt5-plugin-platform-eglfs
zypper in qt5-qtdeclarative-qmlscene
zypper in qt5-qtdeclarative-import-qtquick2plugin
zypper in qt5-qtdeclarative-import-window2
zypper in qt5-plugin-generic-evdev
zypper in vim
zypper in qt5-qtdeclarative-import-particles2
zypper in qt5-qtquick*
curl -O http://quitcoding.com/download/Qt5_CinematicExperience_rpi_1.0.tgz
tar -xf Qt5_CinematicExperience_rpi_1.0.tgz
cd Qt5_CinematicExperience_rpi_1.0
Now edit content/Mainview.qml with vim, and comment out the PathAnimation part.