Skip to content

process-node 0.3.1: RL78 boot ROM emulator (Protocol A) for testing RL78 programming - #12

Merged
wardviaene merged 2 commits into
mainfrom
process-node-rl78-emu
Nov 18, 2026
Merged

wardviaene merged 2 commits into
mainfrom
process-node-rl78-emu

Conversation

@wardviaene

Copy link
Copy Markdown
Member

An RL78 boot ROM emulator in process-node, so RL78 programming over the BenchPod (embeddedci-com/benchpod-firmware#135) can be tested on the bench without an RL78.

What it does

When PA9 (the console TX, which is the bench's LA3) is held low through reset, the node starts an emulated R5F100LE (RL78/G13) boot ROM instead of booting normally. It speaks RL78 Protocol A on that one wire, following Renesas R01AN0815 Rev. 1.10:

  • Commands: Reset, Baud Rate Set (115200, 250000, 500000, 1000000), Silicon Signature, Block Erase, Block Blank Check, Programming (with the final internal-verify status), Verify (a mismatch is reported in the last frame's ST2), Checksum, and Security Set, Get and Release.
  • Frames: the guide's frames, checksums and status codes. The PDF's worked checksum examples are in the tests.
  • Flash: 64 KB code flash plus 4 KB data flash, in RAM, so every entry starts with an erased part. As on real flash, a byte is written only when blank, and the security flags are enforced.
  • Line: USART1 in single-wire half-duplex mode on PA9, open drain. It sends 1 stop bit; the programmer sends 2. It answers only after the programmer's second stop bit has ended.

A normal boot is unchanged: the strap is sampled with the internal pull-up on, so an undriven LA3 never starts the emulator.

One limit vs a real part: the emulator needs TOOL0 held low for about 6 ms after the reset release, the time it takes to set up its flash. A real RL78 needs only 723 µs + tHD. The README says this.

Tests

  • Host: tests/test_rl78emu.c (in make test-host) checks every command flow byte for byte, including the bad-checksum, bad-footer, parameter and security cases.
  • Bench: tests/rl78_programmer.py is a minimal Protocol A programmer over the pod's one-wire UART (open_uart(half_duplex=True, entry=UartEntry(...))). tests/test_rl78.py (marker rl78) runs it against the emulator:
    • entry and signature;
    • program, verify and checksum;
    • data flash;
    • parameter errors;
    • 250k, 500k and 1M baud (4 KB programmed in 0.37, 0.23 and 0.20 s);
    • security;
    • a normal boot afterwards.

Hardware results

On benchpod-30a9f1, with pod firmware from embeddedci-com/benchpod-firmware#161 (gateware v57) and the SDK from embeddedci-com/embeddedci-python#104:

  • test_rl78.py --soak 3: 30/30 passed.
  • test_lifecycle.py, test_rl78.py and test_power.py in one run: 21 passed. The node's console is paused for the RL78 module and the node boots normally afterwards.

On pods without uart_hd the RL78 tests skip.

Two bugs found on hardware

Both made the first frames after entry go missing:

  • Zeroing the 68 KB in .bss at startup made main() start after the programmer had already released TOOL0. Fix: the buffer is in .noinit.
  • GCC turned the word-wise flash fill back into newlib-nano's byte-wise memset, about 30 ms. Fix: no-tree-loop-distribute-patterns on that loop.

Merge after embeddedci-com/benchpod-firmware#161 and embeddedci-com/embeddedci-python#104.

🤖 Generated with Claude Code

wardviaene and others added 2 commits November 18, 2026 09:33
…0 strap on PA9

PA9 (the console TX, the bench's LA3) held low through reset starts an
emulated R5F100LE boot ROM instead of the node: RL78 Protocol A on one
wire, open-drain single-wire half duplex, 115200 to 1 Mbit/s. Every command
of R01AN0815 Rev. 1.10 (reset, baud rate set, signature, erase, blank check,
program, verify, checksum, security set/get/release) with the guide's
frames, checksums and status codes; flash in RAM, written only when blank.

The emulator's 68 KB is kept out of .bss and filled word-wise (GCC turned
the loop into byte-wise memset): zeroing it at startup and filling it byte
by byte took longer than a programmer holds TOOL0 after reset. The strap is
sampled with the internal pull-up, so an undriven LA3 never starts it.
Host-tested in tests/test_rl78emu.c.

Refs embeddedci-com/benchpod-firmware#135

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/rl78_programmer.py, a minimal Protocol A programmer over the pod's
one-wire UART and pod-timed entry; tests/test_rl78.py (marker rl78) runs
it: signature, program/verify/checksum, data flash, parameter errors,
250k/500k/1M baud, security, and a normal boot afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant