Esim on Xperia 10 iii (and other SFOS devices)

Might really be of interest, since eSIM prevalence increases. My provider offered me eSIM, I declined in believe that eSIM is not supported by SFOS. Not too long in the future there might be the situation that eSIM will be standard and physical SIMs hard to come by.
In addition, when traveling and roaming with the current provider not wanted or possible, eSIM use makes sense…

I have an Xperia 10 V that has hardware eSIM, but since Sailfish does not yet support integrated eSIM chips, I decided to buy a 9eSIM SIM that also comes with a USB-C reader so I can programme it with my mobile phone or from my PC Strengthen(V3) package – 9eSIM.

Yesterday I installed the 9eSIM app in AppSupport and when I ran the compatibility check, it told me that it did not support doing it from the mobile’s integrated SIM reader but it did support USB, so when I get the reader and the SIM, I will try plugging the reader into the mobile to see if it recognises it properly and can be programmed with that app via AppSupport. I will also try lpac via commands from Sailfish to see if it recognises both the internal chip and the reader and if it is possible to have a native app 9eSIM Card Tool Selection Guide – 9eSIM

Currently, there is lpa-gtk for Linux phones using Phosh/GNOME Mobile. Perhaps it could be used as a starting point, and the graphics could be done with QT for Sailfish :smiley: lucaweiss/lpa-gtk: Download and manage eSIM profiles - Codeberg.org .

In my case, I can test things, but I don’t have any programming knowledge about QT and packaging for Sailfish, so it would be a great contribution!

4 Likes

I’m pretty sure designing a entirely new QML app on top of a text-mode binary is way easier than trying to adapt an existing GUI.

I don’t have such a SIM yet but I can do the UI and packaging if you’re willing to try out the lpac binary.

2 Likes

When I receive the order, I will test the binary and let you know about it :smiley:

1 Like

Hmm, I checked my esim me I bought approximately few months ago, and it appears like it does not support standard eUICC. Also I heard that esim me require access to their servers to manage profiles

But I see eiotclub you mentioned also offer card-reader as well as 9esim (means it has eUICC), so there are at least two working options for SailfishOS

Recent versions of lpac have dynamically linked drivers, which seems to cause problems with Sailfish. You have to compile the version from @tvall eSIM and Sailfish OS - #36 by tvall .

As for the version from the official repository, this is the last functional tree in Sailfish, before they introduced dynamic drivers GitHub - estkme-group/lpac at e9e28c4f731b4e5046332d6fc22ef1a219463e4b

I have compiled it with all the drivers supported by Sailfish

cmake -B build -DLPAC_WITH_APDU_GBINDER=ON -DLPAC_WITH_APDU_PCSC=ON -DLPAC_WITH_APDU_AT=ON -DLPAC_WITH_HTTP_CURL=ON -L
cmake --build build
( for -DLPAC_WITH_APDU_QMI=ON and -DLPAC_WITH_APDU_QMI_QRTR=ON requires qmi-glib, for -DLPAC_WITH_APDU_MBIM=ON requires mbim-glib, which are not available in Sailfish), and it seems to work.

[defaultuser@Xperia10V lpac]$ LPAC_APDU_DEBUG=true build/output/lpac version | jq .
{
  "type": "lpa",
  "payload": {
    "code": 0,
    "message": "success",
    "data": "2.3.0.r388.e9e28c4f731b"
  }
}
[defaultuser@Xperia10V lpac]$ LPAC_APDU_DEBUG=true build/output/lpac driver list | jq .
{
  "type": "driver",
  "payload": {
    "LPAC_APDU": [
      "gbinder_hidl",
      "pcsc",
      "at",
      "stdio"
    ],
    "LPAC_HTTP": [
      "curl",
      "stdio"
    ]
  }
}

So far, I have tested that it detects a USB card reader. When I receive the 9eSIM I have ordered, I will test to see if it works to insert profiles with both the external reader and the mobile SIM reader. Esim on Xperia 10 iii (and other SFOS devices) - #23 by Juanro49

[defaultuser@Xperia10V lpac]$ LPAC_APDU_DEBUG=true LPAC_APDU=pcsc build/output/lpac driver apdu list | jq .
{
  "type": "driver",
  "payload": {
    "env": "LPAC_APDU_PCSC_DRV_IFID",
    "data": [
      {
        "env": "0",
        "name": "Alcor Micro AU9540 00 00"
      }
    ]
  }
}

On the downside, it does not seem to detect the eSIM chip on my Xperia 10 V so that I can’t configure it, although this may be due to Sony’s faulty blobs, or because it may be necessary to use the QMI APDU backend (which is not available for Sailfish at the moment, but seems to work on PostmarketOS An eSIM manager for Mobile Linux - Luca Weiss ) instead of GBinder APDU Backend .

[defaultuser@Xperia10V lpac]$ LPAC_APDU_DEBUG=true LPAC_APDU=gbinder_hidl build/output/lpac chip info | jq .
Attempting to connect to android.hardware.radio@1.0::IRadio/slot1
Failed to open APDU logical channel: 17
Attempting to connect to android.hardware.radio@1.0::IRadio/slot2
Failed to open APDU logical channel: 38
{
  "type": "lpa",
  "payload": {
    "code": -1,
    "message": "euicc_init",
    "data": ""
  }
}

2 Likes

Do you maybe have a working binary somewhere to download?

I have it on my phone where I compiled it. I will try to package it and upload it somewhere so it can be downloaded for testing

1 Like

Thank you. Packaging is nice, but should that make any issues I would be happy with a simple binary (or tar.gz) for now.

1 Like

I have packaged the entire code directory, as certain libraries are generated during the compilation process that may be necessary for the binary to work. The binary is located in build/output/lpac.

If you run cmake --install build, various files will be installed in /usr/local/
– Install configuration: “”
– Installing: /usr/local/include/cjson/cJSON.h
– Installing: /usr/local/lib64/pkgconfig/libcjson.pc
– Installing: /usr/local/lib64/libcjson.a
– Installing: /usr/local/lib64/cmake/cJSON/cjson.cmake
– Installing: /usr/local/lib64/cmake/cJSON/cjson-noconfig.cmake
– Installing: /usr/local/lib64/cmake/cJSON/cJSONConfig.cmake
– Installing: /usr/local/lib64/cmake/cJSON/cJSONConfigVersion.cmake
– Installing: /usr/local/bin/lpac
– Set runtime path of “/usr/local/bin/lpac” to “/usr/local/lib64/lpac”

I have uploaded the tar.gz to this temporary link. Lufi - Disroot file uploader

1 Like

I have managed to get the latest version of lpac with dynamic drivers working by making some corrections for SailfishOS. The changes made are available in this repository GitHub - juanro49/lpac: C-based eUICC LPA and I also created a PR in the main repository fix gbinder driver compile and dynamic drivers detection for SailfishOS by juanro49 · Pull Request #411 · estkme-group/lpac · GitHub

[defaultuser@Xperia10V ~]$ whereis lpac
lpac: /usr/local/bin/lpac
[defaultuser@Xperia10V ~]$ LPAC_APDU_DEBUG=true LPAC_APDU_GBINDER_DEBUG=true LPAC_APDU=gbinder /usr/local/bin/lpac version | jq .
{
  "type": "lpa",
  "payload": {
    "code": 0,
    "message": "success",
    "data": "2.3.0.r440.ce4abfaf75d2"
  }
}
[defaultuser@Xperia10V ~]$ LPAC_APDU_DEBUG=true LPAC_APDU_GBINDER_DEBUG=true LPAC_APDU=gbinder /usr/local/bin/lpac driver list | jq .
{
  "type": "driver",
  "payload": {
    "LPAC_APDU": [
      "stdio",
      "at_csim",
      "pcsc",
      "at",
      "gbinder_hidl"
    ],
    "LPAC_HTTP": [
      "curl",
      "stdio"
    ]
  }
}
[defaultuser@Xperia10V ~]$ LPAC_APDU_DEBUG=true LPAC_APDU_GBINDER_DEBUG=true LPAC_APDU=gbinder /usr/local/bin/lpac chip info | jq .
Attempting to connect to android.hardware.radio@1.0::IRadio/slot1
Failed to open APDU logical channel: 17
Attempting to connect to android.hardware.radio@1.0::IRadio/slot2
Failed to open APDU logical channel: 38
{
  "type": "lpa",
  "payload": {
    "code": -1,
    "message": "euicc_init",
    "data": ""
  }
}
[defaultuser@Xperia10V ~]$ LPAC_APDU_DEBUG=true LPAC_APDU_GBINDER_DEBUG=true LPAC_APDU=pcsc /usr/local/bin/lpac driver apdu list | jq .
{
  "type": "driver",
  "payload": {
    "env": "LPAC_APDU_PCSC_DRV_IFID",
    "data": [
      {
        "env": "0",
        "name": "Alcor Micro AU9540 00 00"
      }
    ]
  }
}
[defaultuser@Xperia10V ~]$ 
7 Likes

I don’t have a regular Sailfish build environment, so compiling the sources would take too much time to set up. However, if you don’t want to do it yourself but can provide all the binary files needed to run lpac, I can create an RPM from them and upload it to OpenRepos.

1 Like

Creating the rpm with the precompiled binaries is something I have in mind (both for aarch64 and armv7a, as I have also tested it on my old Xperia 10 Plus), but I’m waiting for my 9eSIM to arrive (my order should arrive next week) to see if it really works well on Sailfish, either with binder and the internal SIM slot (the Xperia 10 V’s internal eSIM chip doesn’t work because I saw in the Sailfish release notes that it’s disabled at the firmware level) or with pcsc and an external reader.

With pcsc and an external reader, I think it will work, as I have tested it with other cards (Spanish electronic ID card and a prepaid debit card) and lpac detects it, although it gives an error because it is obviously not a supported card type, but it is better to wait for confirmation when I can test it with a supported card such as the 9eSIM.

From there, an interface could be created to make it easy to use.

That makes sense. Sorry, I was mistakenly under the impression that you already had your eSIM.

1 Like

Yesterday I received my 9eSIM, I was able to test it and it works both with the phone’s SIM reader with the gbinder driver, and with the external USB-C reader with the pcsc driver. I was able to install profiles on the SIM, list them, and activate them.

I updated the repository by adding the spec file to create the rpm GitHub - juanro49/lpac: C-based eUICC LPA , and I also published it on OpenRepos lpac | OpenRepos.net — Community Repository System , so it’s now available to everyone and graphical interfaces can be created on it :smiley: .

As for the Android part, it seems that AppSupport does not read the external reader to be able to use the Android profile management apps, so those apps cannot be used for SIM profile management.

11 Likes

Great work and looking forward to start testing and working on it with Xperia Nagara. Few suggestions:

  • Please make packaging in a separate repository. For example, see GitHub - sailfishos-chum/qt6-qtbase . When packaged that way, you just point to original repository or your patched version through git submodules (in that example its upstream - common name for such subfolder that we use). There are many advantages for it with the main that you can make your changes in a clean way and send the updates to upstream.
  • You probably have to close your PR and make a new one with the clean repository. Right now, you pushed rpm files into your main branch and as it was used in fix gbinder driver compile and dynamic drivers detection for SailfishOS by juanro49 · Pull Request #411 · estkme-group/lpac · GitHub, it messed up your PR too. As a simple rule, make separate branches for each PR and use them to push your changes upstream. Again, with revised packaging approach it will be easy.

If you are in trouble with such packaging, I’ll be happy to help you out. Probably can’t do it in next few days, but I am interested in getting eSIM to work on Xperia Nagara and will surely test your approach.

With packaging sorted out, we can add it to Chum or use in our ported devices repositories.

7 Likes

Thank you for the great work!

Any quick ways I can test it on Xperia 10 III without having the actual card yet?
I tried the following commands from one of your earlier posts, and they seem to do something:

LPAC_APDU_DEBUG=true LPAC_APDU_GBINDER_DEBUG=true LPAC_APDU=gbinder /usr/bin/lpac version

{“type”:“lpa”,“payload”:{“code”:0,“message”:“success”,“data”:“2.3.0.r442.666ba263343c”}}

LPAC_APDU_DEBUG=true LPAC_APDU_GBINDER_DEBUG=true LPAC_APDU=gbinder /usr/bin/lpac driver list

{“type”:“driver”,“payload”:{“LPAC_APDU”:[“stdio”,“at_csim”,“gbinder_hidl”,“pcsc”,“at”],“LPAC_HTTP”:[“stdio”,“curl”]}}

LPAC_APDU_DEBUG=true LPAC_APDU_GBINDER_DEBUG=true LPAC_APDU=gbinder /usr/bin/lpac chip info

Attempting to connect to android.hardware.radio@1.0::IRadio/slot1
Failed to open APDU logical channel: 17
Attempting to connect to android.hardware.radio@1.0::IRadio/slot2
Failed to open APDU logical channel: 38
{“type”:“lpa”,“payload”:{“code”:-1,“message”:“euicc_init”,“data”:“”}}

I guess the last one fails because I don’t have a USB-C reader present?

LPAC_APDU_DEBUG=true LPAC_APDU_GBINDER_DEBUG=true LPAC_APDU=pcsc /usr/bin/lpac driver apdu list

SCardEstablishContext() failed: 8010001D (Unknown error: 0xFFFFFFFF8010001D)
APDU driver init failed

There seem to be two versions of the 9eSIM available on Amazon: V0 and V3.
Which one makes more sense to buy?
(sorry, I have zero experience with eSIMs)

I don’t really have any use for an eSIM, but I want to see Sailfish cover this area, so I might create a GUI for lpac if there is any demand.

1 Like

different chips, and v3 has more memory: V0 - 470kb , V3 - 1.5mb

https://4pda.to/forum/index.php?showtopic=934612&st=18020#entry139963326

1 Like

Thanks for the suggestion. I’ll look into it and see if I can get it sorted out in the next few days. I’ve also solved the PR problem (for now, to avoid creating a new PR, I moved the files to generate the rpm to another branch so that they are still available, pending the creation of the new repository with the new package with submodules and the rpm files).

For now, you can only test that lpac accepts commands and recognizes drivers. Once you obtain the e9SIM SIM card, by running lpac chip info with gbinder or pcsc, you will obtain the SIM’s eUICC information and be able to manage profiles (list them, download them, activate them, etc.).

The error SCardEstablishContext() failed: 8010001D (Unknown error: 0xFFFFFFFF8010001D) occurs because after installing the lpac pcsc-lite dependency for the first time, you need to restart for the pcsc socket to initialize correctly. (I tried to see if it would work to manually start the daemon and the socket to integrate it into the rpm spec, but I always got the error utils.c:60:GetDaemonPid() Can’t open /var/run/pcscd/pcscd.pid: No such file or directory, and the only way it would start properly was by restarting the phone).

Once you reboot, if you don’t have a reader connected, you will get the error SCardListReaders() failed: 8010002E (Unknown error: 0xFFFFFFFF8010002E), which indicates that it does not detect any readers.