This section will explain the basic setup of our little project. A lot of other sections will use directories and files in relation to this setup.
Getting the Source and PCB Layout
All required sources and files for a build of hardware and software of the SD2SNES are available from either the official SD2SNES repository or my repository found HERE. Currently, the Rev. K. files are only available on my repository. They are stored in an extra branch called devaltron/RevKWork.
On Ubuntu/Linux, checking this out/cloning the repository is done like this:
mkdir -p ~/git/retroconsoles
git clone firstname.lastname@example.org:DevLaTron/sd2snes.git 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.
The four most important directories here are pcb/, src/, snes/ and verilog/. Everything else is either old and 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 with stuff 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, both written in C. 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 will 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. They are loaded by the firmware onto the FPGA from the SDCard. (They are stored in the sd2snes directory on the card). They can be downloaded 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. Loosely speaking, this is a Super Nintendo ROM file, the only difference being that it’s loaded on startup by the firmware, and the firmware has ways to communicate with the ROM file while running. There is a dedicated section on building the user interface, but the user interface can also be downloaded pre- built.