How to debug custom sd2snes fw? (Possible n00b question)

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
kmeisthax
Posts: 4
Joined: Thu Nov 23, 2017 2:50 pm

How to debug custom sd2snes fw? (Possible n00b question)

Post by kmeisthax » Thu Nov 23, 2017 3:23 pm

Some context first: I am busy attempting to add SPC7110 support to the sd2snes firmware. I have gotten to the point where I have everything but the Epson RTC implemented. I also had to alter the MCU firmware to load the SPC7110 FPGA bitstream file, which I placed on the SD card alongside my custom firmware.img. It boots normal games just fine, but any (non-RTC) SPC7110 software fails to load. It doesn't even crash. It just hangs at "Loading..." forever.

I would like to be able to debug the MCU firmware somehow, so I can see which step is actually hanging the MCU. I noticed the sd2snes cart has a mini-B USB port present, so I plugged a computer into it, but nothing seems to appear on the port. Is there something I am missing? I would assume it would provide at least a serial adapter interface for reading all the printf messages.

For the record, I have pushed all my code onto this branch of my fork. The only other change I made to the MCU firmware was building it with ARM's own GCC toolchain, instead of the one recommended in the readme, since I wasn't able to get that toolchain to build on Windows or Ubuntu. I'm under the assumption that if there is some kind of serial debug functionality in the MCU firmware, that it isn't particular to the snowcat.de provided toolchain.

qwertymodo
Posts: 774
Joined: Mon Jul 02, 2012 7:46 am

Re: How to debug custom sd2snes fw? (Possible n00b question)

Post by qwertymodo » Thu Nov 23, 2017 4:18 pm

I'm pretty sure ikari has said that the SD2SNES's built-in RTC is actually based on the SPC7110, so you can probably use that instead of reinventing the wheel...

kmeisthax
Posts: 4
Joined: Thu Nov 23, 2017 2:50 pm

Re: How to debug custom sd2snes fw? (Possible n00b question)

Post by kmeisthax » Thu Nov 23, 2017 6:22 pm

Well, that'll help out a bunch once I get the MCU to actually load the new FPGA config...

Optiroc
Posts: 129
Joined: Thu Feb 07, 2013 1:15 am
Location: Sweden

Re: How to debug custom sd2snes fw? (Possible n00b question)

Post by Optiroc » Fri Nov 24, 2017 10:40 am

Have you tried to get in touch with ikari_01 about it? I’m sure he’d be happy to help with getting this addition to a releasable state. He’s usually around in #snesdev on IRCNet.

redguy
Posts: 6
Joined: Sat Jun 24, 2017 10:22 am

Re: How to debug custom sd2snes fw? (Possible n00b question)

Post by redguy » Fri Nov 24, 2017 3:40 pm

There's a 14-pin bus on the side of the sd2snes (next to the battery). 3 of those pins are the UART output where the firmware printf output goes to. You can solder in a header and get a 3-wire UART to USB cable to view the output in a serial terminal. 3-GND, 6-RX, 7-TX. Hopefully the attached picture helps. It probably won't be a problem for what you are doing, but the printf code is not reentrant which can cause issues in the interrupt handlers.

The USB port isn't clocked/enabled in the current 0.1.7x firmware.
Attachments
sd2snes_uart_connections.jpg

kmeisthax
Posts: 4
Joined: Thu Nov 23, 2017 2:50 pm

Re: How to debug custom sd2snes fw? (Possible n00b question)

Post by kmeisthax » Sat Nov 25, 2017 2:24 pm

Thanks a ton redguy, I'll try those UART pins next time I get a chance with a soldering iron. Wonder why the USB port is even there...

redguy
Posts: 6
Joined: Sat Jun 24, 2017 10:22 am

Re: How to debug custom sd2snes fw? (Possible n00b question)

Post by redguy » Sat Nov 25, 2017 3:01 pm

I recall seeing something about loading the firmware over JTAG using USB when reading through the source. Maybe that's how it was done before the bootloader supported it from the SD card.

There is a custom firmware that enables the USB port and adds some features:
viewtopic.php?f=12&t=16720

kmeisthax
Posts: 4
Joined: Thu Nov 23, 2017 2:50 pm

Re: How to debug custom sd2snes fw? (Possible n00b question)

Post by kmeisthax » Sun Dec 03, 2017 9:31 pm

So, I haven't got a chance to find a UART cable yet (I'm worried about getting a fake one and then it getting bricked by FTDI) but I did notice the MCU firmware actually does use the LEDs as a 3-bit error output when FPGA errors occur. Specifically, it's the LED_PANIC_FPGA_DEAD pattern, which fires if the FPGA fails to return the correct test token over the SPI bus. I audited all my changes to main.v and it turns out I was a *little* more overzealous when getting rid of bsx/dsp and accidentally removed some of the cheat outputs, which I guess broke SPI? Adding them back in means that I'm now greeted with a failing SPC7110 test ROM when I load an SPC game (everything reads NG), but that's better than the MCU not starting the game at all.

redguy
Posts: 6
Joined: Sat Jun 24, 2017 10:22 am

Re: How to debug custom sd2snes fw? (Possible n00b question)

Post by redguy » Mon Dec 04, 2017 9:27 pm

The cheat module and associated $200B snescmd_buf handle some features for the menu like fades and reset related things. The firmware fully unlocks the $2A00-$2BFF block for the menu and then it gets locked (open bus to SNES) except for certain events like NMI/IRQ hook execution. The hook code attempts to read the controller 1 buttons (usually too early with AJR enabled) and performs the WRAM cheat writes along with button checks for resets+other commands.

Optiroc
Posts: 129
Joined: Thu Feb 07, 2013 1:15 am
Location: Sweden

Re: How to debug custom sd2snes fw? (Possible n00b question)

Post by Optiroc » Mon Jan 15, 2018 4:58 am

I'm very curious about this project! Did you make any progress, kmeisthax?

Post Reply