Skip to content
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

Use copy_to_ram to (hopefully) improve stability #5

Merged
merged 3 commits into from
Aug 16, 2024
Merged

Conversation

shermp
Copy link
Owner

@shermp shermp commented Aug 16, 2024

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.

@shermp shermp merged commit 59e8f65 into main Aug 16, 2024
2 checks passed
@shermp shermp deleted the optimisations-1 branch August 16, 2024 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant