Reverse Engineering a Cheap NES Phone Case: Firmware, Hardware, and Custom Code Analysis
Poking Technology
Summary:
The video details the reverse engineering of a cheap NES/Famicom clone phone case.
- The device, a "NES-on-a-chip" rather than an emulator, features a unique menu and 36 pre-loaded games.
- Disassembly reveals a simple PCB with an epoxy blob (main chip) and an SPI flash chip containing the firmware and games.
- Initial attempts to dump the flash chip on-board fail due to signal interference.
- After desoldering the chip, the firmware is successfully dumped, revealing unencrypted code and data.
- Signal analysis using an oscilloscope shows 90 MHz QSPI communication, posing challenges for a logic analyzer.
- A custom test jig is built, and after breaking the screen, the system is made stable for signal capture.
- Detailed analysis of QSPI commands identifies the continuous read mode.
- Further reverse engineering identifies the underlying chip as a VT369, which includes a 4KB internal ROM for initialization and an external EEPROM for settings.
- The internal ROM is dumped using a novel Morse code method by blinking the screen's backlight.
- Attempts to emulate the device in MAME fail, suggesting a possibly undocumented mapper.
- The project concludes with all ROM images successfully dumped and shared, leaving future work for emulator support.
Introduction to the NES Phone Case [0:00]
The video begins with the presenter introducing a novel phone case that doubles as a functional NES (Nintendo Entertainment System) console. The device, purchased from AliExpress for a low price (5 Swiss francs), is noted for its ubiquity and "cheap and nasty" nature.
Disassembly and Internal Components [3:23]
The presenter proceeds to disassemble the phone case to examine its internal workings.
Examination of the Printed Circuit Board (PCB) [5:30]
The PCB is removed and inspected more closely, revealing the core logic of the device.
ROM Dumping and Initial Analysis [7:24]
The presenter attempts to extract the firmware from the SPI flash chip.
On-board Dumping Attempt (Failure) [7:34]
- An initial attempt to dump the chip using a clip on the board fails due to interference from the powered microcontroller. The programmer reports an incorrect chip ID.
Off-board Dumping (Success) [8:45]
- The flash chip is desoldered and placed onto a carrier board, allowing for a clean read. The programmer correctly identifies the chip (Winbond 25Q16) and successfully extracts the 2MB ROM image.
Basic ROM Analysis [9:35]
- Encryption Check: The ROM image is confirmed to be unencrypted after running string searches, revealing plain text strings like the Greek alphabet.
- Machine Code Detection: Running
CPU rec to detect 6502 machine code yields minimal results, which is unexpected for an NES system. This suggests that code reads might be encrypted on-the-fly, while data reads are not, or the system uses an unrecognized architecture.
- NES Boot Vectors: Expected NES reset vectors are not found at the typical memory locations.
Signal Analysis and Debugging [12:00]
To understand the system's runtime behavior, the presenter connects a logic analyzer to the PCB.
Initial Logic Analyzer Setup Challenges [12:00]
- Wiring the logic analyzer to the board causes glitches and boot failures, attributed to long wires introducing capacitance at the detected 90 MHz SPI clock speed, which is beyond the comfort zone for hobbyist tools.
- The speaker notes that the speaker sound became "nasty scratchy" and the device would glitch out, suggesting signal integrity issues.
Hardware Modifications and New Issues [13:51]
- A ZIF (Zero Insertion Force) socket is soldered to the board for the flash chip, requiring hot glue for stability. This makes reassembly impossible but improves signal integrity for the flash chip.
- Further issues arise with power, as the power supply cannot provide the necessary inrush current, causing the device to boot loop. This is solved with a large capacitor.
- During these attempts, the screen is accidentally broken.
Successful Test Jig and QSPI Protocol [20:41]
- A fully functional test jig with external buttons is assembled.
- The working system allows for capturing SPI signals. A deeper look with the oscilloscope reveals the clock signal for the SPI flash can reach 90 MHz in bursts.
- Analysis of the Winbond datasheet confirms the use of a Quad SPI (QSPI) mode (command E7) for continuous read operations, transferring 4 bits per clock cycle for faster data retrieval.
- The logic analyzer successfully decodes reads from the flash chip, matching the dumped ROM data.
Unreliable Logic Analyzer Capture [24:30]
- Despite using a high-end Saleae Logic Pro 16, the logic analyzer itself interferes with the 90 MHz signals, causing the device to crash and leading to corrupted data captures. The captures are deemed unusable for understanding program execution flow.
Deeper ROM Analysis and Chip Identification [33:28]
With unreliable signal captures, the focus shifts back to static analysis of the dumped ROM and further research.
Identifying Game ROMs [37:12]
- Within the 2MB flash dump, ROMs for "Super Mario" (0.5MB) and "Super Contra" (1MB) are found.
- Other areas contain structured information and blocks of actual 6502 machine code that
CPU rec initially missed.
Vendor and Chip Identification [44:51]
- A string "Cube Technology Company" is found in the ROM. Cube Technology is known for bootleg NES devices.
- Through pattern analysis and a MAME database search using the ROM's SHA1 hash, the device is identified as a "36P case" based on the VT369 "NES-on-a-chip" solution, one of the most advanced NES clones.
- The VT369 chip features hardware multiplication, fast CPU, and 8-bit per pixel graphics, explaining the colorful menu seen earlier.
Internal ROM and EEPROM Discovery [49:27]
- The VT369 has a 4KB internal ROM for initialization, which executes before accessing the external SPI flash. This explains the initial slow boot sequence observed in the logic analyzer.
- The Nesdev Wiki (Mapper 427 for VT369) describes a possible "i-squared C based protection chip" and a 24C04 EEPROM connected to GPIO ports (4148 or 4150).
- The menu code, running on the VT369, reads values from this EEPROM for PPU control and other settings, suggesting a copy protection mechanism or hardware configuration storage.
Dumping Internal ROM and EEPROM [51:30]
Since the internal ROM and EEPROM are inaccessible, creative methods are needed.
Conclusion and Future Work [1:41:53]
The project concludes with all major ROM components dumped, but further emulation proves challenging.