randyrossi / bmc64

A bare metal Commodore 64 emulator for the Raspberry Pi with true 50hz/60hz smooth scrolling, low input latency and better audio/video sync.
GNU General Public License v3.0
479 stars 56 forks source link

Frequent Pi Zero crashes on 3.6 beta and sound buffer errors on earlier versions #123

Closed CemTezcan closed 4 years ago

CemTezcan commented 4 years ago

I tried the 3.6 beta on Pi Zero and it crashes (freezes) in 1 to 10 minutes runtime even I turn off both CRT filter and scaling interpolation.

On the earlier versions there was some random error like "sound running too slow" and that was not a freezing crash. I just use the emulator as it is with just losing the sounds until I reset the Pi zero or I load a snapshot without resetting.

This crashes may somehow related to that sound error because on the 3.6 beta, I get none of that fault.

And a feature request: please make 1541 drive sounds can be enabled for pi zero :)

randyrossi commented 4 years ago

I've seen this before on my Pi0 and I don't know what causes it. I just ran my Pi0 (Ghostbusters) for several hours and it did not crash. I only had a keyboard plugged in. I have seen it before when a gamepad is plugged in so it might be related to that. I'll try to reproduce it.

CemTezcan commented 4 years ago

Yes it's possible because I'm using a gamepad as well.

randyrossi commented 4 years ago

I have two gamepads that consistently crash the Pi0 and even the circle usb gamepad test app. I think the crash is related to this msg that gets repeated many times:

00:00:02.08 dwhci: Transaction failed (status 0x82)

I will have to open a ticket with circle2 project to see if it's a known issue.

It doesn't happen with a different gamepad I have so I suspect it's related to circle's usb driver support library. Something about these gamepads causes many thousands of usb transactions per second and it ends up crashing / stalling on the Pi0. Maybe rene knows about this.

CemTezcan commented 4 years ago

I have a more than 40 minutes runtime on some cases. Sometimes it took just 2 minutes for the crash. It's really possible that it's caused by the gamepad inputs I'm using but FYI, I used same gamepad with pi 3a+ for hours. There is no freezing happens on that. This may possibly be a p0 specific problem.

CemTezcan commented 4 years ago

Just a hunch but I see the note "Increased Pi0 audio sample rate to 44100" on the 3.6 change log.

Since I'm not gettng any "sound running too slow" error and instead of that pi0 crashes. Maybe that is the reason for the crashes.

randyrossi commented 4 years ago

I've been trying different combinations and it seems the crash is brought on by certain gamepads. I've attached both a keyboard and different gamepad and the Pi0 will run for hours without any issue. Certain gamepads are causing many thousands of HID reports to be generated when (I think) they should not be. So it's a limitation of the USB stack. Somehow, the problem sometimes manifests itself by the emulator complaining the sound is running too slow (which really means an internal buffer was allowed to overflow). Still searching for the answer.

randyrossi commented 4 years ago

I bisected changes and found the point at which the Pi0 started crashing but it doesn't make much sense. Still trying to isolate what causes this. I think it's actually the same problem as when the sound cuts out but now instead of displaying a message and continuing to run the graphics, it crashes. Still looking.

randyrossi commented 4 years ago

Good news. I found the source of the crash. It will be fixed in the 3.6 release.

CemTezcan commented 4 years ago

I can't thank you enough for your genius and effort on this Randy. Can't wait for the new release. This will be awesome!!

randyrossi commented 4 years ago

I was also able to fix the "Running too slow" problem. It happened because an interrupt routine was clobbering floating point registers and some gamepads caused a lot of interrupts so the problem showed up more often with those. I have not seen the running too slow problem since I made the fix so that's good news too.

CemTezcan commented 4 years ago

That is totally amazing!

I know you made this lite version for a low level of compatibility (alt least for the start) but I can clearly say that it's really as well as the pi3 versions. I was using lite version to play games with no considerable latency. Since this sound and crash problem is solved, you really made my day. Thanks so much.