modem/msm-modem: uim-selection: Allow configuring wait time for SIM (MR 2695)

Unfortunately it looks like some modem firmwares (or SIM cards?) need
more time until the SIM card shows up in the modem. This means that the
SIM card might not get configured, making it look like it was not
detected at all. On the other hand, having the previous long wait loop
affects _all devices_ when there is really no SIM inserted.

The proper solution would be to make it possible to configure SIM cards
once they show up (probably in ModemManager). Until then, try to make it
possible to workaround this by introducing a configurable delay to wait
for the SIM card. It is set to minimal "1 seconds" by default but could
be increased by the user if needed to give the modem enough time to detect
the SIM card.

This reverts commit 683b543a3b ("msm-modem-uim-selection: Don't wait
for SIM (MR 2470)" but with a new configuration mechanism and a default
of 1 second only.

[ci:skip-build] already built successfully in CI
This commit is contained in:
Minecrell 2021-11-16 11:31:48 +01:00 committed by Clayton Craft
parent 234295575c
commit f563e0ddcf
No known key found for this signature in database
GPG key ID: 4A4CED6D7EDF950A
3 changed files with 27 additions and 2 deletions

View file

@ -1,5 +1,5 @@
pkgname=msm-modem
pkgver=6
pkgver=7
pkgrel=0
pkgdesc="Common support for Qualcomm MSM modems"
url="https://postmarketos.org/"
@ -10,6 +10,7 @@ install="$pkgname.post-install"
subpackages="$pkgname-downstream $pkgname-uim-selection:uim_selection"
source="
msm-modem-downstream.initd
msm-modem-uim-selection.confd
msm-modem-uim-selection.initd
udev-downstream.rules
"
@ -24,6 +25,7 @@ uim_selection() {
depends="$pkgname libqmi"
install="$subpkgname.post-install"
install -Dm644 "$srcdir/$subpkgname.confd" "$subpkgdir/etc/conf.d/$subpkgname"
install -Dm755 "$srcdir/$subpkgname.initd" "$subpkgdir/etc/init.d/$subpkgname"
}
@ -38,6 +40,7 @@ downstream() {
sha512sums="
3172f8c409f552f13d1da29f14ab6c79072cd6da4acab151a1a0ea1858a416974456852609f14fe29cf97a6a45e60b99d0a57ddcde751da243ee5ac6fa8b672c msm-modem-downstream.initd
177cf671a12a9b1de24d1223043fb9fe6dd15f3675112123f2fa080c074cc7c6e7024ed1542ae824bb036cc51a020b8e3ab146106cecd1315649073fd2118db8 msm-modem-uim-selection.initd
efbe0d23f2716e10f5ef0006c6eb21672a14e368ecceb74d296039bc539be2b35964af48efa0db69d0f410e7bee19ba0d69ab1ede43b9cfd443acde6997c8017 msm-modem-uim-selection.confd
9c91febb48409e574695bb04c989b361db9f7678321c6935772c19efae7dd16956bd4b91143b475adf898344225d4095448b95ccb824ced305966ea96b9ae32f msm-modem-uim-selection.initd
2a511c2e249d0ec5a52f04ffe1ef3d29cf3c4813143b103e54879ff89176ea45b1a5ffe21cb7dc2f1cdd84c3102ba45ef9926ed37e00b1ae12a36d01de35ea5a udev-downstream.rules
"

View file

@ -0,0 +1,6 @@
# Maximum time to wait for SIM card to appear after starting the modem.
# Some SIM cards or modem firmwares might take longer to initialize. :(
# To avoid blocking boot without a SIM card for too long this is fairly short
# by default (1 second), but you can increase it to e.g. 30 seconds if necessary.
# Set to 0 to disable waiting entirely.
sim_wait_time=1

View file

@ -64,6 +64,22 @@ start() {
QMI_CARDS=$($QMICLI_MODEM --uim-get-card-status)
# Fail if all slots are empty but wait a bit for the sim to appear.
count=0
while ! printf "%s" "$QMI_CARDS" | grep -Fq "Card state: 'present'"
do
if [ "$count" -ge "$sim_wait_time" ]
then
eend 4 "No sim detected after $sim_wait_time seconds."
return 4
fi
sleep 1
count=$((count+1))
QMI_CARDS=$($QMICLI_MODEM --uim-get-card-status)
done
veinfo "Waited $count seconds for modem to come up"
# Clear the selected application in case the modem is in a bugged state
if ! printf "%s" "$QMI_CARDS" | grep -Fq "Primary GW: session doesn't exist"
then