Firmware: RIOv4_2_patched_31250.bin — wedge fix + SCI retuned to 31250 baud

make_patch.py gains --baud31250: one byte beyond the wedge patch — the SCI
init operand at $D62B ($30 -> $02). BAUD $30 = /13 prescale, /1 divider
(2MHz E / 208 = 9615); $02 = /1, /4 -> 31250 exactly, 3.3x faster. The
init write also confirms the 8MHz crystal, which is why 19200/38400 are
unreachable and why 62500/125k are left alone pending an ISR cycle count.

- 24 bytes changed vs original (sha256 9f866cf3...); re-disassembly diff
  vs the classic patched image shows exactly the one operand line, and
  the classic build still reproduces 3fc8170c... (script regression-safe).
- PC side: SerialPortTransport takes an optional baudRate (default 9600,
  runtime untouched); RioSerialMonitor + --mash accept --baud 31250.
- Caveats documented in README/ANALYSIS: non-standard rate (FTDI-class
  adapters only, no 16550s); native games still speak 9600 so this chip
  is bench/RIOJoy-only; validate the wedge patch at 9600 first.

275 tests green; mash --selftest regression unchanged (FAIL/exit-1).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-17 20:25:00 -05:00
co-authored by Claude Fable 5
parent fcf26cfd15
commit a8ec285b8e
8 changed files with 13258 additions and 14 deletions
+5 -2
View File
@@ -51,6 +51,7 @@ internal static class MashTest
bool lampEcho = true;
double wedgeSec = 2.0;
bool selftest = false;
int baud = 9600;
var positional = new List<string>();
for (int i = 0; i < args.Length; i++)
@@ -63,6 +64,8 @@ internal static class MashTest
case "--label" when i + 1 < args.Length: label = args[++i]; break;
case "--wedge" when i + 1 < args.Length && double.TryParse(args[i + 1], out double w):
wedgeSec = w; i++; break;
case "--baud" when i + 1 < args.Length && int.TryParse(args[i + 1], out int b):
baud = b; i++; break;
default: positional.Add(args[i]); break;
}
}
@@ -96,7 +99,7 @@ internal static class MashTest
lock (gate) { Console.WriteLine(msg); logFile.WriteLine(msg); }
}
Raw($"== RIO mash test :: {port} @ 9600 8N1, {seconds}s, chip label '{label}' ==");
Raw($"== RIO mash test :: {port} @ {baud} 8N1, {seconds}s, chip label '{label}' ==");
Raw($" lamp echo {(lampEcho ? "ON (drives reply/lamp collisions)" : "OFF")}, " +
$"wedge threshold {wedgeSec:F1}s, app auto-recovery DISABLED");
Raw($" log: {Path.GetFullPath(logPath)}");
@@ -104,7 +107,7 @@ internal static class MashTest
IRioTransport transport;
try
{
transport = selftest ? new SelftestTransport() : new SerialPortTransport(port);
transport = selftest ? new SelftestTransport() : new SerialPortTransport(port, baud);
}
catch (Exception ex)
{
+14 -6
View File
@@ -8,17 +8,25 @@ using RioJoy.Core.Serial;
// log every event (buttons, keypad, axis, version/check, control bytes, framing).
// It flashes all lamps once to prove the PC -> RIO output path, then echoes a lamp
// on each button press so a physical press lights up.
// dotnet run --project tools/RioSerialMonitor -- [port] [seconds]
// dotnet run --project tools/RioSerialMonitor -- [port] [seconds] [--baud rate]
// Firmware wedge-patch validation (RIO_TAP mash test, see MashTest.cs):
// dotnet run --project tools/RioSerialMonitor -- --mash [port] [seconds]
// [--label baseline|patched] [--no-lamps] [--wedge seconds]
// [--label baseline|patched] [--no-lamps] [--wedge seconds] [--baud rate]
// --baud: 31250 for the retuned firmware variant (rio-firmware --baud31250).
// Exit: 0 = ran, 2 = could not open the port (mash: 1 = wedge detected).
if (args.Contains("--mash"))
return await RioSerialMonitor.MashTest.RunAsync(args);
string port = args.Length > 0 ? args[0] : "COM1";
int seconds = args.Length > 1 && int.TryParse(args[1], out int s) ? s : 30;
int baud = 9600;
var positional = new List<string>();
for (int i = 0; i < args.Length; i++)
{
if (args[i] == "--baud" && i + 1 < args.Length && int.TryParse(args[i + 1], out int b)) { baud = b; i++; }
else positional.Add(args[i]);
}
string port = positional.Count > 0 ? positional[0] : "COM1";
int seconds = positional.Count > 1 && int.TryParse(positional[1], out int s) ? s : 30;
Dictionary<int, string> groupOf = CockpitPanel.Buttons().ToDictionary(b => b.Address, b => b.Group.Title);
string Name(int addr) => groupOf.TryGetValue(addr, out string? g) ? $"0x{addr:X2} ({g})" : $"0x{addr:X2}";
@@ -30,12 +38,12 @@ void Log(string msg)
lock (gate) Console.WriteLine($"[{sw.Elapsed.TotalSeconds,6:F2}s] {msg}");
}
Console.WriteLine($"== RIO serial monitor :: {port} @ 9600 8N1 for {seconds}s ==");
Console.WriteLine($"== RIO serial monitor :: {port} @ {baud} 8N1 for {seconds}s ==");
SerialPortTransport transport;
try
{
transport = new SerialPortTransport(port);
transport = new SerialPortTransport(port, baud);
}
catch (Exception ex)
{