Downloading eSIM profiles through a USB Modem
If you have a USB modem, you might be able to download and configure eSIM profiles through the USB modem without a smart card reader.
Overview
To download a new eSIM profile to an eSIM adapter, we'll
- Insert the eSIM adapter into the USB modem
- Configure lpac to use the AT commands instead of PC/SC
- Build lpac
- Run lpac to download the profile
Instructions
Below are detailed instructions.
- Using your linux distribution's package manager install prerequisite libraries and header files. For example,
# Arch/EndeavorOS/Manjaro sudo pacman -S pcsclite pcsc-tools libcurl-compat # Fedora/Rocky/Alma sudo dnf install libcurl libcurl-devel pcsc-lite-devel pcsc-lite-libs pcsc-lite pcsc-tools # Debian/Ubuntu apt-get install build-essential libpcsclite-dev libcurl4-openssl-dev zip
Download/unzip or clone the lpac source code. (Even if your linux distribution has a pre-built lpac package, it probably hasn't been built with the option to use the AT APDU.)
- Change directory to the source directory lpac-main
- Configure the source with
cmake . -DLPAC_WITH_APDU_AT=1
If you have a Quectel modem, complete the steps in the section called Patching for Quectel below before building lpac.
- Build with
make
Attach the USB modem and find which serial devices it adds. The most likely useful devices are /dev/ttyUSB2 or /dev/ttyACM2. If it's not clear, detach the modem, run sudo dmesg -w and then plug in the modem. The serial devices will be listed in the dmesg output.
- Find the group ownership of the serial device. For example
ls -l /dev/ttyUSB2 crw-rw---- 1 root uucp 166, 0 Oct 31 18:46 /dev/ttyUSB2
- Add yourself to the group of this device (e.g. uucp or dialout)
sudo usermod -aG user uucp
Logout and login (or run su - user where user is your linux username)
Run groups to verify that your current shell reflects uucp or dialout group membership
In this step we'll stop the ModemManager from accessing the modem so that lpac can
sudo systemctl stop ModemManager
- Check whether lpac is able to access the modem using the AT ADPU. Ensure no errors are output from the following command.
LPAC_APDU=at AT_DEVICE=/dev/ttyUSB2 output/lpac chip info | jq
If there are any errors, it might help to add debug variables.
Connect to the internet using a different interface than the USB modem (e.g. wifi or ethernet). This is only needed for downloading an eSIM profile. Since we stopped the ModemManager service, the modem won't provide internet connectivity. If a separate internet connection is not available, see the instructions for Downloading an eSIM profile for a USB modem without a second network device.
Run the usual lpac commands to list, download, enable and nickname eSIM profiles including the "at" variables
LPAC_APDU=at AT_DEVICE=/dev/ttyUSB2 output/lpac profile download -s "smdp.io" -m "K2-GH4JFI-D9JI"
Tip Instead of typing the AT variables for every command, export them to the environment with export LPAC_APDU=at AT_DEVICE=/dev/ttyUSB2.