Use copy_to_ram to (hopefully) improve stability #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to improve audio streaming stability by using
copy_to_ram
to run the entire program from RAM.By default, the Pico runs code directly from flash over QSPI by using eXecute in Place (XIP), with a 16KB cache. This works fine for many applications which are small, or not too timing sensitive. Unfortunately, Pico-ASHA is not small, and it is latency sensitive.
However, I saw that so long as I can keep the Wifi/BT firmware in flash, there is just enough RAM for the program, variables and buffers. Therefore, I have used the
copy_to_ram
functionality of the Pico SDK to copy all code to RAM on startup, and execute from RAM.To make the code smaller, cmake should be configured to use the
MinSizeRel
configuration (this builds with-Os
instead of-O3
).Anecdotally, with this change, I have noticed that audio streaming is much more stable. My hearing aids are still disconnecting on occasion, but far less often than before this change, and reconnection is generally more reliable. Note I am currently not performing any pre-buffer strategies to minimize latency.