The chip table becomes family blocks covering all 37 targets. The m48s are a new deployment class: no boot section, so the tiny profile spoken over the hardware USART — host-patched reset vector, trampoline hand-over, a 510-byte budget (474 B built), no fuse preflight — while their RWWSRE store stays the buffer discard (Atmel-8271 §26.2); the device keys the patch flag and the CPU-halt waits on the curated boot-section capability and the discard on the RWWSRE bit itself. The 644s' 64 KiB is exactly the 16-bit byte space: plain LPM, byte wire addresses, 498 B in a 512-byte slot — and their 1 KiB minimum boot section holds the resident and staging slots together, so self-update needs no fuse step (the update test's slot pick now keys word-flash on base >= 64 KiB; base + slot merely touching the boundary stays byte-addressed). The 1284 joins the 1284P's word-addressed 1 KiB slot at 558 B. BOOT_FUSE gains every boot-sectioned family's ladder and fuse byte; the planner exercises them all. The sim scaffolding keys patch-vector-ness instead of the atmega name prefix, the fixture app picks its clock by family (the tiny25/45/13 builds surfaced the 16 MHz fallthrough as garbled banners), and the runner's wrapped flash ioctl performs the m48 discard simavr's no-RWW cores turn into a stray buffer fill. Sizes across the fleet: 466-504 B megas, 474 B m48s, 498 B 644s, 488-502 B tinies, 558 B 1284s — every chip passing size/pi/planner/protocol/reloc/update. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
66 lines
2.4 KiB
Python
66 lines
2.4 KiB
Python
"""Shared simavr harness for the pureboot tests: spawn the device runner,
|
|
hand out its pty, restart it from a flash dump (the power-fail path), and
|
|
keep its chatter out of undrained pipes."""
|
|
|
|
import os
|
|
import signal
|
|
import subprocess
|
|
|
|
|
|
class Device:
|
|
def __init__(self, binary, elf, mcu, hz, base_hex, page, baud, dump, reset_hex=None, resume=None):
|
|
cmd = [binary, elf, mcu, hz, base_hex, str(page), str(baud), dump]
|
|
if reset_hex is not None or resume is not None:
|
|
# Chips without a hardware boot section — the tinies and the
|
|
# m48s — reset to address 0 like silicon; the boot-sectioned
|
|
# megas re-vector to the loader base (BOOTRST).
|
|
patch = not mcu.startswith("atmega") or mcu.startswith("atmega48")
|
|
cmd.append(reset_hex if reset_hex is not None else ("0" if patch else base_hex))
|
|
if resume is not None:
|
|
cmd.append(resume)
|
|
self.log = open(dump + ".log", "a")
|
|
self.proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=self.log, text=True)
|
|
self.dump = dump
|
|
self.pty = None
|
|
for _ in range(50):
|
|
line = self.proc.stdout.readline()
|
|
if not line:
|
|
break
|
|
if line.startswith("PB_PTY"):
|
|
self.pty = line.split()[1]
|
|
break
|
|
if not self.pty:
|
|
self.stop()
|
|
raise RuntimeError("device did not report a pty")
|
|
|
|
def reset(self):
|
|
"""The external reset line: SIGUSR1 re-enters at the reset vector."""
|
|
self.proc.send_signal(signal.SIGUSR1)
|
|
|
|
def power_fail(self):
|
|
"""SIGTERM: the runner dumps its flash and exits — the image a
|
|
restart resumes from."""
|
|
self.stop()
|
|
return self.dump
|
|
|
|
def stop(self):
|
|
self.proc.terminate()
|
|
try:
|
|
self.proc.wait(timeout=5)
|
|
except subprocess.TimeoutExpired:
|
|
self.proc.kill()
|
|
self.log.close()
|
|
|
|
|
|
def run_tool(tool, pty, baud, *args, timeout=180):
|
|
result = subprocess.run(
|
|
[os.environ.get("PYTHON", "python3"), tool, "--port", pty, "--baud", str(baud), "--wait", "25", *args],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=timeout,
|
|
)
|
|
print(result.stdout, end="")
|
|
if result.returncode != 0:
|
|
raise RuntimeError(f"tool exited {result.returncode}: {result.stderr.strip()}")
|
|
return result.stdout
|