mu300-vpn gains ENGINE=xray, now the default: Xray-core speaks VLESS and hev-socks5-tunnel owns a plain kernel TUN
(xtun), handing every flow to Xray's SOCKS port on loopback. It reads the same VLESS_URI through the same parser;
ENGINE=sing-box keeps the old engine, and an image without the xray binaries falls back to it by itself.
The script does the routing neither program does, with sing-box's rule prefs and table so routing_cleanup and the
kill switch cover both: Xray's own sockets carry the 0x2d0 mark to main, the LAN and the server's address go to
main, everything else to xtun, and the device's own DNS is DNAT'd to REMOTE_DNS. The server name is resolved
before any of that exists and handed to Xray as an address. Xray, hev and the rules are torn down together on
every exit path.
Xray 26 removed allowInsecure. For a link that asks for it the leaf certificate is fetched with openssl once,
pinned as TLS_PIN_SHA256 in vpn.conf, and re-fetched only when Xray reports a pin mismatch (a renewal), after which
the service restarts. That report is info-level, so Xray runs at info and only warnings reach the system log.
Release: tools/fetch-xray.sh pins both binaries by sha256; make-release, assemble.sh and the OpenWrt build carry
them, and both images get openssl. The example config ships KILL_SWITCH=0 until the kill switch is re-tested
with Xray.
Measured on OpenWrt on the device: exit IP is the server's, apk works through the tunnel, a Wi-Fi client is
forwarded into xtun, and the three pin paths (none, present, mismatched) behave as described. Ubuntu is not yet
run on the device. FINDINGS 26e also records that busybox nc here has no -w - the reason an earlier test read
every destination as closed.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Three things, all from one session chasing "there is no internet" down the wrong hole twice.
sipa-dele-start waited on dmesg lines that the modem *loader* prints, so it was satisfied on its first check
and loaded the [permanent] module as early as before. It now waits for AT+CGATT? to answer 1, which cannot be
true before the CP's packet domain is running.
mobile-data's up() ended by turning the blue LED on. The PMIC rejected that write once, and under set -e the
failing && list ended the function one line before it reported success - with the context already up. The
caller saw a failure for a call that was live. LED writes go through a led() helper that cannot fail.
FINDINGS 13g records what the outage actually was - the internet PDP context had gone while the IMS one
stayed, and sipa_eth0 kept the previous address so every interface-level check still passed - plus the two
measurements that lie about it: sing-box's tun answers ICMP itself (sub-millisecond replies with tx_packets
frozen, and -I does not escape its ip rules), and with sing-box stopped the kill-switch turns the same ping
into EPERM. An idle SIPA reads as a broken one; none of those counters mean anything unless traffic is
leaving while they are read.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
That variant ships with userdata filling the disk, so there is no gap behind it
and the installer had nothing to do but refuse. It can now shrink userdata to
make one, and uninstall can grow it back.
Only userdata, and only because it is the last partition: its end moves and
nothing else does, so every other partition keeps its offset and the AVB
descriptors and the boot chain stay valid. That is the whole safety argument and
it does not transfer to any other partition here, which is why the tool refuses
when the partition named is not the last one.
tools/resize-last-partition.py does the edit and is deliberately fussy. It
validates both GPT signatures, both header CRCs and both entry-array CRCs, checks
that the two headers agree about the layout and sit where a GPT puts them, and
refuses a new end that is past the usable area or that would leave the partition
empty. It re-parses what it produced before the caller is allowed to write it.
Verified against this device's real table: it reads the 64 GB unit correctly
(userdata 12275712..54218751, 20.00 GiB, 32.39 GiB free behind it), shrinks and
refills round-trip, and all three guards fire.
install.sh asks how many GiB Linux should get, keeps at least 4 GiB for Android
and 800 MiB for Linux, aligns the boundary, prints what each side ends up with
and requires ERASE to be typed. It writes the backup GPT before the primary, so a
power cut between the two leaves the old table and a device that still boots, and
it reads the table back and checks the new end took before clearing Android's
data filesystem. --check reports and offers nothing.
uninstall.sh offers the reverse, off by default: on the 64 GB variant growing
userdata would hand it the factory gap, so the numbers are printed and the answer
has to be yes.
Both paths are labelled EXPERIMENTAL and tell the user to take a full backup with
tools/backup-device.sh first. They rewrite the partition table and erase
everything in Android; this has been done by hand on exactly one device (issue #2).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
On some devices su runs the command on a pty, and the tty layer's ONLCR rewrites
every LF as CRLF. exec-out exists to avoid exactly that translation, but the pty
su allocates puts it back, so every binary read came back inflated by about one
byte in 256 - silently, with no error anywhere.
jizni reported it with a proof that leaves no room: `dd bs=1M count=64` cannot
emit more than 67108864 bytes, and 67357842 arrived. For six firmware files the
CRLF count in the corrupted copy equals the LF count in the good one exactly, and
normalising the corrupted copy back makes it byte-identical.
What it costs when it happens: the Wi-Fi firmware reaches /lib/firmware mangled,
the driver loads without complaint and no phy is ever created - the install
reports success, 5G works and there is simply no hotspot, with nothing in any log
pointing at it. The boot image is built from a corrupted dump, so it is the wrong
size and its header and AVB tail are wrong. The vendor tar fails to extract. The
GPU closure dies in struct.unpack_from. The bootloader_control block is read from
a shifted offset.
Every binary read now goes through a file on the device and `adb pull`, which
never touches a pty and is correct whether or not that device's su allocates one:
install.sh (boot_a, the misc head, the six firmware files), uninstall.sh,
backup-device.sh, collect-logs.sh, reset-password.sh, extract-subset.sh,
extract_subset.py, pull_closure.py and both .ps1 scripts.
install.sh also refuses to continue when a firmware file could not be read, which
is what turns the worst case above into a loud failure instead of a device that
boots without Wi-Fi.
Secondary problems from the same report, all confirmed in the source:
* install.ps1 piped into the `Python` helper, an advanced function with no
pipeline-bound parameter - the binding fails, and its body would not forward
$input to the child's stdin even if it bound. Calls the interpreter directly.
* Python detection read only Get-Command's .Source, which is empty for the
Microsoft Store's app-execution alias, so a working interpreter was "not found".
Falls back to .Path.
* extract_subset.py created the output directory before validating the archive, so
a failed run left an empty directory that every later run then skipped.
Validates first.
* regdb-load's `sleep 0.3` is rejected by busybox sleep, so the wait loop spun
instead of waiting.
FINDINGS 9b gains the 32 GB variant: shrinking `userdata`, which is the last
partition so nothing else moves and the boot chain stays valid, recovers 10 GiB
and the installer then runs unmodified.
Worth recording that this never reproduced here - the backups taken with
backup-device.sh on the maintainer's device are all exact partition sizes - which
is why it survived this long, and why the fix is written to be correct on both
kinds of device rather than conditional on detecting one.
Reported-by: jizni
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Two mistakes stacked, and each one hid the other.
The patch was first written into audio_mem_whale2_parse_dt. This board's node is
compatible = "unisoc,audio-mem-sharkl5", so the code compiled, loaded, accepted
its module parameter and never ran. Moving it to the sharkl5 parser was the
obvious fix and it still did nothing, because of the second one:
build-audio.sh guarded the patch with `grep -q shm_shift`, and the first version
had already put that string in the tree - so the corrected patch was never
applied. The module kept the pr_info string from the old build, which made
`strings audio_mem.ko` look right while the call sat in the wrong function.
Then the regenerated patch would not compile: it had been diffed against a tree
that already carried the draft, so the declaration came out as a *context* line
and only the helper was an addition - putting the helper above the variable it
uses. It is now generated against pristine + audio-mem-fixed-region, which is the
base it actually builds on, and the guard keys on the function name instead of a
string an earlier version also had.
It works now: "moved the shared-memory addresses down by 0x100000, cmdaddr is now
0xaf880000", with smsg, aud-str, dsp-vbc and reg-dump following, all matching the
Moto G35's device tree.
Which turns that experiment into a clean negative. At its own addresses, its own
7 MiB region and its own shared memory, the Moto image still never answers, while
the donor image answers on the first try at this board's addresses. Whatever it
wants beyond a matching memory map, it is not the addresses.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Why the Moto G35 image takes this device down, from its own device tree rather
than a guess: pulled out of vendor_boot.img in the same firmware, it puts
audio-mem at 0xaf600000 and a 7 MiB DSP region at 0xaf900000, with cmdaddr
0xaf880000 - a megabyte below this board's 0xaf700000 / 0xafa00000 / 0xaf980000.
Written to the wrong base the image runs into memory belonging to something else.
Read the other way it is reassuring: the donor image answers SIPC at 0xaf980000,
so it is built for this layout and is where it should be.
CONFIG_OF_RESERVED_MEM_ADD now reserves 0xaf600000,3M;0xaf900000,7M, contiguous
to 0xb0000000 and a superset of what this board uses, so one boot image can host
either. audio-mem-shm-shift.patch adds shm_shift for the addresses that are
absolute in the device tree instead of derived from the region - ddr32_base and
dspbin_base already move everything else.
The experiment itself is inconclusive rather than negative. At its own addresses
the Moto image no longer takes the board down and ldinfo reads 0xaf900000 /
7340032, but the DSP does not answer and shm_shift is not confirmed to have
taken effect - cmdaddr still shows as 0xaf980000 in the SIPC trace. FINDINGS says
so, along with two things that cost time here: audio_mem has three DT parsers and
this board uses the sharkl5 one, so a change made in whale2's compiles, loads,
accepts its parameter and does nothing; and the boot service loads audio_mem at
startup where it is [permanent], so trying another layout needs the service
disabled and a reboot first.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Read the VBC registers during a stalled stream (only safe then; reading AGCP MMIO
with the domain asleep hangs the board). AUD_EN 0x300 and AUD_DMA_EN 0x3: the
playback FIFO is enabled and both DMA channels are on. PLY_FIFO0/1_STS 0x24a1 -
the low nine bits are 0xa1, so 161 words are sitting in the FIFO and not moving,
which is hw_ptr's 160 frames exactly. The DMA filled the FIFO once and stopped
because nothing is draining it, and in this design the consumer is the DSP.
That closes the AP side. Also closes parameters and modes: both sets were tried
with the param_id that works - the community's donor set, which comes from a ZTE
Voyage 41S (the same T760/UMS9620 as this board, and a phone with real audio),
and the U30 Air's native set - across modes 0, 2, 7, 9, 28 and Loopback 63, all
stalling identically. The sets are equivalent where it could matter: dsp_vbc mode
7 is byte-identical between them and audio_structure differs only in tuning, so
neither is a stripped build.
What remains is inside the AGDSP image: it answers SIPC commands on the first try
and never reads its input FIFO.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
kernel/patches/mcdt-enable-clock.patch: check_agcp_mcdt_clock() reads BIT_MCDT_EN
and, when it is clear, every MCDT accessor returns early without touching the
hardware - so MCDT gets configured into a void while setup still looks like it
worked. Nothing in the driver set writes that bit. Since the driver already holds
the regmap and knows the bit, have it enable the block it is about to program.
The write only happens when the bit is clear and the result is read back, so a
controller that genuinely cannot be enabled still reports false.
mu300-audio-dsp gains a "profiles" command. The kernel takes the DSP parameters
through request_firmware(), so tools/vbc-profile's output in /lib/firmware is all
it needs, and the select value matters: (mode << 24) | (param_id << 16) | dsp_case
does nothing visible with param_id 0, but with 0x5e - what a working device of
this family carries - the mode is copied into the DSP's shared memory at
sprd,shmaddr-dsp-vbc. The mode numbers are call scenes (Handset, Handsfree,
Headset, BTHS, ... each NB/WB/SWB/FB/VOIP); there is no media mode in there at
all, which is worth knowing before chasing media playback through them.
FINDINGS records the reference comparison. A ZTE MU5358 registers the same
sprdphone-sc2730 card and does carry call audio; between idle and an active call
exactly 18 of its controls move, all routing and output. Applying the same shape
here - every S_*_CODEC switch at once, the codec output tree, agdsp_access_en -
changes nothing. Neither the F50's own Android nor a U30 Air (same ums9620) has
any audio to compare against, but the U30 Air does carry the native UMS9620
parameter XMLs, which are a better source than the community's donor copies.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Reading VBC at 0x56510000 with the AGDSP domain powered down hangs the bus and
the watchdog takes the board with it - which on this device also costs slot B its
boot trial, so LK rolls back to Android. I did this while trying to check whether
the AP01 FIFO was draining, on the assumption that a read-only peek could not
hurt. It can. The same goes for MCDT and the AGCP AHB syscon; DDR and the
always-on syscons are fine at any time.
The repo copy of the tool was also still the read-only version; this brings over
the set/clr support that found BIT_MCDT_EN.
FINDINGS now lists all three ways the board has been taken down in this area -
the Moto firmware, opening a capture stream, and this - together with the
recovery, which needs ANDROID_SERIAL pinned because a second F50-family unit
answers adb at the same time.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
BIT_MCDT_EN (bit 12 of MODULE_EB0_STS at 0x64900000) was clear, so
check_agcp_mcdt_clock() returned false and every MCDT register access was
skipped - setup included, since mcdt_reg_read/raw_write/update all return early
without touching the hardware. "mcdt_dac_dma_enable ... mcdt_dma_ap_channel=1"
still prints, which is what makes it look healthy. Nothing in the audio drivers
ever writes that bit; they only read it.
I had written the "agcp mcdt clocl not available" message off as a teardown
artifact because that is where it first appears - after agdsp_access_disable()
drops the power domain. It was telling the truth. Setting the bit while the
domain is powered silences it and it persists. This matters for the voice path,
which runs through MCDT; normal playback does not, and its trace has no MCDT
lines at all.
Also records where media playback actually stops, with the measurements rather
than the guesses: the DMA advances once by 160 frames - exactly the burst:160
the driver programs - and then stops, with both sprd_dma interrupt counters at
zero throughout. Around that, the trigger path runs in full, the codec DAC and
its clocks are powered, and the DSP answers. Dynamic debug on the four audio
modules is what makes it visible and is the first thing to turn on when picking
this up. The device-type, mute, volume, codec-output, Virt Output Switch and
agdsp_access_en controls were all tried and change nothing.
With a warning attached: two experiments here took the board down hard enough
that slot B lost its trial and LK rolled back to Android.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
vbc_profile_loading() takes its parameters through request_firmware() under the
bare names audio_structure, dsp_vbc, cvs and dsp_smartamp, so the kernel will
read them straight out of /lib/firmware and the proprietary audio HAL is not in
the picture at all. Writing 1 to the matching "… Profile Update" control loads a
blob; writing a mode to "… Profile Select" applies it. The format is a 24-byte
header ("audio_profile", num_mode, len_mode) and then num_mode * len_mode bytes.
The vendor ships the same data as XML, which carries both numbers in its root
element and then every field with an offset, a width and a value. The one thing
about it that is not guessable: id is an offset into the whole mode array rather
than into the mode it appears under - mode 1's first field sits at struct_size,
mode 2's at twice that. Read per-mode, every field outside mode 0 lands out of
range, which is exactly what the first attempt did. The converter checks the two
readings against each other and would say so rather than quietly truncating.
Verified on the device: all three blobs load with "vbc_profile_loading, return
0", selecting mode 0 applies them, and the DSP acknowledges the 620-byte
parameter payload that follows.
The XML is vendor parameter data and stays out of this repo; the tool takes a
path to a copy.
Also records two things about the audio path that cost time. "[MCDT] agcp mcdt
clocl not available" is a teardown artifact - it is logged after hw_free, once
agdsp_access_disable() has dropped the power domain, while during setup the same
block is fine and MODULE_EB0_STS reads 0x2063e2d1 with every relevant bit set.
And the real remaining symptom, measured rather than inferred: with everything in
place the DMA advances once, by 160 frames, and then freezes -
state: RUNNING hw_ptr: 160 appl_ptr: 24160 avail: 0 (t=2s through t=10s)
so the path is wired end to end and the DSP takes a first chunk. What makes it
come back for the second is the open question.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Retracting the previous commit's conclusion. It said the core was not executing
the image, on the strength of /dev/audio_dsp_log returning nothing. That was one
negative signal treated as a measurement: this firmware does not log at all.
The test that settles it is aud_send_cmd's own trace, because its exit line is
only reachable when aud_recv_cmd returned a reply - an unanswered command retries
four times and leaves through "failed to get command" instead. The kernel logs
[Audio:SIPC] aud_send_cmd out,cmd =5 id:0 ret-value:0,repeat_count=1
on every PCM open. A reply on the first attempt: the DSP is up and answering.
mu300-audio-dsp now reports power-up and liveness as two separate things and uses
this for the second, instead of the log.
Two more inferences corrected. 0xaf700000 is sprd,ddr32-dma, a DMA buffer - the
AP/DSP mailbox is at sprd,cmdaddr 0xaf980000 and sprd,smsg-addr 0xaf980400, and
it does fill in once the domain powers. And /audio-mem-mgr's own compatible is
"unisoc,audio-mem-sharkl5" on a board whose syscons are "sprd,ums9620-glbregs",
so the SharkL5 string in the firmware header was never evidence of a wrong chip;
Motorola's genuine QogirN6Pro image carries the same label.
What actually blocks a PCM is configuration the Whale HAL supplies on Android.
vbc_profile_loading() pulls it in with request_firmware() under the bare names
audio_structure, dsp_vbc, cvs and dsp_smartamp, so the kernel will take them from
/lib/firmware with no HAL in the picture, triggered by writing 1 to the matching
"… Profile Update" control. The format is a 24-byte header ("audio_profile",
num_mode, len_mode) followed by num_mode * len_mode bytes, and the community's
donor-params XML carries exactly those numbers plus every field's offset, bits
and value. Converting one to the other is the next piece of work.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
This kernel is built with CONFIG_DEVMEM unset, so there is no /dev/mem and no
way to look at either the AGDSP's reserved DDR or the syscon registers that
sprd_audcp_boot writes through regmap. mu300_peek.ko is a dozen lines that
memremap or ioremap an address and hex-dump it to dmesg, and fails its own init
on purpose so the next insmod does not need an rmmod first.
With it, the AP side of the AGDSP is now verified rather than assumed. After
"start": bootprotect holds the 0x9620 magic, bootvector is 0x57d00040 which is
(0xafa00000 + 0x80) >> 1 exactly, bootaddress_sel is set, both force-shutdown
bits are clear and all three resets are released. The firmware is in DDR where
it should be - peeking 0xafa00000 shows the image's own header.
So the core is powered, pointed at the right address, and writes nothing: the
communication area at 0xaf700000 is byte-for-byte identical before and during
power-up, holding only the AP's own ring descriptors. agdsp_access and
audiocp_boot also read the same power-status register with the same mask, so
they cannot be disagreeing about whether the domain came up.
That leaves the image, which is a donor from a SharkL5/L6 device - the F50 has
no l_agdsp partition to take one from, and super carries no AUDCP header either.
What this needs is a genuine Qogirn6pro/UMS9620 AGDSP image. Everything else is
ready for one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
I reported the DSP as running and wrote it into FINDINGS. It is not, and the
mistake was reading a powered domain as an executing one: agdsp_access_enable()
takes the AGDSP up through the PMU whether or not the core has an image to run,
so "wake up done" with no timeout and status core=0 sys=0 say nothing about the
firmware.
The test that does settle it is the DSP's own log. A running AGDSP writes to
/dev/audio_dsp_log over the audio SIPC sblock channel; here a read returns zero
bytes and the kernel says "sblock_receive wait interrupted". mu300-audio-dsp
now reports power-up and running as two separate lines.
This is not a Linux problem. The Android module says so in its own service.sh -
"AudioCP still times out on F50 even with the donor memory layout" - and the
Whale HAL module's README lists bridging cellular RX/TX through AudioRecord/
AudioTrack as explicitly outside what it achieves, which is exactly what a SIP
gateway needs. What works there is media audio and calls over a Bluetooth
headset's SCO link, which bypasses the AGDSP entirely.
Ruled out along the way, each checked rather than assumed: the firmware is
byte-identical to the image Android uses; the memory really is reserved; ldinfo
matches the image size so the whole of it is copied; and the load order does not
matter - writing it with sound@0 unbound, the way Android does, changes nothing.
That last one also makes the old "start reboots the device unless the card is
registered" rule untenable, so it is marked as not reproducible rather than left
standing as an explanation.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Two corrections, both measured, and together they are the difference between
"the audio DSP does not work on this board" and a running one.
* The card registers with every route switched off. Opening a PCM then fails
with "Unable to install hw params", which reads like a driver that cannot do
16-bit 48 kHz; the real line is "no backend DAIs enabled for FE_NORMAL_AP01"
a few above it in dmesg. The DPCM front ends reach their back ends through
~70 S_..._SWITCH mixer controls, all off at probe, which Android's HAL sets
from configuration there is nothing to inherit from here. New "routes"
command, also run by "start".
* An idle AGDSP reads exactly like one that never started: the power domain is
only up while a PCM is open, so sys_status is 7 the rest of the time. "start"
checked it one second after writing the firmware and called a perfectly good
load a failure. It now opens a PCM and watches agdsp_access_enable() take the
domain up, and says so: "loaded - it woke when a PCM was opened".
With both in place the DSP runs - status core=0 sys=0 while a PCM is open - and
FE_ST_VOICE_PCM_P opens through BE_DAI_ID_VOICE_PCM_P, which is the path a call
needs and which needs no speaker. The header warning that "start" reboots the
device is gone: that was the card-ordering bug and it is fixed.
Also notes that agdsp_store() clamps each write to ldinfo's size, so a firmware
larger than the reserved region is truncated in silence while dd reports success.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Three traps, all measured on the device:
* The code has to be hex. AT+CUSD=1,"*101#",15 answers +CME ERROR: 3, and
still does after AT+CSCS="GSM", so this is not the character set doing what
the character set is documented to do. The hex form is accepted regardless
of AT+CSCS.
* The answer does not come back on the channel the command went out on. The
command gets a bare OK on nr1 and the +CUSD arrives seconds later on nr0,
the unsolicited channel, so anything waiting for it on nr1 waits for ever.
mu300-atd already drains nr0 to a log, and that log is what this reads -
waiting on a file also costs the modem nothing, which matters because
polling it with AT commands is what jammed the channel in the first place.
* The third +CUSD field is a CBS coding scheme, not an SMS one: 15 is the GSM
alphabet, 72 is UCS2, which is what a Turkish menu comes back as. The body
is hex-dumped one byte per character rather than packed into septets, so
sms-pdu.awk gets a "ussd" mode instead of reusing the PDU path.
Verified end to end: *101# returns the SIM's own number, and a dcs=72 body
decodes with its Turkish characters intact.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
mu300-audio runs "start" rather than "load": it loads the drivers and the DMA engine, binds the card, and only
then writes the firmware - and the script refuses to touch the reset registers unless the card is registered,
which is the ordering that keeps the device from rebooting.
Verified from a clean boot with nothing typed: cards shows sprdphone-sc2730, the service log says "DSP started
from /lib/firmware/agdsp.bin (6291456 bytes)", and FE_ST_VOICE_PCM_P is at 01-53.
Two things that looked like faults and are not. The start is once per boot - from the cold state it works every
time, and re-running it on a DSP that has already booted leaves sys=7 while every step still reports success.
And sys flips between 0 and 7 by itself, which is the DSP's own power management; reading the status at an
arbitrary moment says little.
What says the path works is opening the endpoint: /dev/snd/pcmC1D53p opens and closes cleanly and takes its DMA
buffer from the reserved region (audio_mem_alloc addr = 0xaf725000). A call carrying audio through it is still
not done.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Two answers, one of them a mistake of mine.
Starting the DSP reboots the device only when the sound card is not registered. Measured both ways: with
sprdphone-sc2730 up, writing the firmware and the reset registers leaves the device running - uptime went from
972 to 1225 seconds across the attempt; with the card missing, which is the state before sprd-dma is loaded,
the console shows an orderly CPU shutdown and "reboot: Restarting system" seconds later. Registering the card
is what exercises agdsp_access_enable, so with no card the AGDSP power domain is never up and start_store
writes RESET_SEL, CORE_RESET and SYS_RESET into a domain that is off. mu300-audio-dsp start now refuses unless
the card is there.
The register sequence itself was compared against the driver and the device tree and is fine, including the
boot vector: "dsp reboot by DDR!" means the dsp-reboot-mode property is absent and the mode is 0, which is the
branch that does set the vector.
And status is not a number. It is three u32s - core, sys, sleep - where sys is 0 for "power up finished" and 7
for "power off". After the first firmware write it read core=0 sys=0 sleep=6: the DSP was up, and the script
had been reporting failure because it compared the raw struct against the string "1".
Still open: the start is not repeatable. The first attempt after a boot works; later ones leave sys=7 with
every step reporting success - stop accepted and it does reset ppos, 1536 records written, ldinfo showing
0xafa00000 and 0x600000, start accepted, and not one line of kernel output. The suspicion is that the power
request agdsp_access_enable asserts has to be held across the start, and that the card bring-up at boot
provides that window once.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
mu300-audio on OpenWrt and mu300-audio.service on Ubuntu, both running "load" and never "start" - so nothing
at boot can reach the firmware write that reboots the device. The procd one backgrounds itself the way the
rest of the hardware bring-up does: binding the card takes about half a minute of waiting on probes, and
busybox init does not spawn the consoles until sysinit has returned.
Verified from a clean boot with no help: cards shows sprdphone-sc2730 and FE_ST_VOICE_PCM_P is at 01-53.
The README's sound row said the amplifier does not respond, which was true and is no longer the whole story.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
cat /proc/asound/cards now has a second entry, and /proc/asound/pcm has nineteen devices on it including
FE_ST_VOICE_PCM_P at card 1 device 53 - the same card the community Android modules produce, and the endpoint
sipserver's detectVoicePCMDevice looks for. mu300-audio-dsp load does the whole thing in one command and it
survives a reboot.
The last obstacle was the DMA engine, and nothing points at it. CONFIG_SPRD_DMA is a module that nothing pulls
in, so /sys/class/dma is empty, sprd-pcm-audio defers for want of a channel, its component never registers, and
snd_soc_register_card fails with "ASoC: failed to init link FE_NORMAL_AP01: -517" - a message that names a link
and never mentions DMA. virt-dma and sprd-dma bring up two controllers with sixty channels and the platform
components follow.
The card's probe runs before any of that exists and is not retried, because it returns 0 even when the
registration deferred. Binding sound@0 again once everything is in place is what finishes it.
sprd-card-dummy-on-defer.patch handles the links whose codecs this board does not have. Two details cost a boot
each: it must apply only to the codec, since giving the cpu dai a dummy kills the card at link 0 instead of 57;
and the dummy has to be filled in directly rather than by returning -ENOENT, because
asoc_sprd_card_dummy_codec_sel reads 'sound-dai' as a u32 and insists on a zero phandle, so it answers -EINVAL
for a node that exists and merely never arrives.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
sprd-card-dummy-on-defer.patch settles dai link 57. BE_FAST_P_SMART_AMP asks for the smart amplifier this
board does not have, so snd_soc_of_get_dai_name defers for ever and asoc_sprd_card_probe abandons all 58 links
- the other 57 parse, BE_VOICE_PCM_P among them. A link whose codec phandle is simply absent already falls
back to a dummy one frame up; dummy_on_defer=1 extends that to one that keeps deferring. Only for the codec:
args_count is NULL exactly on the codec call, and giving the cpu dai a dummy kills the card at link 0 instead
of 57, which is how the narrower condition was found.
The firmware is 6 MiB, which is what settles which region is which - the DSP binary goes in audiodsp-mem at
0xafa00000 and the 3 MiB at 0xaf700000 is the shared memory. sprd_audcp_boot confirms it: base_addr_phy =
0xafa00000, bin size = 0x600000. No image is in this repository and none can be.
Where it stops: starting the DSP reboots the device. The drivers load, the firmware writes, and seconds later
the console shows an orderly CPU shutdown and "reboot: Restarting system" - deliberate, from userspace, not a
panic. start_store writes AUDCPBOOT_CTRL_SYS_RESET and CORE_RESET through regmap and on this board that
appears to reach past the audio core. So mu300-audio-dsp grew a "load" command that stops short of it and
brings up everything else; "start" is the opt-in that reboots, and says so.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Verified on the device after rebooting into the patched kernel. Both ranges are reserved at boot, audio_mem
takes them from its module parameters, and the audio SIPC channel that used to answer ENODEV now allocates its
blocks inside the reserved region and sends to the DSP:
OF: fdt: Reserved memory: reserved 0x00000000af700000 size 0x0000000000300000 (reserved_mem_add)
[Audio:MEM] dsp_bin (addr, size): (0xaf700000, 0x300000)
[Audio:SBLCK] audio_sblock_create: p_rxblks[6].addr 0xaf71d060
[Audio:SMSG] aud_smsg_send: dst=1, channel=3
The machine card went from deferring at dai link 0 for ever to parsing 57 of 58, BE_VOICE_PCM_P - the back end
the SIP gateway wants - among them. It stops on the last, BE_FAST_P_SMART_AMP, which asks for the smart
amplifier this board does not have: nothing answers at I2C 0x34 and the device tree's own sprd,spk-ext-pa-info
count fails with -22. Links whose codec phandle is missing already fall back to a dummy codec, but one that
defers is fatal, asoc_sprd_card_probe gives up, and nothing re-probes.
So the remaining work has moved off the DSP memory entirely: let a deferring codec fall back to the dummy the
way a missing one does, and supply an image for sprd_audcp_boot.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
audio-mem-mgr on this board has every Unisoc audio address there is - cmdaddr, smsg-addr, shmaddr-dsp-vbc,
offload-addr, ddr32-dma, both iram bases and a dozen more - and lacks only memory-region. audio_mem reads that
as two phandles pointing at reserved DDR, and without them audio_mem_alloc(MEM_AUDCP_DSPBIN) has nothing to
give sprd_audcp_boot, so the image cannot be written and the DSP never starts. ZTE kept the whole audio
description and removed just the reservation, which fits a board built without a speaker.
There is also no firmware file to hunt for: sprd_audcp_boot has no request_firmware() at all. Userspace writes
the image into the agdsp sysfs attribute in chunks between stop and start. A read-only scan of the F50's super
partition for an agdsp-shaped filename turns up slog config and dump-region names only.
The encouraging part is the memory map. The F50 reserves up to ae8fffff and then nothing until b0000000, about
23 MiB free, and the two ranges another UMS9620 device uses for audio - 0xaf700000 3 MiB and 0xafa00000 6 MiB -
both sit in that hole, the second ending exactly where logobuffer starts. That reads as the right addresses for
the SoC family rather than a guess.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
kernel/build-audio.sh produces the drivers behind real call audio from the realme unisoc-5.4 tree - the DSP
loader sprd_audcp_boot, agdsp_access, audio_sipc, audio_mem, the VBC v4 voice DAI, the UMP9620 codec, the PCM
platform and the machine card - and all 23 insmod cleanly on the device. The kernel config needed nothing:
CONFIG_SND_SOC, SND_SOC_COMPRESS and SND_SOC_TOPOLOGY are already built in, which is why soc-audio was sitting
there as a registered platform driver with nothing to do.
Three things about the build are worth the comments they got. Order matters and one pass does not suffice, so
it builds repeatedly and hands every Module.symvers produced so far to the next attempt. A failed attempt must
be cleaned before retrying or the leftover objects link twice and the error is "duplicate symbol:
__this_module", which points nowhere. And the UMP9620 codec only compiles with
BSP_KERNEL_DEFCONFIG=sprd_qogirn6pro_defconfig, because its Kbuild hides the codec define behind that and the
failure without it is an implicit declaration of TO_STRING hundreds of lines away.
The device tree turns out not to be the obstacle. sound@0 is okay and fully described, audiocp_boot has its
whole register set, and the machine driver binds it as vbc-rxpx-codec-sc27xx - the same binding the community
Android modules use. What stops it is the DSP: the card defers for ever because the DAI link cannot be parsed
until the audio SIPC channel exists, and that channel says ENODEV because nothing has started the DSP. This
board reserves no memory for it and carries no AGDSP image.
That leaves two concrete tasks rather than a port: reserve the memory, and supply the image.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
sms list / read / send / delete / watch, straight from the modem through mu300-atd. Text mode was the obvious
route and it does not work here: whenever the sender is a name rather than a number - most of what a SIM in a
router receives - this modem returns "144414+4140224P444" where the PDU plainly says type-of-address 0xD0 and
the septets spell ADANA BLD. IRA, GSM and HEX charsets all return the same broken string. Text mode also cannot
say that three stored messages are one long one.
The codec is awk, because busybox awk is the only interpreter the device has. It has the bitwise functions and
printf "%c" writes a raw byte under 256, so UTF-8 comes out a byte at a time, and the same file runs under gawk
and mawk for the Ubuntu image.
Turkish needed one more thing. It arrives as ordinary GSM 7-bit with a header - information element 0x25,
national language locking shift, value 0x01 - saying to read it against a different table. Without that the
text has the right shape and the wrong letters: hastası becomes hastasì, bağışta becomes baøìæta. Eight
positions move and they are exactly the Turkish ones. The header is walked element by element, since the
concatenation element is not always first and the language element never is.
Verified on the device against the four messages already on the SIM - a three-part message reassembled with
its accents intact - and by sending to the SIM's own number: "MU300 Linux test: Türkçe karakterler ığşçöü
ÇĞİÖŞÜ" went out, came back through the network and decoded unchanged. Sending picks GSM 7-bit while the text
fits it and UCS-2 otherwise.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
FINDINGS 20b recommended a wrapper on /sbin/reboot to find out who was rebooting the device. It does not work,
and it takes the device's ability to reboot with it: reboot hands the request to procd, procd runs /sbin/reboot
itself on the way down, that is the wrapper again, and it execs the applet that tells procd. Round it goes.
Nothing reboots, the command returns, and the machine keeps running.
The only trace is an audit entry whose caller is "pid=1 /sbin/procd", which is what the wrapper writes when
procd, not a person, invoked it. That cost time twice: once wondering why the device would not reboot on
command, and once reading two such entries from an earlier session as evidence that somebody had deliberately
rebooted it.
A wrapper that must exist has to call reboot(2) directly - busybox reboot -f - instead of the applet that talks
to init. The kprobe on __arm64_sys_reboot in the same section has none of this problem and answers the same
question.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Everything through the VPN failed while the VPN itself looked healthy: it reached its server, resolved names
through the tunnel, and sbtun counted the packets going in. Applications got "Connection refused" from nc and
"Failed to send request: Operation not permitted" from uclient-fetch, and sing-box logged exactly one line per
connection - "router: pre-match[0] => sniff" - and nothing after it. No outbound was ever selected.
It is the tun inbound's default system stack, which this 5.4 vendor kernel cannot support, and it says so at
startup in a warning that reads as cosmetic:
inbound/tun[tun-in]: enable offload: set udp offload: TUNSETOFFLOAD: invalid argument
"stack":"gvisor" brings its own TCP/IP and asks the kernel for none of it. With that one field, and the kill
switch active throughout, apk update goes from "8 unavailable, 145 distinct packages" to "OK: 11168 distinct
packages available", and https downloads complete.
DNS worked the whole time, which is what kept this looking like routing or firewall trouble: it is hijacked and
answered inside sing-box instead of being carried as a connection. A tunnel that resolves names but carries
nothing points at the stack - the routing rules and every nftables chain were searched first, and not one rule
had a counter that moved.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Measured on the device, one boot after the reordering. sipa_eth0 receives for the first time, the IPA receive
interrupt fires, DNS resolves through the carrier's own resolvers and a TCP handshake to 1.1.1.1:443 completes.
before after
rx_packets 0, always climbs with every request
irq 64 multi-sipa-0 0 67 and rising
PROD_CP released granted, ref 1
nic rc / nrt 0 / 1 4 / 0
channel 5-120 no trace send open msg 50.9s, receive open msg + success 60.8s
sipa_dele silent type=5 flag=1 -> CONS_WWAN_DL 0->2 -> type=6 flag=1, cycling
The modem answers the channel open as soon as it is up, and 60.8 s is exactly when modem_control has the CP
talking - smsg_ch_open(dst, chan, -1) waits that out quite happily. So the early load did not fail by being
early in itself; it failed because the CP was reset underneath it afterwards, which is the path where
smsg_recv errors out and conn_thread exits for good.
Two things that are not this bug and cost hours looking like it, both now written down and one now fixed:
A stopped VPN left its policy routing behind. sing-box installs prefs 9000-9010 and table 2022 itself through
auto_route and can only remove them when it exits cleanly, so a kill or a crash leaves every packet directed
into a tunnel with nothing at the other end. The whole system then answers "Operation not permitted" and reads
exactly like a dead modem - the data path was fine and the tests were being answered by a routing rule.
"mu300-vpn off" now clears that too, and only when nothing is running, so it can never take the rules away
from a live tunnel.
And a resolv.conf left behind by Docker: images built before the build fix carry the container's
nameserver 192.168.65.7 as a regular file instead of the symlink to /tmp/resolv.conf, so every name lookup
fails while addresses work.
What remains is not ours. With the tunnel down, DNS and 1.1.1.1:443 are reachable over the bearer and other
destinations time out, which is the carrier restricting where this SIM may go.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
sipa_dele's conn_thread opens SIPC channel 120 as its first act, with smsg_ch_open(dst, chan, -1), and that is
the only attempt it ever makes. With the modem not up it either waits for ever for an OPEN that never comes,
or smsg_recv errors out, smsg_ch_open frees the channel, and the thread logs "sipa_delegator failed to open
dst 5 channel 120" and returns. The SMSG_TYPE_OPEN handling further down - which does survive a modem restart -
only runs after that first open has succeeded. And there is no retry: sipa_dele is [permanent], so it cannot be
removed and inserted again.
Our boot order made that the likely outcome. The initramfs loaded sipa-dele.ko with the rest of the modem stack
at about twenty seconds, while modem_control does not have the CP talking until about sixty - on this device
"sprd-sbuf: channel 5-*" and "sbuf ready for pmic wdt init" both land at 60.8 s. Android loads it the other way
round, and Android is the one whose modem asks permission to send downlink.
sipa-dele-start waits for either of those lines and then inserts the module, in the background so that Wi-Fi,
the GPU and the sound card do not wait a minute for the modem, and it reports straight away whether
"channel 5-120 send open msg" reached the log. The two module-order lists no longer carry the delegate.
This is reasoned from the source and our own timestamps, not yet confirmed on the device - one boot with a
rebuilt image and "dmesg | grep -E '5-120|sipa_dele'" settles it. Nothing regresses if it is wrong: sipa_core
creates every consumer resource itself and the delegator only adds PROD_CP and the CONS_WWAN_UL -> PROD_CP
edge, so sipa_eth0 opens exactly as before. It does need a rebuilt boot image to do anything at all, since an
image that still loads the delegate early leaves sipa-dele-start with nothing to do.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
It needs the device booted into stock Android with the SIM passing data, which is exactly the state this port
replaces, so every comparison against it would otherwise mean going back and forth. Collected with debugfs
mounted by hand (Android does not mount it) and stored whole rather than summarised: the parts that mattered
today were not the ones expected, and the next question will not be this one.
docs/FINDINGS.md 13f reads it; mu300-ipa-dump produces the other half.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Taken from stock Android with data flowing, this is what the downlink actually is: a conversation on SIPC
channel 120 (SMSG_CH_COMM_SIPA, dst 5 PSCP), repeating every few seconds.
sipa_dele: smsg_recv, dst=5, chan=120, type=5, flag=0x1 the modem asks
sipa_rm: SIPA_RM_RES_CONS_WWAN_DL state changed 0->2 the AP grants
sipa_dele: smsg_send, dst=5 chan=120 type=6 flag=1 and acks
Packets follow, and three seconds later the modem releases it again. Two things fall out of that. CONS_WWAN_DL
is not "released on a working system", which is what a single sample of rm_res suggested - it cycles. And the
modem sends nothing until the AP answers, which is a complete explanation of our symptom on its own: never
asked, never sends, so sipa_receiver_notify_cb is never called and rx_packets stays at zero while the call,
the address and the routes all look right.
Both halves are pr_info, so the check is one command, and silence is the interesting answer. conn_thread calls
smsg_ch_open(dst, chan, -1) and that waits for ever by design, so a modem that never opens channel 120 leaves
the kthread sitting there saying nothing at all. mu300-ipa-dump now prints this alongside the rest.
Also recorded from the same reference, to stop them being mistaken for faults: 256 receive buffers of 64 KiB
posted on channel 0, alloc_skb_cnt 47, irq 64 (sprd,multi-sipa-0) carrying every interrupt while 65 and 72
stay at zero, and "dts parsing failed" / "get resource failed for remote-base!" printed by Android too - the
delegate probe logs them and carries on.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Measured on stock Android with data flowing: ping -I sipa_eth0 8.8.8.8 reports 100% loss, while a TCP connect
on the same interface completes and rx_packets climbs. The -I form binds to the device and matches Android's
"oif sipa_eth0" rule for uid 0, so that is the cellular path and not a VPN swallowing the echo - ICMP simply
does not survive this bearer.
That matters because it is how this investigation has been measuring. mu300-ipa-dump was written an hour ago
with ping as its traffic generator, which on this network reads "nothing arrives" on a link that is fine.
The counter is the answer, not the connect. A successful connect may well be carried by a VPN - on Android it
is, ip route get 1.1.1.1 goes to tun0 - but the VPN's own packets still leave and arrive over sipa_eth0, the
only WAN this device has, and rx_packets moved from 470 to 479 while that connect was made. Ours has never
moved at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Mobile data is the thing the device is for, and the downlink has never worked on Linux: the call completes,
the address is configured, and sipa_eth0 receives nothing. Until now the Linux dumps had nothing to be read
against, and the obvious reading of them was wrong - an idle IPA reports "suspend_stage = 0x3f rc = 0" and
"open = 0", and none of that is a fault. The driver sets the full suspend mask in probe and wakes the hardware
lazily on the first transmit, and NIC_OPEN is zero because that enum starts at zero.
Taken from stock Android on this device with data flowing (sipa_eth0 rx=419 tx=1440), the configuration turns
out to be identical to ours: same src_id 6, same netid 0, same src_mask 0x7070, same is_bypass = 0x1, and
SIPA_RM_RES_CONS_WWAN_DL released even while downlink is arriving. So the netid mapping is not it, bypass mode
is not it, and the DL consumer is not it either. What differs is only history - rc = 80 against our rc = 0 -
which means the comparison that matters has still not been made: ours has to be dumped while packets are being
pushed at the interface. mu300-ipa-dump does exactly that, in one command, and prints the fields to compare.
Two differences from that reference are cheap to copy and are now the default. Android asks for an "IP" context,
not "IPV4V6", and switches IPv6 off on the interface outright; ours asked for dual stack and carried a
link-local address into a bearer the carrier only gave us IPv4 on. MU300_PDP_TYPE=IPV4V6 restores both for a
carrier that needs them.
Also: mu300-at gets the same guard mobile-data got, since it is the more common way in. No command fifo is not
the same as no daemon, and opening the channel behind a running mu300-atd makes the second reader that breaks
the modem for everything.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Closing /dev/stty_nr1 while the modem is running leaves it silent for the rest of the boot. Measured on 5.4:
with AT+CGACT? answering normally, mu300-atd was killed and started again - one close, one open - and from then
on the channel took writes and returned nothing for forty minutes. Raw opens, opening nr0-nr5 together, draining
nr0 and restarting modem_control all failed to bring it back; modem_control re-attaches without reloading the
modem. Only a reboot does. The modem is alive throughout - nr0 keeps delivering +SIND and +ECIND, and debugfs
modem still reports run_state: 1.
That makes the daemon's old recovery rule - reopen after three unanswered commands - a way to trade a working
modem for a dead one. It now takes five unanswered commands, at most one reopen every five minutes, and only
when the modem has stopped talking on nr0 as well, which is the one signal that separates "restarted, this
descriptor is stale" from "alive, and closing it would be the end of it". nr0 is drained into a capped log under
/run/mu300-at/urc/ for that, the way Android's RIL holds all six channels open; it also keeps the registration
and PDP notices, which are announced there and nowhere else.
The second reader the lock did not catch: mobile-data's at() asks the daemon when /run/mu300-at/cmd exists and
opens the device itself when it does not, and "no fifo" is not "no daemon". Remove /run/mu300-at under a running
mu300-atd and every mobile-data call became a second reader on a channel that hands each line to one of them -
found on the device with mu300-atd and mobile-data watch both holding /dev/stty_nr1 while mu300-at reported the
daemon was not reading commands. It now refuses when /run/mu300-at/lock/pid names a live owner and takes that
same lock otherwise; tty_setup obeys the check too, since stty -F is an open and a close.
Also in FINDINGS: how to tell a userspace reboot from a power cut and how to find the caller (pstore says pid 1
for every reboot on OpenWrt, because busybox hands the request to procd), and how to read /sys/kernel/debug/sipa
without misreading suspend_stage = 0x3f rc = 0 (the probe default, resolved lazily by the first transmit) or
open = 0 (NIC_OPEN, since that enum starts at zero).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
**Audio.** The board has no speaker path, so there is no card at all - and
software that insists on an ALSA device (a SIP gateway running on the device,
for instance) cannot start. The stock config leaves CONFIG_SND_DRIVERS off,
which is what gates the generic cards, so the fragment turns it on and builds
snd-aloop and snd-dummy as modules. extra-modules loads snd-aloop when it is
present. On the device that gives card 0 "Loopback" with two PCM devices of
eight substreams each: write to hw:0,0 and the same audio comes back on hw:0,1,
which is what a call bridge needs. It carries no cellular voice by itself - the
AGDSP path in FINDINGS 24 is still the job for that.
**AT resync.** This modem answers AT+CGACT and AT+CGDATA with "^ORIG: <cid>,<n>"
first and OK or CONNECT ten to twenty seconds later. When a command times out,
that late answer arrives after we have stopped listening and the next command
reads it instead of its own - and from then on every reply is one behind, which
looks exactly like a dead channel. mu300-atd now drains for up to 25 s after a
timeout, so the stale answer is thrown away before anything new is asked.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Measured on the device: AT+CGDATA="M-ETHER",1 answers "^ORIG: <cid>,<n>" and
then CONNECT ten to twenty seconds later. We allowed eight, so the reply
arrived after we had stopped listening and the next command picked it up
instead of its own - which is what "the AT channel dies right after the data
attach" mostly was. It now gets 45 s and says so when CONNECT never comes.
FINDINGS 13f records the rest of the walk-through, because the data call itself
is fine and the packets still do not arrive: registered, context active,
CGCONTRDP hands back address, netmask and DNS, CGDATA answers CONNECT, the
interface is configured with exactly that address - and rx_packets stays at 0
on both kernels, while stock Android on the same SIM shows rx=104. Also noted
there: the radio is off (CFUN=0) until mobile-data turns it on, so any test
that stubs mobile-data out is testing a device with no radio.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Flashed the vendor 5.4 kernel back to slot b and ran the same measurement.
It fails identically - first AT reply at 60 s, silent 17 s later, sipa_eth0
with an address and rx_packets at 0 - where mainline gave 67 s and 22 s. Stock
Android on the same device, SIM and carrier is fine at the same moment:
sipa_eth0 rx=104, tx=223.
So the evening's assumption was wrong. This is not something the port broke;
it is something Android's modem userspace does that ours does not, on both
kernels. Killing our own services does not help either: with mu300-atd and
mobile-data stopped and a single shell holding the tty, the channel still went
quiet, just later (132 s).
FINDINGS 13b-2 now leads with that table and points at the concrete leads:
refnotify cannot open /dev/stime_ch (ENODEV) on either kernel, and the 5.4
module list loads sipa_usb, sprd_pamu3 and sfp_core, which the mainline build
does not have at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
The CP streams its debug log into a SIPC spool channel (slog_nr). Nothing on
this side ever opened it, so it sat full - 257 KB were waiting in it - which is
worth fixing whether or not it explains anything: mu300-modem-log now creates
the node the driver does not and keeps the ring empty.
It does not explain the mainline failure, and neither did the other five things
that looked like it. FINDINGS 13b-2 now records what was measured and ruled
out - the boot recorder, a cached alias of the modem's shared memory, the power
manager's NULL resource ops, the data attach, a second AT daemon, the log ring
and the mailbox queue - together with the shape of what is left: the CP stops
answering 24 to 60 s after the first successful command, its own log stops at
the same moment, and the AP's messages still go out.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
sprd_mbox_send_data() queues a message in a software fifo when the physical
send fails, and only the inbox interrupt - raised on a completed delivery or a
blocked channel - wakes the thread that drains it. check_mbox_chan_state() also
fails with -ETIMEDOUT when the remote core is merely slow to take the previous
message, and that raises nothing at all: the fifo stays non-empty, every later
message takes the "fifo is not empty, queue it" path, and the AP never sends to
the modem again.
Measured on the device: writing an AT command left the mailbox registers
untouched, mbox-deliver-th was asleep in sprd_mbox_deliver_thread, and the
inbox interrupt had fired zero times since boot. With queueing waking the
thread and the thread retrying what is still queued, the registers move again
on every command.
This is not the whole story - the modem still stops answering about ninety
seconds into a boot, and the outbox interrupt stays frozen while the AP's sends
go out - but the send path is no longer a one-way street.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
sipa-dele.ko was being built and never loaded: it is missing from the module
order, so soc:ipa-apb:sipa-dele never probed. The power domain said so on every
boot - "ums9620-ipa-sys-pd soc:aon:sipa-sys: sync_state() pending due to
soc:ipa-apb:sipa-dele" - and the accelerator's receive path never started:
sipa_eth0 took an address from the modem and rx_packets stayed at 0, with the
sipa interrupts at 0 since boot.
With it loaded the delegate probes, the resource graph is built (PROD_CP now
exists with its WWAN/WIFI consumers, visible in
/sys/kernel/debug/25220000.sipa/rm_res) and sprd,multi-sipa-0 takes its first
interrupts. Traffic still does not pass - the AT channel dies before a
connection can be held up long enough to test - but this is one cause removed.
Loading it late also fails: probed by hand at 146 s the dependency setup
returns -EINVAL, so it goes in the boot module order and, for boot images built
before this change, early in extra-modules.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
Two boots in a row died at ~29 s in sc2355_pcie_tx_cmd_pop_list, reached from
the PCIe MSI handler: the chip reported a finished command while hif->tx_mgmt
was still NULL, which is a fatal exception in interrupt context, so the kernel
stopped and LK went back to Android. The bus callbacks are registered across
tx_init()/tx_deinit(), so both PCIe pop callbacks now hand the buffers back and
return when there is no tx context.
The lock added in the previous commit was removed a second after it was taken:
ash and dash run an EXIT trap when a *subshell* exits, and mu300-atd runs one
per command, so the trap deleted the lock and let the next daemon in - exactly
what it was supposed to prevent. Clean up on INT/TERM only, and only if the pid
in the lock is still ours. Measured after the change: one holder of
/dev/stty_nr1 and an unchanged lock owner.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
The installer refused anything under 4 GiB of unpartitioned space with "this
device has a different partition layout", which is what a report from a
Windows user looked like. The number was a guess, and it is far more than the
systems need: installed they measure ~320 MiB (OpenWrt) and ~580 MiB (Ubuntu),
and an update keeps the previous one as <os>.old while the new one is unpacked.
Both installers now refuse only under 700 MiB, check the real requirement once
the systems have been chosen (800 MiB / 1.6 GiB / 2.4 GiB), say up front when
only one system fits, and print the eMMC size and the end of the last partition
so a device that still does not fit can be identified.
The obvious alternative, an image file inside userdata, was measured and cannot
work: metadata encryption (dm-default-key) covers the whole partition, so from
Linux it is ciphertext - no ext4 or f2fs magic, 4079 of the first 4096 bytes
non-zero, while the same dd on our own region returns 53ef/mu300root. The
spare-looking blackbox and fulldumpdb partitions hold firmware crash dumps.
Both are written up in FINDINGS 9b so the idea does not come back.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk
The modem comes up on 6.18: "Modem Alive", AT, SIM READY, radio on,
registration on 5G NSA (+CEREG: 2,1 / +COPS: 28602, AcT 13) and a data context
with an address on sipa_eth0.
What was wrong was one memory attribute. The regions the AP shares with the
modem are reserved inside System RAM, and the modem does not snoop the AP's
caches. The vendor 5.4 driver maps them with vm_map_ram(pages, count, -1,
pgprot_noncached(PAGE_KERNEL)); newer kernels dropped that prot argument, so the
port used memremap(MEMREMAP_WC | MEMREMAP_WB), which falls back to write-back
for a linear-mapped region. Everything the AP wrote then stayed invisible to the
modem: the CP asked for its NV data, the NV server logged "fail SIZE" on the
second packet, wrote three chunks and stalled, and modem_control gave up with
"wait modem alive timeout" and g_modem_state = 8.
ioremap_wc() is not the fix either - the kernel refuses ioremap for System RAM
(WARNING at arch/arm64/mm/ioremap.c:27) and falls back to the cached mapping,
which is what made the first attempt look like a no-op. vmap() still takes a
pgprot, so smem.c builds the page array like the vendor driver and maps
non-cached again, keeping memremap() for regions with no struct page and for
the ones the vendor code wants cached. Measured: fail SIZE 1 -> 0, NV transfer
runs to completion, Modem Alive arrives.
The AT daemon also stops using a fifo for answers. A fifo needs both ends at
once, so a client that gave up left the daemon or a leftover writer blocked for
ever and every later command timed out. The answer now goes into a file the
client names, written complete and moved into place. Measured on 6.18: 15
commands in a row, no failures, no reopen needed, and "mobile-data up" brings
sipa_eth0 up with an address.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk