nwl-distro: Add ModemManager and wwan-config to test tools

These tools are required to properly enable, configure and use the wwan
modems.

id:502637
This commit is contained in:
Alexandre Bard 2024-03-01 17:40:18 +01:00
parent a77ced658e
commit 2837a9f876
7 changed files with 244 additions and 1 deletions

View File

@ -28,12 +28,20 @@ DISTRO_FEATURES:remove = "ptest virtualization"
PACKAGECONFIG:pn-systemd = "usrmerge rfkill kmod timedated vconsole" PACKAGECONFIG:pn-systemd = "usrmerge rfkill kmod timedated vconsole"
# systemd-conf provides a packageconfig for a default dhcp client that we don't need # systemd-conf provides a packageconfig for a default dhcp client that we don't need
PACKAGECONFIG:pn-systemd-conf = "" PACKAGECONFIG:pn-systemd-conf = ""
PACKAGECONFIG:pn-networkmanager = "systemd nss gnutls wifi bluez5 nmcli" PACKAGECONFIG:pn-networkmanager = "systemd nss gnutls wifi bluez5 nmcli modemmanager"
# NetworkManager is starting dnsmasq when it needs it for AP mode # NetworkManager is starting dnsmasq when it needs it for AP mode
SYSTEMD_AUTO_ENABLE:pn-dnsmasq = "disable" SYSTEMD_AUTO_ENABLE:pn-dnsmasq = "disable"
PACKAGECONFIG:pn-bluez5 = "systemd udev" PACKAGECONFIG:pn-bluez5 = "systemd udev"
# ModemManager is started by wwan-config
SYSTEMD_AUTO_ENABLE:pn-modemmanager = "disable"
PACKAGECONFIG:pn-modemmanager = "systemd qmi"
EXTRA_OEMESON:pn-modemmanager = "-Dauto_features=disabled -Dplugin_generic=enabled"
# Enable the python3 bindings for libgpiod
PACKAGECONFIG:append:pn-libgpiod = " python3"
# With busybox "less" the output of "nmcli c" does not show up properly # With busybox "less" the output of "nmcli c" does not show up properly
RDEPENDS:networkmanager-nmcli += "less" RDEPENDS:networkmanager-nmcli += "less"

View File

@ -0,0 +1,69 @@
DESCRIPTION = "WWAN modems configuration tool"
LICENSE = "Proprietary"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Proprietary;md5=0557f9d92cf58f2ccdd50f62f8ac0b28"
RDEPENDS:${PN} += " \
python3-pyserial \
libgpiod-python \
python3-setuptools \
python3-systemd \
lmsensors-sensors \
lmsensors-config-libsensors \
"
DEPENDS = "python3-setuptools-scm-native"
inherit gitpkgv systemd allarch
# Package Version (built from tags)
PKGV = "${GITPKGVTAG}"
# Recipe Version
PV = "1.0-git${SRCPV}"
PR = "r1"
SRCREV = "a943fa76d5385c3f9bc54023c6fcf8b7bf339fd1"
SRC_URI = "git://gitlab.com/netmodule/tools/wwan-config.git;protocol=ssh;user=git;branch=master \
file://wwan-config@.service \
file://default.conf \
file://0001-Hotfixes-for-gemini.patch \
file://0002-hotfix-for-kirkstone.patch \
"
S = "${WORKDIR}/git"
inherit setuptools3_legacy
# Should be set by machine.conf
WWAN_NBR ??= "1"
do_install:append() {
install -d ${D}/${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/wwan-config@.service ${D}/${systemd_unitdir}/system/
install -d ${D}/${sysconfdir}/wwan
if [ ! -z "${WWAN_NBR}" ] ; then
install -d ${D}${sysconfdir}/systemd/system/multi-user.target.requires/
for i in `seq 0 ${WWAN_NBR}`; do
if [ $i = ${WWAN_NBR} ]; then continue; fi
if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ] ; then
ln -sf ${systemd_unitdir}/system/wwan-config@.service \
${D}${sysconfdir}/systemd/system/multi-user.target.requires/wwan-config@wwan$i.service
fi
install -m 0644 ${WORKDIR}/default.conf ${D}${sysconfdir}/wwan/wwan$i.conf
if [ ! -z "${NM_WWAN_APN}" ]; then
sed -i 's/apn=/apn=${NM_WWAN_APN}/g' ${D}${sysconfdir}/wwan/wwan$i.conf
fi
if [ ! -z "${NM_WWAN_USER}" ]; then
sed -i 's/user=/user=${NM_WWAN_USER}/g' ${D}${sysconfdir}/wwan/wwan$i.conf
fi
if [ ! -z "${NM_WWAN_PASSWORD}" ]; then
sed -i 's/password=/password=${NM_WWAN_PASSWORD}/g' ${D}${sysconfdir}/wwan/wwan$i.conf
fi
done
fi
}

View File

@ -0,0 +1,68 @@
From 3ffd1a9c0b42c32e720f05b36b6b837fb1ea8c46 Mon Sep 17 00:00:00 2001
From: Alexandre Bard <alexandre.bard@netmodule.com>
Date: Thu, 22 Feb 2024 17:21:09 +0100
Subject: [PATCH] Hotfixes for gemini
- Handling HUB_RST and GSM_RST lines
- Using GSM_EN instead of GSM_PWR
- Using gpio line EXT_SUPPLY_EN0 instead of "kernel" supply
Signed-off-by: Alexandre Bard <alexandre.bard@netmodule.com>
---
wwan_config/modems/wwan_modem.py | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/wwan_config/modems/wwan_modem.py b/wwan_config/modems/wwan_modem.py
index 710ec76..cc12a53 100755
--- a/wwan_config/modems/wwan_modem.py
+++ b/wwan_config/modems/wwan_modem.py
@@ -25,8 +25,24 @@ class WwanModem:
def __init__(self, device_name):
self.name = device_name
- self.pwr_line = gpiod.find_line('GSM_PWR')
+
+ # Start by disabling the power supply
+ self.supply_line = gpiod.find_line('EXT_SUPPLY_EN0')
+ self.supply_line.request(consumer=self.name, type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0])
+
+ # Release all RST lines
+ self.hub_rst_line = gpiod.find_line('HUB_RST~')
+ self.hub_rst_line.request(consumer=self.name, type=gpiod.LINE_REQ_DIR_OUT, default_vals=[1])
+
+ self.rst_line = gpiod.find_line('GSM_RST')
+ self.rst_line.request(consumer=self.name, type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0])
+
+
+ # Prepare the the PWR line for the pulse
+ self.pwr_line = gpiod.find_line('GSM_EN')
self.pwr_line.request(consumer=self.name, type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0])
+ time.sleep(1)
+
while True:
try:
@@ -34,7 +50,11 @@ class WwanModem:
break
except ModemNotPoweredException as e:
logger.error("The modem did not power up, turning power off and on again")
- self.power_down()
+ try:
+ self.power_down()
+ except PwrNotControllableException as e:
+ logger.error("The power cannot be controlled, not shutting down, the only we can do is wait...");
+
# Make sure the power is down long enough to avoid a glitch
# With toby-l2 this down time must be at least 130ms
time.sleep(1)
@@ -158,9 +178,7 @@ class WwanModem:
raise ModemNotPoweredException()
def set_pwr_state(self, value):
- state = "enabled" if value == 1 else "disabled"
- with open("/sys/devices/platform/" + self.name + "-supply/state", "w") as supply_file:
- supply_file.write(state + "\n")
+ self.supply_line.set_value(value)
def power_up(self):
logger.info("modem power up")

View File

@ -0,0 +1,26 @@
From a2b92fb896bdf2c5579676f05df4fcc7c488d94f Mon Sep 17 00:00:00 2001
From: Alexandre Bard <alexandre.bard@netmodule.com>
Date: Thu, 22 Feb 2024 17:28:56 +0100
Subject: [PATCH] hotfix for kirkstone
With the upgrade from dunfell to kirkstone, setuptools-git-version does
not exists anymore.
Signed-off-by: Alexandre Bard <alexandre.bard@netmodule.com>
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 8009e49..88415ae 100755
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ from setuptools import setup, find_packages
setup(
name='wwan_config',
version_format='{tag}.{commitcount}+{gitsha}',
- setup_requires=['setuptools-git-version'],
+ setup_requires=['setuptools-scm'],
description='WWAN modem configurator',
author='Alexandre Bard',
author_email='alexandre.bard@netmodule.com',

View File

@ -0,0 +1,51 @@
#
# This file is part of wwan-config service
#
# Define a private APN to be used by the modem
# ! ONLY REQUIRED WHEN USING UBLOX TOBY-L2, will be ignored for other modems
#
# Required fields:
# apn: Name of the access point
# user: Username used to authenticate on APN
# password: Password used to authenticate on APN
#
[apn]
apn=
user=
password=
#
# Select the SIM card to be used by the modem
#
# auto: The script will detect if a physical SIM card is
# present and switch to eSIM if it is not the case
# sim1: Use the physical SIM card on the main board
# m2m: Use the eSIM of the main board
# ui-top: Use the SIM card that is on top of the User Interface
# ui-btm: Use the SIM card that is on the bottom of the User Interface
#
[sim]
SIM=auto
#
# ublox specific configurations:
#
# mode (+UBMCONF) :
# - Router : The modem will act as router and DHCP server.
# - Bridge : The modem will only act as a Bridge between the local and the GSM network.
#
# usb_profile (+UUSBCONF) :
# ! ONLY USED WITH TOBY-L2, will be ignored for other modems
# Select between different network/usb interfaces :
# - RNDIS
# - ECM
#
[ublox]
mode=Bridge
usb_profile=ECM

View File

@ -0,0 +1,18 @@
[Unit]
Description=WWAN configurator for device %I
[Service]
Type=forking
ExecStart=/usr/bin/wwan-config %I
PIDFile=/run/%I.pid
Restart=on-failure
Nice=-20
# Start time may include power cycles and start of ModemManager
TimeoutStartSec=180
# The default kill mode is killing the subprocesses created by the "os.system"
# calls used to stop ModemManager when handling the kill signal.
KillMode=mixed
[Install]
RequiredBy=multi-user.target

View File

@ -16,4 +16,7 @@ RDEPENDS:${PN} = " \
minicom \ minicom \
\ \
udev-rules-nmhw \ udev-rules-nmhw \
\
modemmanager \
wwan-config \
" "