Is it possible for micropython running on STM32 to expand memory through PSRAM?
Is it possible for micropython running on STM32 to expand memory through PSRAM?
Thanks for your help.
rp2: RP235: PSRAM support
Depends upon RP2350 support: https://github.com/micropython/micropython/pull/15619
This is a rough draft gathering our PSRAM support code - with a dash of SparkFun's - and attempting to get it into the right shape for mainline.
TODO:
- ~Potential: Remove init from
main.cand add bindings tomodrp2so PSRAM can be enabled (or not) inboot.py~ - Potential: Support for PSRAM as either extending the GC heap (needs split heap) or storage/tmpfs!?
- Clean up auto detect code and dispel magic numbers (Note: Have asked for SDK support)
- Test test test test!
Known issues:
- ~Possibly crashy, need a good test to reliably test the extent of the PSRAM~
- ~Needs to be reconfigured when
machine.freq()is called, since a clock change breaks PSRAM timings~ - Currently no way to specify where MicroPython should store a particular object
- ~Might break USB on startup or otherwise fail to start up~
- Support for PSRAM opens up RP2 to the class of bugs and pitfalls addressed here: https://github.com/micropython/micropython/issues/16644
Improvements:
We're (Pimoroni) currently using yet more customisations on top of this PSRAM code for Presto, which stores the entire display buffer in SRAM and leaves basically none for others buffers. See: https://github.com/pimoroni/micropython/commit/888f52fb464600da9d5d19ada2c103d457ee5b7f
This is a bit rough for inclusion into MicroPython - I always wince at a near duplicate linker script - but incredibly useful nonetheless.
Some kind of bindings for PSRAM rp2.PSRAM() in modrp2 might be nice, too. This would allow us to - theoretically - add a portion of PSRAM to the gc_heap and reserve the remainder for RAMFS, long-lived buffers, custom memory pools and other such nonsense. I did contemplate adding MICROPY_HW_PSRAM_RESERVE_BYTES for this, which would reserve N bytes from the detected PSRAM size for tomfoolery and shenanigans.