Saturday, December 12, 2015

Exporting the Firefox OS Offline Calendar (Firefox OS migration part 1)

Update 2016-03-21: Improved visual appearance and simplified steps 5 onwards - conversions can be done in the browser directly now without having to use Python.


This how-to will describe a way to export the calendar entries of your Firefox OS phone and convert the data into a standard iCalendar / ICS file that can be imported into almost any program / phone / online service.

Why is this even necessary? When Mozilla introduced the Firefox OS product line it started with big promises: Just create a HTML5 application, and it will run on every device including Firefox OS. Unfortunately Mozilla forgot a few essential things, for example to include an API to access calendar data. If you have been using the offline calendar (or your CalDAV server went offline) then the calendar ended as a data sink - you can put stuff in, but you won’t get it out any more with conventional means.

When migrating to another phone (or if you want to get a useful backup copy) you may still want to migrate your calendar data. This article will guide you through this (lengthy) process. A second article for the migration of SMS / MMS data is planned.


This how-to was created on Linux with a German ALCATEL ONE TOUCH FIRE, updated to the official Firefox OS version by the provider. Just saying in case something is working differently in your setup - the instructions should be quite generic and platform independent though ;-)

Step 1: Basic setup

First things first: Both your computer and your phone will have to be configured to allow them to communicate with each other. We will configure the phone, install the Android Debug Bridge extension in Firefox and try the first connection to the phone.

  1. On your phone go to SettingsDevice / Device informationMore InformationDeveloper settings / Developer and select Remote debugging.
  2. In Firefox press the Alt key and select ToolsWeb DeveloperWebIDE in the menu.
  3. In the Firefox WebIDE select Select RuntimeUSB DEVICES / Install ADB Helper.
  4. Install the ADB Helper Add-on.
  5. Choose Select Runtime again and click on your device in the USB DEVICES section.
  6. Accept the connection request on your phone.
  7. Back in the Firefox WebIDE select RuntimeRuntime Info.
  8. Check the value of ADB is root.
  9. If it’s no click on root device.
  10. Remember if it says yes or no now (you will need it for Step 3).

If any of these steps didn’t work go to Mozilla’s troubleshooting site - you will most probably find the solution to your problem there.

Step 2: Connecting to the device on the command line

Excellent - the connection to the phone is working; unfortunately Firefox’s WebIDE doesn’t support transferring files or booting a custom kernel, so we will have to use ADB on the command line.

  1. In Firefox enter about:support into the address line.
  2. Select Application Basics / Profile Directory / Open Directory.
  3. In your file manager navigate to
  4. You will find a directory named after your operating system here (e.g. linux, linux64, win32 or mac64).
  5. Open this directory in a console (Linux / Thunar: right-click on the directory and choose Open Terminal Here; Linux / Dolphin: right-click on the directory and choose ActionsOpen Terminal Here; Windows: How to Use “Open Command Window Here” in Windows 7 (inofficial instructions); Mac OS: Open terminal here in Mac OS finder (inofficial instructions)).
  6. Make sure your phone’s display is turned on and the screen is unlocked - otherwise your device won’t be listed in the next step.
  7. Type ./adb -l (on Linux and Mac) or adb -l (on Windows).
  8. You should see the (internal) name of your device now.

Step 3: Getting root access to your device

Check if your phone is locked by the vendor and (temporarily) boot an alternative kernel if it is.

  1. Remember step 1 when we checked if ADB is root said yes or no? If it was yes: everything is fine and you can directly go to step 4.
  2. Otherwise you will have to find a kernel allowing root access for your device. You should be able to find one on - just choose your device and download the appropriate file. Note: We don’t want to flash the whole device, so most of the documentation on the site isn’t necessary.
  3. You will probably have downloaded a ZIP file - in my case I’ve downloaded the “Version 1.4” image, as that version was closest to the one installed on my phone; I’ve also tried a 2.6 image successfully, so you will probably be fine with any version you can get (don’t blame me if anything goes wrong though :-)).
  4. Extract that ZIP file - it should contain a file called boot.img, which is the one we need.
  5. Restart your phone and keep the volume down button pressed. Keep it pressed for five seconds after seeing your device manufacturer’s logo.
  6. If the manufacturer’s logo stays there you have now successfully entered fastboot mode.
  7. On the command line type ./fastboot boot "<path containing the extracted files>/boot.img" (in my case the patch was /tmp/14_20150406/boot.img; leave out the ./ at the beginning of the line on Windows; on Linux you have to be root for this command to work).
  8. Your phone should continue booting as normal.
  9. When the boot has finished and you unlocked the screen try connecting to your phone via Firefox WebIDE again - you should get ADB is root: yes now.

Step 4: Getting the data from the phone

Now that everything is working we will transfer the calendar data from the phone and store it on your PC.

  1. For the sake of convenience we will do a backup of all your data (otherwise we would have to find out the exact file name for your device first); type ./adb pull /data/local/storage on the command line (again without the leading ./ on Windows).
  2. When the transfer is complete a directory called persistent will contain a backup of your data; if you have a very recent version of Firefox OS you may have gotten three directories called default, permanent and temporary instead - this will make a difference in step 5. In any case I’d recommend using your file manager to move those directories out of the Firefox profile now and keep them in a save place ;-)
  3. If you want you can reboot your phone now (and get the original kernel back) - we have all the data we need.

Step 5: Importing the data into Firefox

You just backed up several SQLite files.

In case you are interested some technical background: Firefox OS is using IndexedDB to store it’s data. IndexedDB itself is using an SQL database, however the data is not stored in plain text, but only as an internal serialized representation; this is also the reason why we can only use Firefox to decode the data again: Other browsers have different internal representations and wouldn’t be able to decode it. Fortunately the serializer is the same for desktop Firefox and Firefox OS…

The data will be imported into Firefox now. IndexedDB data is always connected to a specific URL, so we will have to create a fake one.

If your phone’s backup data resides in a directory called persistent proceed with step 5a, if you got default and permanent instead proceed with step 5b.

Step 5a: When you got a “persistent” directory

  1. You got the data in an old format. In the following steps a new profile will be created, as the databases have to be migrated to Firefox’s new internal format first.
  2. Close Firefox.
  3. Start Firefox’s ProfileManager by typing firefox --ProfileManager --new-instance on the command line.
  4. Click Create Profile….
  5. Click Next.
  6. Enter a profile name (e.g. Firefox OS import)
  7. Remember the directory that is shown in the middle of the dialogue and click Finish.
  8. Don’t start Firefox yet!
  9. Open the directory you just created in your file manager - it should be almost empty.
  10. In the profile directory create a new directory called storage.
  11. In the storage directory create another directory called persistent.
  12. Inside persistent create another directory called
  13. Inside that directory create a directory called idb.
  14. Now copy all the calendar data from your phone backup into this directory. You will need the sqlite and sqlite-journal files - on my device they were located in persistent/
  15. Now you can finally start Firefox - but make sure that Use the selected profile without asking at startup is not selected; Firefox will migrate the data to it’s new storage format, so don’t be surprised when the directories you just created don’t exists any more afterwards.

Step 5b: When you got a “default” directory

  1. Switch to your file manager: The default directory of your phone backup data should contain a directory ending with
  2. Copy this directory into the directory storage/default of your Firefox profile.
  3. Now rename the directory to

Step 5: Continued (both cases)

  1. In Firefox open the URL If you just created a new Firefox profile (Step 5a) use the new browser window to open the URL!
  2. Click on Export database and press the Export button to get a dump of all related databases.

If the page just says Done without any further output you probably didn’t create the directories correctly - remove the storage directory in the profile and try again…

Step 6: Convert the data into ICS format

Now the only remaining step is to convert the data into something usable by other programs - we will use iCalendar / ICS files for this purpose.

  1. The required data can be found in the section events.
  2. Just click the button Convert Calendar data to ICS file below that textfield.
  3. Now you can save the converted data using the Save button.

Congratulations, you have made it. You should have a new file called “events.ics”, a standard ICS file containing all your Offline Calendar entries, now - use it with any program you like.


This sounds complicated - isn’t there any easier way

I’m not aware of any - as said Firefox OS doesn’t provide any API for calendar access. Syncto aimed to provide calendar synchronization among others, but as far as I can see only Bookmarks and History synchronization are implemented. Backup and Restore Firefox OS data (and a few others) are essentially doing the same, but don’t provide a way to export the data (i.e. they are missing steps 5 & 6).

I don’t want to upload my data to you!

You won’t - the whole export / conversion process happens locally on your computer.

I don’t understand how to do xxx

Feel free to use the issues section on GitHub and ask away!


The following sites were particularly useful for finding out about Firefox OS’ way of operation:
Hacking FirefoxOS: Excellent information about flashing and building a custom kernel for your Firefox OS phone
Firefox OS Builds, imágenes Vanilla actualizadas para ZTE y Alcatel (Spanish): I found out about / here; links to Firefox OS builds for Alcatel and ZTE phones
Actualización de Firefox OS 1.0 y 1.1 a Firefox OS 1.3 , 1.4 Y 2.0 (Spanish): Another blog with links to Alcatel images
Instalado las roms de Firefox OS (Spanish): And another blog with a detailled flashing guide
iCalendar documentation
IndexedDB: Subdomain Quota Management: Mozilla bug documenting the movement of the IndexedDB directories
idbbrowser: Browse Firefox’s IndexedDB databases used to provide images for different phones, but unfortunately that site doesn’t exist any more.

Sunday, April 19, 2015

Troubleshooting Unity engine games on Linux

Deutsche Version

Problem: Mouse constantly moving to the top / game freezes after a few seconds

Some games using the Unity 4 engine seem to be affected by a problem using the mouse: Typically the mouse is constantly moving up to the top of the screen and the picture is freezing after a few seconds. If you change to another application via Alt + Tab and change back to the game again (in some environments clicking a mouse button in the game is also sufficient), picture and mouse will move for a few seconds again. Especially games played from a first person perspective are affected.

Known workarounds

Workaround option 1
Play the game in window mode and set the resolution to your native resolution minus the width of your window decoration (e.g. 1912×1072 instead of 1920×1080) or lower. The game’s configuration file where you can adjust those settings can be found in ~/.config/unity3d/<Developer name>/<Game name>/prefs

Workaround option 2
Use another window manager (e.g. openbox, fluxbox, blackbox, wmaker, fvwm2, twm are known to work).

Other workarounds
KDE users may also try the following: http://steamcommunit … #c846965882766096888

Affected games

I’m currently aware of the following games still affected, which is almost certainly not a complete list. Whether the problem occurs or not seems to be dependent on the mouse polling rate and window manager, so just because those games are listed here doesn’t necessarily mean you will also get this problem.

  • Doorways
  • Surgeon Simulator 2013
  • Gone Home
  • Ravensword
  • MirrorMoon EP
  • Jazzpunk
  • Galak-Z
  • Nimble Quest

Problem: Strange things are happening in the game

Some Unity 4 games don’t like non english locales. Typical symptoms when this happens are events that won’t be triggered or will be triggered only after a long delay, overlapping graphical elements in the user interface or a black screen after loading the main game.

Or in other words: If a Unity based game doesn’t work as expected just try this workaround :-)


Start the game e.g. on the command line with the variables LC_ALL=C LANG=C; for example Ravensword would be started with

LC_ALL=C LANG=C ./rs2.x86

Problem: The game doesn’t start, xxx is corrupted

If the game doesn’t start (i.e. it just crashes or only shows a cursor on a black screen) and the log file in ~/.config/unity3d/<Developer name>/<Game name>/Player.log contains messages such as

Error (8/12/2017 6:10:57 PM) - The file '<installation directory>/<Game name>/<Game name>_Data/resources.assets' is corrupted! Remove it and launch unity again!
[Position out of bounds! 875850853 > 69016]

then you will need to install lsb_release to get the game working.

Known affected games

  • Caravan
  • The Raven: Legacy of a Master Thief

Wednesday, February 20, 2013

Setting the default wallpaper and theme in KDE4

Google didn’t know the answer, so here’s the solution:



and set the appropriate entries.

You can also put this file into your Kiosk profile, the location would be

<path to your Kiosk profile>/share/apps/desktoptheme/default/metadata.desktop


Thursday, November 17, 2011

Backing up your physical media (like CDs / DVDs) including copy protection

When my first floppy discs slowly went unreadable I finally decided to create images of all of my physical media. However this is not as trivial as one would think: A lot of discs (especially games) have copy protections included, so you have to plan what you want to do. My goal is always to create 1:1 copies of the original discs. Please also note that the following information is to the best of my knowledge and / or future hardware may be able to circumvent some of today’s limits (though I doubt that’s too likely).

Without copy protection

ISO / disc dumps

Both terms are equivalent - a file used for optical media (CD, DVD, BlueRay) is usually called an ISO image, while images of other media (floppies, hard discs) often have the ending .img.

These images can be easily created with the UNIX command ‘dd’:

dd if=/dev/<device_you_want_to_make_the_image_from> of=<filename_of_the_image>

Note: While various forum entries praise these commands as the panacea of all copying needs, dd is in fact quite limited or even useless when dealing with copy protections. As dd operates on the UNIX file system, it can only copy the data section of any media - additional information like subchannel data is not visible on this layer and thus cannot be saved. Additionally dd will abort at any read error (or alternatively it will write zeros or skip those sectors completely) - even the most simple protections will check if the error is still there, which wouldn’t be the case any more. And dd will only save the first track of a disc, making it worthless to create copies of Mixed Mode or Audio CDs.


This format has a lot of similarities to the ISO format - in fact, if the media has only a single session the resulting .bin file is exactly the same as the ISO file from above. The difference is that it is possible to store several tracks at once: The .bin file contains the binary data, the .cue file tells where and how to split the file for the individual tracks.

While the format is not an official standard it is easy to understand and has broad support among programs (e.g. almost every burning software and DOSBox, which will also play the audio tracks; notable exceptions are Virtual Machines (VMWare, VirtualBox) which are usually limited to ISO images / disc dumps).

The following commands will create the files:

cdrdao read-cd --datafile <filename>.bin --driver generic-mmc:0x00020000 --device /dev/<CD_DEV> <filename>.toc
toc2cue <filename>.toc <filename>.cue

This first command will create this .bin file and a .toc file (instead of expected .cue file). cdrdao is using the toc files internally, but it offers the converter toc2cue to generate the more common CUE file from that. Another thing to note is the option “–driver generic-mmc:0×00020000”: Most modern CD drives will return audio data in little endian order, however most programs expect the data in big endian order. You can also switch the order later, you can find a handly little program on

Note: I couldn’t get cdrdao to create usable images of copy protected discs, though the options “–read-raw” and “–read-subchan=rw_raw” sounded like they could do so (though the later option will create BIN/CUE files which are not compatible with other programs).

Copy protected discs

Old protection systems (- ~2002)

Old protection systems are based on defect sectors and / or subchannel data. Both of them can be stored with cdrecord:

readcd dev="/dev/<CD_DEV>" -clone -nocorr retries=0 f="<filename>.raw"

New protection systems

… will not work. The reason is simple: The current hardware is not able to create images that are exactly like the original - some programs check for physical properties of the disc, others will create unreachable sectors etc.

While workarounds DO exist it, they require emulation, modified binaries or additional data on the discs. The manufacturers of copy protection mechanisms finally seem to have found a way to really prevent to be able to copy a CD…

Even if the hardware should support all those techniques one day, you still have to invent a new image format to be able to store that information in Linux and extend the burning software to use it.

Wednesday, September 7, 2011

Videos on Squeezebox Radio / Touch / Controller

Note: This blog post is the long version of the article. For a short HOWTO better visit the Squeezebox forum post.


Welcome to another chapter of the series “Making devices do things they weren’t designed for” ;-)

Before you get too excited because of the title I should probably warn you: This solution is a hack. When following this guide you will be bypassing SqueezePlay (meaning no integration into the devices’ GUI) and the solution is not really straightforward either (i.e. more complicated than you may be willing to accept). Also a decent amount of Linux knowledge is required.

Looking on the bright side: You will be able to watch videos after this tutorial - you may even want to experiment yourself and find more effective ways to do some things or work on the integration into SqueezePlay and Logitech Media Server :-)

This article was written using a Squeezebox Radio, however I don’t see any reason why it shouldn’t also work for the Squeezbox Touch or Squeezebox Controller. If you try it with any of those please drop me a note if it worked!

The goal

Watching videos on the Squeezebox!


The hardware

Newer Squeezebox devices (i.e. all devices with a LCD display) have an ARM processor and are running an embedded Linux. The devices aren’t really powerful - Radio has a 400 MHz CPU with integrated audio acceleration, but no floating point or video acceleration unit. In fact it is way too slow to play most of today’s video contents from the web, as most newer codecs (like MPEG4/H.264 or OGG Theora) require a lot of computing power.
The embedded Linux system is very minimal and mainly exists to run SqueezePlay (called jive in the process list), using a framebuffer driver for graphics and an ALSA driver for audio output. The system itself, using kernel, is stored on 128MB of flash memory, which is formatted with UBIFS.
To access the device we will be using SSH (if you are on Windows you may use Putty or similar programs for this).

Choosing a video player

We want to play videos, so we have to find some video playback program that can be used on the Squeezebox. There are several good video players for Linux, and most of them will run on Squeezebox’ ARM architecture. The only additional requirement is framebuffer output, as that is everything the Squeezebox has. Several candidates match these requirements, among them are

In this tutorial we will be using MPlayer because it has a few advantages which make it perfect for a quick hack:

  • The package is self contained, i.e. it already contains all required libraries, making it much easier to compile
  • Most of the libraries can be statically linked into the binary, so only a few additional files are needed on the Squeezebox.

Compiling MPlayer

Note: This step can be quite a lengthy process, so you may just skip it and download the binaries I have built from here instead: http://digitalimagec … s/mplayer_arm.tar.gz
(You may also try to use a mplayer binary from another Linux distribution for ARM, however those usually have a lot of dependencies…)

First you have to set up a cross compile environment to build MPlayer for the Squeezebox. Please follow the instructions from SqueezeOS Build Instructions Wiki page to do so.

When you have set up your environment download the MPlayer source and extract it. Change to the directory containing the MPlayer source and enter the following commands:

SQUEEZEOS="<enter path containing the poky directory from your SqueezeOS checkout>"
./configure --enable-cross-compile --host-cc=gcc --cc="${SQUEEZEOS}/poky/build/tmp-jive/cross/armv5te/bin/arm-none-linux-gnueabi-gcc" --target=arm-linux --enable-alsa --extra-cflags=-I"${SQUEEZEOS}/poky/build/tmp-jive/staging/armv5te-none-linux-gnueabi/usr/include" --extra-ldflags=-L"${SQUEEZEOS}/poky/build/tmp-jive/staging/armv5te-none-linux-gnueabi/usr/lib"

Your will find the resulting binary in the root directory of the MPlayer source. You will also need three libraries from your SqueezeOS build:, and

MPLAYERFILES="<enter a path where you want to store the files for your Squeezebox>"
cp mplayer "$MPLAYERFILES"
cp "${SQUEEZEOS}/poky/build/tmp-jive/work/armv5te-none-linux-gnueabi/ncurses-5.4-r11/image/usr/lib/"
cp "${SQUEEZEOS}/poky/build/tmp-jive/work/armv5te-none-linux-gnueabi/lzo-2.02-r1/image/usr/lib/"
cp "${SQUEEZEOS}/poky/build/tmp-jive/work/armv5te-none-linux-gnueabi/jpeg-6b-r6/image/usr/lib/"

(The version numbers of the libraries are from SqueezeOS 7.7, change them if you use another version.)

Finding a /home

Now that we finally got our binaries we just have to copy them to our Squeezebox and use them. But - surprise - there’s trouble ahead: The root file system doesn’t have enough space to store our files. And even worse: We can’t change that: The (old) kernel doesn’t support mounting more than one UBIFS file system, so even if we add another UBIFS volume using unallocated space we will not be able to mount it - see http://lists.infrade … 009-July/026422.html for details.
However ‘df’ reveals another possible location for our files: /dev. When looking at the ‘mount’ output we see can see that it’s mounted with tmpfs, so we will loose all files from there after a reboot - but hey, we don’t have any other chance, do we?

So for now, copy the mplayer binary and the library files to your Squeezebox:

scp "$MPLAYERFILES"/* root@<IP of your Squeezebox>:/dev

Trying to play a video

If you want you can try to play a video now. First of all make sure that your device is turned on (i.e. you can see the menu). Now log into your Squeezebox and enter the following commands:

cd /dev

Not very successful, is it? Press Ctrl+C to cancel the video. It seems that the video won’t start because the audio device cannot be opened. Looking around which process is blocking the device we see that it’s Jive. Rings a bell? This is the Squeezebox GUI…

Let’s try to turn it off:

/etc/init.d/squeezeplay stopwdog     # Important: Always use the option "stopwdog" (instead of "stop"), otherwise your Squeezebox will reboot after a few seconds.

Well… At least we are seeing something. You may have noted a few things:

  1. The picture is rotated
  2. Even if it would have the correct orientation it would be too big
  3. The movie is way too slow
  4. The sound is way too loud (if there was any)

Let’s try to optimize things a bit:

./mplayer -volume 50 -vf rotate=2,scale=240:320 -vfm ffmpeg -vo fbdev -framedrop

Still too slow, but we’re coming closer otherwise.

Let’s try the same command, but this time with a MPEG-1 video instead of MPEG-4:

./mplayer -volume 50 -vf rotate=2,scale=240:320 -vfm ffmpeg -vo fbdev -framedrop

Finally! Not perfect, but something we can start with.

Recoding the video

As we can see the Squeezebox isn’t fast enough for any real world video playback, so we have to recode the videos (similar to watching videos on Sony’s PSP ;-)).

There are dozens of video transcoding programs for all platforms - it doesn’t matter what program or operating system you use for this step. You do, however, have to put the transcoded video on a webserver or provide a live stream (i.e. some remote protocol mplayer can handle like HTTP, FTP or RTP) if you are using a Squeezebox Radio; Touch and Controller users should also be able to use the external storage. Personally I’m using an Excito B3, a small Linux based NAS, to convert and serve the videos via HTTP.

I’m using ffmpeg for video conversion. Another popular program (also available for Windows users) would be VLC which also offers a graphical interface. Both programs also support video streaming, so if your PC is fast enough you may try to recode your video in realtime.

Example: My daily script to recode the stream at 8:00 PM

#!/bin/bash -x

# Get the filename of the stream and periodically check if has been uploaded yet
cd /tmp
filepattern="`date +http://media\\\.tagesschau\\\.de/video/%Y/%m%d/TV-%Y%m%d-.*\\\.h264\\\.mp4`"
while [ ! "$filename" ]; do
        filename=`grep -o "$filepattern" index.html`
        rm index.html
        if [ ! "$filename" ]; then
                let retries++
                if [ $retries -gt 60 ]; then
                        rm "$VIDEOFILE"
                        exit 1;
                sleep 180;

# Convert the stream
ffmpeg -y -i "$filename" -vcodec mpeg1video "$VIDEOFILE"

Btw: If anyone finds an all-purpose call for ffmpeg converting from any format to something suitable for the Squeezebox please post a comment :-)

Mission accomplished: Now just play your converted file, using the playback command from the last chapter :-)

Bonus: Automatic video playback

If you want to initiate playback remotely there are a few other things to consider: First of all the speaker is turned off when the Squeezebox is not active, so it has to be turned on first. I’m using the CLI interface of the Logitech Media Server to do so. To automate the calls you should also log in to your Squeezebox with a certificate (instead of username and password) to avoid being asked to enter them manually.

The following script is run on my server hosting the Logitech Media Server:


DEVICENAME="<Name of your Squeezebox device (from Logitech Media Center)>"
SQUEEZEBOX="<IP or DNS name of your Squeezebox device>"
VIDEO_URL="<URI of the file to be played (e.g.>"
USERNAME="" # Only required if your Logitech Media Server is password protected
PASSWORD="" # Only required if your Logitech Media Server is password protected

# Turn on Squeezebox
cat << EOF | expect
        spawn nc -q 3 localhost 9090
        sleep 2
        if { "$USERNAME" != "" } {
                send "login $USERNAME $PASSWORD\r"
        send "$DEVICENAME power 1\r"
        send "$DEVICENAME display Video%20playback%20will%20begin shortly... 60\r"
        expect "shortly"

# Copy required programs to the Squeezebox
cd /opt/squeezebox
scp mplayer root@${SQUEEZEBOX}:/dev

# Remotely prepare the Squeezebox and play the video
ssh root@${SQUEEZEBOX} " \
  /etc/init.d/squeezeplay stopwdog; \
  cd /dev; \
  export LD_LIBRARY_PATH=.; \
  ./mplayer -volume 50 -vf rotate=2,scale=240:320 -vfm ffmpeg -vo fbdev -framedrop "$VIDEO_URL"; \
  /etc/init.d/squeezeplay restart; \