Direct Raspa interfacing - intermittent crashes


I have an application that I cross-compile for Elk on RasPi + HifiBerry DAC ADC+ Pro, which is interfacing Raspa directly (include raspa.h, link with Raspa and Cobalt provided in the SDK. Largely, I have followed the example set by the raspa/apps code and the Sushi Xenomai raspa frontend.

The app works in the meaning that it creates sound, however I get intermittent (after 2-15 minutes of running) hard crashes that I cannot figure out. When this happens I can’t Ctrl+C, I can’t ssh into the machine - the entire OS locks up and I need to power cycle. Running the process through gdb gives the same result.

I have previously monitored mode switches and successfully removed some using gdb according to the instructions, but this doesn’t seem to the same kind of issue. Same code compiled with on Mac does not have the same issue.

I have also disabled all sound generating code that would be called from

Is there a way I can get data on what actually happened prior to the crash?
Anyone with any ideas I could try?



Hi Gustav. My best guess is that you still have mode switches/syscalls from somewhere in the audio thread.

Timing calls in particular, can cause this behaviour, we’ve seen that for instance clock_gettime() or gettimeofday() can cause hard lockups if called from a realtime thread. It could be that it deadlocks something in the kernel, I don’t know. But you should avoid those calls and use our twine library instead if you need a current timestamp from the audio thread.

Sometimes you find these calls deep down in things like logging libraries, where it’s not immediately obvious that they’re doing something unsafe, and the risk of a single call crashing the system is quite low, which is why it seems quite random.

1 Like

Thanks for your feedback, you set me off on the right mental track again. :slight_smile:

I had been searching for the wrong thing in the wrong place, and now found a timing call hiding in plain sight. I’ve been running the app over night, seems stable!

1 Like