Adaptations/libhybris/Install SailfishOS for jfltexx



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

Hardware Support

 * }

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
/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 $ udevadm monitor
 * 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:
 * using udev rfkill signal to catch events and trigger patchram:

useful links

 * HADK Porting Guide - used 1.1.1 (outdated, check out 1.1.2)
 * Simon Van der Veldt's Github repos
 * Wickwire's Github repos
 * Cyanogenmod jfltexx Page
 * Cyanogenmod jfltexx Installation
 * Cyanogenmod jfltexx Releases
 * Adaptations/libhybris


 * cm-12.1-20151117-SNAPSHOT-YOG7DAO1JN-jfltexx.zip
 * cm-12.1-20151117-SNAPSHOT-YOG7DAO1JN-jfltexx-recovery.img
 * I9505XXUHOB7_I9505YXYHOB5_BTU.zip
 * Odin3_v3.10.7.zip
 * heimdall-suite-1.4.0-win32.zip

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

$HOME/.hadk.env

export MER_ROOT="/home/ /mer" export ANDROID_ROOT="$MER_ROOT/android/droid" export VENDOR="samsung" export DEVICE="jfltexx" export PORT_ARCH="armv7hl"
 * 1) ARCH conflicts with kernel build

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://github.com/mer-hybris/android.git -b hybris-12.1

Proceed as described;

5.2 Device repos

$ANDROID_ROOT/.repo/local_manifests/jfltexx.xml

            

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:

"jfltexx")      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 http://piratepad.net/hadk-faq lines 66-114 in order to get GSM calls working:

cd $ANDROID_ROOT cd /external/sonivox git checkout 047330f1c245bcb3641856a6adabfc344d6e3c36 cd $ANDROID_ROOT 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' WARNING: CONFIG_SCHEDSTATS is invalid WARNING: CONFIG_SCHED_DEBUG is invalid WARNING: CONFIG_WATCHDOG_NOWAYOUT is invalid

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 http://repo.merproject.org/obs/home:/mal:/testing/sailfishos_latest_armv7hl/ 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:

PKG=ngfd-plugin-droid-vibrator 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 build_packages.sh

When done, continue with http://piratepad.net/hadk-faq, follow the steps between lines 79-114:

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

cd $ANDROID_ROOT

(create the two files below)

pack_source_af.sh

fold=audioflingerglue-0.0.1 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/libaudioflingerglue.so $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

audioflingerglue.spec

%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 Source0:      %{name}-%{version}.tgz AutoReqProv:  no
 * 1) BuildRequires: ubu-trusty
 * 2) BuildRequires: sudo-for-abuild
 * 3) BuildRequires: droid-bin-src-full

%description %{summary}

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

%description  devel %{summary}

%prep

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

%setup

%build pwd ls tar -xvf %name-%version.tgz %install
 * 1) sudo chown -R abuild:abuild /home/abuild/src/droid/
 * 2) mv /home/abuild/src/droid/*.
 * 3) mkdir -p external
 * 4) pushd external
 * 5) tar -zxf %SOURCE0
 * 6) mv audioflingerglue* audioflingerglue
 * 7) popd

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/libaudioflingerglue.so \ $RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/lib/

cp out/target/product/*/system/bin/miniafservice \ $RPM_BUILD_ROOT/%{_libexecdir}/droid-hybris/system/bin/

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

popd %files %defattr(-,root,root,-) %{_libexecdir}/droid-hybris/system/lib/libaudioflingerglue.so %{_libexecdir}/droid-hybris/system/bin/miniafservice

%files devel %defattr(-,root,root,-) %{_includedir}/audioflingerglue/*.h %{_datadir}/audioflingerglue/hybris.c

7.2.2 Troubleshoot errors from build_packages.sh -> 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@" KS="Jolla-@RELEASE@-$DEVICE-@ARCH@.ks"

tmp/$KS --baseurl=http://repo.merproject.org/obs/home:/mal:/testing2/sailfishos_latest_armv7hl\nrepo --name=common \ --baseurl=http://repo.merproject.org/obs/nemo:/testing:/hw:/common/sailfish_latest_armv7hl|" \ $ANDROID_ROOT/hybris/droid-configs/installroot/usr/share/kickstarts/$KS > tmp/$KS
 * 1) older lines, kept for posterity and because sed is cool #####
 * 2) 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 > \
 * 1) repo --name=testing2 --baseurl=http://repo.merproject.org/obs/home:/mal:/testing2/sailfishos_latest_armv7hl
 * 2) repo --name=common --baseurl=http://repo.merproject.org/obs/nemo:/testing:/hw:/common/sailfish_latest_armv7hl
 * 3) sed -e "s|^$HA_REPO.*$|$HA_REPO --baseurl=file://$ANDROID_ROOT/droid-local-repo/$DEVICE|;s|^repo --name=jolla-@RELEASE@.*|& \nrepo --name=testing2 \
 * 1) 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=http://repo.merproject.org/obs/nemo:/testing:/hw:/common/sailfish_latest_armv7hl|" \ $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

cd $ANDROID_ROOT hybris/droid-configs/droid-configs-device/helpers/process_patterns.sh

Proceed as described;

RELEASE=2.0.1.11 EXTRA_NAME=-wickwire-005-devel sudo mic create fs --arch $PORT_ARCH --tokenmap=ARCH:$PORT_ARCH,RELEASE:$RELEASE,EXTRA_NAME:$EXTRA_NAME --record-pkgs=name,url \ --outdir=sfe-$DEVICE-$RELEASE$EXTRA_NAME --pack-to=sfe-$DEVICE-$RELEASE$EXTRA_NAME.tar.bz2 $ANDROID_ROOT/tmp/Jolla-@RELEASE@-$DEVICE-@ARCH@.ks

Installation

 * For hot discussions about bleeding edge issues, welcome to this xda thread :)