Canonical Voices

Posts tagged with 'embedded'

Jussi Pakkanen

There are two different schools of thought when it comes to embedded development such as working on Ubuntu phone. The first group feels that compiling on the device is better and the other group prefers doing cross-builds. Both have their advantages and disadvantages.

One of the biggest disadvantages for compiling on-device is the fact that a reflash wipes all your state and you need to compile your project from scratch again. This is unfortunate if a fresh build takes 20 minutes (which is not that uncommon).

The question then becomes whether you can avoid this. It turns out that you can by doing a ccache transplant. Here’s how to do it.

First you install ccache and set up your project:

sudo apt install ccache
CC='ccache gcc' CXX='ccache g++' cmake <your flags>

and develop as normal. Just before reflashing do a backup:

tar czf ccachedir.tar.gz .ccache/ (on device) 
adb pull /home/phablet/ccachedir.tar.gz (on desktop)

Then flash and put your ccachedir back:

adb push ccachedir.tar.gz /home/phablet/ccachedir.tar.gz (on desktop) 
tar xf ccachedir.tar.gz (on device)

Then set up your project with the same CMake stanza as above, run your build command and you are back to having a fully up-to-date build on your reflashed device.

A test done with a small-to-medium Qt5 project dropped the build time from 6 minutes to 30 seconds.

Read more

For an embedded/thin client project without GNOME, KDE, or even full XFCE I needed a small daemon to automount USB sticks. Using the full gvfs/gdu/nautilus or Thunar stack is too heavyweight for my purposes, but a simple udev rule just doesn’t cut it — I need to mount these USB sticks for a particular user (permissions), and also want to do an action like pop up a window with the contents.

This finally provided me the opportunity to write something bigger than just a 10 line demo in Vala (well, it’s not that much bigger admittedly :-) ). Since that is my first real Vala project, it took quite a lot longer than anticipated; some areas of Vala are still a bit underdocumented, e. g. I spent some half an hour trying to find out how to set a result callback for an asynchronous function invocation. Mikkel Kamstrup Erlandsen suggested to just use a wrapper instead which uses yield, which works fine indeed. Mikkel, thanks for bearing with me!

Anyway, here it is:, complete with a first release, bzr branch (lp:udisks-automounter), and a package for Ubuntu 10.04 LTS in my PPA.

For avoidance of doubt, this won’t ever make sense on a GNOME/KDE/XFCE desktop, which already have their (much better developed) automounting services. But perhaps it’s useful for someone else with similar constraints.

Read more