What's new

freddiefiasco

Professional
Joined
Feb 20, 2016
Messages
477
Reaction score
84
Location
California, USA
I had brought up this idea on KLOV and someone suggested I might get more interest/feedback/help here, so here goes! :D

Short project description:
Emulate the NAOMI 2 card reader and interface it with an actual NAOMI 2 for the purposes of saving progress in Initial D3.

Background:
I've got a Sega driving cab (OutRun2 SP) and I've got a NAOMI 2 hooked up and netbooting working. I've also got an ID3 card reader and cards, and have that wired up and working just fine. For this game, the cards work essentially to save your progress along with car upgrades. This is a great feature for home use. While I'm good to go with a currently working setup and a large quantity of compatible cards, I thought it would be a fun project to try to emulate the card reader, maybe using a Raspberry Pi, so that the NAOMI thinks a card reader is plugged up, and the data can be saved and loaded accordingly. If that works, then others can get a cheap alternative to the expensive and dying card readers. Apparently cards are getting hard to come by, too, and each has a limit of 50 uses as far as I know.

The data is transmitted between the NAOMI and Card Reader by serial communication.

In my brief review of serial communication standards, I believe that in spite of the CN8 port on NAOMI 2 saying RS-422, the labeling of the pins for the card reader make me think the standard is RS-232.

On the actual reader at CN2, we've got:
Pin 2: RXD (Serial Data Input)
Pin 3: TXD (Serial Data Output)
Pin 4: CTS (Clear to Send)
Pin 5: RTS (Request to Send)
Pin 6: SG (Signal Ground)

On the NAOMI 2 at CN8, we've got:
Pin 1: RXD
Pin 2: TXD
Pin 3: GND
Pin 4: RTS
Pin 5: CTS

Wiring from Card Reader to NAOMI 2:
RXD to TXD
TXD to RXD
CTS to RTS
RTS to CTS
SG to GND

My thinking is that while the 2 are wired up, I could tap into one side of this communication and sniff it with a serial input on the computer to read what's happening one way and then wire in to the other and see what's happening in that direction. After getting that information, I could try to unhook the reader and wire up just the computer to send the same signals back to the NAOMI2 that it expects from the reader.

The short term goal would be to trick the NAOMI into thinking the card reader has initialized. After that, it's a matter of figuring out what communication happens back and forth during the reading and writing of the card, then somehow figuring out how to store that data and give it back to the NAOMI when it expects it.

I've got almost no experience with serial communication standards. I would initially appreciate any help with regards to methods I could use for sniffing the signals and help addressing any concerns over signal voltage differences between computer and NAOMI 2. I've got a working serial port on an older laptop that I was hoping to use in the initial experiments before moving to an RPi.

I was thinking I could maybe take the RXD and RTS from either device and wire into the computer while the 2 devices are communicating to intercept the communication one way. Is there a good way to listen to the signal coming from both devices at once?

Once I'm able to analyze the signals to see what's sent from the NAOMI and what it expects to receive back, I think I could come up with some kind of program to manage the feedback.

Does this project seem realistic? Anyone have any advice to offer?

Thanks for any and all help!
I'm glad I'm not the only one thinking about this. You have made more progress than I have. I don't have any advice at the moment but hopefully as more of these discussions come up, I hope to have some in the future. Just to add to your planning, card reader saving/loading would be pretty cool if data was saved to something more tangible like a USB flash drive. One flash drive per 'vehicle'. :)
 

MetalliC

Grand Master
Joined
Nov 19, 2015
Messages
1,172
Reaction score
1,043
I wonder how difficult it would be to setup community run servers for these older games, similar to how the Bemani players managed to created a whole fake E-Amuse server system for players outside of Japan.
it depends. if servers still alive, so some network data can be sniffed during game talk to them - not easy task but real. if servers already dead - things becomes much complicated, if possible.


One flash drive per 'vehicle'.
each ID card hold just 207 bytes of information, typical flash drive can store many millions of them ;)
 

freddiefiasco

Professional
Joined
Feb 20, 2016
Messages
477
Reaction score
84
Location
California, USA
No, i get that. I meant for each player to have their own. But yes, it would be very cool.
 

twistedsymphony

Enlightened
Staff member
Immortal
Joined
Jul 21, 2015
Messages
10,122
Reaction score
9,519
Location
NH, USA
No, i get that. I meant for each player to have their own. But yes, it would be very cool.
That's why I suggested earlier making an app for your cell phone and using NFC to transmit card data. your phone could then store millions of cards. you'd select the card you want to use in the app then touch it to your new "card reader" interface and it transmits the card data.

Most new phones have an NFC antenna, and USB NFC readers are cheap (<$50). Plug it into a Raspberry Pi and have the Pi fake the communication to the game board and there you go...

No need to waste an SD card or USB drive, and if your friends want cards then you just have them download the app and thats it.

If other card reader formats are figured out the app could then be modified to work with them.
 

winteriscoming

Champion
Joined
Feb 16, 2016
Messages
1,400
Reaction score
1,097
Location
Indiana, US
Well, I got the serial adapter in and wired up to the reader/NAOMI. I hooked up RX, CTS and GND on the adapter to the corresponding outputs from either the reader or the NAOMI, and I never receive anything on the RX line. Under certain conditions, I was getting CTS read as intermittent on and off.

When RX from the adapter is wired into TXD on the reader while signal ground is wired, the reader stops responding to the initialization test from the NAOMI. With signal ground removed, it will respond to the test, but nothing gets read.

I'm not sure what else to try with the current hardware I have. I don't have a logic analyzer and am not sure what to look for to get something cheap and functional for this purpose. Any suggestions on what next steps should be?
 

freddiefiasco

Professional
Joined
Feb 20, 2016
Messages
477
Reaction score
84
Location
California, USA
No, i get that. I meant for each player to have their own. But yes, it would be very cool.
That's why I suggested earlier making an app for your cell phone and using NFC to transmit card data. your phone could then store millions of cards. you'd select the card you want to use in the app then touch it to your new "card reader" interface and it transmits the card data.
Most new phones have an NFC antenna, and USB NFC readers are cheap (<$50). Plug it into a Raspberry Pi and have the Pi fake the communication to the game board and there you go...

No need to waste an SD card or USB drive, and if your friends want cards then you just have them download the app and thats it.

If other card reader formats are figured out the app could then be modified to work with them.
this is cool too. baby steps. writing to USB or direct interface is probably the first step after establishing communication. once that's established, then all the fancy stuff would work. gotta learn to walk before you can run.
 

freddiefiasco

Professional
Joined
Feb 20, 2016
Messages
477
Reaction score
84
Location
California, USA
Well, I got the serial adapter in and wired up to the reader/NAOMI. I hooked up RX, CTS and GND on the adapter to the corresponding outputs from either the reader or the NAOMI, and I never receive anything on the RX line. Under certain conditions, I was getting CTS read as intermittent on and off.

When RX from the adapter is wired into TXD on the reader while signal ground is wired, the reader stops responding to the initialization test from the NAOMI. With signal ground removed, it will respond to the test, but nothing gets read.

I'm not sure what else to try with the current hardware I have. I don't have a logic analyzer and am not sure what to look for to get something cheap and functional for this purpose. Any suggestions on what next steps should be?
Do you have the card reader diagram laid out? Can you send me the layout you so I can mimic your setup? I have access to a logic analyzer. Hopefully it will give us more information. I have to look at my documentation but i believe there are a few more I/O you have to tap into to get the initialization to occur. There should also be a sensor trigger that enables the card printer to enable before RX provides a signal. What do you consider cheap and functional? A logic analyzer will give you at least the amount of I/O you need to watch the signals. And i'm talking OLD logic analyzers. The fancy ones now would work for sure. This is just to get the signals to appear when communicating with the whole interface.
 

winteriscoming

Champion
Joined
Feb 16, 2016
Messages
1,400
Reaction score
1,097
Location
Indiana, US
I was just trying to sniff the signals from when the NAOMI and the reader communicate during the initialization sequence. I wasn't trying to send anything. The way I had it wired up, I thought I'd at least see the communication coming from one direction.

I referenced the wiring diagram here:
https://www.google.com/url?sa=t&rct...u9VlOdOgSZHQqfiTA&sig2=zVz5ZHhIjl6fvqAE7t526A

If that doesn't work, search google for Initial D Wiring. The document is called "Initial D 3 Twin Wire.pdf".

Basically CN2 on the reader to CN8 on the NAOMI 2:
CN2 Pin 2 - RXD - RED - CN8 Pin 2 - TXD
CN2 Pin 3 - TXD - GREEN - CN8 Pin 1 - RXD
CN2 Pin 4 - CTS - BLACK - CN8 Pin 4 - RTS
CN2 Pin 5 - RTS - BROWN - CN8 Pin 5 CTS
CN2 Pin 7 - SG - WHITE - CN8 Pin 3 GND
 

winteriscoming

Champion
Joined
Feb 16, 2016
Messages
1,400
Reaction score
1,097
Location
Indiana, US
Good news!

I had my new USB serial adapter wired up to the reader/NAOMI incorrectly.

Now with it wired up so that I'm just getting input from one direction, I monitored what the reader receives from the NAOMI. Basically I think I'm seeing what the reader would see with regards to data coming on the RXT input and anything happening on CTS.

Reading the data in as decimals, I see a series of repeating strings sent to the reader during initialization, a few more smaller strings after initialization during attract mode, and then some during the command to insert a card and read it in. I only saw CTS activity very briefly, I believe after the card was read in, but I'd have to confirm that. I did not see any CTS activity during initialization.

During the request to remove the card, I see a constant repeating string sent to the reader that keeps coming until I remove the card.
 

winteriscoming

Champion
Joined
Feb 16, 2016
Messages
1,400
Reaction score
1,097
Location
Indiana, US
I've ordered a 2nd USB RS232 adapter so that I can monitor the information going both ways.

I'm not sure at the moment how I'll manage monitoring both ports simultaneously, but I might at least be able to open two instances of 232Analyzer where each one monitors a separate port. Ideally I'd be able to set up something to read in both simultaneously in the same window so that I can easily see the sequence of communication back and forth.

Just monitoring what goes to the reader, there really isn't that much going on, so figuring out the correct responses to the NAOMI shouldn't be too difficult to code for from an emulator perspective. Once I get a handle on the two way communication, it's going to be a matter of figuring out what comes in for writing to the card and what goes back when a card is read. I'm really hoping it ends up being pretty straight forward in that whatever string comes in as the data to write to the card is the exact string that goes back when it gets read in. We'll see.
 

winteriscoming

Champion
Joined
Feb 16, 2016
Messages
1,400
Reaction score
1,097
Location
Indiana, US
More good news!

I've successfully communicated with the NAOMI from the USB serial adapter on my laptop!

Just sniffing one direction during the initialization sequence and then swapping pins and sniffing the other direction, I tracked down the send and receive from NAOMI and reader during initialization in the test menu.

I decided to try unplugging the reader and see if I could fake the signals back during the initialization sequence. I wired everything including RTS from the serial adapter into the NAOMI.

One important piece of information I figured out is that the NAOMI expects the reader's RTS to be on. While off, it immediately fails the test and doesn't even send any kind of request.

Using the free version of 232Analyzer, which has some annoying limitations so that you'll buy the full version, I managed to figure out the responses to the output from the NAOMI during the test menu initialization. I didn't have the ability to program any kind of macro, so I was just copy/pasting strings of numbers for the program to send back to the NAOMI. Fortunately the NAOMI sends repeated requests several times before giving up. That gave me enough time to quickly reference the next line I needed to send back.

I allowed the game to boot and got through most of the initialization that comes up there, but it sent a different string at the end than it did during the test menu manual initialization, so I wasn't able to get the game to start.

I'm pretty optimistic that reader emulation is going to be possible with just a simple $10 USB Serial adapter. I'm currently working in Windows and may proceed with figuring out the proof of concept on this platform before porting to something more permanent like the RPi.

Just for reference, if I consider the NAOMI's output as the Question and the computer's (emulated reader) output as the Answer, I used the following to get through the manual initialization in the test menu:
Q: 2,6,64,0,0,0,3,69,
A: 6,2,6,64,160,48,50,3,231,
Q: 2,6,32,0,0,0,3,37,
A: 6,2,6,32,160,48,48,3,133,
Q: 2,7,16,0,0,0,49,3,37,
A: 6,2,6,16,160,48,51,3,182,
6,2,6,32,160,48,48,3,133,
Q: 2,6,32,0,0,0,3,37,
A: 6,2,6,64,160,48,50,3,231,
Q: 2,6,32,0,0,0,3,37,
A: 6,2,6,32,160,48,48,3,133,
Q: 2,6,64,0,0,0,3,69,
A: 6,2,6,122,160,48,50,3,221,
Q: 2,79,122,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,18,
A: 6,2,6,122,160,48,50,3,221,

I'm not sure what to make of it, but that long string that the NAOMI outputs isn't the same every time. In the test menu initialization, it doesn't seem to matter. I could give the same response every time and it indicates that the test was completed without errors.

I'll have to do some more sniffing to see if I can get through the boot initialization sequence.
 

TechnicalMonkey

Student
Joined
Jul 28, 2015
Messages
125
Reaction score
31
Question guys if you don't mind. Could a card reader emulator like this be used for other naomi 2 games? Say Virtua fighter 4 series which have 4, Evo, Final Tuned. Be awesome to be able to collect items and dress up your characters like in the arcades in Japan back when the game was popular.
noJapan VF4s have completely different reader, cards (they are RFID, not magnetic like ID ones), and the way it connected to NAOMI (to MAPLE port(s) through special MAPLE-RS board(s)).
and the worst - it is almost useless without online connection to VF.net services (are they still alive ? I doubt it is), so all you get is fights count increased and stored on card. no items, no dress, no char naming is possible without Sega's VF4 servers.
This answer makes me incredibly sad, but we will take what ever we can get.
 

winteriscoming

Champion
Joined
Feb 16, 2016
Messages
1,400
Reaction score
1,097
Location
Indiana, US
I'm going to try to program in Python with pyserial and hope that the script is easily portable.

If successful in Windows, I'll look into migrating.

My hope is that my current usb serial adapter is compatible with Linux and I can just use that instead of messing with GPIO pins. That way a Windows setup remains a viable option if someone just wants to make up a wiring adapter to the NAOMI and use their laptop.

I don't currently have an RPi setup for netbooting, but using a usb serial adapter might enable the whole LCD setup to stay for netbooting and maybe kick off the script for card reader when an applicable game is booted.

Anyway, I have to get this stuff working before going down that road.
 

gamemaster14

Enthusiast
Joined
Feb 23, 2016
Messages
291
Reaction score
55
Location
The Game Nexus (USA)
I am very glad I had found this topic, I now have all the information I need to wire up that card reader I had purchased cheaply on ebay a couple months back. I am just hopeful it works.

Also great to hear someone is working on emulating the card system because those later races would be easier with an upgraded car.

Does anyone know if F-Zero AX for Triforce uses a similar card or is it completely different?
 

MetalliC

Grand Master
Joined
Nov 19, 2015
Messages
1,172
Reaction score
1,043
@gamemaster14 nice to see you here )

yes, F-Z AX uses similar or even exact same card R/W unit
Dolphin guys RE-d it's protocol based on game code and I see (almost) no differences with ID 1-3
 

MetalliC

Grand Master
Joined
Nov 19, 2015
Messages
1,172
Reaction score
1,043
Just for reference, if I consider the NAOMI's output as the Question and the computer's (emulated reader) output as the Answer, I used the following to get through the manual initialization in the test menu:
can you pleeeease provide same/similar log of same test, BUT with no card(s) inserted ?
 

MetalliC

Grand Master
Joined
Nov 19, 2015
Messages
1,172
Reaction score
1,043
if I not mistaken status in your log says front door is opened, so card can be insterted, or I'm wrong and its closed during INIT ?
 
Top