Thursday, 4 April 2013

I.MX6 GK802 - Ubuntu 12.04 preview image

Following on from the oneiric preview image, I've put together a rootfs based on Linaro 12.04. Thanks to the Otavio from the yocto project for help building the gpu drivers. It should be possible to deploy the rootfs on other imx6 devices by deploying the correct uboot, kernel + modules.

Note: updated rootfs has working VPU.

What's working :

1. GPU + VPU acceleration.
2. Wifi
3. Choice of Unity 2D or Xubuntu desktop
4. Chromium
5. glxgears/glmark2-es2/es2gears working in Unity 2D and Xubuntu.

What's currently not working:

1. Bluetooth
2. Pre-installed Neverball (3D ball game) - broken something





If you prefer not to follow the manual instructions listed below user hste (aka
Haakon Stende
) on freenode imx6dongle has created a script to build and deploy. Script is here, any problems contact hste on freenode for advice.

To install (assuming oneiric image already on sd card):

1. Download rootfs linaro_12_04_gpu_vpu.tar.gz. Thanks to hste for hosting.
2. Delete existing rootfs from oneiric image (this is the "ubuntu" partition on the SD card).
 
    rm -rf <sd card mount point>/ubuntu/*
    sync

3. Extract new rootfs:

    cd <sd card mount point>/ubuntu
    tar xvf linaro_12_04_gpu.tar.gz
    sync

4.  Download kernel with cpu frequency or without (requires a good heatsink) and 'dd' to sd card.

    dd if=arch/arm/boot/uImage_cpufreq of=/dev/sdc bs=1048576 seek=1 && sudo sync 

         OR


    dd if=arch/arm/boot/uImage_no_cpufreq of=/dev/sdc bs=1048576 seek=1 && sudo sync 

5. Download uboot and 'dd' to sd card.
    dd if=u-boot.imx bs=1k seek=1 of=/dev/sdc && sync


4. Remove SD card and place in internal SD slot and power up.

Sunday, 10 March 2013

GK802 - Ubuntu oneiric preview image


For those of you waiting for a pre-built image, here goes!

If you want to find out more about our development efforts or want to contribute 

1. irc channel  #imx6-dongle on freenode
2. Kernel/Uboot Source 
3. Wiki Page
4. Google Group

I've called this a preview image because it's still work in progress. What's working:

1. New uboot - based on abrasive's (aka James Laids) excellent work.
2. GPU and VPU h/w acceleration
3. Working wifi (although performance can be below par)
4. Working internal/external SD slots.
5. Working usb ports.

Instructions:

1. Download image (thanks to miniand.com for hosting).

2. Unzip image and dd to an SD card. This image is for a 8GB SD card, however the ext4 file partition is only 3GB therefore should work on a 4GB card. Fix the partition (by expanding it) after completing the dd.

3. Download a new uboot and 'dd' to your sd card (replace <drive> with the correct value):

    sudo dd if=u-boot.imx bs=1k seek=1 of=/dev/<drive> && sync

Update: To fix the problem of sound not working, down a pre-built kernel with the fix or compile your own using the our latest kernel source. To use pre-built follow instructions below:

3a. Down the pre-built kernel with cpu frequency scaling enabled or without it and 'dd' to sd card. Replace <cpu_freq_option> with cpu_freq or no_cpu_freq depending on which file you downloaded :

    sudo dd if=uImage_3.0.35-0269_<cpu_freq_option> of=/dev/<drive> bs=1048576 seek=1 && sudo sync 
                                                   
3b. Download the kernel modules for the prebuilt kernel and copy to the sd card (replace <sd card> with mount point of your sd card:

 tar xvf modules_3.0.35-02695.tar
 cp -r modules/3.0.35-02695-ga09806b-dirty <sd card>/lib/modules

4. Place image in the internal sd card slot (you need to remove the casing to access the internal sd slot) and fingers crossed it should boot (useful to have a serial console open). The image defaults to 1280x720 screen resolution, once the desktop appears, plug-in a keboard/mouse via the usb port.

5. Next configure wifi, and it may be useful to reboot after setting wifi so that the correct time is picked up.

6. Then enjoy the desktop experience!

Unfortunately shutting down from the desktop just takes you back to the logon screen. To force a  proper shut down open a command shell and issue "sudo shutdown -P now", wait a minute or so to ensure shut down is complete and then remove the usb power cable.

To verify GPU acceleration you can run glmark2-es or es2gears. To verfiy VPU run totem with a file of your choice.

Saturday, 2 March 2013

GK802 - Ubuntu Update 1 (GPU/VPU Acceleration)

Since my last post, we have made rapid progress in getting a functional kernel working on the GK802. This couldn't have been done without the invaluable contributions from rz2k (aka Dmitriy ) and abrasive (aka James Laird)  on the irc channel imx-dongle. Coupled with countless hours from myself the progress so far:

1. Wifi working.
2. External SD working
3. Matched IOMUX configuration to align with the Android image. Managed to work out how compile        C programs to run under the Android image.
4. Stripped out unnecessary device initialisation from the original HDMI dongle source.
5. Enabled EGL and GLES HW Acceleration in Ubuntu (big thanks r2zk).
6. Unity desktop I think is partially HW accelerated.

I plan to push kernel patches in the coming days. There is still a fair amount of work to do due to  thermal/CPU freq driver patches in the kernel and lack of PMIC on the GK802

Update: Changes are now merged into the main repo https://github.com/imx6-dongle/linux-imx. If you want to build the kernel then use imx6_gk802_defconfig.

Here's a video to demonstrate what's been achieved and how capable the IMX6Q is. In the video Firefox seems sluggish, however this is easily compensated by the fact I run glmark-es2 whilst simultaneously playing a 720p video. 



Compared to the Chinese SOC manufactures it is miles ahead in the availability of reference documentation and Linux support. The video playback is pretty impressive and I hope that we will see XBMC development commence at some point.



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.

Monday, 31 December 2012

Hackberry A10 : Ubuntu 12.10 with Razor-qt

Having heard about Razor-qt, I thought I would give it a go on the Hackberry. Razor-qt is a light-weight desktop built for simplicity and speed. It is also intended to target 'weak machines' therefore I was hoping it would perform well on the Hackberry giving that we still lack full hardware acceleration.



To start with I reused my XBMC image which is basically a Ubuntu 12.10 install complemented with a 3.0.42+ kernel. You can remove the xbmc install by removing the /allwinner (ie rm -rf /allwinner).

I couldn't find a pre-compiled armhf package of raxor-qt therefore I built from scratch (using root user) following the build instructions here as a guide. Fortunately the xbmc image already includes most of the build tools for compilation.

Download the latest release and untar to a directory (eg src/razor) :

    mkdir src; cd src; mkdir razor;
    wget https://github.com/downloads/Razor-qt/razor-qt/razorqt-0.5.1.tar.bz2
    tar xvf razorqt-0.5.1.tar.bz2 razorqt-0.5.1
    cd ..
    mkdir build
    
Before building get some additional packages for building:    

    apt-get install qt4-dev-tools qt4-designer
    apt-get install libmagic-dev

Now build (this takes a bit of time) and install

    cd build
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../razorqt-0.5.1
    make
    make install

Once built successfully we need to replace the existing window manager fluxbox with openbox the default for razor-qt.

    apt-get remove fluxbox
    apt-get clean
    apt-get install openbox

Now we create a simple startup script to invoke razor-qt.

    echo 'exec razor-session -w openbox' > /root/.xinitrc_razor

I suggest setting the CPU governor profile to performance:

     cpufreq-set -g performance

To start razor-qt from the command line:

    cd /root
    xinit ~/.xinitrc_razor -- :1

The basic desktop has minimal applications because the XBMC image has no defaults application installed (eg browser, file manager, text editor, etc ..) however these is can be easily installed. You would also need to customise the image to your requirements ie wifi/ethernet etc. Also further work is require to auto-start razort-qt and use for non-root users.

Although the desktop experience is primitive I found it to be more responsive than the Linaro image although my main use has been for code development/compilation on the Hackberry, requiring multiple open command shells.

I also compiled the mesa-demo library to stress the windowing system/cpu along with 'openssl speed' to see how responsive the GUI would remain under load. Below is a another badly made video to demonstrate how it performs.


Saturday, 22 December 2012

Hackberry A10 - Booting Android from an SD Card

Having spent many hours attempting to get a custom kernel booting for the factory Android image, I found that is was easier to first create an factory Android image that would boot from an SD card. The main advantage is that it removes the arduous steps of packaging a complete image and then re-flashing to Nand for each small change.  It also opens up the possibility of booting other Android distributions from an SD card.

To start with I created a mirror image of the nand paritition on an SD card, to do this requires a linux installation. The nand partitions range from A-K as are covered in more detail here. I used gparted to create the partitions with the correct sizes as below, it is important that you leave 16MB free at the start of the SD card for uboot (shown by 'unallocated' partition) .  You need to create an extended partition (shown by /dev/sdc4) in order to create more than 4 partitions.



You need to create an additional partition on the SD card to represent the extrernal sd card /mnt/extsd, I created a FAT32 partition which becomes /dev/sdc13 (mmcblk0p13).

Next step is to copy across all the nand partitions from the hackberry. This can be done by booting the hackberry with a linux distro and using the linux dd command to copy the partitions to files. I copied the partitions on to a usb stick (needs to be at least 4GB) as below:

   dd if =/dev/block/nanda of=nanda
   dd if =/dev/block/nandb of=nandb
   dd if=/dev/block/nandc  of=nandc
   ...
   ...
   dd if=/dev/block/nandk  of=nandk

Once all the nand files are created we can 'dd' the files to the SD card. The boot partition file nandc is not copied because we need to extract the rootfs from it and create a ext4 partition. The bootloader  file nanda is also not copied as we create our uboot on FAT16 partition (/dev/sdc1). Assuming the SD card shows up as /dev/sdc I executed the following (amend /dev/sdc with correct device name for your SD card).

   
   sudo dd if=nandb of=/dev/sdc2
   sudo dd if=nandd of=/dev/sdc5 bs=1M
   sudo dd if=nande of=/dev/sdc6
   sudo dd if=nandf of=/dev/sdc7
   sudo dd if=nandg of=/dev/sdc8
   sudo dd if=nandh of=/dev/sdc9
   sudo dd if=nandi of=/dev/sdc10
   sudo dd if=nandj of=/dev/sdc11
   sudo dd if=nandk of=/dev/sdc12 bs=1M
   sudo sync

Next I extracted the ramdisk rootfs from the nandc file, fortunately I have done this for you. Download the file android_sd.tar.gz, it contains  all the additional files required to create a bootable sd card. If your interested how I extract the kernel and rootfs I used the split_bootimg.pl utility, further info here.  I also fixed the files init.sun4i.rc and ueventd.sun4i.rc so that they refer to the sdcard paritions /dev/ /dev/mmcblk0pX instead of /dev/nandX.

The mapping between nand and mmcblk0p are shown below

   nanda -> mmcblk0p1  
   nandb -> mmcblk0p2
   nandc -> mmcblk0p3       
            mmcblk0p4              
   nandd -> mmcblk0p5       
   nande -> mmcblk0p6       
   nandf -> mmcblk0p7       
   nandg -> mmcblk0p8       
   nandh -> mmcblk0p9       
   nandi -> mmcblk0p10      
   nandj -> mmcblk0p11      
   nandk -> mmcblk0p12    

Take the nandc file from the zip file and dd it to the correct SD card parition, in my example it is /dev/sdc eg:

   sudo dd if=nandc of=/dev/sdc3


I then changed all references in the script files on the system partition (/dev/sdc5 in my example) from /dev/nandX to /dev/mmcblk0pX.  The files to amend are:

   ./etc/vold.fstab
   ./bin/preinstall.sh
   ./bin/sop.sh

You need to edit ./etc/vold.fstab and replace the /mnt/extsd  with the following:

dev_mount extsd   /mnt/extsd   auto  /devices/virtual/block/mmcblk0p13

Next I converted the extracted kernel from the nandc file to be uboot compatible, again in the download zip there is a pre-built file (uImage). If your interested, I used the following command to convert the kernel:

    mkimage -A ARM -C none -T kernel -O linux  -a 40008000 -e 40008000 -d nandc-kernel uImage

Copy the uImage file to first partition on the SD card (this is bootloader FAT16 partition which is empty ). Also copy the uboot config files uEnv.txt and boot.scr to the first partition.

Finally I copied the Hackberry uboot files sunxi-spl.bin and u-boot.bin to the SD card to make it bootable. This is the reason for the leaving 16MB free at the start of the SD card.

    sudo dd if=sunxi-spl.bin of=/dev/[drive] bs=1024 seek=8
    sudo dd if=u-boot.bin of=/dev/[drive] bs=1024 seek=32
    sudo sync

I suggest you delete everything of the data partition (eg /dev/sdc6), this will ensure the correct device partitions are found and recorded on the first boot. It would be prudent to hook up a serial console to the Hackberry to monitor boot progress in case of failures. Insert the SD card into the Hackberry and power up.

Once you have Android booting, turn off media scanning for the SD card. This option is in Setting->Storage>"Enable media scanning on SD".

If want to try deploy another kernel (assuming the kernel and modules are compatible with the Android image) then:

  1. Copy the newly built uImage file to the first partition of the SD card.
  2. Copy the modules to the /vendor/modules on the system partition of the SD card.

Sunday, 11 November 2012

Hackberry A10 - XBMC

I spent some time creating a working XBMC image for the Hackberry because of the increased interest generated on the xbmc forum. Firstly a big thanks to numerous contributors (empatzero,rellla,shivansps,gimli) on the xbmc forum for getting the cedar libaries integrated and getting a build-able xbmc for the A10 soc.

The latest compiled version of xbmc is towards the end of this post if just want to download it works on hackberry and should work on any distro with fb support (for non hackberry deployment).

Standard disclaimer at this point, its an unsupported release as there are many untested/non-working features but hopefully gives you a taste of progress or starting point for further improvements. Furthermore there's nothing stopping you getting this running on other A10 devices, at minimum you will need to replace script.bin, uboot and if no ethernet remove this from /etc/network/interfaces otherwise there will be a long delay before you see a command prompt on the screen. Lastly you may also need to replace the kernel.

To start with I took guillaume ubuntu 12.10 (armhf) build and reworked it so that it boots for the Hackberry from an SD card using a 3.0.42+ kernel (revision cbf3d41b7ed513a743854fde1ca0b5c4d0f11610 + my wemac patch). Again thanks to guillaume for such a useful headless build. One of the highlights of this build is that it presents an on screen command console, meaning there is no longer a reliance on ssh for a command shell. The main issue with the build seems to be graphical tearing while editing at the command line, something I can live for now. The build still starts an ssh daemon if you need access through Ethernet (host name is hackberry, try ssh root@hackberry). There's nothing stopping you using the image without xbmc, although it currently it assumes a default resolution of 1280 x 720 which is required by xbmc.

I created an armhf build of xbmc which was compiled on the Hackberry (taking numerous hour to complete, something to leave overnight). I mainly followed the instructions here.

Download the image (its quite large 722Mb) and dd (or equivalent in Windows) to an SD card, the image expands to 4GB but only takes around 2GB and should easily fit on a 4GB card. Repartition the ext3/ext4 partition to make use of the remaining space on your SD card. Instructions to dd the image:

    gunzip
    dd if=xbmc_hackberry.img of=/dev/<device> bs=1M
    sudo sync

You should alter script.bin (on the FAT partition) to contain a different mac address if you intend to use ethernet, more instruction here.

Boot the Hackberry with the newly created SD card and hopefully the command console should appear on your display:

    Ubuntu 12.10 hackberry tty1

    hackberry login :

To logon user/password is root and to start xbmc

    cd /allwinner/xbmc-pvr-binhf/lib 
    xbmc/xbmc.bin

Fingers crossed the xbmc log should appear followed by the main screen. Plug-in a keyboard/mouse to navigate.



Short video to demonstrate how well it runs (unfortunately no sound as I was using a hdmi to vga adapter).



I tried a 1080p video (.mov) which it played without any problems.

To enable audio,  go to setting and cycle through audio adapters and until sound is heard. For me thiss worked for hdmi and also through the hackberry AV port (the socket nearest to the usb ports).

I couldn't exit xmbc using the menu options, 'Power off System' occasionally worked but dropped to the command line. In the end I resorted to ssh'ing and powering down (shutdown -Ph now).

I compiled a new xbmc version based on commits as of  01-12-2012 from empatzero's repo. Main change as per commit log is:

FIXED MPEG4 CODECS: FLV1, WMV2, DIVX4, DIVX4, DIVX5, XVID.

Download xbmc_01_12_2012.tar.gz, which  contains the contents of the allwinner directory and replace with the existing one on the image. Beware the allwinner directory is owned by root on the image. Copy the downloaded tar file to the hackberry and then untar, example below.

    cd /
    tar xvf xbmc_01_12_2012.tar,gz

For those looking to make modifications or build from source, the repository I used is git://github.com/empatzero/xbmca10 along with following the instructions here to a greater extent.