Friday 15 February 2013

I.MX6 GK802/Hi802 - A working Kernel with Ubuntu

The Hi802/GK802 mini-pcs are interesting devices because of the vast reference documentation available for the IMX6Q processor. Freescale are also providing a HDMI TV Dongle reference design complete with source code, the Hi802/GK802 are partially based on this design. With this is mind and after spending many hours decoding the pcb layout coupled with bouts of head scratching, I finally got a kernel booting ubuntu. This is a work in progress but hopefully will kick start further development by community see here. Considering this is work in progress you definitely require serial console access if booting fails. Furthermore I'm testing on a GK802 with 1.2 CPU version therefore no guarantee on a 1.1 CPU which I think are GEN 1 or for Hi802 devices.



1. Kernel Boots from SD card.
2. USB port functions with USB hub (for me works with keyboard and mouse).
3. Serial console shell active.
4. HDMI output is set to 1280x720@60.
5. Ubuntu Desktop launches but freezes randomly :(. Not that use-able in its current state.
6. No wifi or bluetooth. Wifi shouldn't be too hard to add.

So if your keen or want to help out, instructions below, I assuming you know how to use git and have armel compiler (I use arm-linux-gnueabi-) :

1. Check out the Freescale imx6 kernel tree and checkout imx_3.0.35_1.1.0. I found 1.1.0 to be more stabe than the 2012-09-01 branch.

    cd linux-2.6-imx
    git checkout imx_3.0.35_1.1.0
          
2. Down this tar file containing patches and kernel config (thanks to miniand.com for provding hosting). Extract and apply patches

    git apply gk802_patch_1.patch
    git apply gk802_patch_2.patch

3. Make kernel config

    make ARCH=arm imx6_defconfig
    make ARCH=arm menuconfig
        
4. Copy the file kernel_config to .config 

    cp kernel_config .config

5. Build the kernel and modules

    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=output      modules     
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=output modules_install

6. Download the rootfs L3.0.35_1.1.0_UBUNTU_RFS from the freescale website. You may need to create an account to access to the files.

7. To create a bootable SD card, I took the bare ubuntu image from here (thanks ArmTvTech.com and   dylandn ) and dd'd this to the card. I then reformated the ext4 partition and untar'd the rootfs 
L3.0.35_1.1.0_UBUNTU_RFS to it.

8. Next step is to copy the new kernel and modules over:

    sudo dd if=arch/arm/boot/uImage of=/dev/<device> bs=1048576 seek=1 && sudo sync

    sudo cp -r output/lib/modules/3.0.35-05236-gc9dfae3-dirty /media/ubuntu/lib/modules


9. Now try to boot, fingers crossed you should see the kernel trace output appearing and finally a command shell in the serial console.

generic-usb 0003:413C:2107.0002: input,hidraw1: USB HID v1.10 Keyboard [Dell Dell USB Entry Keyboard] on usb-fsl-ehci.0-1.4/input0
EXT4-fs (mmcblk0p1): couldn't mount as ext3 due to feature incompatibilities
EXT4-fs (mmcblk0p1): couldn't mount as ext2 due to feature incompatibilities
EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device 179:1.
Freeing init memory: 184K
 * Starting mDNS/DNS-SD daemon[ OK ]
 * Starting load fallback graphics devices[ OK ]
 * Starting Userspace bootsplash[ OK ]
 * Stopping load fallback graphics devices[ OK ]
 * Starting configure network device security[ OK ]
 * Starting Mount network filesystems[ OK ]
 * Starting Upstart job to start rpcbind on boot only[ OK ]
 * Stopping Upstart job to start rpcbind on boot only[ OK ]
 * Starting network connection manager[ OK ]
 * Stopping Mount network filesystems[ OK ]
 * Starting Failsafe Boot Delay[ OK ]
 * Stopping Failsafe Boot Delay[ OK ]
 * Starting System V initialisation compatibility[ OK ]
 * Starting configure network device[ OK ]
 * Starting Bridge socket events into upstart[ OK ]
 * Starting RPC portmapper replacement[ OK ]
 * Starting Start this job to wait until rpcbind is started or fails to start[ OK ]
 * Stopping rpcsec_gss daemon[ OK ]
 * Stopping Start this job to wait until rpcbind is started or fails to start[ OK ]

[ OK ]rting Advanced Power Management daemon...        
Last login: Thu Jan  1 00:00:41 UTC 1970 on tty1
speech-dispatcher disabled; edit /etc/default/speech-dispatcher
Checking for running unattended-upgrades: 
[ OK ]rting bluetooth        
 * PulseAudio configured for per-user sessions
saned disabled; edit /etc/default/saned
 1 Jan 01:36:59 ntpdate[5241]: no servers can be used, exiting
Welcome to Linaro 11.10 (development branch) (GNU/Linux 3.0.35-02666-gc27cb38-dirty armv7l)

 * Documentation:  https://wiki.linaro.org/

301 packages can be updated.
53 updates are security updates.

New release '12.04 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

root@linaro-ubuntu-desktop:~# 


10. Your HDMI display should show a Ubuntu desktop after a while. If the desktop appears then try launching a terminal window which should appear without it freezing. Once the deskop freezes it can be recovered in the serial console shell by:

    service lightdm stop
    service lightdm start

Xorg is reporting the following error when frozen:

[    71.433] (II) XKB: reuse xkmfile /var/lib/xkb/server-A77BBE312A49C9FE89948D38B2A8CB84C3CBB410.xkm
[   101.398] (II) XKB: reuse xkmfile /var/lib/xkb/server-A77BBE312A49C9FE89948D38B2A8CB84C3CBB410.xkm
[   181.556] [mi] EQ overflowing. The server is probably stuck in an infinite loop.