-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Firmware: Add an additional layer of DMA-assisted sample buffering #1601
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
base: main
Are you sure you want to change the base?
Conversation
d863307 to
8c54161
Compare
be432d4 to
912d993
Compare
|
On my Linux test host, this improves maximum shortfall-free RX sample rate from 19.2 Msps to 21.8 Msps and improves TX from 20.1 Msps to 21.8 Msps. |
mossmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't spotted the bug, but I'm seeing short TX with hackrf_transfer -n truncated by a few milliseconds. Looks like the transmissions are about 9000 samples short.
|
Transmission duration does not change linearly with the number of samples. Testing with 32768 samples: 8.88 ms (expected 16.38 ms) |
|
I believe this is due to the current behaviour of When that function is used, the host will send 32KB of zeroes after the end of the provided TX data, before making the control request to switch transceiver mode back to idle. The theory behind that approach was that, since there's only 32KB of space to store samples, once you've sent that many zeroes and the device has accepted them, the earlier samples you care about must have been transmitted. With this PR, we double the buffer space, so the host would now need to send 64KB of zeroes to achieve the same. If you change Unfortunately, we hardcoded that figure rather than adding a vendor request to query it from the device. My recollection is that we discussed that decision verbally at the time, but since I'd already made some attempts to increase the buffer size without success, we thought that 32KB figure wasn't ever going to change and it wasn't worth adding this query. Our options are:
I'll implement the latter. |
|
Ensuring that all data in the USB buffer is moved to the sample buffer before stopping TX has fixed the non-linearity you were seeing, but I'm now seeing timing coming up short by what looks like a consistent 4.096ms, i.e. 8KB of samples or one DMA transfer. I'll see about tracking down the remaining bug. |
ffc5ad4 to
33bf9ad
Compare
|
Some experimentation with looking at ramped signals on a scope shows that the transmission includes the first 32KB preloaded into the sample buffer; is missing the next 8KB, which is the first to be transferred by DMA; then all subsequent samples are transmitted correctly. This is true from the memcpy version onwards, regardless of whether |
33bf9ad to
b1b2e25
Compare
|
Fixed that - still some issues with small sample counts. |
b1b2e25 to
10a9836
Compare
This PR attempts to implement the buffer scheme described in #1363 (comment).
The M0 SGPIO code continues to use the existing 32KB sample buffer, which has special placement.
An additional 32KB USB buffer is placed in
ram_local1, above the.textsection.The GPDMA controller is used to transfer samples between the sample buffer and USB buffer.
The initial commits in this PR set up the new buffer scheme, whilst using
memcpyrunning synchronously on the M4 core as a placeholder for the DMA operations. This works correctly up to around 8Msps.The final commit switches to the DMA implementation.