I haven't tested r2021b with Ubuntu yet - but I have a few ideas.
[b]1. Try starting MATLAB with a serial port argument and select the Java serial interface:
This send communication with the state machine via MALTAB's Java based serial interface instead of PsychToolbox IOPort
[b]2. Try changing line 153 of ArCOMObject_Bpod from:
obj.Port = IOPort('OpenSerialPort', portString, ['ReceiveTimeout=3, BaudRate=' num2str(baudRate) ',...
OutputBufferSize=' num2str(obj.OutputBufferSize) ', InputBufferSize=' num2str(obj.InputBufferSize) ', DTR=1']);
obj.Port = IOPort('OpenSerialPort', portString, ['ReceiveTimeout=0.05, BaudRate=' num2str(baudRate) ',...
OutputBufferSize=' num2str(obj.OutputBufferSize) ', InputBufferSize=' num2str(obj.InputBufferSize) ',...
DTR=1, PollLatency=0.0001, StartBackgroundRead=1']);
In this case, don't select the Java interface when starting up.
[b]3. (a more radical option) - try the develop branch of Bpod_Gen2. You'll have to remove all references to the master branch from the MATLAB path, and add the develop branch instead. There is also updated state machine firmware on the develop branch of the firmware repo, though the MATLAB software should work with your existing firmware v22. The develop branches are not completely stable, though we're very close to a major release - so any feedback would be more than welcome!
Is there other software running besides MATLAB and the default Ubuntu processes?