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 the SDK XIP cache clean method #7

Open
wants to merge 17 commits into
base: feature/psram
Choose a base branch
from

Conversation

MichaelBell
Copy link

This PR picks up the CMake and linker script changes from #6, and additionally switches to using the new pico-sdk 2.1 method for cleaning the XIP cache.

Gadgetoid and others added 17 commits October 21, 2024 11:06
Add PSRAM support with auto detection.

Performs a best-effort attempt to detect attached PSRAM,
configure it and *add* it to the MicroPython heap.

If PSRAM is not present, should fall back to use internal
RAM.

Introduce two new port/board defines:

* MICROPY_HW_ENABLE_PSRAM to enable PSRAM.
* MICROPY_HW_PSRAM_CS_PIN to define the chip-select pin.

Changes:

ports/rp2/rp2_psram.c/h: Add new PSRAM module.
ports/rp2/main.c: Add optional PSRAM support.
ports/rp2/CMakeLists.txt: Include rp2_psram.c.
ports/rp2/rp2_flash.c: Add buffered write to avoid reads from PSRAM.
ports/rp2/mpconfigport.h: Enable MICROPY_GC_SPLIT_HEAP
for boards that set MICROPY_HW_ENABLE_PSRAM.

Co-authored-by: Kirk Benell <[email protected]>
Co-authored-by: Mike Bell <[email protected]>
Signed-off-by: Phil Howard <[email protected]>
My tests found issues when PSRAM is combined with the existing
RAM in a split-heap configuration. Since this option is not
enabled by default on RP2 I have changed it to be optional.

PSRAM will be used exclusively if MICROPY_GC_SPLIT_HEAP == 0,
it will be added to RAM if MICROPY_GC_SPLIT_HEAP == 1,
and the system will fall back to RAM only if it's not detected.

Signed-off-by: Phil Howard <[email protected]>
Try to avoid causing an upset with USB startup by
detecting PSRAM as early as possible.

Signed-off-by: Phil Howard <[email protected]>
Move PSRAM setup to immediately after flash timing setup.
Disable interrupts while setting up PSRAM.

Signed-off-by: Mike Bell <[email protected]>
Enable split heap if PSRAM is enabled.

This allows both the internal SRAM and PSRAM to be used as heap.

Signed-off-by: Phil Howard <[email protected]>
GC stack was overflowing and causing the GC to scan through the
entire memory pool, which is a particularly pathological case
with 8MB PSRAM. This caused noticable slowdowns during GC.

This change takes the stack from 256 to 4096 bytes to avoid
overflow.

Co-authored-by: Kirk Benell <[email protected]>
Signed-off-by: Phil Howard <[email protected]>
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.

2 participants