← index #7762PR #15620
Off-topic · high · value 1.302
QUERY · ISSUE

Is it possible for micropython running on STM32 to expand memory through PSRAM?

openby china-zhangdjopened 2021-09-08updated 2021-09-13
port-stm32

Is it possible for micropython running on STM32 to expand memory through PSRAM?
Thanks for your help.

CANDIDATE · PULL REQUEST

rp2: RP235: PSRAM support

closedby Gadgetoidopened 2024-08-08updated 2025-04-08
port-rp2

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.c and add bindings to modrp2 so PSRAM can be enabled (or not) in boot.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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied