Unlock the FCC lock of EM120R-GL for Linux

Background

The FCC lock is a software lock, that is put into WWAN modems so that the laptop manufacturer can get a FCC certification for that laptop + modem bundle within the US. Usually the laptop manufacturer provides tools for the laptop to unlock the modem. Within my setup, NIXOS upon a lenovo X1, I was unable to use tools of the manufacturer.

Therefore I needed to take the following steps, in order to unlock the modem manually.

It seems, that I need to unlock the modem after every reboot again.

Initial Steps

Create a folder somewhere within your system (I use ~/Programming/C/ as base folder)

mkdir -p lenovo/snap

Then download the latest .snap file for that modem. To find out, what the latest snap file is and where it is use curl:

curl -H 'Snap-Device-Series: 16' http://api.snapcraft.io/v2/snaps/info/lenovo-wwan-dpr

Within the curl output, you will find a link to the snap file, mine was: https://api.snapcraft.io/api/v1/snaps/download/LLzS0Nb7rtM5RH6dNadpAzWAiRfHuefk_20.snap. Download that file somewhere and then mount it into the newly created snap folder:

sudo mount -t squashfs -o ro ~/Programming/C/lenovo/LLzS0Nb7rtM5RH6dNadpAzWAiRfHuefk_20.snap ~/Programming/C/lenovo/snap

After that, download the fcc-unlock.c sourcecode, also into the folder where also the snap folder is located:

wget https://gist.githubusercontent.com/joar/416f37fe81558f5be0d5131018eb7f2a/raw/b6a2a83620b044efc2d13aee86910743969218de/fcc-unlock.c

Now the source fcc-unlock.c needs to be altered, such that the MBIM_DEVICE_PATH and the MBIM2SAR_SO_PATH point to the correct files:

  • here MBIM_DEVICE_PATH must point to /dev/wwan0mbim0
  • and MBIM2SAR_SO_PATH must point to mbim2sar.so on the local machine, here /home/frosch03/Programming/C/lenovo/snap/usr/lib/mbim2sar.so

Now one can compile and run that compiled programm in order to unlock the fcc lock of the modem

gcc -o fcc-unlock_v2 fcc-unlock.c
sudo env VERBOSE=1 ./fcc-unlock_v2

After that terminated sucessfully, the modem is unlocked and can be used. Don't forget to unmount the snap folder:

sudo umount ~/Programming/C/lenovo/snap

Steps to be repeated after reboot

Later on, one needs only to mount the snap again, before running the fcc-unlock_v2 programm:

pushd ~/Programming/C/lenovo
sudo mount -t squashfs -o ro LLzS0Nb7rtM5RH6dNadpAzWAiRfHuefk_20.snap ./snap
sudo env VERBOSE=1 ./fcc-unlock_v2
sudo umount ./snap
popd

Sources

All steps are taken from this thread: https://forums.quectel.com/t/em120r-gl-for-linux/9350/4

Other posts