Controlling program ROM with a RPi or Arduino

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Controlling program ROM with a RPi or Arduino
by on (#219845)
So I have desoldered the program ROM from a UNROM pcb and put jumper headers in its place.

All I want to do in this first experiment is see if I can load the data from the controller rather than EPROM. File I/O is likely slow so I'll load the data into a byte array.

Firstly is there likely to be any issues here with actually doing this? Clock issues?

Secondly what's the best way to get just the program data from the UNROM NES file?

Many thanks

Chris
Re: Controlling program ROM with a RPi or Arduino
by on (#219846)
The device that you are attempting to make is called a "ROM emulator".

A Raspberry Pi or an arduino are completely unsuitable for this task; they simply lack the ability to respond dynamically to the 2A03 with low enough delay.

The Atari 2600 has a device (the "Harmony Cart") that uses a microcontroller as a ROM emulator, but it's using one with drastically lower latency than the RPi / most other ARM cores, and the 2600's CPU is 2/3 the speed of the NES's CPU.
Re: Controlling program ROM with a RPi or Arduino
by on (#219847)
Thanks for the response, I thought that was maybe going to be the answer. Yes the Pi is slow, experience there but I thought the atmega chip at least had some sort of capable speed? The Arduino is reasonably low level compared to the Pi.

What sort of chips and circuitry are the likes of the NES ever drive using to get that sort of speed?

Perhaps an alternative solution would be using the Arduino to program a chip on the fly, but that sounds not much different to just programming the chip manually on a donor.
Re: Controlling program ROM with a RPi or Arduino
by on (#219849)
Milesy303 wrote:
Thanks for the response, I thought that was maybe going to be the answer. Yes the Pi is slow, experience there but I thought the atmega chip at least had some sort of capable speed? The Arduino is reasonably low level compared to the Pi.
Yeah, still no.

It turns out that usually when you get a microcontroller that's fast enough to serve as a ROM emulator, it also grows enough complexity that it can't manage the latency.

Quote:
What sort of chips and circuitry are the likes of the NES ever drive using to get that sort of speed?
RAMs and an FPGA to emulate mapper hardware.

Quote:
Perhaps an alternative solution would be using the Arduino to program a chip on the fly, but that sounds not much different to just programming the chip manually on a donor.
It's true, but not having to physically unplug things and replug things does make it more convenient.
Re: Controlling program ROM with a RPi or Arduino
by on (#219856)
A while back I traced out and drew an (incomplete) schematic of the ROM emulator I used to always use. Wasn't something I built, it was designed in '93 and I bought a used one in '99. Connected to target board with an IDC to DIP adapter, you'd just plug that into an EPROM socket. On the other end, it connected to a PC's parallel port through an RJ6 cable, the "in" connector on the schematic. The "out" connector is so you could chain several of the boards together to emulate multiple EPROMs. Pretty sure there are buffers on the other side of the RAM chip that I didn't trace out and put in the schematic.
edit: also, those "reset" outputs are used to reset the CPU on the target board

That's pretty much the type of circuit you'd need to control the ROM with an MCU. Obviously could be done differently and better with an MCU instead of a few pins from a parallel port. If it's not helpful, I hope it's at least interesting.

Here's a currently available product that does this. At $175 + $12 it's kinda spendy, but it is very niche.
https://www.moates.net/ostrich-20-the-new-breed-p-169.html
http://www.moates.net/emuc3206-emulation-cable-32pin-6inch-p-168.html?cPath=32
Re: Controlling program ROM with a RPi or Arduino
by on (#219947)
Then you can put Atmega16/32, USB, RAM (628512 - 4 MBit), battery backup and you got perfect EPROM emulator, you can project the PCB to make the EPROM pinout like for DIL28 NES Mask Roms or any DIP32.
Atmega has 32 pins, 2 for controlling USB and 30 for controlling RAM (A0-A18, D0-D7, /CE, /OE, /WE).
Atmega has 3 state outputs so it will perfectly act in this role (put all memory-pins in three state mode at powerup and set them to outputs only when receiving command from USB)

With V-USB you can have 7kB/s real transfer rate so filling whole memory would take around minute.

Building cost should not exceed 5$.
Re: Controlling program ROM with a RPi or Arduino
by on (#219968)
lidnariq wrote:
Milesy303 wrote:
Thanks for the response, I thought that was maybe going to be the answer. Yes the Pi is slow, experience there but I thought the atmega chip at least had some sort of capable speed? The Arduino is reasonably low level compared to the Pi.
Yeah, still no.

It turns out that usually when you get a microcontroller that's fast enough to serve as a ROM emulator, it also grows enough complexity that it can't manage the latency.

Quote:
What sort of chips and circuitry are the likes of the NES ever drive using to get that sort of speed?
RAMs and an FPGA to emulate mapper hardware.

Quote:
Perhaps an alternative solution would be using the Arduino to program a chip on the fly, but that sounds not much different to just programming the chip manually on a donor.
It's true, but not having to physically unplug things and replug things does make it more convenient.


Thank you. I might just write something to play games on my C64 instead haha.
Re: Controlling program ROM with a RPi or Arduino
by on (#219969)
Memblers wrote:
A while back I traced out and drew an (incomplete) schematic of the ROM emulator I used to always use. Wasn't something I built, it was designed in '93 and I bought a used one in '99. Connected to target board with an IDC to DIP adapter, you'd just plug that into an EPROM socket. On the other end, it connected to a PC's parallel port through an RJ6 cable, the "in" connector on the schematic. The "out" connector is so you could chain several of the boards together to emulate multiple EPROMs. Pretty sure there are buffers on the other side of the RAM chip that I didn't trace out and put in the schematic.
edit: also, those "reset" outputs are used to reset the CPU on the target board

That's pretty much the type of circuit you'd need to control the ROM with an MCU. Obviously could be done differently and better with an MCU instead of a few pins from a parallel port. If it's not helpful, I hope it's at least interesting.

Here's a currently available product that does this. At $175 + $12 it's kinda spendy, but it is very niche.
https://www.moates.net/ostrich-20-the-new-breed-p-169.html
http://www.moates.net/emuc3206-emulation-cable-32pin-6inch-p-168.html?cPath=32



Thank you I will look into this option.
Re: Controlling program ROM with a RPi or Arduino
by on (#219970)
krzysiobal wrote:
Then you can put Atmega16/32, USB, RAM (628512 - 4 MBit), battery backup and you got perfect EPROM emulator, you can project the PCB to make the EPROM pinout like for DIL28 NES Mask Roms or any DIP32.
Atmega has 32 pins, 2 for controlling USB and 30 for controlling RAM (A0-A18, D0-D7, /CE, /OE, /WE).
Atmega has 3 state outputs so it will perfectly act in this role (put all memory-pins in three state mode at powerup and set them to outputs only when receiving command from USB)

With V-USB you can have 7kB/s real transfer rate so filling whole memory would take around minute.

Building cost should not exceed 5$.


I had considered using a couple of shift registers to reduce the number of pins needed. Thanks.
Re: Controlling program ROM with a RPi or Arduino
by on (#219980)
Could you do something with PFGA fast enough?
Re: Controlling program ROM with a RPi or Arduino
by on (#220074)
Can anyone recommend a FPGA dev board that would be suitable for this project?

I see the everdrive N8 only uses a Cyclone II chip so should be cheaper than the IV to do something similar with that.

What about the cheaper Chinese boards?
Re: Controlling program ROM with a RPi or Arduino
by on (#220075)
All preëxisting current FPGA dev boards are strictly 3V only; the NES is 5V. You can't directly connect the two without damaging one or both.

You might be able to find a historical one? I don't know.

The PowerPak contains an (by now very) old XC2S30 ("Spartan-2"), two 512 KiB SRAMs, a 32 KiB SRAM, and a 64 KiB chunk of flash. Nowadays the cheap iCE40 FPGAs are comparable in ability, but will need voltage translation.
Re: Controlling program ROM with a RPi or Arduino
by on (#220080)
This one takes 7.5 input. Can't see much about levels within though.

https://www.digikey.co.uk/product-detai ... gK2PfD_BwE
Re: Controlling program ROM with a RPi or Arduino
by on (#220090)
Sadly, even as old as that IC is, it's still not 5V tolerant.

( https://www.altera.com/products/fpga/cy ... pport.html § Cyclone II Device Handbook (All Sections) ; chapter 5 "DC Characteristics and Timing Specifications" says it supports a maximum voltage of 4.6V and makes no mention of tolerance of higher voltage (so it isn't).