I frequently work with ESP32 microcontrollers (MCU), both at my day job and in my free time. These devices are very flexible, but like any microcontro

Static Allocation in External RAM on ESP32

submited by
Style Pass
2024-06-30 15:00:02

I frequently work with ESP32 microcontrollers (MCU), both at my day job and in my free time. These devices are very flexible, but like any microcontroller they are quite resource constrained in comparison to anything equivalent to or larger than a single-board computer.

There are a few different variants of the ESP32 these days, but one of the newer and most popular is the ESP32-S3. Compared to the ESP32-S2, it offers a dual-core 32-bit Xtensa processor, support for Bluetooth 5.0, and more on-chip SRAM and ROM (full comparison can be found here). Both of these SoC’s, as well as others from Espressif, allow for integrating external RAM and flash, making it possible to run larger, more complex firmware.

At first thought, it may seem as though it would be desirable for microcontrollers to use dynamic random access memory (DRAM) as it is more dense than static random access memory (SRAM), and thus cheaper. However, as the name suggests, DRAM must be constantly refreshed, which leads to higher power consumption when idle. The refresh behavior of DRAM also makes it more complex to integrate into a system. Given that microcontrollers typically only require a small amount of RAM, SRAM is generally used for on-chip memory.

The ESP32-S3 has 512 KB of on-chip SRAM, but is capable of mapping up to 32 MB of external RAM into its memory address space. In order to make this larger external RAM exhibit similar properties to the on-chip RAM, pseudostatic RAM (PSRAM) is used. PSRAM is technically DRAM, but the external chip contains its own refresh circuitry, allowing it to appear to the MCU like SRAM that is communicated with via a serial peripheral interface (SPI) bus.

Leave a Comment