The default subcommand accepts the public card numbers (1 external, 2 internal), but its invalid-value path reused select's 0/1 message: 'mu300-sim default 0' answered 'SIM slot must be 0 (external) or 1 (internal)', which made the command look broken. Give default its own validator and message, and spell both numberings out in the usage line. Test the two refusals and both valid values.
A ZTE V50 has up to four cards on the modem's two SIM interfaces: built-in SIM 1
and the external card share SIM1 behind soft-psim-switch, built-in SIM 2 and 3
share SIM2 behind esim2-esim3-switch, which of them a board has is ZTE's
board_id (four variants). kanoqwq read this from ZTE's B15 firmware
(f0ed60ff, b4c051c8); the #332 reporter found the same GPIO and polarity.
- upstream/port/drivers/misc/zte-v50-sim.c (kano's driver, built in): binds
zte,sim_gpio_ctrl only where the V50's AW9523B is; drives nothing at probe
(GPIOD_ASIS), so a V50 without a choice keeps the bootloader's routing.
- lib/v50-card.sh (kano's table), mu300-sim card 0-3|none: saves the card and
its SIM interface; the V50 boots SIM2 like the F50. mu300-sim v50-boot, from
android-vendor-start before modem_control: sets the saved card's switch once
a boot before the CP starts, drops the dashboard's identity cache of that
interface; never stops the boot.
- card N --now (opt-in, CLI): kano's live switch in ZTE's order (SFUN=5, 3, the
switch, 5 s, SFUN=2, CPIN, SFUN=4) under mobile-data's radio lock, switching
back on failure; physical switching was not validated by kano, so the
next-boot choice is the default.
- LuCI Cellular > SIM card list, WAN page labels, mu300-api sim.card, Cockpit,
backup; catalogs.
Co-authored-by: kanoqwq <kanoqwq@qq.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVN2zDgf76kMDVSuWhHPUE
kano (kanoqwq) ported this project to the ZTE V50 in his line (clean-tf-7.2: f6b0668d, 0438ab01). Brought over
as an experimental third device; nobody in this project has a V50, nothing of it is measured here.
- How it is told apart: mu300-device and boot/init (one rule, the same code): its device tree has an AW9523B at
0x5b on I2C3, which no F50's or U30 Air's has (both read). An F50 label on such a tree (an older installer's
"continue anyway") is a v50; a v50 label without the node is what the tree says. F50 and U30 Air unchanged.
- Installers (install.sh, install.ps1, the Magisk zip, the web installer, the boot chain scripts): exactly
V50 / MU3351 on ums9620, with one line saying it is experimental; any other V50 refused, never offered as an
F50; mainline kernel only.
- Kernel: kano's leds-aw9523b (binds only ZTE's binding), patch 0017 keeps the V50's eMMC host awake (his
measured fix); a mainline bundle names v50 only with the driver, the 5.4 bundle never.
- mu300-led (NET1 network lamp, Wi-Fi lamp by band, never the PMIC's LEDs), no battery, the F50's USB role
switch, USB network 192.168.79.1; SIM2, NFC and SIM selection stay off (mu300-nfc says so).
- README, wiki Hardware-Notes, FINDINGS 95 (kano's findings apart from what was checked here), ADB-INTERFACE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVN2zDgf76kMDVSuWhHPUE
Run on the maintainer's U30 Air (7.2.10), whose second position holds a card that
registers for emergency service only (FINDINGS 74 has the measurements).
Boot path
- "+CME ERROR: 10" is also what a position answers whose SIM power is off: the cold
start switches it on to ask (AT+SPACTCARD=<n>;+SFUN=2), and off again when no card
answers. Without it this unit's second card was taken for an empty position.
- The work modes are read and written back as they are (a mode locked on the Locks
page is kept); the data route is read back (AT+SPSWDATA?) after it is given.
- init.d/mu300-atd never returns without AT owners: whatever cannot be read or
written is a SIM1 boot, with the pin at 0.
- A failed start says why (no-sim, sim-pin, wrong-card, no-radio, ...). Nothing sent
yet: SIM1 in the same boot, through the owner of nr1, or by starting the AT service
over when nr1 has none. The radio already told: one restart into SIM1.
- A second card that never had data gets network.wan.sim_data_wait seconds (300) for
its first; without, the settings go back to SIM1 and the device restarts. A card
that has had data is never checked again.
- The cold start waits for the radio lock, and netifd's first dial waits for the cold
start (data 26.5 s into the boot instead of 39 s).
Live switch
- The card in use goes off before the other one comes on: with the factory's order
the target's AT+SFUN=4 never answered on this unit. Every command names its card;
the bare AT+SPACTCARD=0 lines changed nothing and are gone.
- The target is asked for its card before the WAN is touched (refused in a second).
- No data on the target: back only when the card in use had data; when it had none
either the target stays (no_data_kept), the boot default unchanged.
- A radio left unknown, a controller killed outright: the device restarts into its
saved default (network.wan.sim_restart '0' turns the restarts off).
- mu300-at tells every other client "busy" while the sequence runs; a dial waiting
for a card the radio is leaving ends at once.
- A pipe into grep -q under pipefail could read a radio that had come on as failed.
Everyone else
- mu300-sim active answers a pinned 0 from one file read again (2.8 ms, was 6.7).
- The panel's AT terminal refuses AT+SPACTCARD=, AT+SMMSWAP= and AT+SPSWDATA; its radio
actions are refused in any dual-SIM boot.
- A plain SIM1 dial takes the data route back only where the dual-SIM path left its
mark.
- test_mu300cell: the context tests patch the data owner's directory (main's literal
fifo path is a variable on this branch; they failed since the merge).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVN2zDgf76kMDVSuWhHPUE
mobile-data: main's credential handling (define_context, AT_SECRET) with this
branch's channel selection; the extended slot-1 context stays the F50's
(SIM_NATIVE=0), the U30 Air's native second card keeps the plain definition it
was measured with. mu300-update: both keep-list additions. FINDINGS: main's
63-70 keep their numbers, the dual-SIM section stays 74.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVN2zDgf76kMDVSuWhHPUE
An APN that asks for credentials (a private APN, some MVNOs) could not be
used: the dial knew an APN and a PDP type only. mobile-data now sends
AT+CGPCO=0,"<user>","<password>",<cid>,<auth> after AT+CGDCONT, which is where
ZTE's RIL sends it, and requires OK. Settings: username, password and auth on
OpenWrt's wan interface (on its page next to the APN), MU300_APN_USER,
MU300_APN_PASSWORD and MU300_APN_AUTH in Ubuntu's mobile-data.conf. Without
credentials the dial sends what it always sent, for both cards.
The credential path, after a security review of the first version:
- Never on a command line (mu300-at takes a command on stdin now), never in
the environment of anything mobile-data starts, never printed, logged or
traced; only printable ASCII without a quote or a backslash reaches the AT
argument. mu300-atd writes answer files mode 600 and no longer logs a late
echo of a command.
- Fail closed: credentials without an APN, a settings file others can read, a
mark that cannot be written, a modem that does not answer OK to them or to
the empty form that takes them back, all end the bring-up. The mark (one
per card, empty) is written before the credentials go out and removed only
once the modem has let go of them.
- One reader and one gate for both systems: mobile-data reads what its
environment does not say from mobile-data.conf itself (mu300-power's resume
and a command run by hand dialled without the APN), and settings_private
makes the file that holds the password root's alone, or there is no dial.
OpenWrt's first boot makes /etc/config/network mode 600.
The command and its place in the dial are from kanoqwq's reading of the B09
RIL (clean-tf-7.2 3826be8b); the code is ours. Its profiles, ICCID binding and
block-mount patch are not taken. FINDINGS 65 says where the password is and
who can read it. Unit tests only: never sent to a modem.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVN2zDgf76kMDVSuWhHPUE
On a U30 Air the WAN page offered "Internal SIM (slot 1)". mu300-sim
supports slot 1 on the F50 only: it ignored the saved value for the
boot and every reader stayed on the external card, with no hint on any
page (the dashboard showed the other card's operator).
- dashboard-info: "sim": {slot, wanted, slot1_supported} from
mu300-sim status --json (null without the selector). Local only, no
AT command; it is what mu300dash sysinfo and status return.
- protocol/mu300cell.js: reads it (mu300dash sysinfo). Without slot 1
the internal SIM is not offered; a slot 1 already saved stays listed
as "not supported on this device" so the page shows what is saved.
Nothing known (no panel, the call fails): both, as before.
- home.js: a "SIM source" row only when the card asked for is not the
one in use: not supported on this device, or (F50) in use after a
reboot. Three messages in all 31 catalogs.
- docs/SIM-SELECTION.md: devices without slot 1.
mu300-sim itself is unchanged; the U30 Air's second SIM is PR #166.
Tests: tests/test_sim_selection.py - dashboard-info with the real
mu300-sim on a fake root (U30 Air, F50, no selector, a hostile status),
mu300cell.js and home.js's paintSim under Node with LuCI faked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVN2zDgf76kMDVSuWhHPUE
- mu300-sim: usage errors exit 2 ("valid invalid || exit 2"; under set -e the bare call ended the script
with 1). A stored slot that is not 0 or 1 no longer fails every AT owner at start: active pins the external
card for the boot with a warning (configured and status still report the bad value).
- mobile-data: an APN with a quote, a backslash or a line break is refused before AT+CGDCONT (it was pasted
into the quoted AT argument as it was; both slots).
- ndp-learn: router_lifetime read the default route of sipa_eth0 whatever the slot; now $IFACE.
- uci-defaults/90-mu300: sipa_eth8 (the internal card's bearer) is named in the wan zone like sipa_eth0, so
the boot ruleset masquerades LAN clients on it before the first ifup reload (#67).
- tabs instead of spaces in mu300cell.sh, mu300cell.js, common.js, mu300-atd-dash, mobile-data.
- tests: the two new behaviours, and exit code 2 for bad selections.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqKKtBQZCfxYnHuBCuDqqn