#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Which PSP firmware files has the player supplied? SHA-1s only, nothing copied. A low-level PSP board needs firmware the family never ships (docs/boot-and-firmware.md): the Pre-IPL boot ROM inside Tachyon, the IPL and the flash0 file system from NAND, the syscon MCU's program, and keys held in KIRK. A high-level board needs none of them, but the encrypted game executables still need decryption (docs/hle-vs-lle.md). This script walks $PSP_FIRMWARE_DIR (or --dir), hashes every file in place (SHA-1 and size), and prints them, matched against KNOWN where an entry exists. KNOWN is empty on 2026-11-26: no PSP firmware dump is on this machine and no hash list from a source we may use was found. Entries are added only from a player's own dump or an official update file's published hash, with the source named beside each one. PSP_FIRMWARE_DIR=... python -I scripts/census_firmware.py """ from __future__ import annotations import argparse import hashlib import os import sys from pathlib import Path # SHA-1 -> (what it is, where the hash came from). Empty until a usable source exists. KNOWN: dict[str, tuple[str, str]] = {} def sha1(path: Path) -> str: digest = hashlib.sha1() with path.open("rb") as handle: for block in iter(lambda: handle.read(1 << 20), b""): digest.update(block) return digest.hexdigest() def main() -> int: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("--dir", default=os.environ.get("PSP_FIRMWARE_DIR")) args = parser.parse_args() if not args.dir: print("PSP_FIRMWARE_DIR is not set: no player-supplied firmware to identify") print(f"known hashes: {len(KNOWN)}") return 0 root = Path(args.dir) count = 0 for path in sorted(p for p in root.rglob("*") if p.is_file()): digest = sha1(path) label = KNOWN.get(digest, ("unknown", ""))[0] print(f"{digest} {path.stat().st_size:>10} {label:20} {path.relative_to(root)}") count += 1 print(f"files hashed: {count}; known hashes: {len(KNOWN)}") return 0 if __name__ == "__main__": sys.exit(main())