NES/SNES 240p dejitter mod

The place for all discussion on gaming hardware
User avatar
NoAffinity
Posts: 1019
Joined: Mon May 07, 2018 5:27 pm
Location: Escondido, CA, USA

Re: NES/SNES 240p dejitter mod

Post by NoAffinity »

^All of my failures were related to speed. it failed every time with JTAG clock set to 100khz, worked fine at 8khz and 16khz. that may very well be the first place to look/adjust.

Some other things which may or may not be helpful:

I think this is probably the most useful infromation, from openocd documentation:

Code: Select all

2.4 USB-JTAG / Altera USB-Blaster compatibles

These devices also show up as FTDI devices, but are not protocol-compatible with the FT2232 devices. They are, however, protocol-compatible among themselves. USB-JTAG devices typically consist of a FT245 followed by a CPLD that understands a particular protocol, or emulates this protocol using some other hardware.

They may appear under different USB VID/PID depending on the particular product. The driver can be configured to search for any VID/PID pair (see the section on driver commands).

    USB-JTAG Kolja Waschk’s USB Blaster-compatible adapter

    Link: http://ixo-jtag.sourceforge.net/
    Altera USB-Blaster
    Link: http://www.altera.com/literature/ug/ug_usb_blstr.pdf 
It's not clear if this is already included by way of the ftdi libraries, but something like the following may hone in the compatibility:

> openocd -f /interface/usb_blaster.cfg

It also seems the USB Blasters can operate in bitbang mode or byte shift mode. I haven't found how to force bitbang mode. I believe bitbang is default for openocd, but that may be worth purusing other things don't pan out.

Lastly, I had at least one failure that was a result of not having the dejitter board connected to the pi :? while it appeared to program with nearly ~60% completion before failing. :oops:
samson7point1
Posts: 58
Joined: Sun Jun 26, 2016 6:44 pm

Re: NES/SNES 240p dejitter mod

Post by samson7point1 »

Well, I finally managed to get it to program successfully, though it was far from consistent. But I'll explain what worked in case it's helpful to anyone else.

After looking at "official" USB Blaster prices, yeah, there's no way mine isn't a cheap clone. I paid more than $10, but not $300.

So based on a thread (that I think NoAffinity found first) which explained that OpenOCD will error out when it can't get latency timing because that's not a feature with USB Blaster clones, I wound up messing with the OpenOCD source code to "patch" out the check.

I also shorted the R4 resistor on the dejitter board per marqs' recommendation.

And finally, I switched to a higher-current 5V power supply. The one I was initially using was rated at 700mA - and it may not have even been that high. I switched to a 2400mA supply and the OpenOCD was able to program the chip on the first try.

Just to verify it was necessary, I replaced the R4 resistor and was back to getting failures during programming. When I re-shorted R4, it took a couple of tries before I could get it to work again.


The TL;DR version of "patching" OpenOCD to work with USB Blaster clones:
Some of this will be different if you're using a Debian-based distro like Ubuntu, or unnecessary if you prefer just to 'make install', but I thought I'd post it here because as far as I know this info is no longer available anywhere else.

Download and install the Source RPM for OpenOCD 0.10.0 for your distro.
This puts the source tarball at ~/rpmbuild/SOURCES/openocd-0.10.0.tar.bz2
Unpack it:

Code: Select all

cd ~/rpmbuild/SOURCES/
tar -xf openocd-0.10.0.tar.bz2
With the source tarball extracted, edit the source file that controls the latency timer check:

Code: Select all

vim ~/rpmbuild/SOURCES/openocd-0.10.0/src/jtag/drivers/usb_blaster/ublast_access_ftdi.c
Comment out lines 105-109 and save the file:

Code: Select all

105 /* if (ftdi_get_latency_timer(ftdic, &latency_timer) < 0)
106       LOG_ERROR("unable to get latency timer");
107    else
108       LOG_DEBUG("current latency timer: %u", latency_timer);
109 */
Then while still in the directory "~/rpmbuild/SOURCES", rename the old tarball and replace it with the edited source:

Code: Select all

mv openocd-0.10.0.tar.bz2 openocd-0.10.0.tar.bz2.old
tar -cf openocd-0.10.0.tar openocd-0.10.0
bzip2 openocd-0.10.0.tar
With that done build the RPM

Code: Select all

cd ~/rpmbuild/SPECS
rpmbuild -bb openocd.spec
Of course this requires that you have "rpm-build" installed, and will probably bug you for a bunch of dependencies.

When successful rpmbuild should give you the location of the RPM

Code: Select all

Wrote: /home/user/rpmbuild/RPMS/x86_64/openocd-0.10.0-2.fc26.x86_64.rpm
Wrote: /home/user/rpmbuild/RPMS/x86_64/openocd-debuginfo-0.10.0-2.fc26.x86_64.rpm
From there just install the newly-created RPM and it will no longer check for a latency timer on USB Blaster clones.
User avatar
NoAffinity
Posts: 1019
Joined: Mon May 07, 2018 5:27 pm
Location: Escondido, CA, USA

Re: NES/SNES 240p dejitter mod

Post by NoAffinity »

^'Grats, and nice persistence! :)
konkers
Posts: 13
Joined: Tue Apr 24, 2018 10:15 pm

Re: NES/SNES 240p dejitter mod

Post by konkers »

marqs wrote:
konkers wrote: I've got some boards on order from Oshpark and have been thinking of manually adding such a switch. Looking at the schematic, there's plenty of unused pins on the CPLD. The RTL modifications for such an enable switch should be trivial. This won't completely bypass the board but would enable/disable the clock gating behavior. I'll report back on how that works.
There might be an easier way that doesn't involve RTL modifications. Assuming you're not using MCLK_EXT_i (with multiregion SNES), you could wire it to CPLD pin 37 (MCLK_XTAL_i) and add a ON-OFF switch that connects MCLK_SEL_i to 5V. That should cause both clk & sync to be bypassed to output.
That makes sense. I'll try that when my boards come it and I populate them. Thanks!
User avatar
NoAffinity
Posts: 1019
Joined: Mon May 07, 2018 5:27 pm
Location: Escondido, CA, USA

Re: NES/SNES 240p dejitter mod

Post by NoAffinity »

I have uploaded the gui version of the pi image. It looks like it should fit on a 4GB drive. Both images are now here:

https://drive.google.com/drive/folders/ ... yIsduTYyF9
thebigcheese
Posts: 707
Joined: Sun Aug 21, 2016 5:18 pm

Re: NES/SNES 240p dejitter mod

Post by thebigcheese »

NoAffinity wrote:I have uploaded the gui version of the pi image. It looks like it should fit on a 4GB drive. Both images are now here:

https://drive.google.com/drive/folders/ ... yIsduTYyF9
Awesome! Thank you!
konkers
Posts: 13
Joined: Tue Apr 24, 2018 10:15 pm

Re: NES/SNES 240p dejitter mod

Post by konkers »

konkers wrote:
marqs wrote:There might be an easier way that doesn't involve RTL modifications. Assuming you're not using MCLK_EXT_i (with multiregion SNES), you could wire it to CPLD pin 37 (MCLK_XTAL_i) and add a ON-OFF switch that connects MCLK_SEL_i to 5V. That should cause both clk & sync to be bypassed to output.
That makes sense. I'll try that when my boards come it and I populate them. Thanks!
Got the dejitter mod installed this weekend. Of course my bus pirate stopped working :( Thankfully I had a raspberry pi sitting around :) I had to use the new firmware. After that it worked perfectly. See before and after in MM2 as captured by a startech usb3hdcap:
Spoiler
Image
The bypass switch works as you suggested. Any chance you could upload the new firmware image to github. I got kinda confused by the latest not being there.

Thanks Marqs!!!
User avatar
marqs
Posts: 1034
Joined: Sat Dec 15, 2012 12:11 pm
Location: Finland

Re: NES/SNES 240p dejitter mod

Post by marqs »

konkers wrote:Got the dejitter mod installed this weekend. Of course my bus pirate stopped working :( Thankfully I had a raspberry pi sitting around :) I had to use the new firmware. After that it worked perfectly.
So the default firmware was not stable with your NES either? It's a bit unfortunate if a separate image is needed for NES even though the changes are minimal.
konkers wrote:The bypass switch works as you suggested. Any chance you could upload the new firmware image to github. I got kinda confused by the latest not being there.
I'll double-check the functionality on my FC setup and upload it into a separate branch in a couple days.
konkers
Posts: 13
Joined: Tue Apr 24, 2018 10:15 pm

Re: NES/SNES 240p dejitter mod

Post by konkers »

marqs wrote:
konkers wrote:Got the dejitter mod installed this weekend. Of course my bus pirate stopped working :( Thankfully I had a raspberry pi sitting around :) I had to use the new firmware. After that it worked perfectly.
So the default firmware was not stable with your NES either? It's a bit unfortunate if a separate image is needed for NES even though the changes are minimal.
Correct. Here's what the output looked like with the firmware from github: https://photos.app.goo.gl/j5auat437wwkPJx79
thebigcheese
Posts: 707
Joined: Sun Aug 21, 2016 5:18 pm

Re: NES/SNES 240p dejitter mod

Post by thebigcheese »

Yup, that looks similar to what I was experiencing. Probably makes the most sense to keep SNES and NES firmwares separate. Honestly, I'm still using the one from before the first NES update in my SNES and it's working great. So maybe you'd want to revert the SNES branch back to that one and use this most recent one for just NES. At least the hardware is the same, so there's only one physical item.
sofakng
Posts: 218
Joined: Fri Sep 02, 2016 1:30 am

Re: NES/SNES 240p dejitter mod

Post by sofakng »

Is there any disadvantages to the dejitter mods? Does it change the NES speed (like the FPGA solutions, etc) ?

I can't get the OSSC to work with 3x, 4x, and 5x with my Panasonic Plasma (TCP50GT25).
nmalinoski
Posts: 1974
Joined: Wed Jul 19, 2017 1:52 pm

Re: NES/SNES 240p dejitter mod

Post by nmalinoski »

sofakng wrote:Is there any disadvantages to the dejitter mods? Does it change the NES speed (like the FPGA solutions, etc) ?

I can't get the OSSC to work with 3x, 4x, and 5x with my Panasonic Plasma (TCP50GT25).
Isn't it only the Hi-Def NES that underclocks the NES? As I understand it, the NESRGB doesn't touch CPU clock.
sofakng
Posts: 218
Joined: Fri Sep 02, 2016 1:30 am

Re: NES/SNES 240p dejitter mod

Post by sofakng »

Correct. I don't think the NESRGB affects the clock speed like the HiDef NES.

However, I'm wondering about the impact or differences with the dejitter mod + NESRGB (and the SNES).
sofakng
Posts: 218
Joined: Fri Sep 02, 2016 1:30 am

Re: NES/SNES 240p dejitter mod

Post by sofakng »

One more question... can anybody tell me what needs to be connected for this mod and a SNES 1CHIP-03 using Voultar's RGB amp?

Do I follow the instructions for the SNS-CPU-1CHIP-01 but connect dejitter mod CSYNC_o to CS on the RGB amp? Do I need to do anything else? I'm using a SCART cable with a 470 ohm resistor and the RGB amp set to 'TTL' CSYNC.
thebigcheese
Posts: 707
Joined: Sun Aug 21, 2016 5:18 pm

Re: NES/SNES 240p dejitter mod

Post by thebigcheese »

However, I'm wondering about the impact or differences with the dejitter mod + NESRGB (and the SNES).
It runs just like it would without the dejitter mod, only without jitter :p It is otherwise just like playing a stock NES.
Do I follow the instructions for the SNS-CPU-1CHIP-01 but connect dejitter mod CSYNC_o to CS on the RGB amp? Do I need to do anything else? I'm using a SCART cable with a 470 ohm resistor and the RGB amp set to 'TTL' CSYNC.
I put some guides together on my wiki that might help answer your question (since I am also using Voultar's amp): https://www.retromodwiki.com/wiki/SNES_dejitter_mod. Basically:
Sync out from the dejitter board goes to sync in on the bypass board
Sync in on the dejitter board connects to wherever on the SNES you previously had the bypass sync line connected to.
User avatar
Harrumph
Posts: 368
Joined: Tue Jan 19, 2016 10:06 pm
Location: Sweden

Re: NES/SNES 240p dejitter mod

Post by Harrumph »

sofakng wrote: I can't get the OSSC to work with 3x, 4x, and 5x with my Panasonic Plasma (TCP50GT25).
I wouldn’t count on dejittermod helping for that particular display. Panasonics are really hit and miss for higher linemodes. Have you confirmed the tv can display x3 and up for any other console (e.g. Genesis/MD, PS1, N64 etc)?
sofakng
Posts: 218
Joined: Fri Sep 02, 2016 1:30 am

Re: NES/SNES 240p dejitter mod

Post by sofakng »

Oh... I ordered it hoping it might solve my problem :(
thebigcheese
Posts: 707
Joined: Sun Aug 21, 2016 5:18 pm

Re: NES/SNES 240p dejitter mod

Post by thebigcheese »

For me, it made it so I could use NES and SNES in 3x, 4x, and 5x without audio dropping out or other sync issues. However, other consoles already worked in those modes.
User avatar
marqs
Posts: 1034
Joined: Sat Dec 15, 2012 12:11 pm
Location: Finland

Re: NES/SNES 240p dejitter mod

Post by marqs »

sofakng wrote:Correct. I don't think the NESRGB affects the clock speed like the HiDef NES.

However, I'm wondering about the impact or differences with the dejitter mod + NESRGB (and the SNES).
Gating of the clock affects speed but the difference is minimal - in 1 hour of gameplay a de-jittered system falls less than 2 frames behind a vanilla system.
qcretro
Posts: 12
Joined: Thu Jul 26, 2018 2:33 pm

Re: NES/SNES 240p dejitter mod

Post by qcretro »

I want to try the mod on my NES frontloader with NESRGB. I was looking a the schematic and think I've got this figured out, but I am looking for confirmation. I will remove XTAL, C44 and C45, than bridge C44 and C45 so that the CLK signal goes directly from the CPU pin 29 to PPU pin 18, where I will wire the rest to the NESRGB board in the same way as shown on the Famicom installation page. Is this correct?
samson7point1
Posts: 58
Joined: Sun Jun 26, 2016 6:44 pm

Re: NES/SNES 240p dejitter mod

Post by samson7point1 »

Since I wasn't able to find any posted instructions for installing the dejitter board in an NES-001 Front-loader, I thought I would upload mine.

To prep the NES, you'll need to remove C44, C45, and X1. You'll also need to flatten the three capacitors arranged vertically between the CPU and PPU so they lay flat against the board.

Image

Then to connect Pin 29 on the CPU to Pin 18 on the PPU, solder a jumper wire between the outer legs of the removed C44 and C45 (the red wire in this image).

Image

Also, I strongly recommend orienting the dejitter board like this when you attach it to the NESRGB - it allows access to the update socket and will allow the dejitter board to fit (barely).
Image
thebigcheese
Posts: 707
Joined: Sun Aug 21, 2016 5:18 pm

Re: NES/SNES 240p dejitter mod

Post by thebigcheese »

Mind if I put your images on my wiki? Then it'll have the instructions :)
samson7point1
Posts: 58
Joined: Sun Jun 26, 2016 6:44 pm

Re: NES/SNES 240p dejitter mod

Post by samson7point1 »

thebigcheese wrote:Mind if I put your images on my wiki? Then it'll have the instructions :)
Please do. I tried to update the retromodding wiki (maybe that's the wiki you mean mean?). I posted instructions but I couldn't upload pics.
thebigcheese
Posts: 707
Joined: Sun Aug 21, 2016 5:18 pm

Re: NES/SNES 240p dejitter mod

Post by thebigcheese »

samson7point1 wrote:
thebigcheese wrote:Mind if I put your images on my wiki? Then it'll have the instructions :)
Please do. I tried to update the retromodding wiki (maybe that's the wiki you mean mean?). I posted instructions but I couldn't upload pics.
Yup, that's the one. Awesome, thanks! I have it set to require a confirmed email to upload pictures, but I'm starting to think that's more hassle than it's worth, so maybe I'll just switch it to needing an account. Did it at least send you an email asking for confirmation? Hopefully that's working... Anyway, guides are here: https://www.retromodwiki.com/wiki/NES_dejitter_mod
konkers
Posts: 13
Joined: Tue Apr 24, 2018 10:15 pm

Re: NES/SNES 240p dejitter mod

Post by konkers »

thebigcheese wrote: Yup, that's the one. Awesome, thanks! I have it set to require a confirmed email to upload pictures, but I'm starting to think that's more hassle than it's worth, so maybe I'll just switch it to needing an account. Did it at least send you an email asking for confirmation? Hopefully that's working... Anyway, guides are here: https://www.retromodwiki.com/wiki/NES_dejitter_mod
Perhaps you could convert the guides to markdown and submit a pull request to marqs' git hub repo. That way all the instructions will be in the same place (i.e. https://github.com/marqs85/snes_dejitte ... stallation)

Cheers,
Erik
User avatar
marqs
Posts: 1034
Joined: Sat Dec 15, 2012 12:11 pm
Location: Finland

Re: NES/SNES 240p dejitter mod

Post by marqs »

Finally got around testing the NES-tailored fw with my Famicom. It worked just as well as the default one, so it's probably safer choice for all NES/FC installations. If the caps (or a cap in case of NES-101) were left on the console, the mod might have worked stable with the stock firmware (due to them shifting clock phase), but then the installation would not have been as straightforward. I guess separate NES / SNES firmware is still a manageable solution as long as they work across all console revisions. I'll next update the repo and copy instructions for NES-CPU-?? (NES-001) and NESN-CPU-01 (NES-101).
beast1x5
Posts: 83
Joined: Sun Feb 02, 2014 8:39 pm
Location: New York

Re: NES/SNES 240p dejitter mod

Post by beast1x5 »

Hey Marqs , I've been streaming with my Snes jr with voultars RGB board as well as your dejitter board via the OSSC , retrogaming cables packapunch C-sync cable and the gscartsw lite to a datapath vision LCHD2 and after some extensive play the top part of the screen on game play flickers and sometimes cuts off completely

https://www.twitch.tv/videos/290746800

This is star fox on the SD2Snes highlighted with the issue

https://www.twitch.tv/videos/290748725

During game play of mike tysons punch out the top part of the screen basically removed itself from play
User avatar
marqs
Posts: 1034
Joined: Sat Dec 15, 2012 12:11 pm
Location: Finland

Re: NES/SNES 240p dejitter mod

Post by marqs »

beast1x5 wrote:Hey Marqs , I've been streaming with my Snes jr with voultars RGB board as well as your dejitter board via the OSSC , retrogaming cables packapunch C-sync cable and the gscartsw lite to a datapath vision LCHD2 and after some extensive play the top part of the screen on game play flickers and sometimes cuts off completely

https://www.twitch.tv/videos/290746800

This is star fox on the SD2Snes highlighted with the issue
Does that only occur with SuperFX roms and only after extensive play? I've tested some genuine SuperFX carts with the mod and they seemed to work without issues.
beast1x5 wrote:https://www.twitch.tv/videos/290748725

During game play of mike tysons punch out the top part of the screen basically removed itself from play
Which NES/FC model you use and have you installed the NES-tailored firmware on the board? Some NES-001 owners have reported similar issues with the stock fw.
beast1x5
Posts: 83
Joined: Sun Feb 02, 2014 8:39 pm
Location: New York

Re: NES/SNES 240p dejitter mod

Post by beast1x5 »

For the snes it occurs with any game after some time

The AV famicom I'm not sure.. also the firmware for both boards are the ones provided from vgp
User avatar
marqs
Posts: 1034
Joined: Sat Dec 15, 2012 12:11 pm
Location: Finland

Re: NES/SNES 240p dejitter mod

Post by marqs »

beast1x5 wrote:For the snes it occurs with any game after some time

The AV famicom I'm not sure.. also the firmware for both boards are the ones provided from vgp
Do you have any JTAG programmer you could use for updating the board firmware? Also, when the issue occurs, could you try repeatedly pressing INFO on OSSC remote and check whether the large number on bottom-right corner of the character LCD screen varies by more than 1?
Post Reply