-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clock unstable during boot, tnCart stuck into boot loop #14
Comments
Signed-off-by: Albert Herranz <[email protected]>
Thanks for investigating this issue. You have identified the following issues
What causes the clock signal to be unstable?You mentioned that the VDP clock may be stopped, but why is it repeating? About the problem when using with onboard 27MHzDot clock is generated in sync with 3.58MHz, causing jitter in the DVI output of the V9990 emulation, resulting in DVI devices that cannot be supported If the SYNC_CLK_EN parameter of the UMA module is set to 0, the module will operate asynchronously and the DIV output will be stable. CountermeasureI think there are two means.
|
I quickly checked. |
That was a simply a wild guess with no actual check. Either the clock is stopping (and restarting, otherwise the bootloader would not loop) or the clock is glitching enough for the pll to loose sync. I took a quick look at the manual for V9958 (which is the VDP present on my Omega and Panasonic A1-WSX) to check what should be the behavior of CPUCLK when the V9958 chip RESET_n signal is low, but couldn't find any information (SYS_RESET_n is kept low until the BOOTLOADER completes). Maybe the CPUCLK is not guaranteed to work flawlessly until RESET_n is high. Thanks. |
Eventually, once the reset on the MSX side is released and the clock is stable, the PLL should remain locked. Due to the specifications of the cartridge bus, it is not possible to send a reset signal from the cartridge side to the MSX. |
Oh, you are completely right. I forgot for a moment that the cartridge reset signal is an input signal from the tnCart point of view... So the cpu clock from the vdp should be running continuously. Then I wonder if those clock glitches do happen too outside of the bootloader phase (and if not why only on the bootloader phase). In the bootloader phase they cause a direct reset of the bootloader. Isn't it? |
Does the cartridge reboot when the boot loader is running or when it completes? Accessing SDRAM in the FPGA from MSX generates a lot of noise. Isn't it possible that that noise gets mixed into the clock signal and causes the PLL to unlock? If this is the cause, it cannot be fixed within the FPGA, so the only option is to use the 27MHz onboard clock. |
I made the following test. I modified the fpga code to use again the 3.58MHz clock but this time considering the BASE clock ready when at least the PLL has locked once.
I also used the board LED to signal if the bootloader has started or ended, and once ended, if it was executed again.
I did many tests and that's what I found (remember with the 3.58MHz clock as reference):
So, answering your question, according to my tests, the PLL unlocks randomly only during the bootloader phase. So it seems that we can't reliably use the 3.58MHz clock during the bootloader phase, but for some reason, it works fine after that and we can use it then. |
u_boot.RESET_n is the same as RESET_n in the TOP module, and is generated in the section below.
The READY signal generation for the SDRAM module is as follows: READY will not become 0 unless RESET_n (same as CLK_BASE_READY) becomes 0.
Is something happening somewhere other than what is described in the source? |
The Timing Analysis Report is clean (no red lines), but the report assumes the clock is working correctly. |
I changed tnCartWonder to use 3.58Mhz(defined XXX_TEMP_FIX_MUST_BE_FIXED_IN_A_PROPER_WAY_WONT_PASS_TIMING_REPORT_AND_MAY_CAUSE_INSTABILITIES) and looked at the post-synthesis list and found that BOOT_n was dependent on the state of the LED module. It seems that tnCart 3.58MHz and tnCartWonder 27MHz give correct synthesis results. tnCartWonder3.58Mhz synthesis result
tnCartWonder27Mhz synthesis result
tnCart3.58Mhz synthesis result
|
I think it's a bug in the gowin synthesizer. DAC_SDMODE_n may be the cause, so I fixed it as follows. I'm not sure if this is the cause of the bootloop, so please check.
↓
|
I just tested the proposed fix, but the boot loop continues.
I reverted the define to go back to the 27MHz clock but leaving new DAC_SDMODE_n non-combinatorial assignment, and the boot loop goes away as on the original temp fix:
|
By the way, I just verified that the bootloop problem is not specific of the WonderTANG! V2.0b board, but it is also present in WonderTANG! V1.02d and WonderTANG! V1.01c boards. And in WonderTANG! V1.02d the only difference is the swap of MSEL0 and MSEL1. I think that the fact that DAC_SDMODE_n appears in the 27MHz tnCartWoder synthesis is just because it is combinatorially assigned to RESET_n, and then the synthesis tool may have replaced RESET_n by DAC_SDMODE_n with the same outcome. The strange thing is the synthesis output you posted on the 3.58MHz tnCartWonder, where the RESET_n has been replaced by some expression depending on the blink count of the LED... |
I just did another test. But the bootloop is still there when using the 3.58MHz clock (and gets fixed as soon as switching to the 27MHz clock).
|
When I checked again, I couldn't get any results that depended on the LED module, so I think it was a misunderstanding. |
Since this problem cannot be resolved immediately, onboard 27 MHz will be used until the cause is identified. |
The CART_CLOCK noise was reproducible and occurred immediately after the V9990 video output started. |
Note that in my original tests, the V9990 was not even enabled (to simplify things and reduce rtl build times for tests). Do you have reproduced the boot loop on your tnCart (not WonderTANG!) boards? |
I have tested the tncart on PCB 2.0 on a Philips VG8020 and it gets stuck when starting nextor.sys and a led on the tang lights up. Is there a solution? Thanks. |
That description seems to be unrelated to this specific issue. |
The tnCart board has not had a bootloop problem yet so far. |
Great. Thanks! |
Sorry, work has been busy and no progress has been made on the rev2 board. |
Thanks for your feedback. Yes, there are lots of cheap I2S DAC modules out there. Using one of those would be cheaper (and easier to solder for hobbyists) than sourcing specific components for the active filter (if it is not a trivial one). |
If the freezing problem with 1chip MSX has been resolved? Still got the same issue on fpga based clones. |
Since bus timing on the T80 is more severe than on the Z80, it is imperative that memory access timing be synchronized with the clock. |
Will Nextor work on this branch? |
Yes, it works! |
After reports of many users that latest tnCartWonder bitstreams were not booting into their MSXs when using WonderTANG! V2.0b boards (and strangely my Panasonic FS-A1WSX and Toshiba HX-10 were not affected, or at least rarely), I started troubleshooting the issue.
Users observed that their WonderTANG! V2.0b boards got stuck while booting, showing a continuous fast-blinking board led, and not progressing to the MSX boot screen (video was black).
I made a minimal tnCart configuration for my WonderTANG! V2.0b with the bare minimum to make it wondertang-compatible, i.e.:
User pakoto from msx.org (thanks!) help me making tests remotely with his WonderTANG! V2.0b and his Panasonic FS-A1 (and a Sanyo MSX1) which he was reporting were failing 100% of the time.
Using that bare minimum setup we observed indeed the same boot loop with the fast-blinking board led.
I started suspecting that something was going on during the boot process, before freeing the MSX to boot.
I changed a bit the setup so that I could use the LED output for debugging some signals, connecting it to a logic analyzer.
I diagnosed the CLK_MEM_READY signal through the LED pin (IO 75) and saw that during all those failed boots, the CLK_MEM_READY was deasserted before the bootloader had time to complete, causing a RESET and provoking the boot loop.
I thought what change could have caused that problem, and remembered that in commit 62a343a "Fix #7 Synchronize the operating clock with the bus clock" you switched the clock for deriving the base clock for the fpga from the 27MHz clock of the Tang Nano 20k to the 3.58MHz of the cartridge clock.
To confirm if that was the issue, and without further analyzing the root cause of the clock not being stable for the whole bootloader phase, I did a quick test switching the base clock to the old 108MHz derived from the 27MHz Tang Nano 20k (just the CLK_MEM, without touching anything else for a quick test).
So basically commenting out this:
and adding this:
After that change, the WonderTANG! V2.0 of user pakoto started to boot 100% reliably in his Panasonic FS-A1 and Sanyo MSX1 without getting into the boot loop anymore (something that never happened before).
So, there is clearly a problem when using the CART_CLK, as at least in some MSX, the clock is not stable (and becomes not ready) in the middle of the bootloader process.
As I said, I didn't further analyze the root cause of it, but maybe it could be related to the following: as the CART_CLK comes from the CPU clock and the CPU clock comes from the VDP clock, maybe the fact that SYSRESET is help during bootloader causes the VDP to stop providing a clock. On some MSX that happens before than others, letting some of them complete the bootloader (and get to boot the MSX system) and others to get stuck into the dreaded boot loop.
And that explains too why when using the 27MHz clock to derive the base clock, the bootlopp never happens.
Of course, changing the clock that way was just to confirm the issue, and it is NOT a proposed solution as that change has other implications, and you made that change to fix other issues.
So something needs to be thought to fix the problem the right way.
Looking forward for your comments.
The text was updated successfully, but these errors were encountered: