Livecasting porting notes for Zenfone 8

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

Oh wow! If double-tap-to-wake is working, the essentials are there and the port is ready to release :grinning:
Nah, seriously: this is really cool, like in the days of my J1 :smiley:

4 Likes

Fortunately now there are many more devices that have hardware support for double-tap:)

Regarding release, I will probably make a “devel” release soon, since I will hit a wall on what easy / not started tasks I have, and I’ll have to start the hard ones (video recording, wifi crashing / power consumption) which will probably take more time.

2 Likes

By the way, are you going to add encryption to the port?

Thank you for reminding me “before it’s too late”.
Meaning: for my current device I don’t have encryption because rinigus developed it while I was already daily-driving the device and never “found” the time to back up, re-flash it and,…

There is some work to enable encryption: a small Android package build, 4-5 more SFOS rpms.
I should probably start this before the first release, so its “before it’s too late” for all.
The only problem I have (and is not related to the community encryption but…) is that I have to decide a file size for the home partition.

Why? Because my port (as opposed to Sony ones) is using a bare /data/.stowaways/sailfishos as root mount, instead of building a LVM partition. Why? Because this is how they teach you in HADK and I haven’t invested the time to see how I can go about to make a LVM port.

How is that a “problem”? Well, root and home, in this configuration, can expand any way they like, they will still be a subfolder in /data partition. Meaning I can choose to fill my hundreds of Gigabytes with software in /usr or with files in /home (not with videos for now:). Their sum just needs to be under 227GB as I have the partition today.

But, when I enable encryption, I have to choose the size of the /home partition. And that would be the default for all new installs, and probably instructions can be made to resize it.
Not only is this a 80/20 problem (you can have this problem on your home computer), but there’s also the fact that Asus Zenfone 8 comes in at least 128GB and 256GB variants - so even though I have the latter, I will probably choose a default to match the former…

Anyway, again, this is a good thing, that you brought this up. I will do my best to enable it and report back.

2 Likes

Day 9, Season 2

I moved all my repos to sailfishos-on-sake.
I’ve added -z instead of -j to hybris boot image creation.
I’ve rebuilt kernel, droid-hal and re-uploaded to OBS through the osc command (which is like a SVN for build inputs)
I’m now adding the OBS repo to my locally built device (4.4).
What can go wrong ?:slight_smile: Anything. In that case I’ll have to re-flash.
But that is an opportunity - I would test if -z (gzip) instead of -j (bzip2) would work in TWRP or Lineage Recovery. Bzip2 didn’t,

[root@Zenfone8 defaultuser]# ssu ar adaptation-community http://repo.merproject.org/obs/nemo:/devel:/hw:/asus:/sake/sailfish_latest_aarch64/
[root@Zenfone8 defaultuser]# zypper ref adaptation-community
Retrieving repository 'adaptation-community' metadata ...........................................................................................................[done]
Building repository 'adaptation-community' cache ................................................................................................................[done]
Specified repositories have been refreshed.
[root@Zenfone8 defaultuser]# ssu re 4.5.0.19
Changing release from 4.4.0.58 to 4.5.0.19
Your device is now in release mode!
[root@Zenfone8 defaultuser]# version --dup
REBOOT NOW unless you need to investigate update
issues or know what you are doing (or both).

All bugs encountered until reboot are features.

[root@Zenfone8 defaultuser]# ls -l /etc/systemd/system/usb-moded.service
lrwxrwxrwx 1 root root 9 Apr 29 00:58 /etc/systemd/system/usb-moded.service → /dev/null

Vibration starts later?
But it booooooots!

So I have done my first upgrade from locally-built 4.4 to OBS build 4.5
It does not include a kernel upgrade, I need to do something like this later, maybe tomorrow?

Waydoid

Installing waydroid from chum - it does not start, says something about binder device not found.
I thought having BINDERFS enabled in the kernel would just allow one to create binder devices on the fly.
But that waydroid script only does that for “mainline” devices
Meaning: only if getprop does not return ro.vndk.version it tries to create binder devices using bindercontrol…

One reason to re-build the kernel with pre-defined binder devices as piggz’s FxTech Pro1X

Wifi

ifconfig shows both wlp1s0 but also wifi-aware0.
Searching for it reveals this “Neighbour Aware Network” Wi-Fi Aware overview  |  Android Developers
Maybe I should disable it.

One reason to re-build the kernel

So, two reasons to re-build the kernel and one lingering ‘kernel update’ development to do. I sense an opportunity :slight_smile:

4 Likes

Day 10 Season 2

I finally enabled kernel upgrade, after fighting a bit with a script:

# /usr/sbin/flash-partition 
At least one partition needs to be defined variables PART_1, PART_REAL_1 and PART_I.

This brought me two new kernel changes: binder devices and disablement of wifi-aware0/NAN, in the hope that less power is consumed by WLAN…

Which reminds me that powertop does not start, debugfs related error.
As in day 4, mount -t debugfs none /sys/kernel/debug doesn’t work.
On closer inspection, I am missing CONFIG_DEBUG_FS=y, let’s add that, and build the kernel again…

The worflow for updating kernel from now would be: build it (hybris-boot.img) boot it (fastboot boot hybris-boot.img) and if it works package it (build_packages.sh --droid-hal) and copy the droid-hal* packages through osc to OBS.

About waydroid: it seems that the change I made to the kernel generates these devices

# ls /dev/binderfs/
binder
hwbinder
hwpuddlejumper
puddlejumper
vndbinder
vndpuddlejumper

but Waydroid expects them directly under /dev/

Peeking through previous work again, it seems piggz fixes this with ln -sf /dev/binderfs/* /dev/ here, I should copy that whole service (plus, I also have misc stuff not related to droid-hal-early-init.sh so…)

For now, manually ln -sf /dev/binderfs/* /dev/

# waydroid init
[17:22:54] Downloading https://sourceforge.net/projects/waydroid/files/images/system/lineage/waydroid_arm64/lineage-18.1-20230422-VANILLA-waydroid_arm64-system.zip/download

Good!

When the download finishes, I install waydroid-settings and go to Settings app to stat the daemon.
The new icon is now on my screen but doesn’t “start”.

Let’s see:
May 01 16:49:35 Zenfone8 dnsmasq[7033]: dnsmasq: failed to create listening socket for port 53: Address already in use
This is the first point here: GitHub - sailfishos-open/waydroid: Waydroid packaging for Sailfish OS
Next:
(017197) [17:32:51] Failed to get service waydroidplatform, trying again...

Meanwhile, 20 minutes of kernel build have passed, let’s boot it.
Ooops, takes a long time to turn on the screen and the touch isn’t working. Telnet to the rescue…
Ah… of course. it doesn’t work like this, kernel drivers do not load…

# modprobe qca_cld3_wlan
modprobe: FATAL: Module qca_cld3_wlan not found in directory /lib/modules/5.4.61-qgki-perf-gbb907089bcf2-dirty

I don’t have that directory. Kernel changed magic again. insmod doesn’t work either, “disagrees about version of symbol …”
Ok, build droid-hal then…
Copy droid-hal*.rpms to osc checkout directory, osc commit.
Let’s also cherry pick that binder link service.

# zypper ref adaptation-community
# zypper up

It reboots two times, as expected, flashing the new kernel kicks a reboot.
powertop starts
dnsmasq does not
droid-bootctl does not - didn’t I already fix this?

/lib/udev/rules.d/998-droid-system.rules indeed shows original content.
rpm -qf says it’s from droid-config-sake
I have a locally built variant of that package and it has the correct file…
I also download the OBS built droid-config-sake rpm and it has the correct file…
zypper in --force droid-config-sake reinstalls the package but no changes, the file is incorrect.
strace-ing that shows /home/.zypp-cache but also shows that the download is unlinked…

Hmm… I may make a mistake, the contents seem fine now. But marking boot as successful is not.
?/
This really bugs me… and will probably bite me later but…

Waydroid now starts!
Welcome back, Lineage-in-a-container !

The nice thing about waydroid booting is that I can… have Camera 2 API (no horrbile sharpening) and… wait for it… video recording works! This may mean that the bits I have compiled on the “host droid-hal” are good, and I can strace the waydroid camera to see how they are used.
(for context, on my previous device, recording didn’t work in either SFOS nor in Waydroid)

5 Likes