Link Search Menu Expand Document

Sailfish X Xperia Android 10 Build and Flash

Sailfish OS Hardware Adaptation Development Kit for Sony Xperia 10 II

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


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

Please check the requirements for your build host:

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) 10.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 II Dual SIM variant):

export VENDOR=sony
export DEVICE=xqau52
export HABUILD_DEVICE=pdx201
export FAMILY=seine

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


sudo apt-get install cpio libssl-dev ccache
sudo mkdir -p $ANDROID_ROOT
sudo chown -R $USER $ANDROID_ROOT
git clone --recurse-submodules$FAMILY .

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:

# To save space, you can add "--depth=1 -c" flags to repo init:
repo init -u -b $HAVERSION -m tagged-localbuild.xml
# Adjust X to bandwidth capabilities
repo sync -jX --fetch-submodules
git clone --recurse-submodules droid-src -b "hybris-"$HAVERSION
ln -s droid-src/patches
droid-src/ --mb
./ --mb

source build/
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
lunch aosp_$DEVICE-user
cd kernel/sony/msm-4.14/common-kernel
./ -d $HABUILD_DEVICE -O $ANDROID_ROOT/out/target/product/$HABUILD_DEVICE/obj/kernel || echo ERROR: kernel build failed, please inspect the log file
# FIXME after this is merged:
cp dtbo-$HABUILD_DEVICE.img $ANDROID_ROOT/out/target/product/$HABUILD_DEVICE/dtbo.img
cd -
git clone external/droidmedia
make -j$(nproc --all) hybris-hal droidmedia
# This might take some time (1 hour on Intel Xeon's 12 cores)

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

Once you have hybris-boot.img, hybris-recovery.img, and droidmedia files (including mini*service et al.) successfully built, go through chapter 6 of the HADK document.

Ignore chapter 7, but do the following instead:


sudo zypper ref
rpm/dhd/helpers/ --droid-hal
git clone --recursive$FAMILY hybris/droid-configs -b master
if [ -z "$(grep patterns-sailfish-consumer-generic $ANDROID_ROOT/hybris/droid-configs/patterns/patterns-sailfish-device-configuration-$" ]; then
  sed -i "/Summary: Jolla Configuration $DEVICE/aRequires: patterns-sailfish-consumer-generic\n\n# Early stages of porting benefit from these:\nRequires: patterns-sailfish-device-tools" $ANDROID_ROOT/hybris/droid-configs/patterns/patterns-sailfish-device-configuration-$
# Clean out unavailable packages
if [ -n "$(grep ofono-modem-switcher-plugin $ANDROID_ROOT/hybris/droid-configs/patterns/patterns-sailfish-device-adaptation-$" ]; then
  sed -i "/ofono-modem-switcher-plugin/d" $ANDROID_ROOT/hybris/droid-configs/patterns/patterns-sailfish-device-adaptation-$
if [ -n "$(grep ofono-vendor-qti-radio-plugin $ANDROID_ROOT/hybris/droid-configs/patterns/patterns-sailfish-device-adaptation-$" ]; then
  sed -i "/ofono-vendor-qti-radio-plugin/d" $ANDROID_ROOT/hybris/droid-configs/patterns/patterns-sailfish-device-adaptation-$
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 shell terminal.


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
export CCACHE_EXEC=/usr/bin/ccache
lunch aosp_$DEVICE-user
# Ensure the middleware in the previous shell terminal 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.5 hours on Intel Xeon's 12 cores)

mkdir -p $ANDROID_ROOT-tmp
sudo mkdir -p $ANDROID_ROOT-mnt-system
simg2img $ANDROID_ROOT-syspart/out/target/product/$HABUILD_DEVICE/system.img $ANDROID_ROOT-tmp/system.img.raw
sudo mount $ANDROID_ROOT-tmp/system.img.raw $ANDROID_ROOT-mnt-system

sudo mkdir -p $ANDROID_ROOT-mnt-vendor/vendor
simg2img $ANDROID_ROOT-syspart/out/target/product/$HABUILD_DEVICE/vendor.img $ANDROID_ROOT-tmp/vendor.img.raw
sudo mount $ANDROID_ROOT-tmp/vendor.img.raw $ANDROID_ROOT-mnt-vendor/vendor

cd $ANDROID_ROOT/hybris/mw
git clone --recursive$D
cd $D
# The following command will throw up patch errors for `init.wod.rc` and `ld.config.28.txt`. These are to be expected and can be ignored.
sudo droid-system-device/helpers/ $ANDROID_ROOT-mnt-system/system $ANDROID_ROOT-mnt-vendor/vendor 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-vendor/vendor
sudo umount $ANDROID_ROOT-mnt-system
rm $ANDROID_ROOT-tmp/{system,vendor}.img.raw
sudo rm -rf $ANDROID_ROOT-mnt-{system,vendor}
rmdir $ANDROID_ROOT-tmp || true

You can now close the above shell terminal. Next, please proceed with:


rpm/dhd/helpers/ --gg

rpm/dhd/helpers/ --mw=$FAMILY --spec=rpm/droid-hal-$HABUILD_DEVICE-img-boot.spec

rpm/dhd/helpers/ --mw= --spec=rpm/droid-system-$HABUILD_DEVICE.spec --spec=rpm/droid-system-$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
export RELEASE=
export EXTRA_NAME=-my1
sudo zypper in lvm2 atruncate pigz android-tools
sed -i "s @DEVICEMODEL@ $DEVICE " $srcks
rpm/dhd/helpers/ --mic

The command above will yield a flashable archive, such as $ANDROID_ROOT/SailfishOS-release-<version>-<device>-my1/SailfishOS--my1-<version>-<device>-<hw-version>.zip that you’ll use to flash your device as explained in the next section.


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

Adaptation Status

Feel free to help out in areas that you like. The list of known issues can be found here:


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