Link Search Menu Expand Document

Sailfish X Xperia Android 9 Build and Flash

Sailfish OS Hardware Adaptation Development Kit for Sony Xperia 10

Here you will find instructions how to build Sailfish OS image and flash it to Sony Xperia 10 device, which can be used as reference to port any other Sony Xperia Open Device that has Android 9 support.


  • 2020-06-16: Align with the latest build scripts
  • 2019-07-02: Adapt from Xperia XA2 flash and build instructions


Please download the latest Sailfish OS HADK (Hardware Adaptation Development Kit) from within this link.

Minimum Sailfish OS version for this port is

If you are new to HADK, please carefully read the disclaimer on page 1, then chapters 1 and 2.

The disk space requirement for this build is not what HADK says, but around 200GB . The download size requirement is around 50GB.

HADK uses LineageOS/CyanogenMod as reference base. Here we’ll instead have AOSP (Android Open Source Project) 9.0. Now you can read through chapter 3 of the HADK.

If you ever run into difficulties, please look through the links in the topic of the #sailfishos-porters channel on IRC at

In chapter 4 (Setting up the SDKs) setup the environment as requested in ~/.hadk.env, but then set and add the following additional variables (here we’ll build for Sony Xperia 10 Dual SIM variant):

export VENDOR=sony
export DEVICE=i4113
export HABUILD_DEVICE=kirin
export FAMILY=ganges

Follow through the chapter 4 until the end, and ignore chapter 5, instead perform the following:


git config --global "Your Name"
git config --global ""

You’ll need to ensure you have the repo command from the AOSP source code repositories installed. See the Android Source instructions for how to install it. Once available you can continue:


sudo apt-get install cpio libssl-dev
sudo mkdir -p $ANDROID_ROOT
sudo chown -R $USER $ANDROID_ROOT
git clone --recurse-submodules$FAMILY-$ANDROID_FLAVOUR .
ln -s ../dhd rpm/
mv rpm dhd-rpm
repo init -u -b $HAVERSION -m tagged-manifest.xml
# Adjust X to bandwidth capabilities
repo sync -jX --fetch-submodules
mv rpm droid-src
ln -s droid-src/patches .
droid-src/ --mb
mv dhd-rpm rpm
./ --mb

source build/
export USE_CCACHE=1
lunch aosp_$DEVICE-user
git clone external/droidmedia
make -j$(nproc --all) hybris-hal droidmedia

If you encounter errors, check with HADK’s section 5.5 “Common Pitfalls”.

Once you have hybris-boot.img and hybris-recovery.img files successfully built, go through chapter 6 of the HADK document.

Ignore chapter 7, but do the following instead:


sudo zypper ref
(cd kernel/sony/msm-4.9/kernel; git add drivers/staging/wlan-qc) # build fail workaround until mb -X is somehow worked into
rpm/dhd/helpers/ --droid-hal
git clone --recursive$FAMILY-$ANDROID_FLAVOUR hybris/droid-configs -b master
if [ -z "$(grep community_adaptation $ANDROID_ROOT/hybris/droid-configs/rpm/droid-config-$DEVICE.spec)" ]; then
  sed -i '/%include droid-configs-device/i%define community_adaptation 1\n' $ANDROID_ROOT/hybris/droid-configs/rpm/droid-config-$DEVICE.spec
if [ -z "$(grep patterns-sailfish-consumer-generic $ANDROID_ROOT/hybris/droid-configs/patterns/jolla-configuration-$DEVICE.yaml)" ]; then
  sed -i "/Summary: Jolla Configuration $DEVICE/i- patterns-sailfish-consumer-generic\n- pattern:sailfish-porter-tools\n" $ANDROID_ROOT/hybris/droid-configs/patterns/jolla-configuration-$DEVICE.yaml
rpm/dhd/helpers/ --configs
cd hybris/mw/libhybris
git checkout master
cd -
rpm/dhd/helpers/ --mw=
rpm/dhd/helpers/ --mw # select "all" option when asked

Without waiting for the middleware to finish, open new terminal window shell and enter:


sudo apt-get install rsync
sudo mkdir -p $ANDROID_ROOT-syspart
sudo chown -R $USER $ANDROID_ROOT-syspart
cd $ANDROID_ROOT-syspart
# if you plan to contribute to syspart (/system partition), remove "--depth=1" and "-c" flags below
repo init -u -b $HAVERSION -m tagged-manifest.xml --depth=1
# Adjust X to bandwidth capabilities
repo sync -jX --fetch-submodules -c
ln -s rpm/patches .
rpm/ --mb

source build/
export USE_CCACHE=1
lunch aosp_$DEVICE-user
# Ensure the middlware in the previous terminal window has finished building
# Change $(nproc --all) to your building capabilities, it will be very heavy on RAM if you go for more cores, proceed with care:
make -j$(nproc --all) systemimage vendorimage
# ^ this might take some time (2 hours on Intel Xeon's 12 cores)

sudo mkdir -p $ANDROID_ROOT-mnt
# ensure your /tmp has ~4GB available
simg2img out/target/product/$HABUILD_DEVICE/system.img /tmp/system.img.raw
sudo mount /tmp/system.img.raw $ANDROID_ROOT-mnt
cd $ANDROID_ROOT/hybris/mw
git clone --recursive$D
cd $D
# The following command may throw up patch errors for `init.wod.rc` and `ld.config.29.txt`. These are to be expected and can be ignored.
sudo droid-system-device/helpers/ $ANDROID_ROOT-mnt/system rpm/droid-system-$HABUILD_DEVICE.spec
# You can commit the changes, but before you push them out, make sure:
# - to check binary file/repo size limits
# - to rename the public repo as droid-system-sony-$FAMILY-$HABUILD_DEVICE
# - to not contribute binary files to this *-template repo
sudo chown -R $USER .
sudo umount $ANDROID_ROOT-mnt
rm /tmp/system.img.raw
cd $ANDROID_ROOT-syspart
simg2img out/target/product/$HABUILD_DEVICE/vendor.img /tmp/vendor.img.raw
sudo mount /tmp/vendor.img.raw $ANDROID_ROOT-mnt
cd $ANDROID_ROOT/hybris/mw
git clone --recursive$D
cd $D
# The following command may throw up patch error for `init.wod.rc`. These are to be expected and can be ignored.
sudo droid-system-device/helpers/ $ANDROID_ROOT-mnt rpm/droid-system-vendor-$HABUILD_DEVICE.spec
sudo chown -R $USER .
sudo umount $ANDROID_ROOT-mnt
rm /tmp/vendor.img.raw

You can now close the HABUILD_SDK (syspart) terminal window. Next, please proceed with:


rpm/dhd/helpers/ --gg

sdk-assistant maintain $VENDOR-$DEVICE-$PORT_ARCH zypper in --force-resolution droid-hal-$HABUILD_DEVICE-kernel-modules
rpm/dhd/helpers/ --mw=$FAMILY-$ANDROID_FLAVOUR --spec=rpm/droid-hal-$HABUILD_DEVICE-img-boot.spec

rpm/dhd/helpers/ --mw=$ANDROID_FLAVOUR-template --spec=rpm/droid-system-$HABUILD_DEVICE.spec --spec=rpm/droid-system-$HABUILD_DEVICE-$DEVICE.spec
rpm/dhd/helpers/ --mw=$ANDROID_FLAVOUR-template --spec=rpm/droid-system-vendor-$HABUILD_DEVICE.spec --spec=rpm/droid-system-vendor-$HABUILD_DEVICE-$DEVICE.spec

git clone --recursive$FAMILY hybris/droid-hal-version-$DEVICE
rpm/dhd/helpers/ --version

# The next two variables are explained in chapter 8
sudo zypper in lvm2 atruncate pigz
sudo zypper in android-tools
rpm/dhd/helpers/ --mic

If you want to rebuild your image again later, umount any /var/tmp/mic/imgcreate-*/ mounts manually.

The command above will yield a flashable archive, such as $ANDROID_ROOT/sfe-i4113- that you will use to flash your device as explained in the next section.


All the instructions you will find on our website (yet use your own built .zip bundle!):

Note: in you will need to replace @DEVICES@ with your $DEVICE value in uppercase, e.g. I4113. Naturally, after that you’ll need to adjust or remove the line containing in the md5.lst file.

Adaptation Status

Currently alpha. Feel free to help out in areas that you like:

  • What works: telephony, mobile data, UI, WLAN, GPS, Bluetooth, Camera, internet sharing, operator names in manual network select, (internal) OTA updates,
  • GPS fix holds better than of XA2 (feel free to compare the adaptation implementations)
  • only version --dup can be used to update (Update UI doesn’t work yet)
  • Community OTA updates will work only when OBS repos and packages are setup (feel free to become a maintainer of those)
  • Sensors work except compass
  • Charging mode doesn’t work, phone boots to SFOS UI, so if your battery is really low, it might take one or more reboot cycles to keep charging without shutdown (plug into a strong wall charger)
  • Home partition encryption should now be enabled for community build against 3.1.0, but has not been tested (^ device would then happily continue charging during security code input in the minimal UI boot environment)
  • An issue with side swipes from the middle of the screen (fix coming in 3.2.0)
  • Graphics works but not 100% stable (that has been fixed)
  • Fingerprint works but it’s hard to get it to run (might be fixable with a startup/wait script similar to nile which executes /system/bin/wait_for_keymaster) - currently no packages added to patterns (see XA2)
  • NFC should work, the packages haven’t been added - feel free to take this simple task (look how it’s done in XA2)
  • Non-productised things such as battery drain are still possible in such stages of this port (WLAN drain improvements are tangible and currently WIP)


If you find bugs while building an image from this page, please report them in our IRC channel.

Have fun and enjoy the fully-flashable Sailfish OS image built by you! Your Jolla HW Team