SD2SNES Assembly – Source code and preparations

First steps…

This section will explain the basic setup of our little project by fetching the SD2SNES source code and having a look at it. A lot of other sections will use directories and files in relation to this setup.

Getting the source and PCB Layout

First off, all required SD2SNES source code for a build of hardware as well as software is available from GitHub. Either use the official SD2SNES repository or my own clone, which can be found HERE. Currently, the Rev. K. files are only available on my repository. You can access them through an extra branch called devaltron/RevKWork containing the needed files.

On Ubuntu/Linux, checking this out/cloning the repository is done like this:

mkdir -p ~/git/retroconsoles
cd ~/git/retroconsoles
git clone git@github.com:DevLaTron/sd2snes.git sd2snes
cd sd2snes
git checkout -b devlatron/RevKWork origin/RevKWork

This will create and populate the git repository in your home directory.

Having a look around

First, let’s have a look at the new folder and what’s in it:

bin/         Binary files go here that are used for some expansion chips (BSX, DSP, Cx4)
cic/ Source and compiled files for the CIC chip. We need this later!
gfx/ Some image files, not relevant to us for now.
lbr/ Not used.
misc/ Not used.
mk1-src/ Not used.
pcb/ PCB construction data. We'll need this very soon!
snes/ This is the code for the SNES menu, which is SNES assembler.
src/ Source files, contains a lot of code used to program the Microcontroller.
utils/ Some small utilities used in the other code.
verilog/ Source code for the FPGA configurations.

SD2SNES source code directory information

The four most important directories here are pcb/, src/, snes/ and verilog/. Everything else is either old, outdated, or only support stuff that we’ll just use when we get there. It’s all a bit hacky and not very well maintained. Some stuff is juggled together, but we’ll get the hang of it. Let’s have a look at those for directories in the order of importance:

pcb/

There is a lot of crud in this directory. You can ignore everything except pcb/kicad/RevK for now, which is the directory that contains the Revision of the PCB schematics that we’re interested in. We can load the project file in this directory in KiCAD to get all the information we need to build our PCB. More on this later.

src/

This directory contains the actual firmware source code as well as the source code for the bootloader and both are written in C. Remember, the bootloader is the most critical component in this directory, as the firmware can be downloaded pre- built. The src/bootldr directory also comes with Makefiles that flash it onto the Microcontroller. The actual firmware will then be loaded from the SDCard, so it’s required at a much later step in the process compared to the bootloader. Flashing the Bootloader is akin to breathing life into the SD2SNES, as after this step is successful, most work can be done by changing files on the SDCard.

verilog/

These are the FPGA configurations written in Verilog. This is what gives the FPGA on the board the capability to act as different chips. These are loaded by the firmware onto the FPGA from the SDCard. (They are stored in the sd2snes directory on the card). You can download them pre-built, but we’ll go into the process of building these from scratch in a dedicated section.

snes/

This is the SD2SNES user interface. In lose terms, this is a Super Nintendo ROM file. The only difference is that it’s loaded on startup by the firmware, and has hooks that allow it to communicate with the firmware. There is a dedicated section on building the user interface, but it can also be downloaded pre- built.