Esp32 Psram Design

External PSRAM exists because on-chip SRAM on a chip this size and cost tier is measured in a few hundred kilobytes, and some applications — a camera buffer, a larger TLS session, a more capable application — simply need megabytes of working memory that would be far too expensive to replicate in on-die SRAM at this chip's price point. PSRAM (pseudo-static RAM) looks like ordinary SRAM to the software that uses it but is internally built from DRAM cells that need periodic refresh — a tradeoff that buys much higher density per unit die area in the external memory chip than true SRAM would, in exchange for a refresh mechanism and an access latency the system has to accommodate rather than ignore.

Application needs more working memory than on-chip SRAM provides
Camera frame buffer, larger heap, bigger network buffers
External PSRAM interface
SPI or Octal-SPI bus to external PSRAM die
Octal SPI trades more board pins for much higher bandwidth
Memory controller handles refresh
DRAM cells need periodic refresh, hidden from software entirely
Cache sits between CPU and PSRAM
Same hit/miss tradeoff XIP flash access already has
Software sees one flat extra memory region
Allocatable like any other RAM, latency hidden by the cache

Octal SPI over standard single-lane or quad SPI is the specific board-level decision that turns PSRAM from a capacity add-on into something fast enough to actually use for performance-sensitive data, and the tradeoff is real pin budget spent to get there. A single-lane SPI connection to PSRAM is cheap on pins but limits bandwidth badly enough that only genuinely latency-tolerant uses make sense over it; Octal SPI uses eight data lines instead of one, multiplying raw transfer bandwidth roughly proportionally, which is exactly what makes PSRAM viable for something like a camera frame buffer that needs to move substantial data every frame — but those extra seven data lines are seven more pins a cost-constrained, already-tight pin budget has to find room for, which is precisely the kind of package/pinout tradeoff a different ESP32-class variant might decide isn't worth making if its target applications don't need that bandwidth.

External PSRAM — Capacity Through DRAM, Speed Through Octal SPI more pins spent for bandwidth, with refresh and latency hidden from software CPU + cache Same hit/miss pattern as XIP flash access Latency hidden on a hit Memory controller Issues periodic refresh to PSRAM cells Entirely hidden from software 8 lanes External PSRAM die DRAM cells, high density Octal SPI interface Needs periodic refresh Bandwidth vs. pin cost by interface width Single-lane SPI 1 pin, lowest BW Quad SPI 4 pins, 4× bandwidth Octal SPI 8 pins, highest BW Why not all variants include PSRAM support Octal SPI's 8 lanes compete directly with the chip's own pin budget a real tradeoff, not free bandwidth Capacity and bandwidth are both bought with something — pins or density

Cache coherency between the CPU's view of PSRAM and anything else that can access the same memory — a DMA engine moving camera data into it, for instance — is a correctness problem that's easy to get subtly wrong, because a cached read can return stale data if the underlying memory changed through a path the cache never saw. If a DMA engine writes new frame data directly into PSRAM while the CPU's cache still holds an old cached copy of that same address range, the CPU can read back stale pixel data unless the system explicitly invalidates the relevant cache lines after the DMA write completes — this is exactly the same class of cache-coherency bug that shows up in any system where more than one bus master can touch the same memory region, and it has to be handled deliberately in firmware (explicit cache invalidation at the right points) rather than assumed to resolve itself.

PSRAM's DRAM-based refresh mechanism means its access latency isn't perfectly uniform the way true SRAM's is, and a refresh cycle landing at the wrong moment can occasionally stretch an access longer than expected. Every DRAM cell needs to be refreshed periodically or it loses its stored data, and that refresh operation briefly makes the memory array unavailable for a normal read or write — the memory controller schedules refresh cycles to minimize collision with real access requests, but an access that happens to land during a refresh window still incurs extra latency; for most application code running through the cache this is invisible, but latency-sensitive, uncached PSRAM access patterns need to account for this occasional variability rather than assuming every PSRAM access takes the same fixed time.

External PSRAM is the memory-capacity escape valve for applications this chip's limited on-die SRAM can't serve on its own, bought through a real board-level tradeoff — Octal SPI's bandwidth in exchange for pins a cost-constrained design might not have to spare — and requiring the same cache-coherency and refresh-latency discipline that any DRAM-backed, multi-master memory system demands, even when the chip's own cache makes most of that complexity invisible to application code running on top of it.

Take esp32 psram design further

Ask the copilot about this term, or have our engineers assess it against your process.