-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hackrf_transfer -c produces possible buffer underruns #1503
Comments
The host is probably failing to keep up with supplying samples to the HackRF in time. Check the statistics from With the |
Software versionsPrevious firmware version reported by
The problem persists even after the update. I am running Testing scriptI made a short script for testing: #!/bin/bash
printf "Resetting device...\n"
hackrf_spiflash -R
sleep 1
hackrf_transfer -f 10000000 -a 0 -c 0 -x 0 -n 10000000
hackrf_debug -S Typical output with this script:
15168 bytes = 7584 samples. Root cause debugThere are quite a few differences in
I checked if The main difference of the codes is the sample rate, 2M in case of mine and 10M default in Cross-checking revealed this to be the main problem (was not suprising), Fixing - no idea howI did not find any tips on how to help the host keep up. Both codebases are just as optimized as they can be, so I think some settings in the OS or in libusb need to be changed, but I have no idea on that. I recommend adding a warning display in the output of |
The problem is not with the speed of your code but with how steadily the host's USB stack pushes data to the HackRF. There is limited buffer space on the device, and it runs out quickly if the flow of data from the host is interrupted for a while. The main thing you can optimize here is to have the HackRF on its own USB bus. If there are other devices on the bus then the data flow to the HackRF will inevitably be interrupted whilst the host is servicing them. There isn't really anything to tweak in libusb here. We're already queuing up multiple asynchronous transfers to get the best throughput. And I'm not aware of anything to tweak on the OS side, but we have had someone reporting shortfall problems on Linux even with a dedicated bus, which never used to happen, so it might be that something has changed on the kernel side that's relevant here.
Yeah, this is a good idea. IIRC, it wasn't done when I first added the shortfall stats because older firmware wouldn't support the request. But we should probably go ahead and do it now. I also have #1484 open, which warns in |
I think this deserves an entry in the FAQ, as it can be a potential problem in other applications as well.
I have a hard time debugging this, but it seems like (according to
The correct solution would be to offload processing to the MCU, but that would be an entire redesign, so impossible now.
The only problem I could see with it is other software (GNURadio, SDR receiving software, etc.) possibly resetting the MCU thus clearing the stats. |
What type of issue is this?
permanent - occurring repeatedly
What issue are you facing?
While measuring the output of a clone HackRF one with a proper spectrum analyser, I noticed the power output fluctuating, and with slower sweep times, the spectrum looked exactly like an OOK spectrum.
I confirmed the result using time-domain measurements with a low-frequency carrier - the output went to 0 for extended periods (milliseconds) somewhat randomly.
I suspected software error, and wrote a small piece of C++ code on my own to transmit. My code did NOT produce the same effect, confirming a software bug in or triggered by
hackrf_transfer
.I am planning to investigate the real cause, but in the meantime, I'm opening this issue in case anyone else encountered the same effect.
What are the steps to reproduce this?
hackrf_transfer -f 10000000 -a 0 -c 127 -x 47
(10 MHz output with maximum gain settings without amplifier)Can you provide any logs? (output, errors, etc.)
No response
The text was updated successfully, but these errors were encountered: