U-boot, Linux Kernel, and Android Patches for Freescale i.MX6 HDMI TV Dongles

We can now get some quad core Android mini PCs (e.g. Hi802, GK802) featuring Freescale i.MX6Q processor, Freescale has released full documentation and source code its development platforms, Hi802 / GK802 HDMI TV dongles are easily hackable, and there’s even an Ubuntu image for the devices. So it looks pretty good ,right? Well almost.. there are some patches and config for GK802 that have not been released by Richtechie, so we can’t modify the  bootloader and Linux kernel. But this may change, as ARMTvTech forum user hste noticed some Freescale i.MX6 HDMI dongle patches om IMX Community website. Even though I’m not sure those are fully compatible with Hi802 / GK802, this could be a starting point. Today, I’ll provide the instructions to build u-boot, the linux kernel and Android ICS with those patches in a machine running Linux 12.04 64-bit.

Patch Sets Descriptions

There are two set of patches that can be applied to R13.4-GA release:

  • hdmidongle_REVB_R13.4_patch-20121115.tgz –  Adds HDMI dongle support in U-boot, the Linux kernel and customize Android 4.0.4 for mini PCs.
  • hdmidongle_REVB_R13.4_patch-20130201.tgz –   Adds support for ldo bypass , uboot fastboot, ntfs, Bluetooth A2DP, fakes an alway full battery, removed the screen locker, and check the video mode. There are also patches for bug fixes for WifiDirect, Wi-Fi performance, uboot mmu, and system stability

A script (revb_dongle_patch_install.sh) is provided to apply 20121115 patches.

Getting Freescale i.MX6 U-boot, Linux kernel and Android source code (R13.4-GA)

Since those patches need to be applied against R13.4-GA, so we need to get the code first. The instructions are explained in section 5 “Get Android Source Code (Android/Kernel/U-Boot)” of R13.4-GA.01_Android_User_Guide.pdf.

First download IMX6_R13.4_ANDROID_SOURCE_CODE (171 MB). After download, you should get a file named imx-android-r13.4-ga.01.tar.gz that includes the documentation, patches, and Mfgtool for Android 4.0.4.

Let’s extract it, extract the (default) patches:

If you don’t have it the repo tool yet download it, and add it to your path:

Now let’s create a working directory (myandroid) and get Android 4.0.4 r1.1 AOSP source code:

repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.4_r1.1
cp ../code/r13.4-ga/default.xml .repo/manifests/default.xml
repo sync

This will take a little while, after or while it’s progressing you can (also) get imx kernel and U-boot source code:

When checking out imx-android-r13.4 branch for the kernel and U-boot, you’ll get messages like:
HEAD is now at c9dfae3… ENGR00224938 HDMI audio: clear HDMI dma done bit before start
HEAD is now at 097643f… ENGR00224313:i.MX6 general:enable CONFIG_CMD_IMXOTP to fix the build error

It just shows the latest commit, so there’s no issue here.

After repo sync is complete, you’ll also need to get some more code:

Now patch all those with R13.4-GA patches:

After a lot of debug output (and warnings), you should see the following message to indicate patching was successful:
Success: Now you can build the Android code for FSL i.MX platform

We’re done for this part we now have all source for R13.4-GA release.

Patching R13.4-GA with HDMI dongle patches

We can now patch the code to add HDMI dongle support. I’ll assume you’ve downloaded all 3 files describe at the top of this post to ~/edev/Freescale/imx-android-r13.4-ga directory:

For the second set of patches, you’ll noticed patches 0001 to 0012 have been applied, except 0008 since it’s not needed anymore.

One more step completed. Have a tea break, or drink a beer, since there’s still a bit more work to do.

Building U-Boot, the kernel and Android for Freescale i.MX6 HDMI TV Dongles

I’m probably missing some per-requisites in this part, and most required dependencies were already installed in my PC. You may want to have a look at the post “How to compile Android on Ubuntu 12.04“, and in particular the part about install Sun Java 6 JDK, where you need to download Sun Java 6 JDK, install it, and run update-alternatives:

Now we should be ready to build:

Build Freescale imx6 hdmidongle lunch menu

We can select either hdmidongle_6dq-eng or hdmidongle_6dq-user for the build. The “eng(ineering)” build is a debug build, and the “user” build is a release version. I’ve gone with hdmidongle_6dq-user (15) to try it out.

In theory, we now just need to run make:

However “in theory, there is no difference between theory and practice; In practice, there is”, and I’ve come across a few issues during the build, and if you build in Ubuntu 12.04 64-bit, you may want to perform the following steps before running make.

Some directories are duplicates in the source tree, and the build ends with error such as:

build/core/base_rules.mk:166: *** external/mtd-utils/mtd-utils/mkfs.ubifs: MODULE.HOST.EXECUTABLES.mkfs.ubifs already defined by external/mtd-utils/mkfs.ubifs.  Stop

I fixed it by deleting one of the duplicate in the source:

I found some dependencies missing, so you may have to install:

But the build still failed, so here’s an ugly hack:

Then I got several errors:

error: “_FORTIFY_SOURCE” redefined [-Werror]
make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1

The solution is to edit vi build/core/combo/HOST_linux-x86.mk and edit the corresponding line as follows:

Source: http://code.google.com/p/android/issues/detail?id=20795

External/mesa3d/src/glsl/linker.cpp:1734:59: error: ‘offsetof’ was not declared in this scope make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] Error 1

Edit external/mesa3d/src/glsl/linker.cpp and add #include <stddef.h>
Source: http://code.google.com/p/android/issues/detail?id=23206

host C++: liboprofile_pp <= external/oprofile/libpp/arrange_profiles.cpp In file included from external/oprofile/libpp/arrange_profiles.cpp:24:0: external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive] make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1

Edit external/oprofile/libpp/format_output.h and Remove ‘mutable’ from ‘mutable counts_t & counts;’ on line 94 => counts_t & counts;
Source: https://groups.google.com/forum/?fromgroups=#!msg/android-building/2EwtWQTqjdI/eBl1bK-KNM8J

external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type

Edit external/gtest/include/gtest/internal/gtest-param-util.h and add one line:

Source: http://code.google.com/p/android/issues/detail?id=22005

/home/jaufranc/edev/Freescale/imx-android-r13.4-ga/myandroid/external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock’
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1

Edit vi frameworks/compile/linkloader/Android.mk and rename LOCAL_LDFLAGS to LOCAL_LDLIBS.
Source: https://bugs.launchpad.net/linaro-android/+bug/1018832/comments/6

frameworks/compile/slang/slang_rs_export_foreach.cpp:249:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs_export_foreach.o] Error 1

Edit frameworks/compile/slang/Android.mk and remove -Werror
Source: http://code.google.com/p/android/issues/detail?id=22006

After all those changes, I was finally able to complete the build with the output in out/target/product/hdmidongle_6dq including the following directories and files:

  • root/ – Root file system (including init, init.rc, etc). Mounted at /
  • system/ – Android system binary/libraries. Mounted at /system.
  • data/ – Android data area. Mounted at /data.
  • recovery/ – Root file system when booting in “recovery” mode.
  • boot.img – Image which includes the kernel zImage, ramdisk, and boot parameters.
  • ramdisk.img – Ramdisk image generated from “root/”.
  • system.img – EXT4 image generated from “system/”. It can be programmed to “SYSTEM” partition on SD/eMMC card with “dd”.
  • userdata.img – EXT4 image generated from “data/”.
  • recovery.img – EXT4 image generated from “recovery/”. It can be programmed to “RECOVERY” partition on SD/eMMC card with “dd”.
  • u-boot-6q.bin – U-Boot image with padding for i.MX 6Quad version of the HDMI dongle.
  • u-boot-6dl.bin – U-Boot image with padding for i.MX 6Dual version of the HDMI dongle.
  • uImage – Kernel image

If you just want to build U-boot and/or the Kernel follow section 5.3 and 5.4 in R13.4-GA.01_Android_User_Guide.pdf. For the kernel there are 5 configs which all seem quite different from GK802 config:

  • imx6_android_defconfig – Android kernel config
  • imx6_defconfig – Linux kernel config
  • imx6_nand_android_defconfig
  • imx6_nand_updater_defconfig
  • imx6_updater_defconfig

To build U-boot for Freescale HDMI dongles, there are over 12 config (6 for i.MX6 dual, 6 for i.MX6 Quad), but the most interesting appear to be mx6q_hdmidongle_android_config and mx6q_hdmidongle_nand_android_config.

That’s all for today, I’ll post more if I, or somebody else, make progress trying it or/and building it for GK802 / Hi802 mini PC.

Support CNX Software - Donate via PayPal or cryptocurrencies, become a Patron on Patreon, or buy review samples
Notify of
newest most voted