Lineage OS - sailfishos-sony-nagara/main GitHub Wiki
Below are some Lineage porting notes that maybe important at some stage later
There is no Lineage OS port for Xperia Nagara. If we want to make one, here are the repositories that were needed for Yodo.
-
GitHub - LineageOS/android_device_sony_pdx234
-
GitHub - LineageOS/android_device_sony_sm8550-common
-
GitHub - LineageOS/android_hardware_sony Seems like generic Sony hw repo
-
vendor/sony/sm8550-common/BoardConfigVendor.mk
-
-
vendor/sony/pdx234/BoardConfigVendor.mk
-
Tracked using lineage.dependencies and includes in BoardConfig.mk
-
Device trees: GitHub - sonyxperiadev/kernel-copyleft-dts
-
Kernel and modules: Open source archives ; For codes see copyleft dts repo above
We can get missing information from stock ROM. See Extracting-data-from-stock-ROM.
At the moment of writing, device trees are buggy and do not allow to boot. To work around it, stock DTB (on vendor_boot) and DTBO (dtbo image) can be used.
Some differences that stayed after importing Sony copyleft trees:
Differing file without match: qcom/waipio-cdp.dtsi
Differing file without match: qcom/waipio-mtp.dtsi
Differing file without match: qcom/waipio-qrd.dtsi
The differences are all related to NFC. One of them:
diff ~/stock/kernel-copyleft-dts/devicetree/qcom/waipio-qrd.dtsi qcom/waipio-qrd.dtsi
146a147,170
> &qupv3_se9_i2c {
> status = "ok";
> qcom,clk-freq-out = <1000000>;
> #address-cells = <1>;
> #size-cells = <0>;
> nq@28 {
> compatible = "qcom,sn-nci";
> reg = <0x28>;
> qcom,sn-irq = <&tlmm 46 0x00>;
> qcom,sn-ven = <&tlmm 34 0x00>;
> qcom,sn-firm = <&tlmm 45 0x00>;
> qcom,sn-clkreq = <&tlmm 35 0x00>;
> qcom,sn-vdd-1p8-supply = <&S10B>;
> qcom,sn-vdd-1p8-voltage = <1800000 1800000>;
> qcom,sn-vdd-1p8-current = <157000>;
> interrupt-parent = <&tlmm>;
> interrupts = <46 0>;
> interrupt-names = "nfc_irq";
> pinctrl-names = "nfc_active", "nfc_suspend";
> pinctrl-0 = <&nfc_int_active &nfc_enable_active>;
> pinctrl-1 = <&nfc_int_suspend &nfc_enable_suspend>;
> };
> };
>
Kernel and its modules were merged with Sony changes. To identify changes, find-archive-matches.py
script was used.
When comparing the changes in modules, it makes sense to use original repository that contained corresponding subtree in android_kernel_sony_sm8450-modules and figure out which commit of that original repository was used by Sony. Later, after applying the changes, merging to the tag used by android_kernel_sony_sm8450-modules and only then copying changes to android_kernel_sony_sm8450-modules.
sm8450-common/overlay of Lineage is filled using information from stock. To extract it, find the corresponding APK and extract data as shown in the example below:
java -jar $LINEAGE_SOURCE/prebuilts/extract-tools/common/apktool/apktool.jar \
d root/product/overlay/CarrierConfig-Platform-Overlay.apk \
-o CarrierConfig_decoded
Here, new directory CarrierConfig_decoded will be created and XML files will be extracted.
The used overlays and corresponding APK:
- CarrierConfigResCommon: product/overlay/CarrierConfig-Platform-Overlay.apk
- SonyNagaraFrameworksResCommon: not really sure where the data comes from, would have to look into it
config.fs can be generated from ROM using a script distributed with Lineage sources by running it from the root of source tree as shown below:
lineage/scripts/config-fs-gen/config-fs-gen.py \
bionic/libc/kernel/uapi/linux/capability.h \
system/core/libcutils/include/private/android_filesystem_config.h \
~/nagara/stock/root/vendor/etc/group ~/nagara/stock/root/*/etc/fs_config* \
> device/sony/sm8450-common/config.fs
Most of the blobs are pulled from Sony. Exception is for display drivers that did not work with Sony provided ones:
# ls -R vendor_overlay
vendor_overlay/lib64:
libdisplayqos.so libdisplayskuutils.so libqrtrclient.so libqseed3.so librcmask.so libsdm-colormgr-algo.so libsdm-color.so libsdm-disp-vndapis.so libsdmextension.so libtestutils.so libtinyxml2_1.so
Currently pulled ones were from From Motorola sm8475-common, U1SQS34.52-21-1-10 (see https://github.com/sony-nagara/android_device_sony_sm8450-common/blob/staging/lineage-21/proprietary-files.txt)
md5sum vendor_overlay/lib64/*
b80cec18046b3cea75be8fdebc81c8ee vendor_overlay/lib64/libdisplayqos.so
58a4c7659e48c05673e5259bec726acb vendor_overlay/lib64/libdisplayskuutils.so
4a6aec4cc87a53b87bc88d21974ef4a6 vendor_overlay/lib64/libqrtrclient.so
b216e501c25f61a923465771ef9b2ccc vendor_overlay/lib64/libqseed3.so
cfb0b9bf4f2ef16b67b6f379109e7147 vendor_overlay/lib64/librcmask.so
84d9525d0ca4c4b1166ddcfc5987f04e vendor_overlay/lib64/libsdm-colormgr-algo.so
71c8b76d2586d9be7493dfcfd696b538 vendor_overlay/lib64/libsdm-color.so
0da55abad4658cc5f8d24bd8c5a4e10e vendor_overlay/lib64/libsdm-disp-vndapis.so
95b667322df3b4b5682ab0ff055ddd27 vendor_overlay/lib64/libsdmextension.so
8d0252112546953c8135e729fa36dbe8 vendor_overlay/lib64/libtestutils.so
7bd663757210301b5346827568d32269 vendor_overlay/lib64/libtinyxml2_1.so
Setup build environment. You can use Dockerfile or follow https://wiki.lineageos.org/devices/pdx234/build/ instructions
In Android build environment, setup sources as described in https://wiki.lineageos.org/devices/pdx234/build/ until you get to device-specific code. Instead of that, clone the following repos in your Lineage source root:
git clone https://github.com/rinigus/android_device_sony_pdx223 device/sony/pdx223
git clone https://github.com/rinigus/android_device_sony_sm8450-common device/sony/sm8450-common
Get kernel, kernel modules, and device trees from https://github.com/sony-nagara . Put them into expected location.
To extract blobs, use instructions in https://github.com/sailfishos-sony-nagara/main/wiki/Extracting-data-from-stock-ROM and mount it in your Android environment in such way that you could extract them by running
cd device/sony/pdx223 && ./extract-files.sh /stock
or similar.
Before building, get the patches:
repopick 423299 423083 410938
repopick -f 423304
Add stock dtb to device/sony/pdx223/dtb/stock.dtb (current device tree doesn't work).
Then build with
breakfast pdx223 userdebug && m && /bin/bash -c "(out/host/linux-x86/bin/mkbootimg --dtb device/sony/pdx223/dtb/stock.dtb --base 0x00000000 --pagesize 4096 --vendor_cmdline \"video=vfb:640x400,bpp=32,memsize=3072000 androidboot.selinux=permissive avc.debug=0 audit=0 buildproduct=pdx223 bootconfig printk.devkmsg=on printk.always_kmsg_dump printk.ratelimit=0\" --vendor_bootconfig out/target/product/pdx223/vendor-bootconfig.img --header_version 4 --vendor_ramdisk out/target/product/pdx223/obj/PACKAGING/vendor_boot_intermediates/vendor_ramdisk.cpio.lz4 --vendor_boot out/target/product/pdx223/vendor_boot.img ) && (size=\$(for i in out/target/product/pdx223/vendor_boot.img; do stat -c \"%s\" \"\$i\" | tr -d '\\n'; echo +; done; echo 0); total=\$(( \$( echo \"\$size\" ) )); printname=\$(echo -n \"out/target/product/pdx223/vendor_boot.img\" | tr \" \" +); maxsize=\$((0x6000000)); if [ \"\$total\" -gt \"\$maxsize\" ]; then echo \"error: \$printname too large (\$total > \$maxsize)\"; false; elif [ \"\$total\" -gt \$((maxsize - 32768)) ]; then echo \"WARNING: \$printname approaching size limit (\$total now; limit \$maxsize)\"; fi ) && (out/host/linux-x86/bin/avbtool add_hash_footer --image out/target/product/pdx223/vendor_boot.img --partition_size 0x6000000 --partition_name vendor_boot --prop com.android.build.vendor_boot.fingerprint:\$(cat out/target/product/pdx223/build_fingerprint.txt) )"
When flashing, keep DTBO.img as it is from stock.