Need help! How to debug on real hardware?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
Haruka
Posts: 45
Joined: Fri Mar 23, 2018 8:58 pm

Need help! How to debug on real hardware?

Post by Haruka » Wed Jul 01, 2020 11:09 pm

Hello guys. I'm working on a mapper hack project recently, and the hacked ROM works perfectly on almost all modern emulators.
But when running on a flash cartridge, the ROM locks up immediately after power-on. Solid color screen, no sound, no response on controller input, no response on hardware reset...
Other ROMs work fine on this cartridge so this is not the hardware's fault.
Tested on several consoles including famiclones without any good news.
So I think there must be something wrong on this ROM hack that only affects real hardwares.
But where? Since it works on all emulators, I can't figure out the problem. I wonder what I should do to debug on real hardware.
Could anyone please give me some hints? I'm eagerly waiting for your replies! Thank you!

And here is the ROM patch.
Salamander (C) - Namcot163.zip
(66.68 KiB) Downloaded 18 times
Please apply it on Salamander (j).nes.

User avatar
Controllerhead
Posts: 89
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Need help! How to debug on real hardware?

Post by Controllerhead » Thu Jul 02, 2020 12:41 am

Haruka wrote:
Wed Jul 01, 2020 11:09 pm
But when running on a flash cartridge, the ROM locks up immediately after power-on. Solid color screen, no sound, no response on controller input, no response on hardware reset...
It doesn't seem to run on my Everdrive either when the original does. It also seems like its waiting for 2 vBlanks on startup and zeroing memory. Have you tested any other games with that same mapper on your flashcart? It could be an issue with your code, but perhaps there are issues with the mapper emulation...
Last edited by Controllerhead on Thu Jul 02, 2020 9:21 am, edited 1 time in total.

Haruka
Posts: 45
Joined: Fri Mar 23, 2018 8:58 pm

Re: Need help! How to debug on real hardware?

Post by Haruka » Thu Jul 02, 2020 1:05 am

Yes, I tested other mapper 19 games (both official and my other mapper hack ROMs) on my cartridge and every game works perfectly. Only this one does not work on it.

User avatar
gauauu
Posts: 699
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: Need help! How to debug on real hardware?

Post by gauauu » Thu Jul 02, 2020 7:27 am

Did you test using mesen, with the "randomize power-on state for mappers" selected?

Many of my startup issues (particularly after making mapper changes) have been that a cart boots into a random/unknown bank, while most emulators always start in the same bank. So it works well on an emulator, but fails on hardware. You need to check and make sure it can boot with any bank configuration active. Mesen can help with that.

Haruka
Posts: 45
Joined: Fri Mar 23, 2018 8:58 pm

Re: Need help! How to debug on real hardware?

Post by Haruka » Thu Jul 02, 2020 7:47 am

Yes exactly. I tested on many emulators including mesen.
And I always enable this on every emulator that provides this option.

Sour
Posts: 815
Joined: Sun Feb 07, 2016 6:16 pm

Re: Need help! How to debug on real hardware?

Post by Sour » Thu Jul 02, 2020 8:45 am

Since you're testing on a flash cartridge, it's hard to know if the problem is the flash cart (e.g the FPGA implementation of mapper 19) or the actual hardware without actually testing on a namco 163 board. There are also a number of variants for this board/mapper, and historically some emulators used heuristics/etc. to determine which variant to use - it's possible the flash cart's behavior differs here. If the flash cart supports NES 2.0 headers, try setting the exact mapper+submapper, work/save ram size, etc. for the board you're using.

Haruka
Posts: 45
Joined: Fri Mar 23, 2018 8:58 pm

Re: Need help! How to debug on real hardware?

Post by Haruka » Thu Jul 02, 2020 8:53 am

Well, it is not fpga-based.
It is a legit famicom cartridge (Namco Classic) that removed both mask ROM chips and replaced with flash chips. And I programmed it using kazzo.

EDIT: After written the ROM to the flashcart I then dumped it and compared the result with the ROM itself. Both identical on every byte, which proved the ROM is fully and correctly written to the chips.

Sour
Posts: 815
Joined: Sun Feb 07, 2016 6:16 pm

Re: Need help! How to debug on real hardware?

Post by Sour » Thu Jul 02, 2020 12:06 pm

I tried randomizing some of the power on state for this mapper in Mesen, but nothing I've tried (including removing all save ram) appears to cause what you're describing.

Your hack's PRG size is 128kb, is the chip on your board also 128kb? If you're flashing a 128kb rom on a 256kb/512kb chip (Namco Classic is 256kb) and all the PRG lines on the board are connected to the chip, the board will end up booting in the last 8kb of the 256/512kb chip, which will presumably be empty. If this isn't it, I'm out of ideas, unfortunately.

Haruka
Posts: 45
Joined: Fri Mar 23, 2018 8:58 pm

Re: Need help! How to debug on real hardware?

Post by Haruka » Thu Jul 02, 2020 5:33 pm

I used two 512kb flash chips. But I connected both A18 to +5v to half their sizes. So they are 256k now.

From what I've already learned, kazzo will automatically padding the ROM to fill up the whole chip if the PRG/CHR of the ROM is smaller than the chip size.
And I also tested some smaller ROMs. (e.g. Mappy Kids, Youkai Douchuuki and others) All work fine.

I also tried doubling the PRG manually to make the ROM 256k+256k just for 100% sure. The result is still a big nope.

User avatar
Controllerhead
Posts: 89
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Need help! How to debug on real hardware?

Post by Controllerhead » Fri Jul 03, 2020 11:48 pm

So, your mapper hack works on every emulator you've tried; and crashes instantly on every flashcart in every console; and even the real board itself with flashed chips in every console you've tried ...wow man. That's a rough one.

At this point ....uh ....perhaps trigger the APU as soon as possible to generate a tone and see if you can hear something and just loop forever, if you can hear it, step forward with that code a few lines at a time and try and see where it's crashing at... I would also try and squeeze a valid reset vector at the end of every bank to generate that test tone or something. Try to force any signs of life and work from there... Godspeed!

Haruka
Posts: 45
Joined: Fri Mar 23, 2018 8:58 pm

Re: Need help! How to debug on real hardware?

Post by Haruka » Sat Jul 04, 2020 1:33 am

That's indeed a way of solution, although it is extremely tedious and low-efficiency. Anyway I'll try it until I find a better method.
Flashing the cartridge again and again using kazzo is very time-consuming. Maybe I should borrow a powerpak or Everdrive N8 from my friends, which is far more faster when updating the ROM on the flashcart.

Oziphantom
Posts: 856
Joined: Tue Feb 07, 2017 2:03 am

Re: Need help! How to debug on real hardware?

Post by Oziphantom » Sat Jul 04, 2020 2:30 am

The way you do this normally is you change the RGB colour emphasis flags. Not sure how well they show up on black, so you might need to set something into colour 0 to make it more visible.

So pick a point
Set Red
another
set Blue
another
set Green
another
Red + Blue
another
Red + Green
....

Then you run the code, and see what colour you get. Say you get Purple.
Then you know its stops between Green and purple. You remove all the old ones, then insert them finer grained between where you had green and purple. this lets you find the point in 2~3 test runs usually.

Post Reply