probonopd / MiniDexed

Dexed FM synthesizer similar to 8x DX7 (TX816/TX802) running on a bare metal Raspberry Pi (without a Linux kernel or operating system)
https://github.com/probonopd/MiniDexed/wiki
1.08k stars 80 forks source link

Transaction failed (status 0x202), Transaction failed (status 0x402) #26

Closed probonopd closed 2 years ago

probonopd commented 2 years ago

Using M-Audio Keystation Mini 32 MK3, getting Transaction failed (status 0x202), Transaction failed (status 0x402) when playing many notes at once or in quick succession.

Raspberry Pi 2 and 3 with sndhdmi

Raspberry Pi 2 and 3 with sndpwm

As a result, notes get not played or notes get sustained. Looks like individual key down/up events are missed.

To reproduce, play e.g. quick glissandos.

probonopd commented 2 years ago

I can also produce 0x202 on the Raspberry Pi 2 on the ASCII keyboard by pressing many keys repeatedly at once. (fwiw, with sndhdmi)

rsta2 commented 2 years ago

It is known, that the USB driver for the Raspberry Pi 1-3 and Zero is not perfect. The timing is critical there. I will try to reproduce this here and will see, what I can do about it.

rsta2 commented 2 years ago

A first test to reproduce this on a Raspberry Pi 2B with PWM and a LPK25 keyboard and two different ASCII keyboards failed. I wasn't able to reproduce it. These messages are warnings, not hard errors. But of course when some MIDI events do not get to the synth because of USB transaction errors, that's a problem.

Can you please apply the following patch for a test and try again. It enables the REALTIME system option, maybe the timing is better then.

diff --git a/build.sh b/build.sh
index 9ffcd89..b1ffd38 100755
--- a/build.sh
+++ b/build.sh
@@ -19,6 +19,7 @@ cd circle-stdlib/
 make mrproper || true
 ./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}"
 echo "DEFINE += -DSAVE_VFP_REGS_ON_IRQ" >> libs/circle/Config.mk
+echo "DEFINE += -DREALTIME" >> libs/circle/Config.mk
 make -j$(nproc)
 cd ..
probonopd commented 2 years ago

@rsta2 I get no more error messages) but actually I still get missed keyDowns and keyUps and it seems to have killed the ASCII keyboard. (Raspberry Pi 2 HDMI)

rsta2 commented 2 years ago

The ASCII keyboard does not work any more? That's bad. :(

That you do not get messages any more is caused by the REALTIME option. It suppresses the screen output from IRQ handlers, because especially scrolling the screen from an IRQ handler kills the timing.

But if you still get missed MIDI events, the problem obviously still exists. :(

probonopd commented 2 years ago

Interestingly I don't get missed MIDI events when using an oldschool CASIO MIDI keyboard with a selfmade Arduino based USB MIDI Adapter.

So maybe there is something particular about some (e.g., M-Audio Keystation Mini 32 MK3), but not all, USB MIDI devices?

rsta2 commented 2 years ago

Seems so. Another thing, you can try, is adding the option usbspeed=full to the file cmdline.txt (on the first line, delimited by a space from the sounddev=sndXXX option). As I remembered now, this helped with MiniSynth Pi in some similar cases.

probonopd commented 2 years ago

Yes! This does the trick. So cool! Thanks again @rsta2.

rsta2 commented 2 years ago

I had added this to the Troubleshooting section of the MiniSynth Pi README, but had forgotten it.

probonopd commented 2 years ago

Is there a way to hardcode this in the kernel so users can't accidentally delete it?

rsta2 commented 2 years ago

I think it's not a good idea to generally enable this option, because it's a workaround. That it works with your USB keyboard, does not mean, that this works with all USB keyboards. This has to be tried.

Also this option disables the USB high-speed mode and uses full-speed instead. This is not a problem with USB keyboards normally, because they use full-speed anyway, but if you want to attach an USB flash drive for example, the access to it will be slow or not possible at all for some flash drives, when this option is enabled. I don't know, if this will be needed in MiniDexed some day.

I would suggest to take this option as a workaround and add some troubleshooting info somewhere, as I did for MiniSynth Pi.

BTW. This option is only valid for the Raspberry Pi 1-3 and Zero USB. It has not effect on the RPi 4 and 400, and should not be needed there, because the RPi 4 has a much more modern xHCI USB controller, which handles the timing on its own. I heard about a synth, which handles four USB MIDI inputs at the same time without data loss on the RPi 4. I suppose this is not possible on RPi 1-3, at least not with Circle.