Repository navigation
[DRAFT] Implement EverDrive-64 V-series and X-series firmware support - #434
Draft
networkfusion wants to merge 3 commits into
Draft
networkfusion wants to merge 3 commits into
networkfusion wants to merge 3 commits into
Conversation
…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).
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
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
force-pushed
the
feature/ed64-vseries-support
branch
from
October 3, 2026 19:50
3304aa7 to
0affdb0
Compare
networkfusion
marked this pull request as draft
October 3, 2026 23:21
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.ed64_bios_ll.c/.hmodule: 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.hdriver rather than ahand-rolled program/erase sequence).
GAMEMODbit, the sameone 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.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.
ed64_xseries.c/ed64_xseries_ll.c): same save support, plus loads both theICE40 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).
ed64_proseries(Pro series): it was an empty, unwired stub and isn't currentlysupportable.
Known limitations
FLASHCART_SAVE_TYPE_FLASHRAM_1MBIT/PKST2) are supported vialibdragon's
flashram.hdriver but haven't been hardware-tested against a realFlashRAM-equipped cart/game.
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.), makingthe menu effectively unusable for the large majority of N64 games that rely on saves.
How Has This Been Tested?
make clean && make all) at every step, zerocompiler warnings/errors.
that hardware. The register-level protocol is grounded in the publicly-available
networkfusion/ED64(EverDrive-64 OS) source and libdragon's own already-vendoredlibcart/flashram/sramdrivers, cross-referenced where possible, but real-hardwarevalidation is still needed before this should be considered production-ready.
Screenshots
N/A (no UI changes)
Types of changes
Checklist:
You agree with the license terms and that other license types may be granted with permission of the original
N64FlashcartMenuproject license holders.Signed-off-by: networkfusion networkfusion@users.noreply.github.com