Page 1 of 3

Refining design for really low-cost devcart

Posted: Thu Jul 29, 2010 10:24 am
by blargg
arfink and I are discussing a really low-cost NES development cartridge that can be constructed from SNROM (MMC1) boards. The basic idea is to replace the PRG ROM with a 128K/256K/512K Flash ROM and connect the write line. I'd like input, especially from Memblers, who I know has also done similar things, and bunnyboy, about the cost-effectiveness of making this as a custom board, or whether it would work with his unpopulated MMC1 board's automatic-chip-detection.

The MMC1 and Flash chip would both get writes to the $8000-$FFFF region, but this shouldn't be a problem because the Flash chip doesn't respond to writes unless preceeded by several writes to particular addresses, ones that wouldn't ever occur accidentally. And the values written often have the high bit set, so it naturally resets the MMC1 shift register as well, avoiding MMC1 disruption when programming the Flash. I realize that 5V DIP Flash chips aren't produced anymore, but these are just too convenient. Jameco Electronics at least seems to have them, and for a decent price (around $4 USD).

We're also considering making the CHR RAM battery-backed and write-protectable, using one of the MMC1 CHR bank selection lines. Both of these features have worked on another MMC1 cart I've modified to implement these features.

To allow programming, we're making cheap serial interface cables for the NES, with the NES implementing the UART in software. The basic design uses a MAX232 or equivalent to convert between the NES 5V and RS232 +/-12V signals. An alternate design uses an FTDI TTL-232R cable which has a USB connector on one end, and bare wires on the other with 5V serial signals. While more expensive, the cable can be made by literally just splicing it to a NES controller cable. With some heat-shrink tubing, such a cable would look very elegant. :)

A third approach not yet tried is to use a few resistors and diodes to interface the NES directly with RS232, without any level shifting. This should work for sending data from the PC to the NES, but might not work the other direction. For many uses, this is sufficient.

In the Flash ROM resides a tiny bootloader that waits for a 256-byte program from the PC, then executes it. This 256-byte program can then receive a larger loader program, or whatever. This design has worked very well on my devcart. The benefit is that the tiny bootloader doesn't have to be updated every time you improve the larger loader, lessening the chance of bricking the cartridge.

In order to reduce the chance of an end-user bricking the cartridge, we're considering a small bank-select switch/button that selects an alternate copy of the bootloader, in case the main one gets corrupt. Since the end-user has no way of reprogramming the cartridge beyond the PC interface, something like this seems important.

While the initial goal is to make and sell some at a $40 price point (I've left all monetary decisions to arfink, and declined to receive any money for this), it'd be nice if anyone could make one of these, or at least other people also make some. They should at the very least allow running 32K NROM NES programs, and provide a cheaper platform if you just want to run other homebrew stuff.

Thoughts on the design/improvements/problems?

Posted: Thu Jul 29, 2010 2:05 pm
by arfink
I'll just add that while I will be making a few batches of these, my target audience is the folks at the various chipmusic sites and such. If people here want to buy ready-made hardware from me when the time comes I'll be happy to do that. However, something Bargg forgot to mention is that there will be a full tutorial made up which will detail the construction of these devices.

Also, as you'd expect, since there is lots of RAM on board this can be used for running NROM stuff pretty easily too.

Posted: Thu Jul 29, 2010 4:12 pm
by tokumaru
The idea is interesting, but I think that $40 is a bit too much for a cart that can only run NROM and MMC1 games.

I still didn't understand exactly how this work though. Does your program get written to the Flash ROM or is that chip only for booting? If the Flash is used for the program I think that the cart doesn't qualify it for intense use (i.e. emulator replacement), so the only advantage I see over standard socketed carts + EPROM programmer is the direct PC connection that eliminates the chip swapping.

Re: Refining design for really low-cost devcart

Posted: Thu Jul 29, 2010 5:17 pm
by tepples
blargg wrote:And the values written often have the high bit set, so it naturally resets the MMC1 shift register as well
A string of multiple bytes with set to true will likely disrupt which bank you're reprogramming. You might have to use discrete logic or an extra feature in an MMC1-clone CPLD to add a register at $5000 that switches writes between the MMC1 and the flash chip. This technique would also allow saving without a battery, as I've explained in another topic.
tokumaru wrote: I think that $40 is a bit too much for a cart that can only run NROM and MMC1 games.
Compare to the difference between a SuperCard and an M3. Both are flash cards that run GBA programs, but most programs have to be patched to run properly on a SuperCard. In the case of an MMC1-only card, this might involve mapper-hacking a CNROM or UNROM game.

Re: Refining design for really low-cost devcart

Posted: Thu Jul 29, 2010 5:39 pm
by tokumaru
tepples wrote:In the case of an MMC1-only card, this might involve mapper-hacking a CNROM or UNROM game.
If you try to mapper-hack my UOROM game that uses a timed NMI routine for the MMC1 you will probably fail.

But yeah, I can see that with the MMC1 you can play most UxROM games, while the reverse is not true, so it makes sense to use that mapper. Most CNROM games probably don't need instantaneous CHR switching either (although a program of mine does - but I guess I just like to "break the rules"...).

Posted: Thu Jul 29, 2010 7:06 pm
by arfink
Part of the reason is that it's fun to do! One thing to note is that the bootstrap is intended to be able to load code into flash or ram, or both. In some ways this then becomes the poor-man's CopyNES. With the lockout chip disabled Blargg seems to think that it would even be possible to do a stop-n-swop type thing in order to work with other RAM cartridges and such.

While $40 may seem somewhat steep to some people, that's the price for everything, including the donor cartridge (if we go that route) the flash chip, cabling stuff, and a less-than-minimum wage for me so compensate for building them. A DIY-er who follows the tutorial could make a similar one for far less money with a donor cart he already has, stealing a flash chip from an old PC motherboard's bios, etc. I don't know of any other dev cart which you can just buy outright that comes with everything needed to get going with basic NES development for $40.

EDIT: lastly, with something like this which is a basic development kit, hopefully more people will find doing some NES development work a little more interesting, and maybe more people will try it. I'm really stretching my knowledge of the NES working on this project.

EDIT2: Also, newbs shy away from NES development because they don't want to fork over the dough for an EPROM programmer. This design allows reprogramming the cartridge without needing an EPROM programmer at all.

Posted: Thu Jul 29, 2010 7:17 pm
by tepples
Every PC made in the last decade has a USB port, but a lot of newer machines (especially Macs and smaller laptop PCs) lack an RS-232 serial port. Would it be cheaper to use the TTL-232R, or would it be cheaper to use the MAX232 and bundle a USB to RS-232 adapter?

Posted: Thu Jul 29, 2010 7:23 pm
by tokumaru
Well, if you can load code to RAM that's already better than what I though. How much RAM is there?

BTW, I don't think $40 is an outrageous price or anything, I understand what that much covers and it makes sense, but for what the cart does it might not be worth it, that's what I meant. I can see the appeal for a person who doesn't own an EPROM programmer and/or a PowerPak though, since it is a much cheaper alternative.

Posted: Fri Jul 30, 2010 2:26 am
by blargg
The idea is interesting, but I think that $40 is a bit too much for a cart that can only run NROM and MMC1 games.
The point is to allow chip musicians to run homebrew stuff more cheaply, so that more people can afford to. It would of course also run other homebrew stuff as well. And with the PC cable, you can do fun things like use the NES as an authentic output device for an NSF player running on the PC or Famitracker, and even do homebrew development with a very short edit-test cycle. If the CIC is disabled on your NES, you can do stop-n-swop and dump your own cartridges/back up their battery RAM, or even load your code into WRAM (if the swapped-in cart has it) and test with its mapper, e.g. test code on the MMC5 or whatever.
A string of multiple bytes with [the high bit] set to true will likely disrupt which bank you're reprogramming.
I believe that simply resets the bank mapping, but not the bank, so I can do all writes to the appropriate 16K bank without any disruption. I'll see once I have a prototype to test on.
Also, newbs shy away from NES development because they don't want to fork over the dough for an EPROM programmer. This design allows reprogramming the cartridge without needing an EPROM programmer at all.
And greatly shortens the edit-test cycle. No cartridge swapping or EPROM chip swapping.
Would it be cheaper to use the TTL-232R, or would it be cheaper to use the MAX232 and bundle a USB to RS-232 adapter?
Yeah, I think TTL-232R cable would be the simplest, and with proper heat shrink tubing, would look professional. But arfink believes he can do the MAX232 adaptor + cheapo USB to RS232 adaptor cheaper (which is kind of funny because the USB adaptor basically has a MAX232 in it as well). This as an option is necessary anyway because some people might already have a serial port.
Well, if you can load code to RAM that's already better than what I though. How much RAM is there?
The RAM would just be WRAM at $6000. The Flash is what is intended for most code loading. We could probably put 32K WRAM and have it bank-switched by the MMC1, but then code written for it wouldn't run on emulators anymore. I think it's best for code to be written for standard mappers. An earlier design was considering running code from WRAM, before I learned about these great Flash chips (that are sadly not even manufactured anymore).

Posted: Fri Jul 30, 2010 7:18 am
by tokumaru
blargg wrote:The point is to allow chip musicians to run homebrew stuff more cheaply
Aren't most of those guys crazy about expansion chips?

Posted: Fri Jul 30, 2010 9:42 am
by arfink
Expansion chips? Heh, not really. Surprisingly enough, alot of them don't deal with them because it's "too hard" to use the real hardware. Actually, with a stop-n-swop it'd be possible to do more with expansion hardware too, probably. Hmm, an interesting possibility...

Posted: Fri Jul 30, 2010 9:51 am
by blargg
Aren't most of those guys crazy about expansion chips?
Simple: disable the CIC on your NES, then use stop-n-swop and put in a cartridge with the audio expansion chip of your preference, and run the NSF player with that.

Posted: Fri Jul 30, 2010 10:16 am
by tepples
blargg wrote:
Aren't most of those guys crazy about expansion chips?
Simple: disable the CIC on your NES, then use stop-n-swop and put in a cartridge with the audio expansion chip of your preference, and run the NSF player with that.
Only $0000-$07FF and possibly $6000-$7FFF can be loaded after a stop-n-swop. Your NSF would have to copy itself down there, and this location is off limits to APU DMC.

Posted: Fri Jul 30, 2010 11:22 am
by arfink
Well, not necessarily Tepples. Once swopped, presumably a loader program will still be in the 2k WRAM of the NES, and then one can draw more data off the serial cable for playback and use it immediately, discarding it. One would not have to store everything.

EDIT: correct me if I'm wrong Blargg, but if NSF playback is all that is desired, once the player is in the WRAM then you could run without a cartridge at all, and simply play NSF's being fed through the controller port.

Posted: Fri Jul 30, 2010 11:31 am
by tepples
arfink wrote:Well, not necessarily Tepples. Once swopped, presumably a loader program will still be in the 2k WRAM of the NES
It would have to use the DPCM samples that are already in the PRG ROM. The only mappers I know of that can map RAM into $C000 are FDS and MMC5.