Flash Memory - TeensyUser/doc GitHub Wiki
Flash Memory and psram memory
- Flash memory is persistent memory in that it is saved when the power is cut off to the Teensy.
- psram memory is volatile memory that may not preserve its contents when the power is cut off.
Flash Memory on the Audio Shield
The Teensy audio shield contains 8 pads that you can solder a SOIC 8-pin flash memory chip to the shield. The CS pin to access the flash memory is 6.
You can also use a SOIC-8 pin to through hole pin header to bring out the flash memory, such as the Sparkfun BOB-13655.
You would use the Serial Flash library to access this memory.
Flash memory chips that are known to work with both the audio shield and the Teensy 4.1 include:
- W25Q128JVSIQ-ND, 128 megabit/16 megabyte storage.
Here is a post containing timing information on accessing flash memory vs. SD cards.
You can use Frank Boesing's Teensy Transfer to inspect, write to, and read from flash memory on a Teensy LC, 3.1, 3.2, 3.5, or 3.6 (right now it does not work on a Teensy 4.0):
In 2020, patches were provided in the thread by Michael Meissner to allow Teensy Transfer to work on the Teensy 4.0 to access flash memory on the audio shield. Teensy Transfer has not yet been ported to the Teensy 4.1 to access the flash memory that can be directly soldered to the Teensy 4.1.
Flash memory on the prop shields
Both of the prop shields (with motion detection and without) include an 8 megabyte flash memory module. Like the audio shield, the CS pin is 6.
Teensy 4.1 QSPI flash and psram pads
The Teensy 4.1 has two sets of pads to solder one or two 8 pin QSPI flash memory chips directly on the Teensy.
- One of the pads is set up for a SOIC 8-pin flash (same flash as used by the audio board).
- The other set of pads has a smaller footprint, and is meant for SOC 8-pin psram memory.
PJRC.COM sells a psram chip for the Teensy 4.1, and there are 3 other known sellers of the chip:
- PJRC.com 8 megabyte psram chip
- Aliexpress.com 8 megabyte psram chip, English version
- Aliexpress.com 8 megabyte psram chip, German version
- Electrodragon.com 8 megabyte psram chip
- ExpTech 8 megabyte psram chip (Germany)
- Lyontek Inc. LY68L6400SLIT -- should work, but not confirmed.
The psram chip is used on some ESP32 boards. Frank Boesing has mentioned that he de-soldered the psram chip from a donor ESP32 board and moved it to a Teensy 4.1. This can be useful if you want to use the psram immediately, and can't wait for mail from the USA (pjrc.com) or China (aliexpress.com or electrodragon.com).
Adafruit has added the psram chip to their products list. Hopefully other Adafruit distributors will also pick it up.
Digikey has added the Adafruit psram chip but as on August 19th, 2020, they did not yet have stock:
This test from Frank Boesing can be used to test if the psram is properly connected.
Flash/psram combinations:
- If you only have a single psram chip, it must be soldered to the pads nearest the end of the Teensy (between pins 30 and 32).
- If you only have a single FLASH chip, it must be soldered to the pads next to the first set of pads (between pins 28 and 30).
- If you have one psram chip and one FLASH chip, they must be soldered to the pads mentioned above.
- If you have 2 sets of psram chips, you can solder them to each of the two pads.
- If you solder in 1 or 2 psram chips, starting with Teensydunio 1.52, the Teensy startup code will initialize the psram.
- Unlike flash memory, psram does not persist when the Teensy is powered off.
- This post on pjrc.com shows the pinouts of the flash pads underneath the Teensy 4.1.
There is no compile time test for whether psram memory is installed or not. Starting with Teensydunio 1.52, when the sketch starts up, the start up code indicates the number of megabytes of psram is available into the external_psram_size variable. You should use the following declaration to check this variable:
extern "C" uint8_t external_psram_size __attribute__((weak));
You would test it with:
if (&external_psram_size && external_psram_size > 0) { ... }
If you aren't running on of the beta versions of Teensy 1.52, you can eliminate the weak attribute and the test to make sure the address is not NULL.
On the Teensy 4.1, you can declare static or global variables to be EXTMEM, and the linker will allocate these variables in the space that the flash memory will be loaded into. These variables cannot be initialized.