mirror of
https://github.com/D-Modem/courier-emu.git
synced 2026-11-28 20:38:07 -08:00
AT&N1&T1 on 302 crashed with "C51 ROM loader did not acknowledge strobe 1": _commit_rom_group wrote @56 and stepped 4096 instructions waiting for the acknowledgement, and nothing answered. Port 0x18 is not the loader's alone. A supervisor routine at 0x95a54-0x95a6c walks a single bit along it and mirrors it to 0x1a - ..0x20, 0, 1, 0, 2, 0, 4, 8, 0x10, 0x20.. - so three of its six values collide with the transfer strobes. Every collision was being taken for a reload request. The recovered mask ROM says exactly when the C51 is listening. Its download loop is 0638-0652: bit 2/@56 for the finish strobe, bit 0/@56 then rpt #3 / bldp *+ / lacl #01 / samm @56 for group 1, bit 1/@56 and the same for group 2, then bd 0638. Outside that span - resident code at 810a, a mask-ROM vector at 0008 after a restart, the 0653 exit that branches into the downloaded program - nothing polls @56 and no acknowledgement can come. So arm a strobe only when the DSP pc is inside that loop, or when the loader has not been started at all, which is the case the first commit synchronizes. Real downloads acknowledge from 0642 and 064c, both inside it. The crashing run now completes and reports CONNECT. Checked inert elsewhere: a linked 302 pair with the DSP on both sides produces a byte-identical report with the gate forced open, and the standalone AT&T1 run makes the same 13874 commit decisions as before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
86 lines
2.6 KiB
Python
86 lines
2.6 KiB
Python
from courier_emu.bridge import CourierDspBridge
|
|
|
|
|
|
class DataCore:
|
|
def __init__(self, flags: int = 0x4042):
|
|
self.flags = flags
|
|
self.writes: list[tuple[int, int]] = []
|
|
|
|
def data(self, address: int) -> int:
|
|
assert address == 0x006F
|
|
return self.flags
|
|
|
|
def set_data(self, address: int, value: int) -> None:
|
|
self.writes.append((address, value))
|
|
self.flags = value
|
|
|
|
|
|
def bridge_for_assist(*, enabled: bool = True, t1: bool = True):
|
|
bridge = CourierDspBridge.__new__(CourierDspBridge)
|
|
bridge.core = DataCore()
|
|
bridge.rx_acquisition_assist = enabled
|
|
bridge._t1_requested = t1
|
|
bridge._rx_acquisition_assisted = False
|
|
return bridge
|
|
|
|
|
|
def proven_loop() -> dict[str, int]:
|
|
return {
|
|
"line_tx_nonzero": 64,
|
|
"hybrid_frames": 64,
|
|
"drr_reads": 1_000,
|
|
"codec_rx_peak": 0x1000,
|
|
}
|
|
|
|
|
|
def test_t1_acquisition_assist_opens_decision_gate_once():
|
|
bridge = bridge_for_assist()
|
|
|
|
bridge._maybe_assist_t1_acquisition(proven_loop())
|
|
bridge._maybe_assist_t1_acquisition(proven_loop())
|
|
|
|
assert bridge.core.writes == [(0x006F, 0x404A)]
|
|
assert bridge._rx_acquisition_assisted is True
|
|
|
|
|
|
def test_t1_acquisition_assist_requires_opt_in_and_proven_return():
|
|
disabled = bridge_for_assist(enabled=False)
|
|
disabled._maybe_assist_t1_acquisition(proven_loop())
|
|
assert disabled.core.writes == []
|
|
|
|
weak = bridge_for_assist()
|
|
serial = proven_loop()
|
|
serial["codec_rx_peak"] = 0x0FFF
|
|
weak._maybe_assist_t1_acquisition(serial)
|
|
assert weak.core.writes == []
|
|
|
|
|
|
class LoopCore:
|
|
def __init__(self, pc: int):
|
|
self.pc = pc
|
|
|
|
def state(self) -> dict[str, int]:
|
|
return {"pc": self.pc}
|
|
|
|
|
|
def bridge_at(pc: int, started: bool = True):
|
|
bridge = CourierDspBridge.__new__(CourierDspBridge)
|
|
bridge.core = LoopCore(pc)
|
|
bridge._loader_started = started
|
|
return bridge
|
|
|
|
|
|
def test_rom_loader_armed_only_inside_the_mask_rom_download_loop():
|
|
# 0x0642 and 0x064c are where real downloads acknowledge from.
|
|
assert bridge_at(0x0642)._rom_loader_armed()
|
|
assert bridge_at(0x064C)._rom_loader_armed()
|
|
assert bridge_at(0x0638)._rom_loader_armed()
|
|
# The supervisor's bit-walk on port 0x18 lands on 1, 2 and 4 while the
|
|
# C51 is in resident code, or restarted at a mask-ROM vector.
|
|
assert not bridge_at(0x810A)._rom_loader_armed()
|
|
assert not bridge_at(0x0008)._rom_loader_armed()
|
|
# The exit path has left the poll behind.
|
|
assert not bridge_at(0x0653)._rom_loader_armed()
|
|
# Nothing has synchronized the loader yet: the first commit does.
|
|
assert bridge_at(0x0008, started=False)._rom_loader_armed()
|