Adding More RAM and Flash to the Teensy 4.1

See how to add external PSRAM and NOR flash modules to your Teensy 4.1, as well as how to test and use them.

Evan Rust
4 years agoSensors / HW101 / Displays

The Teensy 4.1 is the newest board from PJRC, and it's their best one yet. Sporting a high-performance Arm Cortex-M7 processor, this board is capable of incredible things, including an up to 1GHz clock speed, two instructions per clock, a dedicated FPU, and branch prediction. On the storage side of things, it has 1 MB of RAM and 8 MB of flash memory, which makes projects using large arrays of data much easier. The board itself has 35 PWM pins, 18 analog pins, and a whole slew of communication interfaces, not to mention an onboard SD card slot.

RAM and Flash Chips

Although there is already a large amount of space to store your data, some projects might require even more than that. PJRC thought of that and included a way to expand the RAM and flash storage sizes by letting users add additional chips on the underside of the PCB.

One of these is for an PSRAM IC, which simply ties into the SPI bus and provides up to 8 MB of additional RAM to your projects. The one I chose was the chip listed on the PJRC store. To access its storage, either place a pointer to a location beyond 0x70000000 or use the keyword EXTMEM before a variable.

The second footprint can either have another PSRAM chip or a flash memory IC. I opted to use the flash chip for storing non-volatile data, but either is fine. I sourced my W25Q128JVSIQ ICs, and since they're the same ones that can be attached to the Teensy Audio Board, you can buy several to use in different places. This chip also ties into the SPI bus and has 16 MiB of memory.

Testing

PJRC provides a handy test program that goes through the RAM and sets/clears values. If there is an error at any point in the sketch, the program terminates and the onboard LED starts blinking. It works by setting a pointer to the memory location 0x70000000 (memory mapped addressing) and then iterating through each byte. At the end, there is either a success or error message, depending on the result of the tests.

For the flash IC, there is a library called extRAM_t4 that enabled access to the external flash memory module and RAM. It should be used in conjunction with the SPIFFS library to create an entire filesystem in the flash memory that is optimized for the microcontroller. There is a test file that initializes the flash memory module and then attempts to write and read a file on it. After doing those tasks successfully, it then prints out the directory and the total space used.

Future Applications

Adding more storage is great, especially for projects that must process large amounts of data, such as a matrix of pixels or signal processing. Additionally, the extra flash storage space could be ideal for keeping a large configuration file or logging information.

Evan Rust
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles