I recently designed a game cartridge programmer/reader for the Sega Master System (SMS)
/ Mark III / Game Gear ecosystem, because I wanted to program the SMS and Game Gear
flash cartridges I designed, but as it turns out, it is also quite useful to try out games from
my cartridge collection in emulators.
My design features two slots, one for each type of SMS cartridge (Japan vs. overseas). Not much to
mention here, except that one must take care not to insert the cartridge in the wrong slot!
Example using a cartridge from north-america
Example using a japanese game
Game Gear support
There is no dedicated Game Gear cartridge slot on-board, but I also designed an adapter which
uses the 50 pin SMS slot:
Example using a Game Gear game
The Game Gear cartridge adapter
I was not able to locate a source for new Game Gear connectors (reproduction or original) so
instead, I bought a nearly "total loss" console on an auction site. It had dirt, rust, leaked batteries,
bad capacitors... you name it. Thankfully, the cartridge connector was still usable!
If you know a store that sells Game Gear connectors (new or refurbished) please let me know. It would
be nice if I could make ready to use adapters.
Meanwhile, the circuit boards (without a connector) are available from my online store, for those who would like to build
their own adapter.
Bare PCB, component side
Bare PCB, solder side
Sega card / Mycard support
My design does not have a Sega card / My card slot either, but those can be easily read using
a Card Catcher:
Example using a Card Catcher
SG-1000 support
The 44 pin cartridge slot can also be used to read SG-1000 cartridges. (And also very likely
SC-3000 cartridges as well)
Lecture d'un jeu SG-1000
Python GUI
Warning: Never insert/remove a cartridge when the power is ON. (disconnect the USB cable first!)
There is now a user interface based on PySimpleGUI. At the moment it is only tested under Linux and is
distributed in source code format, but eventually I plan to use pyinstaller to make something easier.
To run it, make sure you have the required python packages installed and start client/smsp.py.
At the time of this writing, the UI features are:
Can read normal game cartridge ROMs
Can erase, blank check, program and verify supported flash cartridges
Hex view of the loaded file or content read from a cartridge.
Displays MD5 sum (useful to validate a ROM dump)
Reading a ROM (manually)
Warning: Never insert/remove a cartridge when the power is ON. (disconnect the USB cable first!)
This circuit connects to a PC through USB and works as a virtual serial port. Under Linux,
a character device such as /dev/ttyACM0 should appear when you connect the cable. Under Mac it should
be similar, but the character device will have a different name. Under Windows 10, it should be COMx.
To connect to the reader, you simply start your favorite communication software (for instance, minicom under Linux)
et point it to the virtual serial port. You may then interact with the firmware using keyboard
commands. You may type ? followed by ENTER to show help:
> ?
Supported commands:
boot Enter DFU bootloader
reset Reset the firmware
init Init. mapper hw, detect cart size, detect flash...
r addresshex [length]
dx Download the ROM with XModem
ux Upload and program FLASH with XModem
ce Perform a chip erase operation
>
Before using the dx command to download the ROM contents, you should run the init
command to auto-detect the ROM size.
The ROM size is determined by detecting after which 16k bank the contents starts to repeat. This works
fine for all the games I tested so far, but I do plan to add a way to manually specify the size
in a future version. (Sooner or later, according to demand or my own need, whichever comes first)
> init
54 4d 52 20 53 45 47 41 4d 57 eb 74 04 51 00 4c
Bank 0 CRC: c1b6, first byte f3
Bank 1 first byte: 45
Bank 2 first byte: 00
Bank 4 first byte: 00
Bank 8 CRC: c1b6
ROM size set to 131072
Cartridge type: ROM
>
Ok, so this one is 128KB. Now the download can be started.
> dx
Dumping the rom using XMmodem. 1024 blocks.
Please start the download... CTRL+C to cancel.
You must then start the download from within your communication program. For instance, with minicom under Linux, one must
hit CTRL+A, followed by R, select XModem as the protocol and provide a filename to start the download.
Reading a ROM (python script)
I also created a small python script to automate the steps given in the previous section. The script
is called dumpcart.py, and the help (-h argument) at this time displays the following:
usage: dumpcart.py [-h] [-i] [-r OUTFILE] [-p INFILE] [-d DEVICE]
Dump/Program tool for smscprogr
optional arguments:
-h, --help show this help message and exit
-i, --info Provide information about the cartridge
-r OUTFILE, --read OUTFILE
Read the cartridge contents to a file.
-p INFILE, --prog INFILE
(Re)program the cartridge with contents of file
-d DEVICE, --device DEVICE
Use specified character device.
As an example, here is how I read a cartridge under Linux:
./dumpcart.py -d /dev/ttyACM0 -r supergame.sms
The script is a bit verbose at the moment, because if something goes wrong, I want to know exactly why.
But if all goes well, the file supergame.sms will be created and can be opened as-is by
most sms emulators such as meka, higan and many others.
Programming a cartridge (manually)
Using your communication software (such as minicom under Linux) you should first type
the init command, which should detect the flash chip. (As shown by
the last line below)
> init
init 54 4d 52 20 53 45 47 41 ff ff 51 8a 99 99 00 4c
Bank 0 CRC: da45, first byte f3
Bank 1 first byte: 78
Bank 2 first byte: dd
Bank 4 first byte: 44
Bank 8 CRC: da45
ROM size set to 131072
Cartridge type: FLASH. Manufacturer ID=0xc2, Device=0xa4 => MX29F040 (supported)
The detected size may be incorrect (as is the case here, since this is a 512 KB cartridge,
not merely 128KB) but detected size does not matter when programming.
Before writing however, the contents of the cartridge (or rather, the flash chip contained within)
must be erased using the ce (Chip Erase) command:
> ce
Erasing chip...
Done.
>
This normally takes a few seconds. Next, you simply upload the ROM (.SMS or .GG file) to program
it into the flash chip. To do so, first start the upload using the ux command:
> ux
READY. Please start uploading.
Next start the XModem upload using your communication software. For instance, with minicom
under Linux, one does this by hiting CTRL+A followed by S (for Send), selecting XModem and the ROM file.
The flash chip is programmed on the fly during the upload. When the upload ends, programming is complete.
Important: Do not forget to disconnect the USB cable before removing your cartridge!
Programming a cartridge (python script)
The python script I wrote can also automate the steps necessary to program a cartridge. (See also the Reading a ROM (python script) section)
To program a game, for instance, my homebrew donkey.sms, I use the following command:
./dumpcart.py -d /dev/ttyACM0 -p donkey.sms
The script takes care of erasing the flash (ce command), of starting the upload (ux command)
and of uploading the contents of the file passed in argument (donkey.sms in this example) using the XModem protocol.
Sending command: ce
ce
Erasing chip...
Done.
>
Starting upload
Sending command: ux
Uploading
Upload completed with success.
Sending command:
Done.
When the script exits, programming is complete. Try out your game!
Important: Do not forget to disconnect the USB cable before removing your cartridge!
Programming a raphnet cartridge
Game programmed and running!
Firmware
The firmware is open source in the hope that anyone who need to change something to better
suit their needs or add new features (supporting other flash types or another mapper for instance)
can do it on the spot and with ease.
That said, don't hesitate to contact me if something is not working or need a new feature. I'll see
what I can do.
The firmware is programmed into the micro-controller using the Atmel DFU bootloader. Under Linux,
you can use a tool called dfu-programmer. This example is based on Linux, but dfu-programmer also
exists for Windows.
Step 1: Entering bootloader mode
dfu-programmer looks for an Atmel DFU USB device, not a virtual serial port, so the boot
command must first be sent to the firmware to request execution of the bootloader. As soon as this command is
received, the virtual serial port will disappear and your communication program will likely show an error
message, but in the background the micro-controller will appear on the USB BUS with a new identity (Atmel
Atmega32u2 in bootloader mode).
Step 2: Erasing, programming and starting the firmware
Just ignore the error in your communication software and open another terminal, then use dfu-programmer
to erase, program and finally start the new firmware.
The commands you need to type (init, ce, ux, dx, etc...) are as exposed above. When the time comes
to transfer a file (programming or dumping a cart) you must start an XMODEM transfer in the correct
direction from the File->Transfer->XMODEM menu:
Disclaimer
I cannot be held responsible for any damages that could occur to you
or your equipment while following the procedures present on this page.
Also, I GIVE ABSOLUTELY NO WARRANTY on the correctness and usability
of the informations on this page. Please note, however, that the procedures
above have worked in my case without any damages or problems.