Skip to content

[DRAFT] Implement EverDrive-64 V-series and X-series firmware support - #434

Draft
networkfusion wants to merge 3 commits into
n64brew:developfrom
networkfusion:feature/ed64-vseries-support
Draft

networkfusion wants to merge 3 commits into
n64brew:developfrom
networkfusion:feature/ed64-vseries-support

Conversation

@networkfusion

Copy link
Copy Markdown
Collaborator

Description

Implements save support for EverDrive-64 V-series (V2/V2.5/V3) and X-series (X5/X7),
which were previously stubbed out with FIXME placeholders in ed64_vseries.c/ed64_xseries.c.

  • New shared ed64_bios_ll.c/.h module: cart model detection (EDID/cart-id register)
    and save-type register access via the register bank shared by every model once its
    full-feature personality is active. Handles EEPROM (4K/16K), SRAM (32K/96K-banked/128K),
    and FlashRAM saves (FlashRAM via libdragon's own flashram.h driver rather than a
    hand-rolled program/erase sequence).
  • A persistent "returned from a game" flag (the shared boot-config GAMEMOD bit, the same
    one the official EverDrive OS uses) means a true cold power-on never needs to touch the
    SD card to check for a pending save-writeback, and an unmodified save is skipped on
    writeback rather than needlessly rewritten - both mirror the official OS's own
    bramBackup() behavior.
  • V-series (ed64_vseries.c/ed64_vseries_ll.c): loads the full-feature CPLD personality
    (RTC/USB/save registers) from an RLE-compressed bitstream on every boot, same as the
    official OS does on every one of its own boots. Original V1 boards (and any other
    unrecognized hardware) skip this step and keep working in their pre-existing, basic
    capacity rather than being blocked by a reconfiguration step they never needed.
  • X-series (ed64_xseries.c/ed64_xseries_ll.c): same save support, plus loads both the
    ICE40 and main FPGA personalities (ICE first, main only if that succeeds - the ICE hosts
    the shared register bank including the main FPGA's own config port).
  • Removed ed64_proseries (Pro series): it was an empty, unwired stub and isn't currently
    supportable.

Known limitations

  • FlashRAM saves (FLASHCART_SAVE_TYPE_FLASHRAM_1MBIT/PKST2) are supported via
    libdragon's flashram.h driver but haven't been hardware-tested against a real
    FlashRAM-equipped cart/game.
  • FPGA/ICE40 bitstreams are embedded in the DFS for every flashcart's build (single
    universal ROM/filesystem), accepted as a minor size tradeoff rather than restructuring
    the build for per-cart asset exclusion.

Motivation and Context

EverDrive-64 V-series and X-series carts have had load-ROM support in this project for a
while, but saves were never implemented (// FIXME: the savetype will be none.), making
the menu effectively unusable for the large majority of N64 games that rely on saves.

How Has This Been Tested?

  • Full clean devcontainer rebuilds (make clean && make all) at every step, zero
    compiler warnings/errors.
  • Not yet tested on real V2/V2.5/V3/X5/X7 hardware - I don't currently have access to
    that hardware. The register-level protocol is grounded in the publicly-available
    networkfusion/ED64 (EverDrive-64 OS) source and libdragon's own already-vendored
    libcart/flashram/sram drivers, cross-referenced where possible, but real-hardware
    validation is still needed before this should be considered production-ready.

Screenshots

N/A (no UI changes)

Types of changes

  • Improvement (non-breaking change that adds a new feature)
  • Bug fix (fixes an issue)
  • Breaking change (breaking change)
  • Documentation Improvement
  • Config and build (change in the configuration and build system, has no impact on code or features)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed. (no automated test suite exists for this project; verified via clean builds)

You agree with the license terms and that other license types may be granted with permission of the original N64FlashcartMenu project license holders.

Signed-off-by: networkfusion networkfusion@users.noreply.github.com

…ity loading

Adds working save support for EverDrive-64 V-series (V2/V2.5/V3) and X-series
(X5/X7), previously stubbed out with FIXME placeholders.

Shared infrastructure (ed64_bios_ll.c/.h):
- Cart model detection and save-type register access via the register bank
  shared by every model once its full-feature personality is active (EDID/
  cart-id, ROM_CFG save-type register).
- EEPROM (4K/16K), SRAM (32K/96K-banked/128K), and FlashRAM save read/write.
  FlashRAM is handled via libdragon's own flashram.h driver rather than a
  hand-rolled program/erase sequence.
- A persistent "returned from a game" flag (the shared boot-config GAMEMOD
  bit, same one the official OS uses) so a true cold power-on never needs to
  touch the SD card to check for a pending save-writeback, and an unmodified
  save is skipped on writeback rather than needlessly rewritten - both mirror
  the official OS's own bramBackup() behavior.

V-series (ed64_vseries.c/ed64_vseries_ll.c): loads the full-feature CPLD
personality (RTC/USB/save registers) from an RLE-compressed bitstream on
every boot, same as the official OS does on every one of its own boots.
Original V1 boards (and any other unrecognized hardware) skip this step and
keep working in their pre-existing, basic capacity rather than being blocked
by a reconfiguration step they never needed.

X-series (ed64_xseries.c/ed64_xseries_ll.c): same save support, plus loads
both the ICE40 and main FPGA personalities (ICE first, main only if that
succeeds - the ICE hosts the shared register bank incl. the main FPGA's own
config port, confirmed via the official OS's boot ordering and its own
save/restore of boot-config and EDID around the ICE reconfiguration).

Not supported: ed64_proseries (Pro series) has been removed - it was an
empty, unwired stub and isn't currently supportable.

FPGA/ICE40 bitstreams are embedded in the DFS for every flashcart's build
(single universal ROM/filesystem, accepted as a minor size tradeoff rather
than restructuring the build for per-cart asset exclusion).
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d2286289-d060-4cb4-af69-b805d7e74648

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Real hardware testing on an ED64 X7 surfaced several issues not visible in Docker/QEMU builds:

- DragonFS (rom:/) must be mounted after cart_init()'s per-cart PI bus setup (buried inside debug_init_sdfs()) but before the flashcart driver's own init() runs, since the EverDrive FPGA personality loader needs rom:/ to read its own embedded firmware files. Moved the single dfs_init() call into flashcart_init() accordingly.

- The X series FPGA command register bank (KEY/SYS_CFG/EDID/BOOT_CFG/FPGA_CFG/ICE_CFG) needs every access to go through a real PI DMA transfer, matching the official EverDrive OS's bi_reg_wr()/bi_reg_rd() - a direct register poke isn't reliably honored by this hardware.

- Both FPGA bitstream files must be fully read into memory before any hardware reconfiguration begins, matching the official OS's edConfigureFpga(); reconfiguring the ICE40 leaves the rom:/ read path briefly unready, so a second file read placed after it unreliably fails.

- After main FPGA reconfigure, explicitly unlock the register bank key, re-enable the SDRAM/ROM window, and set the official OS's fixed post-reconfigure PI DOM1 timing (0x04/0x0C) rather than restoring whatever timing was there before reconfiguration.

- V/X series FPGA personality loading no longer buffers whole decompressed bitstreams on the heap (previously up to ~512 KiB peak transient usage); it now reads each RLE-compressed firmware file into small fixed-size static buffers and decodes/streams directly to the FPGA/ICE40 config ports.

- Consolidated 4 separate 128 KiB save-transfer static buffers (2 in ed64_xseries.c, 2 in ed64_vseries.c, never used concurrently) into one shared buffer, cutting static memory usage by ~384 KiB.

- FPGA personality load failure (missing/corrupt firmware) now falls back to the cart's basic cold-boot personality instead of hard-failing the whole menu, matching the existing V1 handling.

Confirmed working on real ED64 X7 hardware (correct firmware version 19.0.0 / cart ID 0x13 reported). V-series (V2/V2.5/V3) real-hardware testing is still pending; its reconfigure flow is structurally simpler (single bitstream file, different register bank) so may not need the same fixes.
@networkfusion
networkfusion force-pushed the feature/ed64-vseries-support branch from 3304aa7 to 0affdb0 Compare October 3, 2026 19:50
@networkfusion networkfusion changed the title Implement EverDrive-64 V-series and X-series save support [DRAFT] Implement EverDrive-64 V-series and X-series firmware support Oct 3, 2026
@networkfusion
networkfusion marked this pull request as draft October 3, 2026 23:21

This branch has not been deployed

No deployments
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