Add EMS NDS Adapter+ support for DS/3DS save backup#4
Draft
Conversation
WebUSB driver for the EMS NDS Adapter+, which reads and writes save data from DS and 3DS cartridges. Follows the scanner pattern (like Amiibo) with continuous polling for cartridge insertion/removal. Key details: - Save data reads use EP3 (not EP1) — undocumented in ndsplus - Discriminates the EMS GB USB Smart Card (same VID/PID, different protocol) - Detects 3DS cartridges via all-0xFF header pattern - Supports EEPROM (512B/8KB/64KB) and FLASH save types Protocol reference: github.com/Thulinma/ndsplus Maker codes derived from devkitPro ndstool (GPL-3.0)
The EMS NDS Adapter+ driver is derived from the GPL-3.0 ndsplus project by Thulinma.
# Conflicts: # src/App.tsx # src/hooks/use-connection.ts # src/lib/core/devices.ts
Extract NDS cart-header parsing into a new shared module so future NDS save devices (Datel PowerSaves for 3DS, etc.) can reuse the same header/CRC validation, region decoding, and No-Intro lookups instead of each driver carrying its own copy. - New `src/lib/systems/nds/nds-header.ts` — header parsing, region decoding, dual-CRC validation (logo CRC + header CRC), 3DS-cart all-0xFF detection, and an `NDSDeviceDriver` interface every NDS driver implements - `nds-save-system-handler.ts` gains `validateDump`, which catches duplicate-half saves, all-0x00 / all-0xFF dumps, and chip-size mismatches at the system layer - EMS driver refactored to use the shared header module and interface; cart identity is now fingerprinted (`statusFingerprint`) and re-verified after every dump/write so a mid-operation cart swap fails closed instead of silently dumping the wrong save - Save read switched to the default bulk IN endpoint — earlier code selected EP3 explicitly based on the ndsplus reference, but every hardware-validated transfer actually returns on EP1, so removing the override fixed a silent hang on some firmware versions - Save-read timeout tuned to 3 s with slow-chunk logging; in-driver recovery paths (orphan-transferIn rescue, stall counter, pre-dump GET_STATUS verify) removed after they were observed corrupting saves on real carts; firmware-version word now decodes the `recovery` bit so the scanner can distinguish a degraded adapter from a missing one - Document the EMS adapter's undocumented protocol surface (`UNDOCUMENTED_CMD`, `UPGRADE`) for future reference; not invoked by the driver - Scanner no longer hot-swaps carts — physical disconnect is required between dumps to keep the SPI bus from being driven while a new chip is energising; UI surfaces cart info, save size, and validation warnings during the read - Generic `CartridgeInfo<M>` plus an `NDSCartMeta` shape; `nointro.ts` filters prerelease tags and maps the `nds_save` system; USB transport exposes `getDevice()` for sibling-protocol probes; `formatBytes` learns MB - THIRD-PARTY-LICENSES: add powerslaves attribution (kitlith, MIT) and refine the existing ndstool note
Owner
Author
|
I bricked my EMS NDS Adaptor Plus while working on this. I was trying to replace the firmware on the device; this didn't happen while trying to read the save data. All of this to say it may be a minute before I can merge support for this device. |
The product itself uses the British spelling on the box and installer (NDS_Adaptor_Plus). Switch user-visible strings — device name, error text, scanner instructions, log messages — to match. Code identifiers, file names, and JSDoc keep 'Adapter' for now to avoid churn.
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.
Summary
nds-header.tsmodule so future NDS save devices can reuse the same header parsing, dual-CRC validation, region decoding, and No-Intro lookupNDSSaveSystemHandler.validateDumpflags duplicate-half saves, all-0x00 / all-0xFF dumps, and chip-size mismatches at the system layer rather than per driverUNDOCUMENTED_CMD,UPGRADE) for future reference; not invoked by the driverwindow.__nabuDriverfor devtoolsCartridgeInfo<M>plusNDSCartMeta;nointrofilters prerelease tags and adds annds_savesystem mapping; USB transport exposesgetDevice()for sibling-protocol probes;formatByteslearns MBpowerslaves(kitlith, MIT) attribution and refine the existingndstool(devkitPro) noteTest plan