Problem when using stream mode

I’m using Chipwhisperer HUSKY and trying to capture long trace with CW313 board and STM32F415. I just turn on the stream mode with scope.adc.stream_mode = True and set the samples to 300000. Then the result is as followed in the top picture
The target code I flashed on the board is from the PQM4 library. The capture script is in the second-to-top one
The makefile is like the third-to-top one picture
Along with a change in hal/stm32f4/Makefile.stm32f4 below
When I turned the mode off, I can still capture the trace with no errors, but only about 130000 samples is valid,which is shown in the picture at bottom

Some addition:
The error is : (ChipWhisperer Scope WARNING|File _OpenADCInterface.py:710) FIFO error occured; see scope.adc.errors for details.
the scope.adc.errors says:
'slow FIFO underflow, fast FIFO overflow, ADC clipped, ’

Some important details are missing so I can only guess… what is scope.clock.adc_freq?
The errors indicate that your host PC isn’t able to keep up with the capture. That can caused by:

  • too high sampling rate (should be < 20 MHz)
  • other activity on your host PC’s USB

Or a combination of the two. If the issue is still not resolved, try a different USB port (must be at least USB 2.0).

When streaming is off, the max number of samples is 131070.

The problem is the first one. I know the sampling rate is high, the scope.clock.adc_freq is over 20M. But it can not be changed, it is read-only.
Apart from changing the scope.clock.clkgen_freq or the adc_mul, is there other ways to change the sampling rate?

Anyway, I think it a solution. Thanks for your help

Glad to hear it.
Unfortunately, 20 MS/s is the highest rate at which we can reliably push “unlimited” captures over the USB. If you sample higher, captures will fail beyond a certain number of samples- this will be system-dependent, but probably not much higher than the max non-streaming capture capacity (131070).
One thing you can do to squeeze a bit more samples is to reduce the resolution by setting scope.adc.bits_per_sample = 8.