XBMC for utilite (CEC support included)

Utilite device

I have already alluded to utilite devices several times (at least here, here and here).

The utilite pro is definitively the best i.MX6 device I currently own for several reasons :

  • It is based on the powerful i.MX6Q with 2Gib of RAM
  • The bootloader is in a dedicated SPI NOR flash (so it is always available)
  • It includes a SanDisk SSD U100 drive which is just a sdcard killer
  • It provides 2 Gbps Ethernet interfaces (one of it being the standard imx6 ENET interface and the other a PCIe intel I211 controller).
  • It comes well packaged in a nice aluminum case (with power button) and accessories (wifi antenna + power supply + S/PDIF coax and uUSB to RS232 cables)
  • It also has an backed RTC (it may appear as a detail but is just another little asset for this product)

(it is worth mentioning that this product is based upon the embedded board cm-fx6 which is properly documented, especially schematics are available)

Some people would argue that it is expensive. Obviously it may seem to be the case when compared to a GK802 stick. But when you have a detailed look at the features, it is simply aligned with the price of comparable devices I guess…

XBMC for utilite

When I released my HardFloat XBMC image, I said I will also release an image for utilite.
So here it is ! This image is special : Not only does it provide my most recent XBMC build for iMX6, but it also features CEC as I mentioned in my previous post
You can download the image from this link – md5sum is cf4523d1e32ebd35faa5264abe3523fb.
Warning : I updated the image on the 30th of September 20:10 GMT because the included XBMC had an issue. Please check carefully your md5sum and download the image again if it is not the good one…

It is a sdcard image : That way you can try it without interfering with your SSD install (of course you will not benefit from the SSD that way but it is a safe and easy way to give a first try at my image)
To get it up and running :

  • Flash the sdcard and insert it in your device
  • Plug the serial line, configure it @115200n8 and power on your device
  • Stop the bootloader by pressing ESC
  • Issue the following commands :
setenv sdargs 'setenv bootargs console=ttymxc3,115200 root=/dev/mmcblk0p2 rootwait video=mxcfb0:dev=hdmi,1920x1080@60,if=RGB24 consoleblank=0' 
setenv start_sd 'mw.l 0x20E0034 0x593A046 ; mmc dev 2 ; fatload mmc 2 0x10800000 uImage-cm-fx6 ; run sdargs ; bootm'
saveenv
  • Then you can boot by issuing the command :
run start_sd

Please note that you will only have to issue the command :

run start_sd

to boot from the sdcard instead of the SSD during the next reboots …

Apart from this, you can refer to my previous post to get more info regarding this image…

i.MX6 CEC

Introduction

According to wikipedia definition : “Consumer Electronics Control (CEC) is an HDMI feature designed to allow the user to command and control up-to 15 CEC-enabled devices, that are connected through HDMI by using only one of their remote controls (for example by controlling a television set, set-top box, and DVD player using only the remote control of the TV). CEC also allows for individual CEC-enabled devices to command and control each other without user intervention.
It is a one-wire bidirectional serial bus that is based on the CENELEC standard AV.link protocol to perform remote control functions.”
Since the Eden release XBMC has support for CEC thanks to libCEC. Besides the freescale i.MX6 SOC is able to handle this bus by itself : There is no need to buy an additional USB device such as this one.
Unfortunately, so far, nobody publicly added i.MX6 CEC support in libCEC. It was a shame and I decided to address this issue.

Development

While developing this missing part, I had to tackle 3 tasks :

  • Finding a hardware platform to develop and test this feature
  • Adding support in libCEC
  • Solving issues with the CEC driver itself

The first item may seem trivial but it is not. Indeed, many iMX6 products/boards do not properly wire the CEC signal.
Here are the info I gathered :

  • Wandboard was reported by a user to have CEC signal unconnected in this comment which refers to wandboard forums
    Edit (october, 12): After lots of comments, I confirm that no wandboard version is properly wired to use CEC (At this time at least). But if you have a wandboard quad and are able to use a soldering iron, then have a look at this thread
  • GK802 is no longer of interest to me : It is a device with no engineering support nor official technical data. It is not properly cooled. It has a very attractive price but, as a developer, I lost enough time with it. CEC signal may be connected or not, I don’t care as I know I will have no resource to understand what happens if it does not work…
  • I also know that nitrogen6x (I don’t own that board by myself) from boundary devices does not expose the CEC signal (thanks to this comment)
  • My utilite pro would have been a perfect device to test CEC. Unfortunately, my device comes from an early batch which was not properly wired (while currently produced devices are all good).

So, at the end, finding the right device for this development was not so easy. Fortunately compulab was kind enough to send me a new utilite from their new batch (and a properly wired CEC signal). I am about to publish a XBMC image with CEC support for utilite as a way to thank them for their support.

Then adding support for a new adapter in libCEC was not so hard : The code is well structured and there is obviously a provision to add new devices.
At some stage, I found that support for existing devices was a little cumbersome but I finally understood that the real culprit was not libCEC but the interface with underlying hardware and that I was able to have a simpler implementation as long as the driver allows for it. Note that, for now, I have not added support to handle several logical addresses at the same time (The hardware allows for it but there is not yet support in the driver for this)

And so we come to the third item : The CEC kernel driver. Freescale provides this driver but I was a little surprised of the current state of this driver (in the their BSP V4.0.0 or V4.1.0). It is supposed to be a simple character device (which is just fine) but I found quite a few shortcomings.

  • First they don’t care about being compliant with the well known POSIX interface :
    The read syscall will immediately return if no data is available even if the device is not opened with the O_NONBLOCK flag.
    This same read syscall will return a false value (ie not the effective number of bytes seen by userspace)
    The write syscall will return 0 if successful while it should return the number of written bytes
    The poll syscall will never state that the device is writable
  • Then they do not properly release the IRQ when the kernel module is unloaded (because of this, you will not be able to reload the module a second time)
  • At last, they use locking in a sometime hazardous way and even copy/paste comments from “vpu” in this driver…

As a conclusion, this driver has not been very carefully developed and is misleading when you try to use it at first time.
But I don’t blame freescale for this : At least they release this driver and, that way, they allow to enhance it. All the more as they also provide an excellent reference manual which describes very well the hardware interface.
So I had to solve the afforded mentioned items in order to use it smoothly from libCEC.

Final thoughts

At the end, I rebuilt XBMC with CEC support and was able to give it a try faced to my panasonic PZ81 TV.
And… it works just fine !
I am able to browse XBMC GUI with my TV remote.
I have already published my changes for libCEC here and will try to mainline them.
Changes for the kernel driver should be released next week.
[Edit : A first (still wip) patch is now public]
Last but not least, all this work is useful only if a product can take advantage of it. So here is a XBMC image which provides XBMC with CEC support targeted at utilite here.

Edit 2014/03/13 : I have moved iMX6 libcec to xbmc-imx6. Enhancement and bug tracking can occur here starting from now…
Edit 2014/04/28 : Other important fixes and port to 3.10 kernel are here