Tutorial: Building a Sega Dreamcast USB coder's port for GDB debugging

Discussion in 'Engineering & Reverse Engineering' started by Cooljerk, Sep 6, 2019.

  1. Cooljerk

    Cooljerk

    NotEqual Tech, Inc - VR & Game Dev Oldbie
    4,275
    1
    18
    A quick and dirty tutorial to guide people through adding a USB development port to their Sega Dreamcast:

    The Sega Dreamcast was one of the most forward thinking consoles ever. One of its best features is the least used: this serial port on the dreamcast is very important for modern dreamcast homebrew.

    [​IMG]

    One of the most apparent uses today is the sd card adapter. This gives the Dreamcast a form of large persistent storage that homebrew games can use. These are cheap and widely available on ebay.

    [​IMG]

    The problem with the serial port is that it has a very unique form, its very hard to source connectors for it. You can make them from hdmi cables but its difficult. Those sd card readers provide a connector that can be sacrificed. For what? A coders cable! Coders cables are an essential part of any Dreamcast Homebrew tool kit. It lets you link your dreamcast up to a pc to do remote debugging, provides a terminal to output, and lets you send executables without burning a disc. Super useful!

    Unfortunately, building a cable is pretty tricky. Tutorials online date back to 2001, and expect a serial port on your pc. And then sourcing connectors. One alternative is to use the $200+ broadband adapter, but thats prohibitively expensive. One other alternative is to solder the cable directly to your dreamcast serial port, but that involves desoldering the existing port and ruins the ability to use an sd card adapter. And its tricky soldering. And the tutorials online to do this are old.

    So let's build a newer cable, as cheaply and easily as possible. Its not 2001 anymore, we can use usb! This FTDI FT232R usb breakout board and chip is perfect for this. They are like $2 on ebay. Make sure you get the red kind, as those are the type that will power via +5V from the USB cable.

    [​IMG]

    Start by taking the top cover off of your Dreamcast. We will have to remove the motherboard, which is under EVERYTHING. Start with the psu on the left.

    [​IMG]

    The Dreamcast psu is held down by screws but is still hard to pull out even after they are removed. Thats because the terminal connection at the bottom has metal prongs going thru the board. So pull up with a bit of force.

    [​IMG]

    Once the Dreamcast psu is off, we can move on to taking out the gdrom drive. Its attached to a metal plate held with screws.

    [​IMG]

    The removed drive:

    [​IMG]

    Next up, we need to remove the Dreamcast controller board. Its sort of tricky, there is a plastic piece holding the controller port that is connected by two screws in the middle.

    [​IMG]

    Make sure you disconnect the Dreamcast fan and ribbon cable carefully, then move the controller board out of the way.

    [​IMG]


    The last step is to remove the Dreamcast metal plate that protects the motherboard. Its just held in by simple screws.

    [​IMG]

    The exposed Dreamcast motherboard. Old tutorials online would tell you to solder on this side of the board, but thats actually a tiny bit tricky.

    [​IMG]

    This is an example of how another user online recommended you'd solder to the Dreamcast motherboard. I find working in that cramped space really difficult myself, but then again I'm not great at soldering. But, there exists a secret alternative that's way easier!

    [​IMG]

    On the back of the Dreamcast motherboard, if you study hard enough, you'll realize there are a bunch of unpopulated ports all over the board. These are called test points. They are intended for diagnostic devices to be soldered to, to test every part of the dreamcast.

    [​IMG]

    Up in the right corner of the back of the Dreamcast exists 5 small solder test points with circles around them. Those 5 points are the serial line connections!

    [​IMG]

    One is tx, for sending data. One is rx, for receiving data. One is rts, for request to send. One is cts, for clear to send. And one is ground. All we need to communicate from our Dreamcast via usb! All that needs to be done is to wire those Dreamcast test points to the appropriate ports on our ft232r usb breakout board, and we'll have a dedicated usb coders port on our dreamcast! Perfect for Homebrew. Reminder that this is a serial connection, so RXD on the Dreamcast goes to TXD on the USB Breakout Board, and TXD on the Dreamcast goes to RXD on the USB Breakout Board. ALSO: RTS on the Dreamcast goes to CTS on the USB board, and CTS on the Dreamcast goes to RTS on the USB board. Don't forget to wire up Ground as well, you can find that in any obvious place.
     
  2. Cooljerk

    Cooljerk

    NotEqual Tech, Inc - VR & Game Dev Oldbie
    4,275
    1
    18
    It's wise to solder in a brightly lit place with good ventilation. If you're lacking in space, a stove/oven is usually a good spot, as they usually have overhead lighting and a fan to blow away smoke. Make sure you use fan while soldering to avoid breathing chemicals.

    [​IMG]

    We need to solder some wire onto 4 test points in the lower corner of the pic. These test points are tiny, they look larger through the magnifying glass I use.

    [​IMG]

    Keep in mind you don't want too much exposed wire when you are soldering, or else you might create accidental bridges. Expose just a tiny piece of metal in your wire.

    [​IMG]

    try to position your 18 gauge wire in a way so that it lays naturally on the test point pad.

    [​IMG]

    You should probably use flux to make for cleaner connections. I use liquid flux and just flood the area I'm working on.

    [​IMG]

    in the tip of your soldering iron after flooding the area with flux, then place it on top of the test point pad with the wire in between, wait a second, and you'll have a clean solder point.

    [​IMG]

    you need to tap these 5 points on the dreamcast board. They map to ground, data transmission, data reception, request to send and clear to send. We need to map those points to the appropriate points on our FTDI FT232R.

    [​IMG]

    Remember: Connect TXD on Dreamcast to RXD on FT232R, and RXD on Dreamcast to TXD on FT232R. Also connect CTS on the Dreamcast to RTS on the USB board, and RTS on the Dreamcast to CTS on the USB board. With all this set, we now have a USB debug port on our dreamcast!

    [​IMG]

    You can connect your running dreamcast to a host PC through this port using a USB cable. Your Host PC will see your dreamcast connected as a serial port, and you can use a program called DC-Load-Serial to debug and execute homebrew Dreamcast games in real time on a retail unit. Far, faaaaar cheaper than trying to buy a Katana dev kit!

    Took a little wiggling. Once everything is properly crossed, files transfer like normal.

    [​IMG]

    All set up and working:

    [​IMG]

    Remember to compile your c/cpp source codes with the -g debugging flag: it's important that the -g flag be the very first flag passed. If it is passed after any other flag, the debug symbols will still be stripped. Also make sure when you launch dc-tool-ser and send your elf to the Dreamcast that you also use the -g flag, again, as the very first flag sent. You need sh-elf-gdb to actually debug the Dreamcast, you can configure to build it from the gdb source using the following flags:

    Code (Text):
    1. gdb-6.6/configure --target=sh-elf --prefix=/home/linus/sh1
    Then just make and make install to put it into your binary folder in your linux partition.

    [​IMG]

    Happy debugging!
     
  3. biggestsonicfan

    biggestsonicfan

    Model2wannaB Oldbie
    969
    8
    18
    Formerly Sonic the Fighters
    I used to own a DC Serial cable. Never got it back from the person that borrowed it, sadly.
     
  4. Cooljerk

    Cooljerk

    NotEqual Tech, Inc - VR & Game Dev Oldbie
    4,275
    1
    18
    I can walk you through building a new cable if you'd like, including sourcing a connector from an hdmi cable. The process is a bit different, if you want a serial cable and not a usb, you'll need some resistors and a different kind of chip. Honestly much easier to do a usb port.
     
  5. biggestsonicfan

    biggestsonicfan

    Model2wannaB Oldbie
    969
    8
    18
    Formerly Sonic the Fighters
    Oh nah, I don't really want to do that. It actually had a legitimate connector from some sort canabilized official cable? I'm not sure. Oh well. Thanks for the offer tho!
     
  6. Cooljerk

    Cooljerk

    NotEqual Tech, Inc - VR & Game Dev Oldbie
    4,275
    1
    18
    That'd be the Neo Geo Pocket Link Cable, sounds like you grabbed one from Lik Sang. Those were really good coder's cables because they would automatically convert +5v to 3.3V for you, the chip used in those cables, the MAX3222CPN required 3.3V to operate. Most online tutorials for building a serial cable just leave it up to the person making the cable to figure out a way to get a 3.3V source to the chip, with many just using an external power source, which is annoying.

    That's one of the big benefits of my tutorial above: don't have to worry about powering anything manually, the breakout board does everything for you through the USB port.

    All that said, someone can totally combine these two approaches -- build a serial port adapter, and instead of running it through a coder's cable, feed it into the FT232R as an external USB port. That would allow someone to do the mod entirely without opening their dreamcast. Only problem is doing that is much harder, not just because of sourcing the connector, but also because the point you'd be soldering to would be smaller.
     
  7. biggestsonicfan

    biggestsonicfan

    Model2wannaB Oldbie
    969
    8
    18
    Formerly Sonic the Fighters
    Ah yes, it was the Lik Sang DC Coder's Cable.