Android RIL and GNSS driver for Android 13 on x86_64

So just wondering. Is there any chance of still getting a RIL driver that is more up to date then IRadio 1.1 ? I found another post here in the forum where someone was provided with multiple zip files that contain the driver versions 3.6.14 and 4.0.1 which according to the file name and the change log do in fact support IRadio 1.6 on Android 13 and they do contain all the files that the RIL driver user guide says…
Namely /vendor/lib64/libril.so which is missing entirely in the V3.6.35_master_beta build that you provided me with…
The issue is those files are completely useless to me since they are for ARM and not for x86_64.

Forgot to add. This is the post in question where the user was provided with the ARM version of pretty much what I’d need:

I previously provided the libs for X86_64. These libraries are compiled by myself in the source code of Android13.
If it still doesn’t work, it may need to provide an sdk environment.

Unfortunately those IRadio 1.6 libs you previously build fail to load. I already provided the details about what happens in an earlier post after you asked me to run some commands to debug the issue. Please see here:

The reason the library fails to load is this error:

CANNOT LINK EXECUTABLE "/vendor/bin/hw/rild": cannot locate symbol "_ZN7android8hardware12ProcessState16initWithMmapSizeEm" referenced by "/vendor/lib64/libril.so"...

As I mentioned.
Where can I find the Android source code?

CANNOT LINK EXECUTABLE “/vendor/bin/hw/rild”: cannot locate symbol “_ZN7android8hardware12ProcessState16initWithMmapSizeEm” referenced by “/vendor/lib64/libril.so”…

That means the libril.so I provided is not compatible with the your Android SDK.

Oh sorry about that. I misunderstood and thought any android 13 source code would do.

The specific version I’m building can be downloaded like this:

repo init -u https://github.com/LineageOS/android.git -b lineage-20.0 --git-lfs
repo sync build/make

wget -O - https://raw.githubusercontent.com/waydroid/android_vendor_waydroid/lineage-20/manifest_scripts/generate-manifest.sh | bash

repo sync

. build/envsetup.sh

apply-waydroid-patches

lunch lineage_waydroid_x86_64-userdebug

Here is the guide I followed as reference just in case:

https://wiki.lineageos.org/emulator

Also not sure if that matters for you but the LineageOS guide mentions using Ubuntu 20.04 LTS for building but that doesn’t work for LineageOS 20 so I’d just use the newest version of Ubuntu instead.

Please try it.

ril.libs.zip (6.6 MB)

For IRadio 1.6 X86_64.
I compile it with the Waydroid Lineage OS.

Thank you very much for all that effort of building a custom RIL with the Waydroid Lineage OS sources.
Unfortunately even with that I`m still getting the same error (cannot locate symbol “_ZN7android8hardware12ProcessState16initWithMmapSizeEm”)…

I spent the entire day testing various things and discovered that the function initWithMmapSizeEm has been moved from libhwbinder.so to libhidlbase.so.
See here: Paket  |  Android Open Source Project

I was also able to confirm that using readelf by looking at all the files involved:

This is the libril.so you just provided me:

lukas@UbuntuVM:~$ readelf -Ws libril.so | grep initWithMmapSize
    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZN7android8hardware12ProcessState16initWithMmapSizeEm
   995: 00000000000f7850    86 FUNC    GLOBAL DEFAULT   13 initWithMmapSize

This is the libhwbinder.so provided by you:

lukas@UbuntuVM:~/$ readelf -Ws --dyn-syms /home/lukas/android/lineage/out/target/product/waydroid_x86_64/system/lib64/libhwbinder.so | grep initWithMmapSize
#No output...

And this is the libhidlbase.so generated by my android build:

lukas@UbuntuVM:~/$ readelf -Ws --dyn-syms /home/lukas/android/lineage/out/target/product/waydroid_x86_64/system/lib64/libhidlbase.so | grep initWithMmapSize
  1766: 00000000000bf8a0    21 FUNC    GLOBAL DEFAULT   14 _ZN7android8hardware12ProcessState16initWithMmapSizeEmb

While it looks like that symbol has just moved there is actually a very tiny difference which causes the linker error:

In libhidlbase.so the symbol is actually called _ZN7android8hardware12ProcessState16initWithMmapSizeEmb while libril.so is looking for just
_ZN7android8hardware12ProcessState16initWithMmapSizeEm (without the b).

I was able to work around that by using patchelf like so:

map_file:

_ZN7android8hardware12ProcessState16initWithMmapSizeEm _ZN7android8hardware12ProcessState16initWithMmapSizeEmb

command:

patchelf --rename-dynamic-symbols map_file --output libril.so.patched libril.so

result:

lukas@UbuntuVM:~/$ readelf -Ws --dyn-syms libril.so.patched | grep initWithMmapSize
    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZN7android8hardware12ProcessState16initWithMmapSizeEmb
   995: 00000000000f7850    86 FUNC    GLOBAL DEFAULT    9 initWithMmapSize

While this does get my a bit further it still does not work :frowning:
This time it successfully initializes the modem but then crashes / just gets stuck while doing an ioctl syscall to interact with the kernel binder module.
Most likely that is something I`ll need to ask the people that made waydroid about but just in case I captured the logs and an strace for you to also have a look at.

RIL_1_6_log.txt (7.8 KB)
Unmodified_libril_missing_symbol.txt (104.1 KB)
Modified_libril_hanging_ioctl.txt (154.9 KB)

I also captured this log file where the ioctl causes a SIGSEGV and the appropriate signal handler kicks in:
Modifed_libril_SIGSEGV.txt (187.4 KB)

If you still have to build files from the waydroid code could you please sent me the libhidlbase.so generated by your build ? I`d like to see if the symbol actually has the correct name there or not.

Also in case it matters. The shared objects where build using this version of gcc / g++ on a freshly setup VM Ubuntu 23.10 VM with make clean being executed on the previously used source:

lukas@UbuntuVM:~/android/lineage$ gcc --version
gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

lukas@UbuntuVM:~/android/lineage$ g++ --version
g++ (Ubuntu 13.2.0-4ubuntu3) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If I provide the libhidlbase.so I am afraid that your Android system cannot boot up.

system.zip (7.9 MB)

It has nothing to do with the gcc version on the Ubuntu.

I don’t have the apply-waydroid-patches

I have the Quectel RIL source code and so I just replace the hardware/ril/ with the Quectel source code.

repo init -u https://github.com/LineageOS/android.git -b lineage-20.0 --git-lfs
repo sync build/make

wget -O - https://raw.githubusercontent.com/waydroid/android_vendor_waydroid/lineage-20/manifest_scripts/generate-manifest.sh | bash

repo sync

. build/envsetup.sh  && lunch lineage_waydroid_x86_64-userdebug && mmm hardware/ril/reference-ril

But if it still cannot run, I am afraid there is still something wrong with the Android source code.

rild.zip (4.4 KB)

Here is the rild.

Thanks I’ll look at them later today.
The system not being able to boot with that isn’tan issue. I’m just interested in seeing if the symbol name is correct there and maybe I’ll be able to patch the libril.so to point to that file instead to see what it does.

I think the reason you don’t have the apply-waydroid-patches is because you need to run the ./build/envsetup.sh before running that command. Otherwise the script is not in your path environment variable.

I don’t have the apply-waydroid-patches. And yes that might be the root cause.
The waydroid is not the real Android 13.

libhidlbase.so is very important if it changed, other service might be affected.
For x86_64 it is easier to use the IRadio 1.1.
I can just compile the reference-ril.so with the ndk.

Waydroid is a container based android. It shares the linux kernel of the host distro and uses Wayland to render graphics. Apart from that its functionally a complete android. My goal woth getting that modem up and running is to eventually build a custom android phone which supports both running a full linux desktop as well as android.

Anyway here is what i found while looking a bit more into the issues:

I just checked where the apply-waydroid-patches is defined.
Since for some reason you are missing the function you should be able to execute the command behind that function manually.

The function is defined here:

Which in turn executes just this script:
vendor/extra/waydroid-patches/apply-patches.sh

The script vendorsetup.sh should automatically be executed when you run . build/envsetup.sh. probably that isn’t happening for some reason.

I also checked and waydroid is applying plenty of patches to the hwbinder code so that probably explains the issues when those patches are missing.
Here is (at least one) of the patches that affects the method initWithMmapSize:

apply-waydroid-patches will generate too much conflicts.

I can just apply the
android_vendor_waydroid/waydroid-patches/base-patches-29/system/libhwbinder/0001-hwbinder-Add-support-for-host_hwbinder-driver.patch at lineage-20 · waydroid/android_vendor_waydroid (github.com)

Huh thats strange. I ran that just yesterday and it ran through with zero conflicts.
Before you apply that please let me look thorough the rest of the patches they have in the repo and see if there are any other that directly affect this part of the code.
The earliest I’ll be able to do that is today evening though. (German time)

I found something while looking at the patches that waydroid applies. They added an extra bool parameter to initWithMmapSize. That causes the extra b at the end of the symbol name. I readded the old method and hardcoded the appropriate bool value for this case.
While this fixes the missing symbol it still crashes with a SIGSEGV on a BINDER_WRITE_READ ioctl.
So for now it looks like I’ll have to debug more on my side first as i think the ril driver you provided has the potential to work once i figure out whats causing the segmentation fault.

Thank you very much for your help so far.
I’ll let you know in case i find anything that has any impact on the RIL driver you provided.

I will download the android sdk again.