Livecasting porting notes for Zenfone 8

Day 27

After droid-hal-init started, I test wlan again:

# echo 1 > /sys/devices/platform/soc/b0000000.qcom,cnss-qca6490/fs_ready
# modprobe modprobe qca_cld3_wlan
# ifconfig -a
wlan0     Link encap:Ethernet  HWaddr 3C:7C:3F:8E:E5:8A  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

wlp1s0    Link encap:Ethernet  HWaddr 3E:7C:3F:8E:E5:8A  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Cool.

Hmmm. forgot to # cp /odm_root/etc/selinux/precompiled_sepolicy /etc/selinux/minimum/policy/policy.30 yesterday?
Btw, I can now safely flash instead of boot the hybris-boot.img. I should do so next.


Done. Bye bye Lineage recovery, see you soon.


About yesterdays’ logcat: Check failed: selinux_status_open(true ) >= 0.
I thought I set up selinux files, but maybe more is needed.
For example, my kernel doesnt display “SELinux: Initializing” on the 0th second on boot, but “AppArmor: AppArmor initialized”.
The function selinux_status_open(int fallback) is in libselinux/src/sestatus.c.
The comment says something about “/selinux/status”.
I do have /selinux but there’s nothing in there.

Checking mount on the device, there is no selinuxfs mount, but there is one securityfs

securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)

In that folder I do find AppArmor references - but no “status”.
Reading a comparison1 of SELinux and AppArmor it is clear to me that those are not related at all, and are parallell developments.
I was “hoping” that ASUS used some rebranded thing that would turn out to be SELinux, but it is not.
It may be older… Also, wikipedia hints at “Yama” and “Tomoyo”.

So the question is, then: how come those same services work on Lineage without SELinux and the fail in hybris?
:facepalm: they were from halium check-kernel-config.
Let’s remove most of that.

Next boot my heart skipped a beat because telnet got disconnected and wouldn’t connect again.
Oh, no not some sfos or android service again.
But when pulling out the USB cable and connecting it back I got back access :whew:

I get a large logcat - of which I save the first 60 seconds since that would be enough for a phone to ‘boot’ - and it doesn’t show that selinux error. Also, /sys/fs/selinux is now mounted as selinuxfs.
Lots of “avc: denied” lines there that end up in “permissive=1”, so it’s just noise (would have been denied, but isn’t)

Some notable errors:

vendor.qti.vibrator: open /dev/input/by-path failed, errno = 21

Altough I see it is world readable.
When CamX enters the stage, logs start to become unreadable:)

Then there’s

--------- beginning of crash
03-17 17:24:47.367 6400 6400 F linker : CANNOT LINK EXECUTABLE “/usr/libexec/droid-hybris/system/bin/minisfservice”: library “libandroidicu.so” not found: needed by /system/lib/libmedia.so in namespace (default)

That I should know how to fix.
From previous debugging experience, confirmed in porter’s channel, the usual path to look for libraries contains /odb/lib[64], and since I control that, I should be able to link these kind of libraries.

Then there’s also

03-17 17:24:47.665 6480 6615 E audioadsprpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:921:Error 0x2: fileExists failed for path /vendor/dsp/adsp/audioadsprpcd.farf, errno is No such file or directory

But /vendor/dsp/adsp/ exists and it is filled with other files.

Good news is that I got one “ACDB-LOADER: ACDB → init done!” which is audio related.

Next, I grep for “Waiting for service” lines. I get

Waiting for service ‘package_native’
Waiting for service ‘statscompanion’

That ‘statscompanion’ is so often waited upon I look for it on the whole device

find / -iname *.rc -exec grep statscompanion {} ; -print

I don’t find anything though. The same for package_native.

Hmm. Let’s:

  1. boot an audit=0 cmdline kernel
  2. fix the libandroidicu.so requirement by linking it from /odm/lib
  3. See the new logcat. Maybe share it on porter’s channel…

For 2. I do # ln -s /apex/com.android.art/lib/libandroidicu.so /odm/lib/libandroidicu.so
Wait, no such file or directory - /odm does not exist unfortunately.
I thought I already created it and linkd /odm/etc to /odm_root/etc… it is not on the rootfs?

Again:

# mkdir /odm
# ln -s /odm_root/etc /odm/etc
# mkdir /odm/lib
# ln -s /apex/com.android.art/lib/libandroidicu.so /odm/lib/libandroidicu.so

Reboot. Boot new hybris-boot with audit=0

Minimedia this time complains about missing libicuuc.so
# ln -s /apex/com.android.art/lib/libicuuc.so /odm/lib/libicuuc.so

Let’s link all libs from my previous port then.

# ln -s /apex/com.android.vndk.v30/lib/libaudioroute.so /odm/lib/libaudioroute.so
# ln -s /apex/com.android.art/lib/libicui18n.so /odm/lib/libicui18n.so

Reboot.

linker : CANNOT LINK EXECUTABLE “/usr/libexec/droid-hybris/system/bin/minimediaservice”: library “libnativehelper.so” not found: needed by /system/lib/libmediandk.so in namespace (default)

Ok, # ln -s /apex/com.android.art/lib/libnativehelper.so /odm/lib/libnativehelper.so
Reboot.

This time I don’t find CANNOT LINK messages in logcat. Let’s see about those services.
# vi /usr/libexec/droid-hybris/system/etc/init/disabled_services.rc

I add them as

service package_native /system/vendor/bin/DISABLED           
                                                  
service statscompanion /system/vendor/bin/DISABLED

and remove the vendor.ipacm disablement line from previous day when I thought that was making me reboot.
And reboot again.

(Btw, each reboot needs cable re-connect to continue telnet. Some service is re-setting something)

02-25 23:16:36.211 985 985 I SurfaceFlinger: Using HWComposer service: ‘default’
02-25 23:16:38.466 985 985 I HWComposer: Switching to generalized multi-display mode
02-25 23:16:38.466 985 985 W DisplayIdentification: Invalid EDID: falling back to serial number due to missing display name.
02-25 23:16:38.466 985 985 W DisplayIdentification: Invalid EDID: falling back to ASCII text due to missing serial number.
02-25 23:16:38.466 985 985 E HWComposer: isConnected failed for display 19261202339590786: Invalid display

Hmm…
I would like to have wlan to test minimer.
But then again…

 # echo 1 > /sys/devices/platform/soc/b0000000.qcom,cnss-qca6490/fs_ready
 # modprobe qca_cld3_wlan
 modprobe: FATAL: Module qca_cld3_wlan not found in directory /lib/modules/5.4.61-qgki-perf-gc8a3515be514
 # uname -r
 5.4.61-qgki-perf-gc8a3515be514

This means that my latest kernel changes changed the magic version too. I need to re-build the mic image… and I was hoping that I will first make screen and wlan work then scp into to transfer the changes.
Maybe I can just copy the /lib/modules though, by booting lineage recovery…

But how to boot it? fastboot boot will not go into recovery…
Maybe it’s safer to flash it.

Hmm Lineage recovery says that my /data needs wiping/reset. I get away by “using” the back button and do enable “Adb shell”
However I cannot mount /data as before. So I may have broken it somehow:(

I try to boot a previous “AppArmor” kernel.
Nope.
So no, I again have borked my /data probably by booting Lineage.

So. To end in a high note. Tomorrow I will have to do all the changes I did in the previous days (/dev/ipa, links to /odm, selinux) properly, offline, in a way they will get picked up by the next --mic build.
Good think I made a note of them all :slight_smile:

Also, I need to fix this “accidentally rebooting without holding vol-up starts lineage that wipes /data” somehow. Either by formatting and mounting data some other way, or by including the recover ramdisk in the hybris-boot image (or vendor boot?)

1 Like

Day 28

Meeting notes from Jolla community meeting mention ‘three month to get a high quality port’. I’m only halfway there:)

Retracing my steps from previous days: selinux, droid-hal-early-init.sh, /etc links.
Good thing I have them noted.
Takes me some time, but done offline on the laptop.

Trying to flash lineage boot… it ends up in slot ‘a’.
Maybe this is what happened yesterday, the slot was changed? But /data should not be slotted.
Anyway, I get `FAILED (remote: ‘Slot Change is not allowed in Lock State’) when trying to switch back to slot B.
I decide to go ahead and boot slot A, and ASUS operating system welcomes me :slight_smile:

I’m pretty sure there was something I hardcoded on slot B though.
So I restart to bootloader and try to --set-active=b again: FAILED (remote: 'unknown command')

Hey, but at least I get access to recovery from slot A since I flash lineage boot.img.
I can do all my stuff from there, and SFOS is going to pick up B-side, right?

One weird thing is that Lineage recovery has lost the abilty to regiter touches and I need to operate it with vol up/down and power.
Is this a side-A thing?

Anyway, I am booting my hybris-boot.img
And it again restarts in 60 seconds.
So I need to get back to Lineage recovery to see why. There is no usb0 interface anyore?

Hmm I needed to fix local changes, there was one error in the init-debug that on the device was hardcoded.

I also redo all the /odm/etc link to /odm_root/etc and cp instead of ln the selinux file.

Fresh logcat with kernel that can load its modules :slight_smile: Ubuntu Pastebin

Lots of “Waiting for service ‘vold’ on ‘/dev/binder’…”, let’s try to comment out its disablement…
No difference - That only makes it (vold) fail because he doesn’t understand how I mount system_a.

I try test_hwcomposer and EGL_PLATFORM=hwcomposer test_hwcomposer under strace and they don’t find hwcomposer.*.so where ‘*’ is either default, lahaina or qcom.
All these paths are tried and do not exist :hmm:

hwcomposer.*.so /odm/lib64/hw/hwcomposer.qcom.so /odm/lib64/hw/hwcomposer.qcom.so /vendor/lib64/hw/hwcomposer.qcom.so /system/lib64/hw/hwcomposer.qcom.so /odm/lib64/hw/hwcomposer.lahaina.so /odm/lib64/hw/hwcomposer.lahaina.so /vendor/lib64/hw/hwcomposer.lahaina.so /system/lib64/hw/hwcomposer.lahaina.so /odm/lib64/hw/hwcomposer.lahaina.so /odm/lib64/hw/hwcomposer.lahaina.so /vendor/lib64/hw/hwcomposer.lahaina.so /system/lib64/hw/hwcomposer.lahaina.so /odm/lib64/hw/hwcomposer.default.so /odm/lib64/hw/hwcomposer.default.so /vendor/lib64/hw/hwcomposer.default.so /system/lib64/hw/hwcomposer.default.so

Let’s try minimer. This is a qml file with a jpeg. I got this as a tar.gz file → I echo it as base64, copy it to clipboard, and transfer it in vi by paste on the device.
Because it’s mini. Mini-Mer:)
Oh, but I need to install qt5-qtdeclarative-qmlscene first.
Which means I need to have internet connectivity.

Trying systemctl mask user@100000 (prevents lipstick restart) and restarting - the test_hwcomposer is… the same.

Hmm… so ssh-ing into the device will not work until I enable developer mode and set a password (so: needs GUI)
But maybe I can connect to the internet since I have a what-seems-to-be-working wlan module.
Or maybe I can route the connection through telnet, and HADK has instructions for that.

Actually is very easy, so I will not use wlan:

$ sudo iptables -t nat -A POSTROUTING -o wlp2s0 -j MASQUERADE
$ sudo echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

(^^on my laptop)
then

# route add default gw 192.168.2.14 # <- host's usb0 IP
# echo 'nameserver 208.67.222.222' > /etc/resolv.conf

on the device.

Then zypper in qt5-qtdeclarative-qmlscene.
Stracing: EGL_PLATFORM=hwcomposer strace /usr/lib64/qt5/bin/qmlscene -platform hwcomposer main.qml
This also opens /usr/libexec/droid-hybris/system/lib64/android.frameworks.vr.composer@1.0.so, android.hardware.graphics.composer, libfmq.so, /vendor/lib64/libqdMetaData.so, /vendor/lib64/libgrallocutils.so
outputs “EGLFS: Failed to open /dev/fb0” and “/dev/pmsg0” (??)

So I still don’t know what’s missing for hwcomposer access. Probably the main thing for tomorrow - as just solving mounts and droid-hal-init starting did not automagically turn the screen on:)

2 Likes

Day 29

hwcomposer should be running. On my current device ps aux | grep composer is

/vendor/bin/hw/android.hardware.graphics.composer@2.3-service

On Zenfone:

/vendor/bin/hw/vendor.qti.hardware.display.composer-service

Q: Also, maybe “egl” related links need to be done in /odm too?

Looking again at journalctl -f now, instead of just logcat:

droid-hal-init: Could not start service 'ptt_socket_app' as part of class 'main': Cannot find '/system/vendor/bin/ptt_socket_app': No such file or directory
droid-hal-init: Could not start service 'miniaf' as part of class 'main': Cannot find '/usr/libexec/droid-hybris/system/bin/miniafservice': No such file or directory
droid-hal-init: Could not start service 'vendor_flash_recovery' as part of class 'main': Cannot find '/vendor/bin/install-recovery.sh': No such file or directory

(that’s a good thing:)

droid-hal-init: Control message: Could not find 'android.hardware.gatekeeper@1.0::IGatekeeper/default' for ctl.interface_start from pid: 5342 (/system/bin/hwservicemanager)
droid-hal-init: Control message: Could not find 'android.hardware.keymaster@4.0::IKeymasterDevice/default' for ctl.interface_start from pid: 5342 (/system/bin/hwservicemanager)

and

droid-hal-init: updatable process 'vendor.qseecomd' exited 4 times before boot completed
apexd: Native process 'vendor.qseecomd' is crashing. Attempting a revert
apexd: Revert failed : Revert requested, when there are no active sessions.

Q: maybe the side A vendor is ASUS’s?
A: Yes it is (of course, since it booted:)
That’s an opportunity to make it work without flashing Lineage first!:slight_smile:

But I fear I need to re-install lineage, so I am using my shiny telnet internet connection to scp the actual selinux files to the host.

The services that won’t start are

service vendor.keymaster-4-1 /vendor/bin/hw/android.hardware.keymaster@4.1-service-qti
(in /vendor/etc/init/android.hardware.keymaster@4.1-service-qti.rc)
service wait_for_keymaster /system/bin/wait_for_keymaster
(in /system/etc/init/wait_for_keymaster.rc)
service gatekeeper-1-0 /vendor/bin/hw/android.hardware.gatekeeper@1.0-service-qti
(in /vendor/etc/init/android.hardware.gatekeeper@1.0-service-qti.rc)
service vendor.qseecomd /vendor/bin/qseecomd
(in /vendor/etc/init/qseecomd.rc)

Maybe keymaster and gatekeeper wait for vendor.qseecom.
strace shows it’s crashing

Another class of errors:

droid-hal-init: Sending signal 9 to service ‘boringssl_self_test_apex64’
droid-hal-init: Sending signal 9 to service 'exec 48 (/system/bin/flags_health_check UPDATABLE_CRASHING)
droid-hal-init: Sending signal 9 to service ‘time_daemon’ (pid 8082) process group… HYBRIS: killing PID instead of process group.
droid-hal-init: Sending signal 9 to service ‘diag_mdlog_stop’ (pid 6775) process group… HYBRIS: killing PID instead of process group.

For boringssl Elros seems to have a clue SUSE Paste (source)

To actually see the strace messages for qseecomd I add -s 256 (“limit length of print strings to STRSIZE chars (default 32)”).
I now see :
rpmb_ufs : “could not find the ufs-bsg dev”
DrmLibRpmb: “Error: rpmb_init failed! with ret = -19”
QSEECOMD : “Init rpmb_init_service ret = -19”
QSEECOMD : “Init dlsym(g_FSHandle, rpmb_init_service) fail”
QSEECOMD : “ERROR: RPMB_INIT failed, shall not start listener services”

Hmm there is actually one

 # ls -l /dev/bsg/ufs-bsg0 
crw-------    1 root     root      242,   3 Mar 31 22:09 /dev/bsg/ufs-bsg0

It is only available to root, but /vendor/etc/init/qseecomd.rc runs qsecoomd as root.

Maybe qseecomd behaves better with system/vendor/etc from Lineage - remember, since switching slots I actually booted Sailfish “over” the Asus operating system.
Since changing active slot is still a mistery for me… I will flash entire Lineage on slot a too.

Large detour:


Reading my notes I see that indeed lineage can be installed by adb sideload-ing the zip, while saifish was not.
Doing that, success. I will not boot lineage as I will have to re-do the /data dance with busybox/tar etc.
Next I 'fastboot boot hybris-boot.img`. Hmm, ramdump. What did I forgot now.

Reboot to recovery, mount /data (works, so sailfish is still there) chroot to .stowaways/sailfishos
journalctl --list-boots then journalctl -b + the last boot id.

linkerconfig.mount: Directory /linkerconfig to mount over is not emp

and

Apr 01 15:03:42 Zenfone8 bash[946]: Skipping zero-length logical partition: system_b
Apr 01 15:03:42 Zenfone8 bash[946]: Skipping zero-length logical partition: system_ext_b
Apr 01 15:03:42 Zenfone8 bash[946]: Skipping zero-length logical partition: product_b
Apr 01 15:03:42 Zenfone8 bash[946]: Skipping zero-length logical partition: vendor_b
Apr 01 15:03:42 Zenfone8 bash[946]: Skipping zero-length logical partition: odm_b

So the b-side is gone ?
No, there is only one /dev/block/by-name/super in recovery, no _a/_b versions.

Let’s mask droid-hal-init, because probably that writing to /dev/ipa that crashes when the firmware folder is not set to /vendor/firmware…
Indeed I can enter telnet now, the device doesn’t ramdump. And the first thing I do is ls /vendor to find out it’s empty.
Something stopped working, about dynparts, but what?
/usr/bin/parse-android-dynparts /dev/sda19 echoes

dynpart-system_a,ro,0 7010296 linear /dev/sda19 2048;dynpart-system_ext_a,ro,0 470248 linear /dev/sda19 7012352;dynpart-product_a,ro,0 2604744 linear /dev/sda19 7483392;dynpart-vendor_a,ro,0 2521232 linear /dev/sda19 10088448;dynpart-odm_a,ro,0 2176 linear /dev/sda19 12611584

But systemctl status vendor.mount says

Apr 01 15:18:35 Zenfone8 mount[2641]: mount: /vendor: wrong fs type, bad option, bad superblock on /dev/mapper/dynpart-vendor_a, missing codepage or helper program, or

Indeed, xxd -l 5120 /dev/mapper/dynpart-vendor_a shows only zeroes.
Maybe Lineage flashing did not work and I didn’t notice (since I didn’t boot it…?)
Let’s boot it. What could possibly go wrong. It doesn’t boot.
Back to recovery. Your data may be corrupt:)
Ok, I think the Lineage flash did not work because something failed because I have a f2fs /data instead of whatever dm-2 was expected.

Hmm… the error when mounting /data is

mount: ‘/dev/block/bootdevice/by-name/userdata’->’/data’: Invalid argument

While thinking abou this I wiped data with the Lineage recovery GUI. Then it occured to me that maybe it was just one link that was broken…
After this, ls -l /dev/block/by-name/userdata shows

/dev/block/by-name/userdata → /dev/block/sda23

Sideload Lineage again, this time I look if there are errors. Looks like it worked, too bad I didn’t pay attention last time.

Grepping the local hadk .rc files for userdata I see this in system/etc/init/hw/init.rc

     # We restorecon /data in case the userdata partition has been reset.
    restorecon /data

Hmm… sounds like a selinux thing.

Anyway, after re-flashing lineage I re-do all the busybox/untar/stowaways steps and boot hybris-boot.img
This time there’s a new “device” connected, called “Failed to boot init in real rootfs”.
Telnet works, but this time on port 23.

mount: mounting /data//.stowaways/sailfishos on /target failed: No such file or directory

Wait, what.
Oh snap.
It’s empty. Because I have done all the above busybox/untar/stowaways steps on a /data folder that was not mounted in reconvery :facepalm:
Again, starting with mount /data first.


End detour.

After this detour of flashing/reflashing I’m back to qseecomd not starting.
Same error, “could not find the ufs-bsg dev”
The string is actually in strings /vendor/lib64/librpmb.so. There is also the string “/dev/ufs-bsg”
Let’s ln -s /dev/bsg/ufs-bsg0 /dev/ufs-bsg. And try starting qseecomd again → no crash :wink:

Adding that to droid-hal-early-init.sh
This time gatekeeper and keymaster services seem to also start.

2 Likes

Day 30

test_hwcomposer still crashes. minimer still doesnt start the display. It says

library "libcutils.so" not found
library "libc++.so" not found
library "libz.so" not found
library "libion.so" not found
library "libhardware.so" not found
library "android.hardware.graphics.mapper@3.0.so" not found
library "android.hardware.graphics.mapper@4.0.so" not found
library "android.hardware.graphics.mapper@2.0.so" not found
library "libhidlbase.so" not found
library "libutils.so" not found
library "android.hardware.graphics.common@1.0.so" not found
library "android.hardware.graphics.common@1.1.so" not found
library "android.hardware.graphics.mapper@2.1.so" not found
library "android.hardware.graphics.common@1.2.so" not found
library "libandroidicu.so" not found

Linking libandroidicu to odm/lib64: ln -s /apex/com.android.art/lib64/libandroidicu.so /odm/lib64/libandroidicu.so gives back

library “libandroidicu.so” needed or dlopened by “/usr/libexec/droid-hybris/system/lib64/libmedia.so” is not accessible for the namespace “(default)”

Let’s unmount /linkerconfig :slight_smile:
Maybe /linkerconfig/default needs to be mounted on /linkerconfig, rather than bootstrap?

Also:

ln -s /vendor/lib64/egl/libGLESv2_adreno.so /odm/lib64/egl/libGLESv2_adreno.so
ln -s /vendor/lib64/egl/eglSubDriverAndroid.so /odm/lib64/egl/eglSubDriverAndroid.so

I also find that the droid-config submodule is “too new” according to hadk-hot.
I reset that to the recommended sha and make some corresponding changes to the files on device,

To my surprise, after reboot… Lineage tries to start again. (logo appears, but it doesn’t start)
This may mean that I only get a couple of boots before the slot is changed → my bootctl service does not correctly mark the system as booted.
I force reboot it to recovery and in /data, .stowaways is still there. Flashing hybris-boot:

Writing ‘boot_b’ OKAY [ 0.705s]
Indeed, it switched slot. Let’s hope super is not gone again.

I have a healthcheck process that restarts, from /system/etc/init/flags_health_check.rc

on property:sys.boot_completed=1
    setprop persist.device_config.attempted_boot_count 0

on property:sys.init.updatable_crashing=1
    exec - system system -- /system/bin/flags_health_check UPDATABLE_CRASHING

That last line. But I see on the line above that boot_completed resets some counter.
Indeed, persist.device_config.attempted_boot_count returns 1 (after it just switched the slot).

Back to linkerconfig. There’s a patch by Elros to make the switch from bootstrap to default, linked above.
Before that:

# ls /linkerconfig/ld.config.txt -l
-rw-r--r--    1 root     root         92135 Mar 31 10:50 /linkerconfig/ld.config.txt
# ls /linkerconfig/default/ld.config.txt -l
-rw-r--r--    1 root     root          4907 Mar 31 10:49 /linkerconfig/default/ld.config.txt
# ls /linkerconfig/bootstrap/ld.config.txt -l
-rw-r--r--    1 root     root          4907 Mar 31 10:49 /linkerconfig/bootstrap/ld.config.txt

After: no default or bootstrap subfolders. ld-config.txt still is 92kib

Let’s “fix” that time_daemon: adding to disabled_services.rc

service time_daemon /vendor/bin/time_daemon_HYBRIS_DISABLED
        override
        disabled

I also find that the droid-config submodule is “too new” according to hadk-hot.
I reset that to the recommended sha and make some corresponding changes to the files on device,

Let’s try harder (this is the commit to “revert” on device)

/ # rm /usr/lib/systemd/user/jolla-actdead-charging.service.d/50-compositor.conf
/ # rm /usr/lib/systemd/user/jolla-startupwizard-pre-user-session.service.d/50-compositor.conf
/ # rm /usr/lib/systemd/user/lipstick.service.d/50-compositor.conf

Ok, now I do get bootanimation + surfaceflinger to work (It’s another sanity test - just start these two (disabled) services by hand to see something on screen. Lineage un-smile in this case.)
But not minimer, that doesn’t turn on the screen.

03-31 04:12:01.936  7994  8050 I Adreno  : IsValidNativeBuffer: Buffer has a NULL handle
03-31 04:12:01.936  7994  8050 I Adreno  : DequeueBuffer: Dequeued Buffer is not valid
03-31 04:12:01.936  5980  8001 W SDM     : DisplayBase::SetVSyncState: Can't enable vsync when display 54-0 is powered off or SecureDisplay/TUI in progress

7995 is minimer
8001 is /vendor/bin/hw/vendor.qti.hardware.display.composer-service

Fortunately I have the sources for that part: android_hardware_qcom_display/display_base.cpp at lineage-18.1-caf-sm8350 · LineageOS/android_hardware_qcom_display · GitHub

Also, I can strace -p 8001.

With a similar command, and another PID, I get a “irisConfigureGetIoctl” error.
Strace shows the ioctl, but how to decrypt?

ioctl(13, _IOC(_IOC_WRITE, 0x64, 0x90, 0x10), 0x7fe3bc1fe8) = -1 EINVAL (Invalid argument)

Nevermind. This ioctl error happens with surfaceflinger too.

However, instead of “SetVSyncState” error, when I start bootanim I get some other messages:

03-31 06:00:00.826 5988 5988 E FMQ : grantorIdx must be less than 3
03-31 06:00:00.828 5988 6899 I SDM : HWCColorModeStc::ApplyCurrentColorModeWithRenderIntent: Applying Stc mode (gamut 1 gamma 1 intent 1), curr mode 7, render intent 0, hdr present 0

logcat when minimer connects to composer:

HWCSession::RegisterCallback: Registering callback: Hotplug
HWCSession::RegisterCallback: Hotplugging primary...
HWCSession::RegisterCallback: Handling built-in displays...
HWCSession::RegisterCallback: Handling pluggable displays...
HWCSession::HandlePluggableDisplays: Handling hotplug...
HWCSession::HandlePluggableDisplays: Handling hotplug... Done.
HWCSession::RegisterCallback: Registering callback: Refresh
HWCSession::RegisterCallback: Registering callback: Vsync
DisplayBase::SetDisplayState: Set state = 1, display 54-0, teardown = 0
DisplayBase::SetDisplayState: Same state transition is requested.

logcat when surfaceflinger connects to composer:

HWCSession::RegisterCallback: Registering callback: Hotplug
HWCSession::RegisterCallback: Hotplugging primary...
HWCColorModeStc::GetColorModeCount: Supported color mode count = 4
HWCColorModeStc::GetColorModes: Color mode = 0 is supported
HWCColorModeStc::GetColorModes: Color mode = 7 is supported
HWCColorModeStc::GetColorModes: Color mode = 9 is supported
HWCColorModeStc::GetColorModes: Color mode = 12 is supported
HWCColorModeStc::GetRenderIntentCount: mode: 0 supported rendering intent count = 1
HWCColorModeStc::GetRenderIntents: Color mode = 0 is supported with render intent = 0
HWCColorModeStc::GetRenderIntentCount: mode: 7 supported rendering intent count = 1
HWCColorModeStc::GetRenderIntents: Color mode = 7 is supported with render intent = 0
HWCColorModeStc::GetRenderIntentCount: mode: 9 supported rendering intent count = 2
HWCColorModeStc::GetRenderIntents: Color mode = 9 is supported with render intent = 0
HWCColorModeStc::GetRenderIntents: Color mode = 9 is supported with render intent = 1
HWCColorModeStc::GetRenderIntentCount: mode: 12 supported rendering intent count = 1
HWCColorModeStc::GetRenderIntents: Color mode = 12 is supported with render intent = 2
HWCSession::RegisterCallback: Handling built-in displays...
HWCSession::RegisterCallback: Handling pluggable displays...
HWCSession::HandlePluggableDisplays: Handling hotplug...
HWCSession::HandlePluggableDisplays: Handling hotplug... Done.
HWCSession::RegisterCallback: Registering callback: Refresh
HWCSession::RegisterCallback: Registering callback: Vsync2.4
HWCSession::RegisterCallback: Registering callback: VsyncPeriodTimingChanged
HWCSession::RegisterCallback: Registering callback: SeamlessPossible
DisplayBase::SetDisplayState: Set state = 1, display 54-0, teardown = 0
DisplayBase::SetDisplayState: Same state transition is requested.

Notice Vsync vs Vsync 2.4
And other callbacks registered. Plus, getting color modes, and rendering intents (whatever that means)

Surfaceflinger… hhm.
There’s qt5-qpa-surfaceflinger-plugin recently adapted by nephros probably fixing build.
Maybe I should use that? But let’s not give up on hwcomposer yet.

Let’s disable minisfservice → this seems to make lipstick not fail at boot time. No screen changes though.

(’/vendor/bin/thermal-engine’ makes some noise like timed, I need to disable that too)

Bootctl seems to not start
droid-bootctl.service: Main process exited, code=exited, status=70/n/a
Trying this fix: GitHub - mer-hybris/hadk-faq: FAQ for Sailfish OS porting guide (HADK)
It seems to work - hopefully I wont’ have reboots that switch slots anytime soon…

Well, still no display, but less time fighting reboots:)

1 Like

Day 31

Building qt5-qpa-surfaceflinger-plugin
Scp-ing it to my device by telnet over usb0 ssh back to laptop.
Doesn’t install because it needs something that provides libsf - it seems that package exists too, libhybris-libsf, same time, so probably built from the same sources.

Next: start

LD_PRELOAD=/usr/libexec/droid-hybris/system/lib64/libsurfaceflinger.so /system/bin/surfaceflinger;

and in another terminal:

EGL_PLATFORM=null QT_QPA_PLATFORM=surfaceflinger /usr/lib64/qt5/bin/qmlscene main.qml

Both commands fail:)

CANNOT LINK EXECUTABLE “/system/bin/surfaceflinger”: library “/usr/libexec/droid-hybris/system/lib64/libsurfaceflinger.so” needed or dlopened by “/system/bin/surfaceflinger” is not accessible for the namespace “(default)”

So I really should get down to the root cause of linker config.

library “libsf_compat_layer.so” not found

The readme said so:

You will need a patched libsurfaceflinger (permission fix), libsf_compat_layer and a recent libhybris.

In the android buildenv make libsf_compat_layer gives many errors however

external/libhybris/libhybris/compat/surface_flinger/surface_flinger_compatibility_layer.cpp:76:45: error: no member named ‘getBuiltInDisplay’ in ‘android::SurfaceComposerClient’
external/libhybris/libhybris/compat/surface_flinger/surface_flinger_compatibility_layer.cpp:77:32: error: no member named ‘eDisplayIdMain’ in ‘android::ISurfaceComposer’
external/libhybris/libhybris/compat/surface_flinger/surface_flinger_compatibility_layer.cpp:102:32: error: no member named ‘eDisplayIdHdmi’ in ‘android::ISurfaceComposer’

And grepping the sailfishos-porters logs I don’t find that the people who had these errors fixed them…

Bisecting through web interface: https://android.googlesource.com/platform/frameworks/native/+log/master/libs/gui/include/gui/SurfaceComposerClient.h?s=838de0622c700345fbfde270c065fdc97f4b9428
88d37dd good
838de06 bad
9f03447 good
74e5377 good
80d94ad good
42d0456 good
dcb38bb bad
So we have the commit: Diff - dcb38bbd32eb96ec46d69658390353a853b3af6d^! - platform/frameworks/native - Git at Google

composerService()->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain)) becomes composerService()->getInternalDisplayToken()

But errors keep crawling up, I cannot find where was that DisplayInfo.h that was used some 10+ years ago…
Quitting this thread for the time.


Let’s disable some failing mount services:

# systemctl mask vendor-asusfw.mount
# systemctl mask vendor-vm\\x2dsystem.mount

qmlscene:

library “libcutils.so” needed or dlopened by “/vendor/lib64/hw/gralloc.default.so” is not accessible for the namespace “sphal”

/linkerconfig is just mounted from sda23 which is just userdata (/data)
But who writes it? (Look who’s posing smart an year ago)

Trying to edit /linkerconfig/ld.config.txt

namespace.default.permitted.paths += /usr/libexec/droid-hybris/system/${LIB}

In the droid-configs base submodule there is a ld.config.29.txt (from Android 10) but no such config for 30 (Android 11).

It is generated in /system/linkerconfig/main.cc

Adding this to droid-hal-early-init.sh

mount --bind /usr/libexec/droid-hybris/system/lib64/libcutils.so /odm/lib64/libcutils.so

“Fixes” the “sphal” error. The odm/lib64 links were

eglSubDriverAndroid.so -> egl/eglSubDriverAndroid.so
gralloc.default.so -> /vendor/lib64/hw/gralloc.default.so
libGLESv2_adreno.so -> egl/libGLESv2_adreno.so
libcutils.so -> /usr/libexec/droid-hybris/system/lib64/libcutils.so

However I now remember libcutils was especially called out as an example in linker docs of a library that can differ between vndk (sphal) and system…
So maybe I’d better remove the link & bind mount…


Back to another train of thought - test_hwcomposer crashes because of this assert.
But maybe it doesn’t need it. So I remove all the lines and leave just return create_hwcomposer2_window();
Rebuild libhybris (–mw) and scp it - doesn’t crash.
It just gives more of

04-03 05:49:28.184 16858 16858 I Adreno  : IsValidNativeBuffer: Buffer has a NULL handle
04-03 05:49:28.184 16858 16858 I Adreno  : DequeueBuffer: Dequeued Buffer is not valid

Just as qmlscene command does.

Maybe I can work out something from here?
My plan is to read through surfaceflinger sources to see what composer init it does that test_hwcomposer/qt5-qpa-hwcomposer does not.

This will take a while.
And there’s also a school holiday coming, so I won’t hold my breath for some weeks…

2 Likes

A few weeks without a livecast? Geez!
:scream:

Then I wish you a nice holiday, you have earned!

1 Like

Season 2, Day 1

(Day 32)

Some gralloc vs libui talk about volla. On #sailfoshos, not porters’ channel.

I’m actually pinging/quoting them now so you know it “takes a village”. And there’s no logs that I know of for that channel.
(If you are new to this thread, please keep in mind that help is always asked on #sailfishos-porters).

@poetaster: I was just looking at GLES2 stuff on the volla22 and noted that gralloc looks odd: crw-rw-rw- 1 root root 1, 3 Apr 15 19:51 /vendor/lib64/hw/gralloc.default.so

@piggz: i think its a bind mount to /dev/null iirc to work around an issue with libhybris

@mal: so the device doesn’t have any gralloc module? libhybris does have support for that, unless you hacked around that somehow before that happened
libhybris does support libui now

I cannot easily find libui resources around Android, while gralloc I can: BufferQueue ve Gralloc  |  Android Open Source Project

There is /apex/com.android.vndk.v30/lib64/libui.so though. And /usr/libexec/droid-hybris/system/lib64/libui.so too.

Found this PR: Use libui for gralloc on devices without legacy gralloc HAL by NotKit · Pull Request #509 · libhybris/libhybris · GitHub

Doing mount -o bind /dev/null /vendor/lib64/hw/gralloc.default.so as on Volla makes test_hwcomposer and minimer say:

library “libui_compat_layer.so” not found

Now, the PR above looks very related, but how to build libui_compat_layer ?

hadk$ cd external/libhybris/libhybris/compat/ui/
[ui]$ mka libui_compat_layer

[100% 12/12] build out/target/product/sake/obj/SHARED_LIBRARIES/libui_compat_layer_intermediates/libui_compat_layer.so.toc

Then find out/target/product/sake/ -iname libui_compat_layer\*

out/target/product/sake/system/lib/libui_compat_layer.so
out/target/product/sake/system/lib64/libui_compat_layer.so

To copy it I need to make sure that ldd shows the dependant libraries.
But ldd on my machine does not work (x64)

Let’s scp them, with connection over telnet as in Day 28 from the previous season:

# scp vlad@192.168.2.14:/mnt/datas/sake/hadk/out/target/product/sake/symbols/system/lib64/libui_compat_layer.so /usr/libexec/droid-hybris/system/lib64/

test_hwcomposer

GUYS!


Above is test_hwcomposer, below is qmlscene with minimer.qml:

I unmask user@100000 and start it: Ahoi!

Display works. Touchscreen works
Wifi works after modprobe qca_cld3_wlan.
Sound and vibration while entering PIN works.
CAMERA works…

But:
No video recording, and trying it makes the camera stop working.
GSM doesn’t work. So mobile data neither.
Probably MTP doesn’t work, as I’ve masked usb-moded.
Rebooting doesn’t boot into GUI, after unmasking user@100000 (I remember there was some lipstick errors).
!Actually, I need to add mount -o bind /dev/null /vendor/lib64/hw/gralloc.default.so to /usr/bin/droid/droid-hal-early-init.sh so it is done at each boot.
Still doesn’t start - I need to manually restart lipstick to have gui, or the whole user@100000 session to have vibrations too.

This is a perfect start for a (dozen) new debugging season :wink:

10 Likes

That’s great news!
I’ve just ordered a used Zenfone 8 on ebay. Will arrive the next days. First I want to try /e/ OS for some time but if you need a beta tester at some point let me know.

Still a bit “too soon” :slight_smile: But I know how that feels. After lighting up the screen I have encountered many more kernel crashes than before (which end up with the ramdump screen). Let’s hope that I can stabilize that.
But agreed that hope went over 9000 after yesterday :wink:

1 Like

Day 2, Season 2

Ramdumps galore (Day 33)

Let’s fix wifi first, then lipstick on boot next.

Wifi: adding a service /usr/lib/systemd/system/wifiservice.service with

[Unit]
Description=wifisetup
After=droid-hal-init.service
Before=connman.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/modprobe qca_cld3_wlan

[Install]
WantedBy=network.target

And

cd /usr/lib/systemd/system/network.target.wants/
ln -s …/wifiservice.service wifiservice.service

Aaaand it reboots to GUI! But maybe it was a luck, because vibration does not work.
So it just probably adds enough timing for GUI to work, but not enough for - dunno, ngfd? - to work.

I still need to systemctl restart user@100000 to get vibration working.
So this service or its parent needs to wait for something else too.

Also… after restarting user@100000, and several seconds of usage, I get ramdump… !!
Of course it would’ve helped to have some pstore logs… again… but not today.

Playing with echo 1 > /sys/devices/platform/soc/990000.i2c/i2c-1/1-0038/fts_gesture_mode
From android_device_asus_sake/Sensor.h at lineage-19.1 · LineageOS/android_device_asus_sake · GitHub
Ramdump again.
Maybe unrelated…

Leaving the phone to charge over the day, and picking it up from the charger - ramdump again.

I need to always run with a telnet + dmesg on, as I saw on Day 25, sometimes the kernel has enough time to pass the crash details by dmesg + telnet…

Let’s also test bluetooth - does not work.
Fresh reboot command → ramdump :facepalm:

Let’s grab fresh logs from boot, to see what user@100000 should wait for for full functionality (right now it misses “just” vibration and… well… has too many ramdumps).

Journal: Ubuntu Pastebin
Logcat: Ubuntu Pastebin

Some things I consider debugging:

Process ‘/bin/ln -s /dev/block/sde31 /dev/block/platform/soc/by-name/mdtpsecapp_b’ failed with exit code 1

Running manually → file already exists (while perror 1 was: Operation not permitted)

(CPU:3-pid:31:wk:request_fir)aw8697_haptic 2-005a: [AW8697] Try to load firmware: /system/vendor/firmware/aw8697_haptic.bin

File exists after boot… haptic sounds like vibration-related. Wonder what was going on there.
Actually, that line was “written in red” but all the “Try to load firmware” ones are. Sometimes later:

(CPU:3-pid:31:wk:request_fir)aw8697_ram_loaded: fw update complete

Then

(CPU:5-pid:351:wk:cnss_driver)cnss: Antenna switch request failed, result: 1, err: 94

This might be GSM? Or wifi :confused:

connmand[5745]: Method “ListAdapters” with signature “” on interface “org.bluez.Manager” doesn’t exist

Bluetooth?

I notice some errors around pulseaudio and I realized that when I said vibration doesn’t work on normal boot, I didn’t check if audio works.
So I unlock the device (no sound on PIN entry), open the browser, type a popular video hosting service url (while noticing that the keyboard does do sound) press enter and…

Ramdump! Ubuntu Pastebin
Dmesg says on the last line:

wlan: [0:F:DP] dp_peer_update_state: Invalid state shift from 2 to 4 peer 00:11:32:c3:b0:e4

Message is in a macro. There are two of them actually - one that does ASSERT and one that doesn’t.

Let’s disable wifiservice and reboot.
Unfortunately the telnet connection does not work in the sailfishos browser…

Continuing to look at the previous boot logs:

wifi as inserted by lineage:

exec 18 (/vendor/bin/modprobe -a -d /vendor/lib/modules/ qca_cld3_wlan qca_cld3_qca6390)’ (pid 7516) exited with status 1 oneshot service took

Ah, modem:

[ 23.058881] (CPU:0-pid:7185:Binder:7150_2)subsys-restart: __subsystem_get(): Changing subsys fw_name to modem
[ 23.061469] (CPU:3-pid:7185:Binder:7150_2)ipa-wan ipa3_lcl_mdm_ssr_notifier_cb:2891 IPA received MPSS BEFORE_POWERUP
[ 23.061976] (CPU:1-pid:7185:Binder:7150_2)ipa-wan ipa3_lcl_mdm_ssr_notifier_cb:2900 IPA BEFORE_POWERUP handling is complete
[ 23.062198] (CPU:3-pid:7185:Binder:7150_2)subsys-pil-tz 4080000.qcom,mss: Direct firmware load for modem.mdt failed with error -2
[ 23.062211] (CPU:3-pid:7185:Binder:7150_2)subsys-pil-tz 4080000.qcom,mss: modem: Failed to locate modem.mdt(rc:-2)
[ 23.062309] (CPU:3-pid:7185:Binder:7150_2)pil_boot failed for modem

There is indeed a file /vendor/firmware_mnt/image/modem.mdt

The problem with that pil_boot was that I already fixed some other ipa_fws not loading but by using /vendor/firmware/.
Let’s # ln -s /vendor/firmware_mnt/image /lib/firmware and reboot.
Nope.

Sailfish porters logs: grep #sailfishos-porters archive
CONFIG_FW_LOADER_USER_HELPER=y.
I don’t have that - mer kernel check… Let’s enable it.
And btw, let’s also remove the ASSERT from wlan, what can hurt.

Building will take a while.

Hmm… it seems that modem.mdt error is not present. But no ofono GSM connection either.
Also, wifi ramdump is something I need to check a whole day to have a verdict…

1 Like

Day 3 Season 2

ofono - (day 34)

Today I’ve tested GPS - installed chum, puremaps and in about 30 minutes the first-cold-fix was done. That’s good, because I have no clue how to debug GPS if it doesn’t work. Hope it’s better next time though.

I temporary copy 5.4.61-qgki-perf-gc8a3515be514 to 5.4.61-qgki-perf-gc8a3515be514-dirty for the wlan module to be picked up without insmod, at bootup.

Trying /usr/lib64/ofono/test/list-modems from zypper in ofono-tests lists no modems.
According to porter’s log I need to have either ofono-ril-binder-plugin or ofono-binder-plugin.
Let’s zypper in ofono-binder-plugin and systemctl restart ofono

Now list-modems outputs stuff !

Unfortunately my SIM card is in slot 2 and the GUI for dual-sim is not available.
zypper in jolla-settings-networking-multisim
Hmm… Im pretty sure there was something else for flashlight… yep:
zypper in jolla-settings-system-flashlight

Also, GSM data doesn’t seem to work. Another grep on the porters channel:
zypper in dummy_netd

All of the above packages need to be added to patterns in droid-config-sake later.

There’s also the sensors part from hadk-faq. I need to create a hw-settings.ini file akin to this: droid-config-f5121/hw-settings.ini at master · mer-hybris/droid-config-f5121 · GitHub
I add it to the device, reboot, and indeed: orientation starts to work. Compass works too. Proximity works too.
(Did I mention I tested telephony today and it luckily “just worked”? After adding the ofono-binder-plugin. But the wonder is that call audio worked too).

There is something about vibration that I need to fix - it seems that no matter what event, the vibra just does one “click”, and a very fad one for that matter.
Also compass works and is one class above my previous device, where it was very unstable.

Ramdumps today: one when testing compass in CSD, one when disabling wifi (reproducible again) and another one when pulling the device out of charger => in the next minute.
Unfortunately, all of them unthethered so no dmesg

Now that I think I figured out GSM data, I can mask wifiservice to be sure that that is the problem.

The last ramdump after disabling wifiservice I took some time to see what the usb device looks like when in the ramdump screen to the host computer (something with QUSB_BULK_SN) and search internet (fail) and github (a bit better) about tools to extract the ramdump from the phone - without success. I did found some repos that claim to analyze qcom ramdumps, but no instructions how to extract them from the device. And I think dd won’t work for /dev/usb…

I think I won’t get away without fixing this - the lack of kernel crash logs. My hope is that I will be able to inspect the ASUS specific changes that lead to ramdump instead of a mainline pstore kernel crash log + reboot.
On the other side, if disabling the wifiservice will make the device not crash, at least I will have the problem localized…

Anyway, while applying those above patterns changes, I notice the reference to -dummy-af in the patterns.
I manually install that package and indeed, there is something different about camera video recording: it starts and updates the screen.
It still crashes on stop, and doesn’t save the video, and it still can’t be restarted.

Also I remembered from previous logs that there was a service that didn’t start:

Could not start service ‘miniaf’ as part of class ‘main’: Cannot find ‘/usr/libexec/droid-hybris/system/bin/miniafservice’: No such file or directory

That would be mini audioflinger service.
Its probably missing because I’ve done something wrong while compiling droidmedia…?
Hmm it’s something obsolete says rinigus in the past archive

Hmm… with wifiservice off, there is “something” less to wait for user@100000 service to start… and the GUI is not showing at boot anymore (it used to be that it did, but without vibra).

When it doesnt start, Lipstick says:

Apr 21 21:53:06 Zenfone8 lipstick[6782]: file offset for the library “/vendor/lib64/hw/gralloc.default.so” >= file size: 0 >= 0
Apr 21 21:53:06 Zenfone8 lipstick[6782]: library “/vendor/lib64/egl/libEGL_adreno.so” needed or dlopened by “/usr/libexec/droid-hybris/system/lib64/libvndksupport.so” is not accessible for the namespace “(default)”

When it does, it says:

Apr 21 21:53:09 Zenfone8 lipstick[6964]: file offset for the library “/vendor/lib64/hw/gralloc.default.so” >= file size: 0 >= 0
Apr 21 21:53:09 Zenfone8 lipstick[6964]: library “libcutils.so” not found

So basically the first error is because I bind-mouted /dev/null over gralloc.default.so in both cases, but the second one is because the init (which is droid-hal-init in SFOS) did not switch the linkerconfig yet, I’d guess.

I need to find a way to way to wait for that - or just be pragmatic and add 5s delay… (notice the timestamps above)
According to my logs from Day 30, linkerconfig has a default subfolder before init finishes switching and none after.
There’s a /usr/lib/startup/wait-for-file script already, maybe I should create a /usr/lib/startup/wait-for-no-file ?
It’s used like this now:

# find /usr/lib/systemd -exec grep wait-for-file  {} \; -print
ExecStartPre=/usr/lib/startup/wait-for-file /run/user-session/user-init-done.flag
/usr/lib/systemd/system/actdead.target.wants/init-done.service

The script is

while [ ! -f $1 ]
do
        sleep 1
done
echo "Found $1 file"

I can just copy it and remove the !.
Unfortunately /usr/lib/systemd/system/user@.service already has an ExecStartPre
But /usr/lib/systemd/user/lipstick.service does not.
And as far as I see in mal’s fp4 I can just use a conf file to add one.

Creating /usr/lib/systemd/user/lipstick.service.d/40-linkerconfig.conf

[Service]
ExecStartPre=/usr/lib/startup/wait-for-no-file /linkerconfig/default/ld.config.txt

reboot

Hmm

lipstick.service: Failed at step EXEC spawning /usr/lib/startup/wait-for-no-file: Permission denied

But there’s another one, more worrying: “Failed to start PulseAudio”

The first one makes sense. The lipstick service is run as user, and the ‘wait-for-file’ I copied was not executable but for root.
Let’s fix that first and see consequences later:)

Hmm… still doesn’t work.
There’s a /usr/lib/systemd/user/pre-user-session.target.wants/ too that lipstick depends on.

In the meantime, just for kicks, I add a sleep 3 to that wait-for-no-file… But this means I more or less give up:-S
But it works - at least one time. Since this is not a well understood problem, this can come back and bite me with a race.

Well, “works” but doesn’t do much - lipstick is on screen, but browser does not start:

invoker[9900]: warning: Launch failed, application specific booster is not available

So maybe I should go with the pre-user-session.target.wants and write a new service.

But looking at logs it seems that the problem is that lipstick starts on re-try, and the booster services don’t (media, browser )
Changing 3 to 5…
This time lipstick, browser and camera work, but pulseaudio does not.
So really, I should fix that with pre-user-session.

One more try, not very scientific:

# cat /usr/lib/systemd/user/linkerconfig-user.service 
[Service]
ExecStartPre=/bin/bash -c "while [ -f /linkerconfig/default/ld.config.txt ]; do sleep 1; done; sleep 5"
ExecStart=/usr/bin/sleep 5
Restart=on-failure
RestartSec=1
TimeoutStartSec=infinity

(linked to pre-user-session.target.wants/)

Notice that I actually added the sleep 5 to ExecStartPre. And I don’t need another script…
Pulseaudio now works, but only because of the 5 seconds.

ngfd does not work, god knows why.
systemctl-user restart ngfd does make vibra work though.

So I think I have a booting device without wifi (that was just adding some delay because of reasons, that made lipstick work).
I should know tomorrow if ramdumps are occuring often without wifi kernel module…

3 Likes

Day 4 Season 2

ngfd and video recording - day 35

Speaking of ngfd. I do have “native vibrator” in the config package.
But I don’t have it in my previous port. It’s memless based.
Let’s see what that package has:

rpm -ql ngfd-plugin-native-vibrator
/usr/lib64/ngf/libngfd_droid-vibrator.so
/usr/share/doc/ngfd-plugin-native-vibrator-1.3.0
/usr/share/doc/ngfd-plugin-native-vibrator-1.3.0/COPYING
/usr/share/doc/ngfd-plugin-native-vibrator-1.3.0/README
/usr/share/ngfd/plugins.d/50-droid-vibrator.ini

I think that only that last ini file matters. Let’s move it out. mv 50-droid-vibrator.ini 40-droid-vibrator.bak
Now let’s increase ngfd verbosity. The service file says:

EnvironmentFile=-/etc/sysconfig/ngfd
ExecStart=/usr/bin/ngfd $NGFD_ARGS

That doesn’t exist, so I create it with `NGFD_ARGS="-vvv"

Hmm… that does show a pagefull of logs at init in journal, but no ffmemless as on my previous device.
So maybe I was wrong that only the .ini file mattered.
Let’s move out the libngfd_droid-vibrator.so too?

Apr 22 01:28:30 Zenfone8 ngfd[13210]: [0.006] DEBUG: core: opened plugin 'ffmemless' (libngfd_ffmemless.so)
Apr 22 01:28:30 Zenfone8 ngfd[13210]: [0.007] ERROR: core: unable to open plugin 'droid-vibrator'

Ok, that’s better(?) but no vibra.
Let’s look at 50-ffmemless.ini
Copying it from my device…
Still no vibra, and I’m not sure that the ffmemless is used, even with -vvv

Video recording

If you remember, it starts now, but crashes at stop. It says:

ServiceManager: Waiting for service ‘media.audio_policy’ on ‘/dev/binder’…

This may need droidmedia changes indeed. A message from 2019 says to set
MINIMEDIA_AUDIOPOLICYSERVICE_ENABLE=1
But there are recent developments by Thaodan that enable the fake audio policy service by default.
But I don’t have them in my git log of external/droidmedia… Because I’m at tag 0.20211101.0
And this is because I’m still building 4.4. I should change that, but I hoped I will change it when uploading my packages to OBS.

Enabling then that “old” flag in env.mk and TEMPORARY_DISABLE_PATH_RESTRICTIONS=true make -j$(nproc --all) droidmedia on host

In file included from external/droidmedia/minimedia.cpp:24:
frameworks/av/media/libaudioclient/include/media/AudioTrack.h:25:10: fatal error: ‘media/MediaMetricsItem.h’ file not found
#include <media/MediaMetricsItem.h>

Which does exist in

$ find . -iname MediaMetricsItem.h
./frameworks/av/media/libmediametrics/include/media/MediaMetricsItem.h

The Android.mk has this

ifeq ($(shell test $(ANDROID_MAJOR) -ge 11 && echo true),true)
LOCAL_C_INCLUDES += frameworks/av/media/libmediametrics/include \
                    frameworks/av/media/libstagefright/include \
                    frameworks/av/drm/libmediadrm/interface

So I just add the libmediametrics… wait, it’s already there.
It seems that the above include was used for include $(BUILD_SHARED_LIBRARY) then include $(CLEAR_VARS) is issued and another build is described below:

 ifeq ($(ANDROID_MAJOR),$(filter $(ANDROID_MAJOR),11))
 LOCAL_SHARED_LIBRARIES += android.hardware.camera.provider@2.6
+LOCAL_C_INCLUDES += frameworks/av/media/libmediametrics/include \
+                    frameworks/av/media/utils/include
 endif

Let’s see what’s to scp. On host:

$ ls -l out/target/product/sake/system/bin/minimediaservice
-rwxr-xr-x 1 vlad vlad 54600 Apr 22 13:25 out/target/product/sake/system/bin/minimediaservice

On device:

# ls -l /usr/libexec/droid-hybris/system/bin/minimediaservice
-rwxr-xr-x    1 root     root         54244 Mar 23 22:48 /usr/libexec/droid-hybris/system/bin/minimediaservice

(libdroidmedia.so doesn’t seem to change)

reboot.
Hmm

F linker : CANNOT LINK EXECUTABLE “/usr/libexec/droid-hybris/system/bin/minimediaservice”: library “libaudiopolicyservice.so” not found: needed by main executable

One more scp? Not only that. The excutable looks in system/lib, vendor/lib and
openat(AT_FDCWD, "/odm/lib/libaudiopolicyservice.so", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)

The last one we control, so I link (along with the next files discovered to be missing):

ln -s /usr/libexec/droid-hybris/system/lib/libaudiopolicyservice.so /odm/lib/
ln -s /usr/libexec/droid-hybris/system/lib/libaudiopolicymanager.so /odm/lib/
ln -s /usr/libexec/droid-hybris/system/lib/libaudiopolicymanagerdefault.so /odm/lib/
ln -s /usr/libexec/droid-hybris/system/lib/libaudiopolicyenginedefault.so /odm/lib/

(This is the stuff you need to do when you’re too lazy to rebuild the rpm package I guess…)

Arrgh and it goes on and on:
Now camera doesn’t start at all because Waiting for service 'media.camera' on '/dev/binder' and ServiceManager: Service media.camera didn't start. Probably, as Thaodan says, the old MINIMEDIA_AUDIOPOLICYSERVICE_ENABLE is not ‘fake’ enough so it requires real android audio services.

Turning point:

  1. build the rinigus miniaudiopolicy that I know works for Sailfish 4.4. and older
  2. or just rebuild everything with Sailfish 4.5
  3. try to backport Thaodan’s patches
  4. just use newer droidmedia from 4.5 - but that also needs newer gst-droid (According to Changelog_from_4.4.0.72_to_4.5.0.16.md, the new gst-droid is 0.20221003.0)

Decisions… decisions.

Let’s go with 4:) First build gst-droid, see if it works.
This is useful for uploading the correct droidmedia to OBS to build 4.5.x

PlatformSDK [hybris/mw]$ git clone https://github.com/sailfishos/gst-droid.git --branch 0.20221003.0
PlatformSDK [hadk]$ rpm/dhd/helpers/build_packages.sh -b hybris/mw/gst-droid

Success. A fresh new hadk/droid-local-repo/sake/gstreamer1.0-droid-0.20221003.0-1.aarch64.rpm waits to get scp’d.
Let’s see about that droidmedia.

HABUILD_SDK [external/droidmedia]$ git checkout 0.20220929.0
HABUILD_SDK [hadk]$ TEMPORARY_DISABLE_PATH_RESTRICTIONS=true make -j$(nproc --all) droidmedia
PlatformSDK [hadk]$ rpm/dhd/helpers/build_packages.sh --gg

Building rpm/droidmedia.spec
echo /usr/libexec/droid-hybris/system/etc/init/disabled_services.rc /usr/libexec/droid-hybris/system/etc/init/ecclist.rc /usr/libexec/droid-hybris/system/etc/init/servicemanager.rc

Processing files: droidmedia-0.20220929.0-1.aarch64
error: File not found: /home/vlad/hadk/hybris/mw/droidmedia-localbuild/installroot/usr/libexec/droid-hybris/system/etc/init/disabled_services.rc
error: More than one file on a line: /usr/libexec/droid-hybris/system/etc/init/ecclist.rc
error: More than one file on a line: /usr/libexec/droid-hybris/system/etc/init/servicemanager.rc

Of course Elroshadk-hot already covers this: droid-hal-device: <= 960d6af for 4.5 building.
And rm -rf hybris/mw/droidmedia-localbuild then and it built.
scp packages to device, install, removed /home/defaultuser/.cache/gstreamer* and reboot

Ah… same results with camera recording.


Even worse, now browser crashes when playing video.
Let’s zypper rm gecko-camera-droid-plugin as seen on [4.5.0.16] Video playback in browser not working - #5 by vlagged
:stuck_out_tongue: Is this cargo cult debugging. It worked, at least browser playback is restored.
But it breaks browser webcam (because … gecko-camera,… get it?)

Hmm. Installed back gecko-camera - webcam works, at least on second try (crash on the first…)

kernel: Failed to create debugfs for msm_vidc

# mount -t debugfs none /sys/kernel/debug doesn’t work, nor creating that directory.

Other things:
export GECKO_CAMERA_DROID_NO_MEDIA_BUFFER=1 would work? /usr/lib/systemd/system/user@.service shows some environment files.
# vi /var/lib/environment/nemo/70-browser.conf
That flag that worked to solve other problems for piggz (garbage playback).


Let’s continue camera recording and leave the browser a bit as it is. The 4.5 browser may have different behavior, hopefully.

Journal: Ubuntu Pastebin
Logcat: Ubuntu Pastebin

Codec2Buffer: GraphicMetadataBuffer does not work on 64-bit arch

Seems I have sources for this: frameworks/av/media/codec2/sfplugin/Codec2Buffer.cpp
They effectively don’t have the 64-bit implementation and put that message instead.

The process that gives the error is jolla-camera. How could this be? Jolla camera links to something which includes this 64-bit code.

Hmm… so plan 4 was not the best.
I don’t know if the errors are specific to 4.4 using droidmedia from the future or just 4.5 errors I will come to see.
I have to sleep on it.

2 Likes

Sounds like you are making good progress :slight_smile:

Well, some progress, yes - some things worked out of the box, some I didn’t look into and there are always things that could take a very long time to figure out.

For example, until now I built SailfishOS 4.4.0.58 locally on my machine, from Lineage 18.1 base.
The status is (and may change on version changes - even for the worse):

Core functionality:

Display/Touch Wifi GSM Calls Cellular Data Sound Camera Pics Video playback
:white_check_mark: only 60fps :warning: driver is crash-happy :white_check_mark: although I saw some disconnects :white_check_mark: tested on SIM 2 :white_check_mark: :white_check_mark: but over-sharpened :white_check_mark:

Those wifi crashes bring the whole system down, so they’re not a small thing.
(There may be some things I’m not aware of, for example audio jack is not tested. Or not listed here, like the led working turning green when a call is missed.)

More features that make the port complete:

Camera recording Bluetooth Vibration Multiple cameras MTP Fingerprint on Display Double-tap to wake
:x: :grey_question: not started :warning: a single vibration for all events :grey_question: not started :grey_question: not started :grey_question: not started :grey_question: not started

(This is just because I needed more lists so this doesn’t turn into a big horizontal table, but they might matter more for some than the core list above.)

Sensors:

GPS Compass Accelerometer Proximity Light NFC
:white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :grey_question: not started

Another thing is that this is not yet “installable” without many manual commands, not even by me. So some packaging work needs to be done also.

3 Likes

Day 5 Season 2

Dropping plans - day 36

I forgot to mention that while I was in vacation, Mister_Magister and K31jo started porting SailfishOS for Zenfone 8 too !
This is excellent news - my dream come true.

I think there’s one thing that can make ports better, and that is having more than one dev working on them.

I have shared the repos I have online under my github username, but we are still figuring out how to work.
Because maintainership of OBS nemo:devel:hw:asus:sake was already requested by him, Mister_Magister added me to that project.

My plan is to make some tests with OBS build, since the “devel” project builds the latest saiflishos.
So, I locally build 4.4.x, and I can add OBS repositiory so that I can simulate an upgrade to 4.5.x
This was one of the reasons I chose to build locally a previous version.

This would also allow me to see if droidmedia works better with 4.5 (though I doubt that 64-bit error will “fix itself”).

So I upload the droid-hal* rpms I have locally to that project, and add a couple more projects from their repositories, as suggested by OBS when the build does not start because ther is a missing package.

Now, if the droidmedia test fails, I can continue to figure out with building locally - but I still have the option to see if 4.4 would work first. Then I could build a slightly outdated droidmedia for 4.5.

But, I have a local change that it is not in github: masking of usb_moded. My local package has that /dev/null link in /etc/systemd, and the remote one would not → so if I update the system, the link will get removed, usb-moded will start, I’ll lose telnet access (which I still require since this is wifi-instable) and I have to go back to TWRP or Lineage Recovery to fix this, which I don’t want to:P

usb_moded: as per hadk-hot, I add -D to see debug arguments, and run in manually. Which immediately cuts me off from the usb connection.
Then reboot (using the GUI;), and look at journalctl -b -1 (that is, previous boot)

/config/usb_gadget/g1/functions/rndis.usb0/ethaddr: can’t open for writing: No such file or directory
/config/usb_gadget/g1/functions/rndis.usb0/wceis: can’t open for writing: No such file or directory

…Hang on, I’m confused. usb-moded disablement made it accidentally into my droid-config-sake repo.
Dropping plans to fix usb_moded for now:)

To update to 4.5.x, I need this line (from tucana ssu lr)
adaptation-community ... http://repo.merproject.org/obs/nemo:/devel:/hw:/xiaomi:/tucana/sailfish_latest_aarch64/
added / replacing this line from sake ssu lr:
adaptation-community-common ... https://repo.sailfishos.org/obs/nemo:/devel:/hw:/common/sailfish_latest_aarch64/

But meanwhile k1gen has the same GraphicMetadataBuffer does not work on 64-bit arch error.
So it might not “fix itself” even by upgrading to 4.5.x
Dropping plans to update to 4.5.x for now:)

# mv /usr/libexec/droid-hybris/system/lib64/libdroidmedia.so /usr/libexec/droid-hybris/system/lib64/libdroidmedia.so-bak
Doesn’t work. I doesn’t just simply start using 32-bit libs:)

Let’s switch plans and actually build the 4.4 droidmedia version with rinigus’ miniaudiopolicy.

$ cd external [vlad@vlinux external]$ git clone https://github.com/sailfishos-sony-tama/miniaudiopolicy.git cd - TEMPORARY_DISABLE_PATH_RESTRICTIONS=true make -j$(nproc --all) miniaudiopolicyservice

external/miniaudiopolicy/Android.mk: error: “miniaudiopolicyservice (EXECUTABLES android-arm64) missing libsoundtriggerservice (SHARED_LIBRARIES android-arm64)”

FAILED: ninja: 'out/target/product/sake/obj/SHARED_LIBRARIES/libsoundtriggerservice_intermediates/libsoundtriggerservice.so.toc', needed by 'out/target/product/sake/obj/EXECUTABLES/miniaudiopolicyservice_intermediates/LINKED/miniaudiopolicyservice', missing and no known rule to make it

Ok, let’s remove it altogether that dependency altogether?

Then I hit some more header errors (the same as with env.mk change the other day) which are again fixed by adding

frameworks/av/media/libmediametrics/include
frameworks/av/media/utils/include \

And the miniaudiopolicy build finally works.

Meanwhile on the device:

zypper in bluebinder doesn’t just “make” bluetooth work.
maybe it needs wifi?

I see this in journal.
Apr 25 10:50:20 Zenfone8 bluebinder_post.sh[7343]: Failed to get bluetooth address!

And this in logcat:
04-25 07:50:46.928 6313 10416 I vendor.qti.bluetooth@1.0-patch_dl_manager: BD Address: 8c:f5:8e:3d:7c:3c

For the first one, I need to fill in the bluetooth address with the second one.
That would go into a file called /var/lib/bluetooth/board-address as expected in this script.
Manually doing echo 8c:f5:8e:3d:7c:3c > /var/lib/bluetooth/board-address does work, but I can’t ship a port with my bluetooth address, can I?

So after stracing and grepping the whole system I “accidentally” find this short 9-byte file:

/mnt/vendor/persist$ xxd bt_nv.bin 
00000000: 0101 068c f58e 3d7c 3c                   ......?|<

Notice it?

This is my new /usr/bin/droid/droid-get-bt-address.sh

#!/bin/sh

B=$(xxd -e -g 8 -ps -s 3 /mnt/vendor/persist/bt_nv.bin)
echo "BT MAC: $B"

if [ ! -z "$B" ] ; then
    bt_mac=${B:0:2}:${B:2:2}:${B:4:2}:${B:6:2}:${B:8:2}:${B:10:2}
    echo $bt_mac > /var/lib/bluetooth/board-address
fi

Not enough time for video debugging today, but at least I have bluetooth.
It works with some audio headphones, but not yet in calls. This should be an easy fix for the next day…

I’m a little confused: do you work together or do you compete with each other?

I’m a little confused: do you work together or do you compete with each other

They weren’t aware that a port was started already, now they know. I asked, they said “later”.

All in all, the fact that there are multiple Zenfone 8 devices in the hands of porters is good.
This is not like an open ended software development project - the more people figure out things the more will be helpful for everybody. And the end result is always a SailfishOS distribution.

(There are caveats though: if we were using a different LineageOS base for the port that could make things different. Today the latest available version is still 18.1 for porting SFOS, and that is the first “sake” Lineage OS available, so I am 99% confident we do use the same base OS.)

2 Likes

Day 6 Season 2

day 37

Back to video recording a bit:

$ external/miniaudiopolicy/rpm/copy-hal.sh

ends up in external/miniaudiopolicy/out/miniaudiopolicy

PlatformSDK $ rpm/dhd/helpers/build_packages.sh -b external/miniaudiopolicy/

As you see, this package has, just as droidmedia, an Android build and a RPM spec - one is built in the Android environment, the other one in sfossdk (PlatformSDK).

But after scp-ing miniaudiopolicy the stop button, while crashes video recording, also triggers:

Waiting for service ‘media.audio_policy’ on ‘/dev/binder’…

And ps doesn’t show “miniaudiopolicy” process. Let’s run it manually:

CANNOT LINK EXECUTABLE "/usr/libexec/droid-hybris/system/bin/miniaudiopolicyservice": library "libandroidicu.so" not found: needed by /system/lib64/libmedia.so in namespace (default)

Quickly link everything for test:
cd /odm/lib64; ln -s /apex/com.android.art/lib64/lib* .

Ok, this doesn’t work. I mean, miniaudiopolicy works, but recording still says:

E Codec2Buffer: GraphicMetadataBuffer does not work on 64-bit arch

So, video recording is becoming the major timesink:)

Back to bluetooth:

%define ofono_enable_plugins bluez5,hfp_ag_bluez5 in spec
Testing on the device by removing those two plugins from /var/lib/environment/ofono/noplugin.conf seems to work (call sound and mike with BT headphones)

I don’t like that the pixel ration 1.5 gives 5 columns of icons on Zenfone 8:
This usally needs to be set at buildtime, but hadk-faq has instructions for runtime.

Trying 1.75:
zypper in zypper in sailfish-content-graphics-default-z1.75

$ dconf write /desktop/sailfish/silica/theme_pixel_ratio 1.75
error: The operation attempted to modify one or more non-writable keys
$ dconf write /desktop/sailfish/silica/theme_icon_subdir z1.75
error: 0:expected value
$ dconf dump /desktop/sailfish/silica/
theme_icon_subdir='z1.5'
theme_pixel_ratio=1.5

There is a script to re-scale the icons, linked from hadk-faq, that does

$ rm -f /etc/dconf/db/vendor.d/locks/silica-configs.txt

The contents of the file are exactly:

/desktop/sailfish/silica/theme_pixel_ratio
/desktop/sailfish/silica/theme_icon_subdir

Removing that, I can write the pixel_ratio, but not the icons subdir (0:expected value)
systemctl --user restart lipstick does show some dpi changes

Aargh more backslash

$ dconf write /desktop/sailfish/silica/theme_icon_subdir \"z1.75\"

Works \o/
But I’m not sure I like the 4 columns. I think I would have got away with 5 :slight_smile: but with the 1.75 pixel ratio.
Anyway, there is time to tinker with that.

2 Likes

Day 7 Season 2

You know I am not happy about that wifi driver. I think its the one that crashes a lot.
But lately I enabled it (when debugging bluetooth) and I only had one crash with the phone in “actdead” charge mode. Of course, no dmesg or other logs.
So I kept it enabled. Yesterday I notice that in 8hours the phone loses 50% of the charge!
Disabling wifi put that back into normal.

So I have a power hog and crashy wifi driver.
I notice lineage-20 uses 5.4.226, a “slightly” newer kernel than my 5.4.61, “only” 35661 commits added.
I should try that sometime…

back to vibra. A more scientific approach…
Last time I tried my ffmemless configuration from tucana, without success (ffmemless does not start?)

Let’s find the driver. Previous experience tells me that I should grep .dtsi files from kernel.
For haptic: I found pm8350b_haptics and a list of custom effects.
That should match that ffmemless configuration though.
But there’s also swr_haptics and that actually matches a kernel module I have.
Which one is it?

# find /sys -iname \*vibr\*
/sys/class/leds/vibrator
/sys/devices/platform/soc/998000.i2c/i2c-2/2-005a/leds/vibrator
/sys/devices/platform/soc/998000.i2c/i2c-2/2-005a/leds/vibrator/boot_vibrator

Aaah the boot vibrator.
Echoing 1 into that last device file makes the short click

And dmesg references aw8697_haptic, this one. So I didn’t guess the driver :slight_smile:

I grep the porters log and literally apply this advice, restart ngfd and bzzzzzzz everything is bouncy and vibrant again!

Btw, did I mention that the secondary (wide) camera actually works in Advanced Camera? So here’s the new status:

Camera recording Bluetooth Vibration Multiple cameras MTP Fingerprint on Display Double-tap to wake
:x: :white_check_mark: :white_check_mark: :white_check_mark: :grey_question: not started :grey_question: not started :grey_question: not started
4 Likes

Day 8 Season 2

Spoke too soon about vibration yesterday. It doesn’t survive reboot.
I also did echo 1 > /sys/class/leds/vibrator/activate_mode while testing the vibrator devices.
That needs to be done at boot time too.

Of course, of of lazyness, I re-use the droid-hal-early-init.sh script.
Up until this point, this script contained only commands to unblock the droid ‘init’ starting.

What I notice is that 1: on reboot, that script does not find the device and 2. the kernel module for aw8697.ko is added by… droid-hal-init.
This must be a mistake :slight_smile: I maybe should depmod -a everything but still… for the moment, I modprobe the haptic driver in that shell script too.

Also!

echo 1 > /sys/devices/platform/soc/990000.i2c/i2c-1/1-0038/fts_aod_ctrl_mode 
echo 1 > /sys/devices/platform/soc/990000.i2c/i2c-1/1-0038/fts_gesture_mode

I spoke too soon again - that activates AOD which works on single touch:
It was actually
echo 1 > /proc/driver/dclick as seen in this proc_create call that made it work.

obligatory:
ezgif-2-87512566ac

3 Likes