Sailfish X Build and Flash
Sailfish OS Hardware Adaptation Development Kit for Sony Xperia X
Here you will find instructions how to build Sailfish OS image and flash it to Sony Xperia X (F5121) device.
- 2017-10-11: EDGE variable added for cutting and bleeding flavours of the HW adaptation
- 2017-10-10: Switching to blobless builds, you no longer have to download SW binaries to build things, will only need them to flash the image (we recommend to start your dev environment from scratch at this point)
- 2017-10-07: Each
repo initbelow now points to the
tagged-manifest.xml, which means a complete re-init, re-sync, and rebuild is required to fix the recent mobile data issue.
- 2017-09-29: Bluetooth is now enabled, you are welcome to test its profiles and fix up as many as you can (ping
jusain IRC for guidance).
Browser video playback fixed.
Camera video recording fixed.
General performance boosted by enabling all 6 CPU cores.
- 2017-09-26: droid-configs has been updated to fix the
nothing provides requested droid-hal-version-f5121error
- 2017-09-23: Starting with HADK v2.0.1, using Platform SDK Target version 2.1.1 is now in force (this also fixes GPS on Sailfish X). You can either rebuild from ground up, or remove your target like so:
PLATFORM_SDK $ sdk-assistant remove $VENDOR-$DEVICE-$PORT_ARCH # Then go through chapter 6 of HADK >=2.0.1, and all the $PLATFORM_SDK snippets of this wiki again
Please download the latest Sailfish OS HADK (Hardware Adaptation Development Kit) from within this link.
If you have used HADK v1.9.9 before and have it already setup, please install newly required packages to your HABUILD_SDK environment in section 4.4.2. If you used v1.2.0 or older, you'll need to start from scratch with HADK v2.
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 16GB as HADK says, but around 80GB. The download bandwidth requirement is around 20GB, but can be reduced to half as much if you add
--depth=10 to each
repo init command and
--current-branch to each
repo sync throughout this guide below.
HADK uses CyanogenMod as reference base. Here we'll instead have Sony's stock Android (6.0.1 or 7.x) – these are the versions that are supported by Sailfish X and need to be flashed to your Sony before flashing Sailfish OS image. Now you can read through chapter 3.
If you ever run into difficulties, we're there to help in the #sailfishos-porters channel on IRC at Freenode.
In chapter 4 (Setting up the SDKs) setup the environment with:
- Also add
HABUILD_DEVICE=suzunext to them in the ~/.hadk.env
- As well as
EDGE=cuttingif you want stable HW adaptation (default), or
EDGE=bleedingif you want the current state of the adaptation, but there be dragons including potential build breakers ;)
Follow through the chapter 4 until the end, and ignore chapter 5, instead perform the following:
PLATFORM_SDK $ git config --global user.name "Your Name" git config --global user.email "email@example.com" ubu-chroot -r $PLATFORM_SDK_ROOT/sdks/ubuntu
At this point, install Android's repo tool: https://source.android.com/source/downloading#installing-repo. Then
HABUILD_SDK $ sudo mkdir -p $ANDROID_ROOT sudo chown -R $USER $ANDROID_ROOT cd $ANDROID_ROOT BRANCH="upgrade-2.1.3-" [ "$EDGE" == "bleeding" ] && BRANCH="" repo init -u git://github.com/mer-hybris/android.git -b "$BRANCH"hybris-sony-aosp-6.0.1_r80-20170902 -m tagged-manifest.xml # Adjust X to your bandwidth capabilities repo sync -jX (cd rpm; git submodule init; git submodule update) source build/envsetup.sh export USE_CCACHE=1 lunch aosp_$DEVICE-userdebug # Adjust XX to your building capabilities make -jXX hybris-hal
If you encounter errors, check with HADK's section 5.5 "Common Pitfalls", and if it's not there, ask us on IRC.
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:
PLATFORM_SDK $ cd $ANDROID_ROOT rpm/dhd/helpers/build_packages.sh --droid-hal BRANCH="-upgrade-2.1.3" [ "$EDGE" == "bleeding" ] && BRANCH="" git clone --recursive https://github.com/mer-hybris/droid-config-$DEVICE hybris/droid-configs -b community"$BRANCH" 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 fi 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- patterns-sailfish-store-applications\n- pattern:sailfish-porter-tools\n" $ANDROID_ROOT/hybris/droid-configs/patterns/jolla-configuration-$DEVICE.yaml fi rpm/dhd/helpers/build_packages.sh --configs
Open new terminal window shell and enter:
HABUILD_SDK $ sudo apt-get install rsync cd $ANDROID_ROOT/.. mkdir syspart cd syspart BRANCH="upgrade-2.1.3-" [ "$EDGE" == "bleeding" ] && BRANCH="" repo init -u git://github.com/mer-hybris/android.git -b "$BRANCH"syspart-sony-aosp-6.0.1_r80-20170902 -m tagged-manifest.xml # Adjust X to your bandwidth capabilities repo sync -jX --fetch-submodules source build/envsetup.sh export USE_CCACHE=1 lunch aosp_$DEVICE-userdebug # Adjust XX to your building capabilities, it will be very heavy on RAM if you go for more cores, proceed with care: make -jXX libnfc-nci bluetooth.default_32 systemtarball # Go and have a cuppa, as this is going to take some time :)
PLATFORM_SDK $ cd $ANDROID_ROOT/../syspart BRANCH="-b upgrade-2.1.3" [ "$EDGE" == "bleeding" ] && BRANCH="" git clone https://github.com/mer-hybris/droid-system-$DEVICE $BRANCH mb2 -t $VENDOR-$DEVICE-$PORT_ARCH -s droid-system-$DEVICE/rpm/droid-system-$DEVICE.spec build rm -f $ANDROID_ROOT/droid-local-repo/$DEVICE/droid-system-*.rpm mv RPMS/droid-system-$DEVICE-0.1.1-1.armv7hl.rpm $ANDROID_ROOT/droid-local-repo/$DEVICE/ createrepo "$ANDROID_ROOT/droid-local-repo/$DEVICE" sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R zypper ref
Close the current terminal window, go back to previous window and wait until middleware finished building (if not already), then:
HABUILD_SDK $ cd $ANDROID_ROOT git clone https://github.com/mer-hybris/audioflingerglue external/audioflingerglue git clone https://github.com/sailfishos/droidmedia external/droidmedia source build/envsetup.sh lunch aosp_$DEVICE-userdebug make -jXX libdroidmedia_32 minimediaservice minisfservice libaudioflingerglue_32 miniafservice
PLATFORM_SDK $ cd $ANDROID_ROOT rpm/dhd/helpers/build_packages.sh --mw # select "all" option when asked DROIDMEDIA_VERSION=$(git --git-dir external/droidmedia/.git describe --tags | sed -r "s/\-/\+/g") DEVICE=$HABUILD_DEVICE rpm/dhd/helpers/pack_source_droidmedia-localbuild.sh $DROIDMEDIA_VERSION mkdir -p hybris/mw/droidmedia-localbuild/rpm cp rpm/dhd/helpers/droidmedia-localbuild.spec hybris/mw/droidmedia-localbuild/rpm/droidmedia.spec sed -ie "s/0.0.0/$DROIDMEDIA_VERSION/" hybris/mw/droidmedia-localbuild/rpm/droidmedia.spec mv hybris/mw/droidmedia-$DROIDMEDIA_VERSION.tgz hybris/mw/droidmedia-localbuild rpm/dhd/helpers/build_packages.sh --build=hybris/mw/droidmedia-localbuild rpm/dhd/helpers/build_packages.sh --mw=https://github.com/sailfishos/gst-droid.git DEVICE=$HABUILD_DEVICE rpm/dhd/helpers/pack_source_audioflingerglue-localbuild.sh mkdir -p hybris/mw/audioflingerglue-localbuild/rpm cp rpm/dhd/helpers/audioflingerglue-localbuild.spec hybris/mw/audioflingerglue-localbuild/rpm/audioflingerglue.spec mv hybris/mw/audioflingerglue-0.0.1.tgz hybris/mw/audioflingerglue-localbuild rpm/dhd/helpers/build_packages.sh --build=hybris/mw/audioflingerglue-localbuild rpm/dhd/helpers/build_packages.sh --mw=https://github.com/mer-hybris/pulseaudio-modules-droid-glue.git sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R zypper in droid-hal-$DEVICE-kernel sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R zypper in --force-resolution droid-hal-$DEVICE-kernel-modules rpm/dhd/helpers/build_packages.sh --mw=https://github.com/sailfishos/initrd-helpers rpm/dhd/helpers/build_packages.sh --mw=https://github.com/nemomobile/hw-ramdisk rpm/dhd/helpers/build_packages.sh --mw=https://github.com/sailfishos/yamui git clone --recursive https://github.com/mer-hybris/droid-hal-img-boot-$DEVICE hybris/mw/droid-hal-img-boot-$DEVICE rpm/dhd/helpers/build_packages.sh --mw=https://github.com/mer-hybris/droid-hal-img-boot-$DEVICE sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R zypper in --force-resolution bluez5-libs-devel rpm/dhd/helpers/build_packages.sh --mw=https://github.com/mer-hybris/bluetooth-rfkill-event --spec=rpm/bluetooth-rfkill-event-hciattach.spec git clone --recursive https://github.com/mer-hybris/droid-hal-version-$DEVICE hybris/droid-hal-version-$DEVICE rpm/dhd/helpers/build_packages.sh --version
Now go through chapter 8, but instead of the `sudo mic create fs ...` command, perform the following:
- Save the contents of Mic-loop.patch as ~/Downloads/mic-loop.patch
PLATFORM_SDK $ RELEASE=18.104.22.168 # if your sb2 target is 2.1.0, remove it and add 2.1.1 one (check HADK v2.0.1 for link) sudo zypper in lvm2 atruncate pigz sudo ssu ar unbreakmic http://repo.merproject.org/obs/home:/sledge:/branches:/mer-tools:/devel/latest_i486/ sudo zypper ref unbreakmic sudo zypper in droid-tools sudo zypper in --force mic cd /usr/lib/python2.7/site-packages/mic/ sudo patch -p1 --dry-run < ~/Downloads/mic-loop.patch # ensure above worked, then sudo patch -p1 < ~/Downloads/mic-loop.patch cd $ANDROID_ROOT sudo mic create loop --arch=$PORT_ARCH \ --tokenmap=ARCH:$PORT_ARCH,RELEASE:$RELEASE,EXTRA_NAME:$EXTRA_NAME \ --record-pkgs=name,url --outdir=sfe-$DEVICE-$RELEASE$EXTRA_NAME \ $ANDROID_ROOT/Jolla-@RELEASE@-$DEVICE-@ARCH@.ks
If you want to rebuild your image again later, umount any
/var/tmp/mic/imgcreate-*/ mounts manually.
Flashing (transitory period!)
Ensure you OTA your stock Sony Android to at least 34.3.A.0.228 (check Settings | About phone | Build number) before unlocking your device, so you do not need Windows in the flashing process. Note, you might need to OTA-update several times to reach that version.
PLATFORM_SDK $ # continue from above mic session mkdir flashing cd flashing unzip $ANDROID_ROOT/sfe-$DEVICE-$RELEASE$EXTRA_NAME/SailfishOS-*.zip cd SailfishOS-*/
Download Sony vendor zip archive from https://developer.sonymobile.com/downloads/software-binaries/software-binaries-for-aosp-marshmallow-android-6-0-1-kernel-3-10-loire/ and place it in current directory, then:
BLOBS=$(ls -1 *_loire.zip | tail -n1) unzip $BLOBS # act upon instructions in the flashing-README.txt, then: bash ./flash.sh
If flash.sh fails with "You have too old Sony Android version (X.Y) on your device"
This means you have not updated your stock Sony Android via OTA to the build 34.3.A.0.228. Since you have already unlocked your device, OTAs are no longer available, and now you have two alternatives: the Linux way or Windows.
The Linux Way
cd $ANDROID_ROOT/flashing/SailfishOS-*/ MATCH='Your Sony Android version ($VMAJOR.$VMINOR) on your device is too old,' LINE=$(grep -n "$MATCH" flash.sh | sed 's/:.*//') if [ -n $LINE ]; then sed -i "$(($LINE+1)),$(($LINE+3)) d" flash.sh sed -i "s/$MATCH/Your Sony Android version is too old, but we'll workaround that via Linux cmdline/" flash.sh else echo 'Ensure you are using droid-configs from the build instructions above (same branch/up-to-date), then:' echo 'cp $ANDROID_ROOT/hybris/droid-configs/sparse/boot/flash.sh .' echo 'And restart this section from its beginning above ^ (cd $ANDROID_ROOT/flashing etc)' fi sed -i 's/echo "Flashing oem partition.."/echo "oem partition is populated manually through recovery"/' flash.sh sed -i 's/$FLASHCMD oem $BLOBS/#$FLASHCMD oem $BLOBS/' flash.sh fastboot flash system *_loire.img
Open a new terminal window and enter Sailfish_X_Build_and_Flash#Recovery_Mode and shell into the device, then:
mkdir oem mount /dev/mmcblk0p28 oem mkdir blobs mount /dev/mmcblk0p52 system rm -rf oem/* cp -ar blobs/* oem umount oem umount blobs rmdir oem blobs exit
Go back to your previous terminal window session, and complete the flashing:
Now reboot the device and you should have Sailfish OS booting normally.
- Download the Emma tool - https://developer.sonymobile.com/open-devices/flash-tool/how-to-download-and-install-the-flash-tool/
- Install the Emma tool
- Connect phone to your computer with USB cable, while holding volume down and then green LED light should be lit on the top speaker
- Update your device to at least to Android version x-x_34.3.x.x.x with the Emma tool.
NOTE: The download size can be 2.5G and take tens of minutes to download so go and get some coffee in the mean while
Go back to your Linux installation where you left off previously, and redo:
# act upon instructions in the flashing-README.txt, then: bash ./flash.sh
If anything goes not according to plan, you can boot the device into fastboot (VolumeUp+Power) and execute this command:
PLATFORM_SDK $ sudo fastboot boot $ANDROID_ROOT/hybris/mw/droid-hal-img-boot-f5121/installroot/boot/hybris-recovery.img
Then follow instructions on screen to SSH into your device recovery mode. Further steps will depend on what you want to achieve, mainly guided by our IRC channel.
The port is pretty functional, but help from you is always appreciated in these areas:
- Fingerterm input is very slow (fix available, ask on IRC or wait for the next Sailfish OS update). In the meantime, please try:
devel-su zypper ref adaptation-community-common devel-su zypper install literm
- Sensors not working: fingerprint, barometer, step counter
- Internet sharing (tethering) does not work, here's a workaround (monich on IRC knows more)
devel-su echo 2 > /sys/module/bcmdhd/parameters/op_mode # Switch WLAN off in Settings or Shortcuts in Events View, afterwards turn Internet Sharing on and: ip link set dev wlan0 master tether
echo 0 > /sys/module/bcmdhd/parameters/op_mode # Switch Internet Sharing off in Settings or Shortcuts in Events View
- Switching some ambiences or editing gallery photos crashes (solution is to build the latest exempi - this has been done for you already on 2017-10-06 -- the updated exempi package will automagically be taken from adaptation-common repo in Mer OBS)
- Double-tap to wake is deactivated. Activate it and help testing in various scenarios by:
- FM radio missing (solution is known by community)
- No big.LITTLE technology is currently enabled, Sailfish OS simply fills up the cores in sequence (from 0 to 3 little, then the big ones 4 and 5), which already gives a very smooth performance.
However, this means there's no special allocation of the two performance cores for the foreground apps (so the UX experience could be improved even further, even under heavy loads). More details:
We can't dedicate two big cores to foreground UI apps because we can't allocate PIDs to the foreground sets. And even if we could, we'd have to add the root process for foreground apps (SFOS booster/invoker?) into there so its children would live on the fast cores. Ping abranson on IRC if you want to chip in, or wait for Android 7 (and kernel v4.4 automatically handling all that much better) where only SFOS booster part will need sorting.
pkcon install-local somepackagedoes not work as it is reading the wrong architecture. Commands
rpm -ivh somefile.rpmor
zypper in somefile.rpmdo work. Solution will be available in the next Sailfish OS update
- Startup Wizard skips one blank page (where usually the Android Support is)
If you find more things to fix, please report them in our IRC channel or file a bug.
Have fun and enjoy our first fully-flashable Sailfish OS image built entirely by you!
Your Jolla HW Team