diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-10-26 01:06:10 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-11-18 11:20:41 +0100 |
commit | e7a6bb7504403b60d098ef8dde39b036c8c31f8d (patch) | |
tree | 7cad1c407319ac311b0bd59d571dd22216c07836 /data | |
parent | 81302efa661f848455a1bfe44b27608b11d6d49b (diff) |
data,fcc-unlock: add example unlock scripts
Added scripts for Foxconn SDX55, Quectel EM120, and several old Sierra
Wireless manufactured devices:
* Installed but not used by default, the user needs to setup manual
links from ${pkgdatadir}/fcc-unlock.available.d, to
${pkgsysconfdir}/fcc-unlock.d in order to enable them.
* Installed with rights only for the owner, so that the dispatcher in
ModemManager can validate them.
* They rely on $PATH to find the qmicli/mbimcli tools.
In addition to these scripts, per-vid:pid links are created in the
same ${pkgdatadir}/fcc-unlock.available.d directory, specifying which
are the specific devices that require the FCC unlock operation.
This patch also creates the ${pkgsysconfdir}/fcc-unlock.d and
${pkglibdir}/fcc-unlock.d directories where ModemManager looks for the
enabled tools.
Note that the meson setup doesn't support creating/deleting links
officially yet, so we use a workaround using meson.add_install_script
that is not perfect (i.e. doesn't handle the symlink removal during
uninstall). See https://github.com/mesonbuild/meson/issues/1602
Diffstat (limited to 'data')
-rw-r--r-- | data/Makefile.am | 2 | ||||
-rw-r--r-- | data/fcc-unlock/105b | 34 | ||||
-rw-r--r-- | data/fcc-unlock/1199 | 33 | ||||
-rw-r--r-- | data/fcc-unlock/1eac | 34 | ||||
-rw-r--r-- | data/fcc-unlock/Makefile.am | 32 | ||||
-rw-r--r-- | data/fcc-unlock/meson.build | 41 |
6 files changed, 175 insertions, 1 deletions
diff --git a/data/Makefile.am b/data/Makefile.am index 447cb3d0..b42b70f8 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS = . tests +SUBDIRS = . fcc-unlock tests edit = @sed \ -e 's|@sbindir[@]|$(sbindir)|g' \ diff --git a/data/fcc-unlock/105b b/data/fcc-unlock/105b new file mode 100644 index 00000000..21fe5329 --- /dev/null +++ b/data/fcc-unlock/105b @@ -0,0 +1,34 @@ +#!/bin/bash + +# SPDX-License-Identifier: CC0-1.0 +# 2021 Aleksander Morgado <aleksander@aleksander.es> +# +# Foxconn SDX55 FCC unlock operation +# + +# require program name and at least 2 arguments +[ $# -lt 2 ] && exit 1 + +# first argument is DBus path, not needed here +shift + +# second and next arguments are control port names +for PORT in "$@"; do + # match port type in Linux 5.14 and newer + grep -q MBIM /sys/class/wwan/${PORT}/type 2>/dev/null && { + MBIM_PORT=$PORT + break + } + # match port name in Linux 5.13 + [[ $PORT == *"MBIM"* ]] && { + MBIM_PORT=$PORT + break + } +done + +# fail if no MBIM port exposed +[ -n "${MBIM_PORT}" ] || exit 2 + +# run qmicli operation over MBIM +qmicli --device-open-proxy --device=/dev/${MBIM_PORT} --dms-foxconn-set-fcc-authentication=0 +exit $? diff --git a/data/fcc-unlock/1199 b/data/fcc-unlock/1199 new file mode 100644 index 00000000..0109c6ab --- /dev/null +++ b/data/fcc-unlock/1199 @@ -0,0 +1,33 @@ +#!/bin/bash + +# SPDX-License-Identifier: CC0-1.0 +# 2021 Aleksander Morgado <aleksander@aleksander.es> +# +# Sierra Wireless FCC unlock mechanism +# HP 820 G1 (EM7355), 03f0:4e1d +# Dell DW5570 (MC8805), 413c:81a3 +# Dell DW5808 (MC7355), 413c:81a8 +# Lenovo-shipped EM7455, 1199:9079 +# + +# require program name and at least 2 arguments +[ $# -lt 2 ] && exit 1 + +# first argument is DBus path, not needed here +shift + +# second and next arguments are control port names +for PORT in "$@"; do + # match port name + [[ $PORT == *"cdc-wdm"* ]] && { + CDC_WDM_PORT=$PORT + break + } +done + +# fail if no cdc-wdm port exposed +[ -n "${CDC_WDM_PORT}" ] || exit 2 + +# run qmicli operation +qmicli --device-open-proxy --device=/dev/${CDC_WDM_PORT} --dms-set-fcc-authentication +exit $? diff --git a/data/fcc-unlock/1eac b/data/fcc-unlock/1eac new file mode 100644 index 00000000..1068d9c2 --- /dev/null +++ b/data/fcc-unlock/1eac @@ -0,0 +1,34 @@ +#!/bin/bash + +# SPDX-License-Identifier: CC0-1.0 +# 2021 Aleksander Morgado <aleksander@aleksander.es> +# +# Quectel EM120 FCC unlock operation +# + +# require program name and at least 2 arguments +[ $# -lt 2 ] && exit 1 + +# first argument is DBus path, not needed here +shift + +# second and next arguments are control port names +for PORT in "$@"; do + # match port type in Linux 5.14 and newer + grep -q MBIM /sys/class/wwan/${PORT}/type 2>/dev/null && { + MBIM_PORT=$PORT + break + } + # match port name in Linux 5.13 + [[ $PORT == *"MBIM"* ]] && { + MBIM_PORT=$PORT + break + } +done + +# fail if no MBIM port exposed +[ -n "${MBIM_PORT}" ] || exit 2 + +# run mbimcli operation +mbimcli --device-open-proxy --device=/dev/${MBIM_PORT} --quectel-set-radio-state=on +exit $? diff --git a/data/fcc-unlock/Makefile.am b/data/fcc-unlock/Makefile.am new file mode 100644 index 00000000..a98a68fa --- /dev/null +++ b/data/fcc-unlock/Makefile.am @@ -0,0 +1,32 @@ + +# Directory for user-enabled tools +fccunlockuser = $(pkgsysconfdir)/fcc-unlock.d + +# Directory for package-enabled tools +fccunlockpackage = $(pkglibdir)/fcc-unlock.d + +# Shipped but disabled FCC unlock tools +fccunlockavailabledir = $(pkgdatadir)/fcc-unlock.available.d +fccunlockavailable_SCRIPTS = \ + 105b \ + 1199 \ + 1eac \ + $(NULL) + +EXTRA_DIST = $(fccunlockavailable_SCRIPTS) + +install-data-hook: + $(MKDIR_P) $(DESTDIR)$(fccunlockuser); \ + $(MKDIR_P) $(DESTDIR)$(fccunlockpackage); \ + cd $(DESTDIR)$(fccunlockavailabledir); \ + chmod go-rwx *; \ + $(LN_S) -f 105b 105b:e0ab; \ + $(LN_S) -f 1199 03f0:4e1d; \ + $(LN_S) -f 1199 1199:9079; \ + $(LN_S) -f 1199 413c:81a3; \ + $(LN_S) -f 1199 413c:81a8; \ + $(LN_S) -f 1eac 1eac:1001; \ + $(NULL) + +uninstall-hook: + cd $(DESTDIR)$(fccunlockavailabledir) && rm -f *:* diff --git a/data/fcc-unlock/meson.build b/data/fcc-unlock/meson.build new file mode 100644 index 00000000..f945fbf8 --- /dev/null +++ b/data/fcc-unlock/meson.build @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es> + +# Shipped but disabled FCC unlock tools +mm_fccunlockdiravailable = mm_pkgdatadir / 'fcc-unlock.available.d' + +# Directory for user-enabled tools +mm_fccunlockdiruser = mm_pkgsysconfdir / 'fcc-unlock.d' + +# Directory for package-enabled tools +mm_fccunlockdirpackage = mm_pkglibdir / 'fcc-unlock.d' + +examples = files( + '105b', + '1199', + '1eac', +) + +install_data( + examples, + install_mode: 'rwx------', + install_dir: mm_fccunlockdiravailable, +) + +vidpids = { + '105b:e0ab': '105b', + '03f0:4e1d': '1199', + '1199:9079': '1199', + '413c:81a3': '1199', + '413c:81a8': '1199', + '1eac:1001': '1eac', +} + +ln_cmd = 'ln -fs @0@ ${DESTDIR}@1@' +foreach output, input: vidpids + meson.add_install_script('sh', '-c', ln_cmd.format(input, mm_prefix / mm_fccunlockdiravailable / output)) +endforeach + +mkdir_cmd = 'mkdir -p ${DESTDIR}@0@' +meson.add_install_script('sh', '-c', mkdir_cmd.format(mm_prefix / mm_fccunlockdiruser)) +meson.add_install_script('sh', '-c', mkdir_cmd.format(mm_prefix / mm_fccunlockdirpackage)) |