The community based Wandboard project (http://www.wandboard.org) is a very interesting open Freescale iMx6 hardware platform. The most recent release of the Android 4.2.2 Source Code for the board makes it an ideal candidate to prototype an Embedded Android System.
For this Blog Post we are using:
Android 4.2.2 wandboard repo sources
IMX Kernel 3.0.35+ (supplied by the Android sources)
U-Boot IMX Fork (supplied by the Android sources)
Host: Ubuntu 12.10 64 Bit (username: user)
Understanding how Android Boots
In this blog post we are looking a bit closer in how to get started with booting the platform using the patched Linux Kernel and u-boot. Both come with the Android Source code which is available for downloading with Android’s repo tool.
Today, it is my pleasure to announce the release of our all new open source Android application of the OsciPrime Oscilloscope. We worked eagerly to bring a large amount of requested and desired features to our Android application, and guess what, it is all Open Source.
With the new release we also announced that we are in the process of making our hardware board available for ordering. Check all news out on our product website www.osciprime.com.
Features and improvements of the new application are:
=> Mutlitouch Interface
=> Control Interleave, Attenuation, Offset, Zoom, etc.
=> Using the new Android USB API for communication with the hardware board
=> Neat new User Interface, as modular as possible
=> Improved processing performance for both Audio and USB
If you want to support our open source development and always receive the newest version of the scope, then consider purchasing our application from the Android Market here.
If you want to meet us and find out more about the project, then join us on the 10. of July 2012 at the Libre Software Meeting in Geneva, where we are going to present our Open Source Project.
Head over to our OsciPrime Website to catch the latest source code and APK. here.
We are eager to hear your thoughts and improvements of the applications in the comments section.
For many projects it would be great to have an RFID-Reader on your tablet. Sadly there is no Tablet yet that has a built in NFC Chip. However, there are plenty of Readers that connect through USB to your device, and some of them use an FTDI USB Serial Converter for communication over the serial protocol.
Provided you have a USB Host Port and Root on your Tablet it is possible to communicate with a large number of peripherals that use the FTDI chip. And we want to show you how we did it.
For our purpose we just downloaded a Snapshot of the Kernel.
Note: if you are unsure which kernel version to use, execute step 1 first on your device and return to the repositories to choose the appropriate version.
Follow these steps to compile the new Kernel module.
1. First you need to find the appropriate Kernel version for your Android Tablet. Some manufacturers change the “Extraversion” parameter. Drop into a root shell on the tablet and find out which version you are running; also pull the current kernel config: # cat /proc/version
extract the kernel config from your device $ adb pull /proc/config.gz config.gz
2. Set up the current Kernel config for your freshly downloaded Kernel snapshot. Let’s assume you put the the Kernel into ~/kernel/ . $ zcat config.gz > ~/kernel/tegra-android-tegra-2.6.36-f48009c/.config
3. Configure your new Kernel to create the FTDI module using menuconfig
Let’s say you have your Android NDK under /opt/android-ndk-r5… ~/kernel/tegra-f6874dc$ export PATH=/opt/android-ndk-r5/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/:$PATH
~/kernel/tegra-f6874dc$ make menuconfig ARCH=arm CROSS_COMPILE=arm-eabi- -j4
Navigate to “Device Drivers -> USB Support -> USB Serial Converter Support -> USB FTDI Single Port Serial Driver” [1]
Select it as a Module hitting the “M” key so that it reads “<M>”.
Now adjust the Makefile so the Extraversion fits your extracted version.
If you did not yet export the path, then do so now: ~/kernel/tegra-f6874dc$ export PATH=/opt/android-ndk-r5/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/:$PATH
And start compiling the modules: ~/kernel/tegra-android-tegra-2.6.36-f48009c$ make modules ARCH=arm CROSS_COMPILE=arm-eabi- -j4
Your modules should be building now.
5. Your FTDI Kernel module is now located in the “drivers/usb/serial” directory. You can copy it to your tablet now:
~/kernel/tegra-android-tegra-2.6.36-f48009c$ adb shell
$ su
# cd sdcard
# insmod ftdi_sio.ko
And done you are! Connect your FTDI Device (for instance this USB FTDI-Board: http://www.sparkfun.com/tutorials/243) and use this Code to start communicating with your peripheral device (in this case an RFID Reader).
To compile the project files extract them and use Android’s “ndk-build” script.
~/simplectrl/jni$ /opt/android-ndk-r5/ndk-build
The executable file is found in simplectrl/lib/armeabi/simpleserial. Push it to your device, connect your FTDI device and make it executable:
~/simplectrl$ adb push lib/armeabi/simpleserial /data/local/
~/simplectrl$ adb shell
$ su
# cd /data/local/
# chmod 777 simpleserial
# ./simpleserial
This has been tested on a Rooted Acer Iconia Tab A500 with Android 3.0.1 and the Kernel Version 2.6.36.3
We hope we were able to get you started with serial programing over USB 🙂
Don’t hesitate to comment our post and give us some feedback to improve our mini-article.
[1] you will also find the “USB Profilic 2303 Single Port Serial Driver” there, which is used for many USB-Serial Converters.
It is long overdue to talk about porting specific projects to Android. It is astonishingly easy to do so with the Android platform.
Since we are using USB for our project we found it convenient to work with libusb 1.0. Using the Beagleboard we are able to make use of the USB 2.0 high speed functionality of libusb.
Libusb itself consists of a shared library and two sample applications. One of those applications is the lsusb command which lists connected USB devices in the console.
These five Steps is all it takes to port the existing libusb open source project to the Android platform.
1. Get the libusb-1.0 sources [link] and create an empty “libusb-1.0.3” folder in the external directory of your Android sources. Unpack the libusb folder into the new directory.
2. Create Android.mk files in each of the libusb directories. In the top folder your Android.mk just calls your mk files in the libusb subfolders :
You see the syntax of these Android.mk files is very simple. You just tell the compiler what modules you want to include and where your header files are.
3. Soon we are ready to compile the library; if we do so now, we will notice that the macro TIMESPEC_TO_TIMEVAL is not defined by the sources inside Android. To overcome this problem we just need to define the macro in the lubusb/io.c file.
#define TIMESPEC_TO_TIMEVAL(tv, ts) \
do { \
(tv)->tv_sec = (ts)->tv_sec; \
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
} while (0)
If you compile your libusb now, there is going to be the following error: build/tools/apriori/prelinkmap.c(137): library ‘libusb.so’ not in prelink map. This is because Android keeps track of all the shared libraries of the root file system (RFS). Therefore we need to add the library to the prelinked map found in ./build/core/prelink-linux-arm.map. We did so and just added libusb.so below libqcamera.so.
libqcamera.so 0xA9400000
libusb.so 0xA8000000
You are now all set to compile libusb. Execute the following commands in your Android root directory:
$ . build/envsetup.sh
$ choosecombo
Choose your build variant. Afterwards you can compile the whole RFS with make or just that one project:
mmm -j4 /external/libusb
4. Your library is ready… but your usb-file system is almost certainly not mounted yet. In your init.rc of the RFS add the following command to mount your USBFS.
mount usbfs none /proc/bus/usb -o devmode=0666
Add the line somewhere below the “on boot” event.
5. Now we need to compile lsusb. The sources are located in the examples folder of libusb. Create a folder lsusb in the ./external directory of the Android sources. Copy the lsusb.c module into it and create a Android.mk file:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= lsusb.c
LOCAL_MODULE := lsusb
LOCAL_C_INCLUDES += external/libusb-1.0.3/
LOCAL_SHARED_LIBRARIES := libc libusb
include $(BUILD_EXECUTABLE)
Execute the build command:
mmm -j4 /external/lsusb
and we are done! Congratulations! You just ported an entirely non-Android specific project to your Android platform!
Simply execute lsusb in your Android shell to verify if everything worked properly.
Update 15.07.2011
Thank you for all your comments. With the new Android versions there are a few things that changed for the tutorial.
1. To correct the devmode you now need to adjust the uevent.rc file rather than the init.rc.
2. The Android.mk requires LOCAL_MODULE_TAGS since Froyo. (for ex. LOCAL_MODULE_TAGS = eng user)
3. It became pretty easy to exclude files from the prelinked map. Add LOCAL_PRELINK_MODULE := false to your Android mk files.
4. As “kos” pointed out the sources will now compile when using ./configure –disable-timerfd before building to avoid compiling errors.