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
This commit is contained in:
@@ -48,6 +48,7 @@ AC_PROG_CC
|
|||||||
AM_PROG_CC_C_O
|
AM_PROG_CC_C_O
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_PROG_MKDIR_P
|
AC_PROG_MKDIR_P
|
||||||
|
AC_PROG_LN_S
|
||||||
|
|
||||||
dnl Initialize libtool
|
dnl Initialize libtool
|
||||||
LT_PREREQ([2.2])
|
LT_PREREQ([2.2])
|
||||||
@@ -567,6 +568,7 @@ Makefile
|
|||||||
data/Makefile
|
data/Makefile
|
||||||
data/ModemManager.pc
|
data/ModemManager.pc
|
||||||
data/mm-glib.pc
|
data/mm-glib.pc
|
||||||
|
data/fcc-unlock/Makefile
|
||||||
data/tests/Makefile
|
data/tests/Makefile
|
||||||
data/tests/org.freedesktop.ModemManager1.service
|
data/tests/org.freedesktop.ModemManager1.service
|
||||||
include/Makefile
|
include/Makefile
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
SUBDIRS = . tests
|
SUBDIRS = . fcc-unlock tests
|
||||||
|
|
||||||
edit = @sed \
|
edit = @sed \
|
||||||
-e 's|@sbindir[@]|$(sbindir)|g' \
|
-e 's|@sbindir[@]|$(sbindir)|g' \
|
||||||
|
34
data/fcc-unlock/105b
Normal file
34
data/fcc-unlock/105b
Normal file
@@ -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 $?
|
33
data/fcc-unlock/1199
Normal file
33
data/fcc-unlock/1199
Normal file
@@ -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 $?
|
34
data/fcc-unlock/1eac
Normal file
34
data/fcc-unlock/1eac
Normal file
@@ -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 $?
|
32
data/fcc-unlock/Makefile.am
Normal file
32
data/fcc-unlock/Makefile.am
Normal file
@@ -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 *:*
|
41
data/fcc-unlock/meson.build
Normal file
41
data/fcc-unlock/meson.build
Normal file
@@ -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))
|
@@ -364,6 +364,7 @@ version_conf = {
|
|||||||
|
|
||||||
subdir('po')
|
subdir('po')
|
||||||
subdir('data')
|
subdir('data')
|
||||||
|
subdir('data/fcc-unlock')
|
||||||
subdir('introspection')
|
subdir('introspection')
|
||||||
subdir('include')
|
subdir('include')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user