The Mer Wiki now uses your Mer user account and password (create account on

Adaptations/libhybris/Install SailfishOS for jfltexx

From Mer Wiki
Jump to: navigation, search

Notes for installing Sailfish OS on the Samsung Galaxy S4 GT-I9505 LTE (jfltexx).


Hardware Support

Legend:  Y  - Working (y=hack),  Y  - HAL works, not hooked up to UI/MW/init yet,  N  - Not working,  ?  - Untested,  N/A  - N/A on device.
Device released Linux
Display Touch LED Audio NFC Bluetooth GSM WLAN GPS Camera Fingerprint Sensors Keys Vibra Haptics Power
USB FM Radio
SMS Voice Data Connect Hotspot ALS PS Accel. Gyro. Magne. Vol+/- Home Net. Charge
3.4.107 Y Y Y Y N Y Y  ? Y Y  ? Y N  ? Y Y Y Y Y Y N Y Y Y  ? Y Y N/A


Things that don't work

  • Jolla Store (Harbour) doesn't work. Do not sign in with Jolla account.
  • Voicecall: receiving calls works properly (along with Speaker, Pad and Mic buttons) / making calls fails with 3 tone signal.
  • Camera: only front camera photo works. back camera photo + any camera video fails.
  • Mobile Internet: intermittent feature, between reboots:
    • setting PIN code for the SIM card seems to help;
    • additionally, try giving it 10-15sec pause once the SIM inserted screen shows up, and then enter the PIN to unlock.
  • Home key not working.
  • Headphone jack.
  • Screen going to suspend mode not working.

Things that work

  • Sensors
  • GPS
  • SMS
  • Audio
  • Bluetooth: now working, but with quirks. Details in the Release Notes for v0.0.9
    • audio over bluetooth doesn't seem to work
    • may interfere with WiFi
    • may fail to load at times: toggling flight mode seems to help reset the state without rebooting
  • using brcm-patchram-plus to make it work
  • working command line:
/usr/sbin/brcm_patchram_plus --patchram /vendor/firmware/bcm4335.hcd --enable_hci --bd_addr $(/bin/cat /efs/bluetooth/bt_addr) --no2bytes --tosleep 6000 /dev/ttyHS0
  • using udev rfkill signal to catch events and trigger patchram:
$ udevadm monitor

Image Building

useful links

  • cm-12.1-20151117-SNAPSHOT-YOG7DAO1JN-jfltexx-recovery.img

build notes

The notes below follow the HADK Porting Guide (v1.1.1), which has recently been updated to v1.1.2)

1 OVERVIEW -> Proceed as described;

2 PREREQUISITES -> Proceed as described;

3 PREPARING YOUR DEVICE -> Proceed as described;

4.1 Setting up required environment variables


export MER_ROOT="/home/<user>/mer"
export ANDROID_ROOT="$MER_ROOT/android/droid"
export VENDOR="samsung"
export DEVICE="jfltexx"
#ARCH conflicts with kernel build
export PORT_ARCH="armv7hl"

Proceed as described;

4.2 Setup the Mer SDK -> Proceed as described;

4.3 Preparing the Mer SDK -> Proceed as described;

4.4 Setting up an Android Build Environment

4.4.1 Downloading and Unpacking Ubuntu Chroot -> Proceed as described;

4.4.2 Entering Ubuntu Chroot -> Proceed as described;

5.1 Checking out CyanogenMod Source

repo init -u git:// -b hybris-12.1

Proceed as described;

5.2 Device repos


<?xml version="1.0" encoding="UTF-8"?>
    <project path="device/samsung/jflte" name="CyanogenMod/android_device_samsung_jfltexx" revision="cm-12.1" />
    <project path="device/samsung/jf-common" name="Cyanogenmod/android_device_samsung_jf-common" revision="cm-12.1" />
    <project path="device/samsung/msm8960-common" name="Cyanogenmod/android_device_samsung_msm8960-common" revision="cm-12.1" />
    <project path="device/samsung/qcom-common" name="Cyanogenmod/android_device_samsung_qcom-common" revision="cm-12.1" />
    <project path="hardware/samsung" name="Cyanogenmod/android_hardware_samsung" revision="cm-12.1" />
    <project path="kernel/samsung/jf" name="Cyanogenmod/android_kernel_samsung_jf" revision="cm-12.1" />
    <project path="rpm" name="wickwire/droid-hal-jfltexx" revision="master" sync-s="true" />
    <project path="hybris/droid-configs" name="wickwire/droid-config-jfltexx" revision="master" sync-s="true" />
    <project path="hybris/droid-hal-version-jfltexx" name="wickwire/droid-hal-version-jfltexx" revision="master" sync-s="true" />
    <project path="mlehtima/audioflingerglue" name="mlehtima/audioflingerglue" revision="master" sync-s="true" />
    <remove-project name="mer-hybris/hybris-boot" />
    <project path="hybris/hybris-boot" name="wickwire/hybris-boot" revision="wickwire-jfltexx" />

Proceed as described;

5.3 Configure Mountpoint Information

$ANDROID_ROOT/hybris/hybris-boot/fixup-mountpoints should already have this additional block - so, nothing to do here:

       sed -i \
            -e 's block/platform/msm_sdcc.1/by-name/aboot mmcblk0p6 ' \
            -e 's block/platform/msm_sdcc.1/by-name/apnhlos mmcblk0p1 ' \
            -e 's block/platform/msm_sdcc.1/by-name/backup mmcblk0p23 ' \
            -e 's block/platform/msm_sdcc.1/by-name/boot mmcblk0p20 ' \
            -e 's block/platform/msm_sdcc.1/by-name/cache mmcblk0p18 ' \
            -e 's block/platform/msm_sdcc.1/by-name/carrier mmcblk0p28 ' \
            -e 's block/platform/msm_sdcc.1/by-name/efs mmcblk0p10 ' \
            -e 's block/platform/msm_sdcc.1/by-name/fota mmcblk0p22 ' \
            -e 's block/platform/msm_sdcc.1/by-name/fsg mmcblk0p24 ' \
            -e 's block/platform/msm_sdcc.1/by-name/hidden mmcblk0p27 ' \
            -e 's block/platform/msm_sdcc.1/by-name/m9kefs1 mmcblk0p13 ' \
            -e 's block/platform/msm_sdcc.1/by-name/m9kefs2 mmcblk0p14 ' \
            -e 's block/platform/msm_sdcc.1/by-name/m9kefs3 mmcblk0p15 ' \
            -e 's block/platform/msm_sdcc.1/by-name/mdm mmcblk0p2 ' \
            -e 's block/platform/msm_sdcc.1/by-name/modemst1 mmcblk0p11 ' \
            -e 's block/platform/msm_sdcc.1/by-name/modemst2 mmcblk0p12 ' \
            -e 's block/platform/msm_sdcc.1/by-name/pad mmcblk0p9 ' \
            -e 's block/platform/msm_sdcc.1/by-name/param mmcblk0p19 ' \
            -e 's block/platform/msm_sdcc.1/by-name/persdata mmcblk0p26 ' \
            -e 's block/platform/msm_sdcc.1/by-name/persist mmcblk0p17 ' \
            -e 's block/platform/msm_sdcc.1/by-name/recovery mmcblk0p21 ' \
            -e 's block/platform/msm_sdcc.1/by-name/rpm mmcblk0p7 ' \
            -e 's block/platform/msm_sdcc.1/by-name/sbl1 mmcblk0p3 ' \
            -e 's block/platform/msm_sdcc.1/by-name/sbl2 mmcblk0p4 ' \
            -e 's block/platform/msm_sdcc.1/by-name/sbl3 mmcblk0p5 ' \
            -e 's block/platform/msm_sdcc.1/by-name/ssd mmcblk0p25 ' \
            -e 's block/platform/msm_sdcc.1/by-name/system mmcblk0p16 ' \
            -e 's block/platform/msm_sdcc.1/by-name/tz mmcblk0p8 ' \
            -e 's block/platform/msm_sdcc.1/by-name/userdata mmcblk0p29 ' \

5.4 Building Relevant Bits of CyanogenMod

using defconfig from: arch/arm/configs/cyanogen_jf_defconfig

Before executing make -j4 hybris-hal, perform actions from lines 66-114 in order to get GSM calls working:

cd /external/sonivox
git checkout 047330f1c245bcb3641856a6adabfc344d6e3c36
cd frameworks/av
git checkout 25be9ac20db51044e1b09ca67906355e4f328d48
cd ~/mer/android/droid/kernel/samsung/jf

(check that the active branch is jfltexx)

make libaudioflingerglue miniafservice

those packages should build ok, and then do

make hybris-hal

and then do

hybris/mer-kernel-check/mer_verify_kernel_config ./out/target/product/$DEVICE/obj/KERNEL_OBJ/.config | egrep -e 'ERROR|WARNING'

those 3 warnings only and no errors should be ok

6 SETTING UP SCRATCHBOX2 TARGET -> Proceed as described;

7.1 Creating Repositories for a New Device -> the files for this part should already be available from the local_manifest, nothing to do

7.2.1 Building the droid-hal-device packages:

add the following repo to the merSDK:

ssu ar testing
zypper ref and then zypper dup --from testing

Proceed as described;

Important note: if the process hangs at ngfd-plugin-droid-vibrator, abort the script and manually build the package:

cd ~/mer/devel/mer-hybris/$PKG
mb2 -s rpm/ngfd-plugin-droid-vibrator.spec -t samsung-jfltexx-armv7hl build
mv RPMS/*.rpm $ANDROID_ROOT/droid-local-repo/$DEVICE/$PKG
sb2 -t $VENDOR-$DEVICE-armv7hl -R -msdk-install zypper ref

then resume

When done, continue with, follow the steps between lines 79-114:

(for the load-module part, check out 14.8 PulseAudio Droid Modules in the HADK Porting Guide)


(create the two files below)

rm -rf $fold
mkdir $fold

mkdir -p $fold/out/target/product/${DEVICE}/system/lib
mkdir -p $fold/out/target/product/${DEVICE}/system/bin
mkdir -p $fold/external/audioflingerglue

cp ./out/target/product/${DEVICE}/system/lib/ $fold/out/target/product/${DEVICE}/system/lib/
cp ./out/target/product/${DEVICE}/system/bin/miniafservice $fold/out/target/product/${DEVICE}/system/bin/
cp ./external/audioflingerglue/*.h $fold/external/audioflingerglue/
cp ./external/audioflingerglue/hybris.c $fold/external/audioflingerglue/

tar -cjvf ${fold}.tgz $fold


%define strip /bin/true
%define __requires_exclude  ^.*$
%define __find_requires     %{nil}
%global debug_package       %{nil}
%define __provides_exclude_from ^.*$
%define device_rpm_architecture_string armv7hl
%define _target_cpu %{device_rpm_architecture_string}

Name:          audioflingerglue
Summary:       Android AudioFlinger glue library
Version:       0.0.1
Release:       1
Group:         System/Libraries
License:       ASL 2.0
#BuildRequires: ubu-trusty
#BuildRequires: sudo-for-abuild
#BuildRequires: droid-bin-src-full
Source0:       %{name}-%{version}.tgz
AutoReqProv:   no


%package       devel
Summary:       audioflingerglue development headers
Group:         System/Libraries
Requires:      audioflingerglue = %{version}-%{release}
BuildArch:     noarch

%description   devel


%if %{?device_rpm_architecture_string:0}%{!?device_rpm_architecture_string:1}
echo "device_rpm_architecture_string is not defined"
exit -1


#sudo chown -R abuild:abuild /home/abuild/src/droid/
#mv /home/abuild/src/droid/* .
#mkdir -p external
#pushd external
#tar -zxf %SOURCE0
#mv audioflingerglue* audioflingerglue
tar -xvf %name-%version.tgz

mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/lib/
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/bin/
mkdir -p $RPM_BUILD_ROOT/%{_includedir}/audioflingerglue/
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/audioflingerglue/
pushd %name-%version
cp out/target/product/*/system/lib/ \

cp out/target/product/*/system/bin/miniafservice \

cp external/audioflingerglue/audioflingerglue.h $RPM_BUILD_ROOT/%{_includedir}/audioflingerglue/
cp external/audioflingerglue/hybris.c $RPM_BUILD_ROOT/%{_datadir}/audioflingerglue/


%files devel

7.2.2 Troubleshoot errors from -> Shouldn't be anything to do here;

8.1 Additional Packages for Hardware Adaptation -> Shouldn't be anything to do here;

8.2 Creating and Configuring the Kickstart File:

Proceed as described - and then add mal- repo to tmp/$KS (watch out for any typos):

HA_REPO="repo --name=adaptation0-$DEVICE-@RELEASE@"

##### older lines, kept for posterity and because sed is cool ##### 
#sed -e "s|^$HA_REPO.*$|$HA_REPO --baseurl=file://$ANDROID_ROOT/droid-local-repo/$DEVICE|" $ANDROID_ROOT/hybris/droid-configs/installroot/usr/share/kickstarts/$KS > \
#repo --name=testing2 --baseurl=
#repo --name=common --baseurl=
#sed -e "s|^$HA_REPO.*$|$HA_REPO --baseurl=file://$ANDROID_ROOT/droid-local-repo/$DEVICE|;s|^repo --name=jolla-@RELEASE@.*|& \nrepo --name=testing2 \
--baseurl=\nrepo --name=common \
--baseurl=|" \
$ANDROID_ROOT/hybris/droid-configs/installroot/usr/share/kickstarts/$KS > tmp/$KS
##### older lines, kept for posterity and because sed is cool #####

sed -e "s|^$HA_REPO.*$|$HA_REPO --baseurl=file://$ANDROID_ROOT/droid-local-repo/$DEVICE|;s|^repo --name=jolla-@RELEASE@.*|& \nrepo --name=common \
--baseurl=|" \
$ANDROID_ROOT/hybris/droid-configs/installroot/usr/share/kickstarts/$KS > tmp/$KS

8.3.1 Making local repo aware of patterns -> Proceed as described;

8.4 Building the Image with MIC


Proceed as described;

sudo mic create fs --arch $PORT_ARCH --tokenmap=ARCH:$PORT_ARCH,RELEASE:$RELEASE,EXTRA_NAME:$EXTRA_NAME --record-pkgs=name,url \


Requirements for installation

Installation steps

  • Install Android base zip by following instructions: CyanogenMod jfltexx Page
  • Install the Sailfish OS zip on top of that Android base
  • Reboot

Report bugs

  • Software-related bugs (Sailfish OS): first search in If not found, add your question and tag with "porting"
  • App bugs (e.g. an app doesn't scale well on different screens): contact its developer
  • Problems which depend on hardware: search existing; add new
  • Please do not contact Jolla Care, Jolla Developer Care or phone's maker (e.g. LG, OnePlus, Google), as this is the Sailfish OS community's build for other phones
  • For hot discussions about bleeding edge issues, welcome to this xda thread :)
Personal tools