Categories
Canonical Computing

Firmware updates for MacBooks that don’t dual boot OSX

My Macbook currently hosts Ubuntu, and there is no copy of OSX on it.

I keep a USB stick with OSX installed on it, and today I got to test if I could use this to install a firmware update.

Short version: It just works. Slightly longer version: I just rebooted a few times, holding down alt/option whenever I needed to boot OSX from the USB stick. The OSX software updater took care of the rest.

Categories
Canonical Computing

Bionic JPEG: A libHybris example

(One of the nice things about my new job is working ‘in public’. I’m tagging posts like these with ‘Canonical’, if you want to filter them)

Hybris (aka libHybris) is a piece of enabling technology that lets an OS distribution like Ubuntu use parts of Android software in binary form, without needing a recompile of those binaries. Ubuntu is using it for its ARM based Ubuntu Touch distributions, which re-use the Android BSP for the underlying hardware platform.

libHybris is two things: A dynamic linker, which provides the generic functionality, and then a set of wrapper libraries that provide particular Android libraries to the other OS. Whilst the code is clearly organised, it might be helpful to have a separate sample which demonstrates how to use the core Hybris features. That is where Bionic JPEG comes in.

Bionic is the name of Android’s C runtime library. On Ubuntu the conventional C runtime is glibC. So another way of looking at Hybris is to regard it as a way to use bionic based binaries in a glibC based OS. Hence the name of this project.

Bionic JPEG aims to demonstrate how to call a library compiled for use on Android (In this case the IJG JPEG library) from an Ubuntu binary. To do this, I’ve divided the IJG code into its library and client components, then compiled the library with the Android NDK, and the client with the Ubuntu Touch toolchain. In order for the clients to use the Android library, a small ‘bridge’ library that calls libHybris glues the two together. By designing this bridge library to present the same API as the IJG library, no changes are needed to any of the IJG source code.

The core of Hybris is clearly derived from the Bionic source, and is a port of the Android dynamic linker to Ubuntu. This knows how to load an Android Elf32 binary into an Ubuntu process, which is a trick the standard Ubuntu dynamic linker can’t do. From the look of the code, Android can effectively link/prelink binaries in several ways, and it is loading these binaries that is the key Hybris feature. In addition, as it resolves symbols present in the binary it loads, it can hook them to somewhere else. Hybris then uses this to hook all the bionic entrypoints, and re-direct them to glibC. This isn’t always a simple symbol substitution – there are differences between the C libraries that means Hybris has some implementations within it, that then call on to glibC.

Whilst the IJG code is unmodified, I have changed the name of the library produced. It turned out that the Android images I was using (derived from CyanogenMod 10.1 images for the Nexus 4) already have a copy of libJPEG, from an earlier version of the IJG code. In order to avoid a collision, Bionic JPEG names its library libjpeg2.

For more details, see the README in the source tarball (available in the project downloads). Note that I don’t anticipate Bionic JPEG demonstrates something commonly done by Ubuntu SDK users. Over time (several release cycles), I think the Ubuntu community hope to phase out our dependence on Android, in favour of the common Linux upstreams Ubuntu and Android share. That will take time, and need us to be successful enough for hardware manufacturers to offer direct support. For now, using Android gets us that support for the cost of maintaining Hybris.

That being said, even while libHybris exists, I don’t think it will be a common thing for people to extend it: for most cases, the Android libraries on a given device will already have a complete libHybris bridge.

For the teams that need to maintain those Android parts, there may be a need to extend libHybris, or even just to understand it a little better. It is with that use case in mind that I created this example.

Bionic JPEG’s homepage on Launchpad.

I intend to refine the sample with clearer instructions on how to add it to the system image, as Ubuntu’s tools here finalise in the run up to the 13.10 release.

Categories
Canonical Computing

Ubuntu Touch Demo for Mobile Asia Expo

Last week, I attended Mobile Asia Expo (MAE) in Shanghai. It was my first experience of China, and I have to say I thoroughly enjoyed it. I got the chance to meet lots of folk from Canonical, as we all arrived from around the world to attend the trade show.

One of my tasks was to assist the London marketing team with loading the demo build we selected for showing off at the show. If you’d like to see it as well (what, you couldn’t fly to Shanghai to see it?), you can simply load it from our servers.

You’ll need a Nexus 4 or a Nexus 10 device, and you need to be prepared to replace the android software on it (you can go back). You need to setup the phablet-flash tool. The desktop setup part of our install instructions are sufficient, but the whole document is worth a read (this is still developer territory, and not quite for end users yet). Connect the device via it’s USB cable to your host Ubuntu desktop.

If your device has already been modified to run adb as root, the instructions are simple:

$ phablet-flash --legacy --revision raring/monthly-06  
$ phablet-network-setup  
$ phablet-demo-setup  

phablet-network-setup clones the current settings from the host laptop. If that’s not what you want you can configure the phone using it’s UI, before running phablet-demo-setup.

Note that you need ‘–legacy’ because our engineering teams have already moved forward to a new way of hosting the Android parts, and last weeks trade show image is old-style!

If your device needs to be prepared from scratch (it’s just come out of the box), then you need to use some extra steps:

First, boot the device to the bootloader (hold down the power key and volume down), and unlock it:

$ fastboot oem unlock

Now partition the storage, and format the data partitions:

$ fastboot -w

Now, download the binaries we’ll need.

$ phablet-flash -b -d mako -D --legacy --revision raring/monthly-06

Now load on the custom recovery image:

$ fastboot flash recovery ~/Downloads/phablet-flash/ubuntu-touch-preview/raring/raring/monthly-06/raring-preinstalled-recovery-armel+mako.img

Now, boot to recovery mode (select it from the bootloader menu), which has a working adb. We can push a zip to ‘/sdcard/autodeploy.zip’ and the recovery tool will flash it at next boot. First, do the android BSP:

$ adb push ~/Downloads/phablet-flash/ubuntu-touch-preview/raring/raring/monthly-06/raring-preinstalled-armel+mako.zip /sdcard/autodeploy.zip  
$ adb reboot recovery  

When the device has rebooted, and settles down to the charging icon, reboot it by hand to the recovery mode again, by booting to the bootloader and selecting recovery mode. We can now flash Ubuntu onto it:

$ adb push ~/Downloads/phablet-flash/ubuntu-touch-preview/raring/raring/monthly-06/raring-preinstalled-phablet-armhf.zip /sdcard/autodeploy.zip  
$ adb reboot recovery  

Now the device will boot into ubuntu, and you can add the demo content as before:

$ phablet-network-setup  
$ phablet-demo-setup  

If you have a Nexus 10, then substitute ‘manta’ where you see ‘mako’ above. Note that it needs both volume keys and the power button held down to get to the bootloader.

I found that sometimes this build would not populate the people lens correctly, or show the thumbnail pictures of contacts. I found that a reboot (after opening contacts in the phone app) worked to resolve it.

If you’re curious what changed to make these images ‘legacy’, it was the container switch, announced here.