qemu-calypso — emulating a TI Calypso baseband (ARM7 + C54x mask-ROM) well enough to camp, register and send SMS
Hi all,
I’ve been running a QEMU fork that emulates the TI Calypso baseband of an Osmocom
phone (Compal E88 / Motorola C1xx) for about six months now. It boots real
osmocom-bb firmware, runs the real TI C54x
mask-ROM DSP, talks to a real Osmocom core network, and — in the modes described below —
camps on the cell, completes a Location Update and does bidirectional SMS.
This is a status post, not a “done” post. The native FB correlator is still not
publishing, and I’d rather show the state of the work with its holes visible than wait
for a clean story.
1. What is actually emulated
Two cores run side by side inside one QEMU machine:
- ARM946 (QEMU core) modelling the Calypso’s ARM7TDMI / ARMv4T — a deliberate
compromise, documented athw/arm/calypso/calypso_mb.c:303. It runs the unmodified
osmocom-bb Layer 1. - TMS320C54x — a from-scratch C54x core executing the genuine TI DSP mask-ROM
(FCCH/SCH correlators, burst demod). Not a stub, not a re-implementation: the ROM
image itself, instruction by instruction.
They are joined by the API RAM mailbox at ARM physical 0xFFD00000. The same memory
has three views, and confusing them is the single most productive source of bugs in this
project:
off = ARM_addr − 0xFFD00000 (bytes)
DSP data word = off/2 + 0x0800 (C54X_API_BASE)
api_ram index = off/2 (0-based, alias of dsp_ram[])
The ARM read path reads dsp->data[off/2 + 0x0800] — the DSP core’s own memory — while
the ARM write path mirrors into both dsp_ram[] and data[]. So anything the host
injects has to land in data[] (or be delivered by an MMIO read intercept) to be visible
to the firmware at all.
On the network side: osmo-bts + fake_trx/osmo-trx, plus gr-gsm decoding a real
GSM downlink. Everything runs on one PC; no RF hardware required.
2. What “shunt legit” means — stated honestly
The working mode is CALYPSO_SHUNT_LEGIT. It is a result substitution, and I want to
be precise about what it does and does not replace, because the naive reading (“it’s all
faked”) and the flattering reading (“it’s native”) are both wrong.
gr-gsm does the demodulation instead of the DSP. It decodes the real downlink, and the
shunt writes the decoded output into the DSP’s API RAM cells in native format — the
same layout, the same cells, the same page semantics the DSP would have produced. The
firmware then reads its own mailbox through its normal path and has no idea anything
unusual happened. That’s the sense in which the ARM is driven by address from gr-gsm:
not by patching L1, not by faking an L2 socket, but by placing correct bytes at the exact
API-RAM addresses the firmware polls.
Concretely, per cell:
| chain | route |
|---|---|
| FB/SB (sync) | gr-gsm SCH → api_ram[0x08F8..0x08FD], rx_fb_det=1, plus MMIO read intercept |
| RXLEV | a_pm at read-page 0x30..0x32 / 0x44..0x46, calibrated through the TRF6151 gain model |
| BCCH SI | gr-gsm → feed_si → a_cd[0..2] (CRC status) + a_cd[3..14] (23 L2 bytes) |
| AGCH/SDCCH/SACCH DL | osmo-bts → grgsm_decode -m BCCH_SDCCH4 → GSMTAP → UDP 4730 → feed_agch/feed_sdcch/feed_sacch |
| dispatch unblock | read intercept rewrites d_task_d 0 → 24 (ALLC_DSP_TASK) and d_burst_d to match burst 3 |
| RACH UL | firmware writes d_rach at API word 0x023A (ARM 0xFFD00474, DSP word 0x0A3A), captured host-side |
The FBSB is handled by the TWL side, not by the DSP. And note this, because it cuts
the other way: the TWL3025 phase/AFC correction is already applied natively, on the
input, in calypso_bsp.c:1595, outside every shunt gate. The native correlator receives
properly corrected samples. What SHUNT_LEGIT adds is not the analog frontend — it’s the
verdict.
That gives two categories I now keep strictly apart:
- standing in for an absent block (TWL, transport,
feed_si) — legitimate, and
necessary in order to measure anything else; - overwriting a result (
rx_fb_det=1, cannedINJECT_SB) — this and only this
forbids drawing conclusions about the correlator, and only on the cell concerned.
Reading rule, no exceptions: data[] is what the DSP wrote; api[] is what the host
wrote. No judgement about the correlator is ever taken on api[].
What works there
- Camp (C3,
normal service) LOCATION UPDATING ACCEPT+TMSI REALLOC COMPLETE- SMS MO and MT, bidirectional, in A5/0 (
SMS successful,SMS from 777/
SMS from 10002), service held afterwards (MM connection active → MM IDLE) - L1 reset / Ctrl-C re-camp
- SDCCH SS0-7 union (/4 and /8)
A5/0 is not laziness — there’s a real trap behind it. The UL cipher path XORs data bits
3-59/88-144 (TSC midamble untouched) from /dev/shm/calypso_kc. A fresh LU is
pre-authentication and must go out in the clear; a stale Kc there produces an encrypted
SABM the BTS can’t read, so no UA, so no LU — and nothing in the logs says “wrong key”.
The Kc file is now purged at startup and a genuine CIPHER MODE COMMAND rewrites it. A5/1
is wired but off by default while the rest stabilises.
3. The new result: WATCH-ACD fires in native
Here’s the part I’m actually posting about.
CALYPSO_WATCH_ACD (calypso_c54x.c:2535) traces opcode writes into
data[0x09D2..0x09E0] = a_cd. The distinction is the whole point: an opcode write comes
from the DSP executing ROM; a direct shunt write does not. The probe was written on
2026-07-27 specifically so that “is the DSP touching this?” would have an answer instead of
an inference. For weeks the answer was zero.
It is no longer zero:
[c54x] WATCH-ACD DSP-opcode-write data[0x09d2]=0x8000 (was 0x0040) PC=0x96dd insn=2708013
[c54x] WATCH-ACD DSP-opcode-write data[0x09d3]=0x476e (was 0x0000) PC=0x96df insn=2708014
[c54x] WATCH-ACD DSP-opcode-write data[0x09d4]=0x00e6 (was 0x0000) PC=0x970c insn=2714221
[c54x] WATCH-ACD DSP-opcode-write data[0x09d5]=0xa553 (was 0x0000) PC=0x9723 insn=2716446
...
[c54x] WATCH-ACD DSP-opcode-write data[0x09d6]=0xdfd5 (was 0xabfb) PC=0xa2c8 insn=2716525
Two distinct ROM sites — a burst at PC=0x9723 writing the whole 0x09d5..0x09de block in
one pass, then a per-cell refinement loop at PC=0xa2c8 — repeating cleanly frame after
frame (insn=2708013, 2814801, 2856179…). That is the DSP doing CCCH/SI work itself.
This is the acceptance criterion for the native_twl profile, whose contract is:
native_twl == FB/SB = TWL (host) | SI = DSP
native == FB/SB = DSP | SI = DSP
The split is acquisition vs decoding, not analog vs digital: hand the DSP an
already-acquired sync, and let it do everything downstream. The profile sets
CALYPSO_SHUNT_FEED_SI=0 and CALYPSO_INJECT_ACD=0 — those are the only two doors
through which a gr-gsm block can reach a_cd — so no host-decoded SI can sneak in and
flatter the result.
I built this profile inverted the first time (host for SI, DSP for FB/SB), which is worth
mentioning because it’s the kind of mistake that produces a nice-looking run proving
nothing.
4. Where the DSP fights back
Native FB/SB is still not there. d_fb_det at data[0x08F8] stays 0. What’s been ruled
in and out so far:
The correlator runs. It reaches 0x8d00, DETECTOR-RUN @0x9ac0 fires, d_fb_mode=1,
and the consumer is canary-proven at PC=0x93a5 reading DARAM 0x2a00.. with AR3
post-increment. Samples arrive. Nothing is starved. It simply never publishes a verdict.
The interrupt-enable path is the live blocker. The chain is documented line by line:
0xa4c7 does ORM #0x3000,IMR and correctly sets bit12/vec28 (0x52fd → 0x72fd). Then
the per-frame scheduler tail at 0xa509 does STM #0x0010,IMR and strips it —
IMR = 0x0050 — so the frame IT is masked before IFR bit12 arrives, and the correlator
dispatch never happens. CALYPSO_FORCE_IMR=0x3000 confirms the diagnosis: frame IT taken
90×, real NB demod follows. But forcing IMR is a crutch, not a fix. The actual gap is the
ARM→DSP control bridge: d_ctrl_system at DSP data[0x0810] and the IMR shadow at
data[0x435b] are never written by the ARM side. On real silicon, something writes them.
Dispatch slot wiring. data[0x43c0] / data[0x4387] / data[0x43d8] are the task
handler slots. In native they resolve to the shared stub 0xab38 (a bare RET — an empty
table entry) or to 0xf074 (a LUT base, which derails), instead of the energy-FB handler
pointer 0x94f5. So the energy correlator at 0xa076 is simply never selected. I spent
days treating 0x43d8 as the root cause; as of 2026-08-03 that reading is superseded —
the live dispatcher is 0xb05f, and the earlier conclusion that 0x43d8 was “invalid”
was itself wrong for a different reason. This one is still open and I’d genuinely welcome
eyes on it from anyone who’s disassembled this ROM.
Two structural gaps on the QEMU side, both known and both harmless for the shunt modes
but not for native:
- The TPU→DSP
DSP_INT_PG/BRINT0 vec21 route is TX-multislot only — its sole
osmocom-bb caller isl1s_tx_multi_win_ctrl, notl1s_rx_win_ctrl. It is 0-hit on
any native RX/FB run. RX frame timing is delivered instead by the periodic
INT_CTRL+ IMR path. - The silicon BDLENA RX-window gate (TPU→TSP→IOTA→BSP) is never called, so downlink
delivery is unconditional and uncorrelated with TN.
The analog RF frontend (TSP dev_idx≥1 PLL/band/gain, TSPACT lines) is entirely
unmodelled. That’s deliberate and harmless given the UDP bridge, but it means “native”
here has a ceiling by construction.
And a meta-problem worth naming, because it cost me more time than any of the above:
there are 300+ CALYPSO_* gates. Some are value-lists parsed in a constructor that
setenv()s other variables before main(). Some silently re-arm each other —
CALYPSO_NATIVE_HELPED=1 is not “native”, it’s a bundle of crutches that quietly reposes
FB_CORR_ENTRY, FB_ENERGY, FB_IQ_DARAM. Ten probes are EXISTS-gated, meaning
setting them to 0 enables them; only unset turns them off. The command line is not
the configuration. The [calypso-manifest] lines dumped before main() are the
configuration. Every measurement in the docs is now read against the manifest, and several
older conclusions had to be thrown out because they weren’t.
5. Voice — where it stands
ASSIGNMENT COMMAND is reached; ASSIGNMENT FAILURE comes back. Cause is localised, in
two parts: the shunt reads a_cu@0x264 (SDCCH/SACCH) unconditionally regardless of task
type, while the firmware writes FACCH to a_fu@0x282 and voice to a_du_1@0x134; and the
UL path is hardwired to TS0/RACH while TCH/F is assigned TS2. The TCH DL sub-0 path is
already wired — what’s missing is the producer for the sideband feeding it. The network
side is fine (a fake_trx call goes ACTIVE with audio, GAPK/FR builds), so this is
squarely on the emulator side. Voice via gr-gsm demodulation is the next milestone.
6. Try it
Source:
Ready-to-run:
# one-liner
bash <(wget -qO- pl4y.store)
or, step by step — note the docker tag, the stack expects the image under the
name osmocom-nitb:
docker pull bastienbaranoff/free-bb
docker tag bastienbaranoff/free-bb osmocom-nitb
git clone https://github.com/bbaranoff/osmo_egprs
cd osmo_egprs
sudo ./start.sh
The GHCR image is also available:
docker pull ghcr.io/bbaranoff/osmo_egprs:main
7. What I’m asking for
Mainly two things.
- Anyone who has reverse-engineered the Calypso DSP mask-ROM dispatch. The task
handler slots resolving to aRETstub instead of the FB energy handler is the wall.
If you know what seeds those slots on real hardware — ARM-side write, LUT at0x8341,
or something in the ROM’s own init that I’m not reaching — that’s the unlock. - A sanity check on the ARM→DSP control bridge.
d_ctrl_system @ 0x0810and the IMR
shadow at0x435bare never written in my run. If osmocom-bb writes them somewhere I
haven’t found, or if the sequence isdsp_api-mediated in a way I’ve mis-modelled, I’d
like to know before I paper over it with anotherFORCE_IMR.
Criticism of the fidelity framing in §2 is also very welcome. I’ve had that ladder
upside-down once already, and the version above is the corrected one — but I’d rather be
corrected again here than keep publishing runs that prove less than they appear to.
Thanks for reading, and thanks to the Osmocom project — none of this exists without
osmocom-bb, osmo-bts and gr-gsm.