Description
The Teensy 4.1 boards supports one of these 8-pin 256MB (2G-bit) NAND Flash chips to expand the memory on the module primarily for use with the LittleFS library
PACKAGE INCLUDES:
- Winbond W25N02KVZEIR NAND Flash IC (WSON Package)
KEY FEATURES OF 256MB SERIAL FLASH:
- 256MB (2G-bit) memory
- NAND Flash technology
- SPI / Dual SPI / Quad SPI Interface
- 104/208/416MHz clock rate
- 3.3V operation
These ICs provide additional non-volatile memory for the Teensy 4.1 board. They are typically used to store sensor data, sound files, image files or similar types of data. Although the external Flash can’t be used to increase the space for programs, in some cases it may help to extend program memory space by providing a way to store large data structures that can be read into the program as needed.
The larger footprint on the bottom of the board supports one of these 256MB Flash chips. The PCB pads are designed for an SOIC chip, but the WSON package can be soldered in the location if care is exercised. Since the leads are tucked under the sides of the chip, soldering and testing the chip before the header pins are installed is highly recommended.
Note that the bottom of the chip has a rectangular metal pad. This pad is not connected to anything in the chip, but can be a possible shorting hazard across the PCB pads if the chip is not centered on the pads. Keeping solder limited to the outer portion of the board pads helps to minimize that concern. It may be desirable to cover the pad with Kapton tape or similar insulator to avoid the possibility of shorting.
If this all sounds good but you don’t want to deal with the soldering or possible debugging if the soldering doesn’t go well, we offer the Teensy 4.1 Fully Loaded with this chip mounted and tested along with additional PSRAM and all the other soldering completed. There are other memory configurations also available. Click on the pic below for more info about the different options.
Using the 256MB/2G-bit Memory Chip
The PaulStoffregen/LittleFS Library can be used to work with this chip.
When used with the LittleFS file system, the 256MB/2G-bit NAND Flash chip uses the LittleFS_QPINAND constructor.
#include “LittleFS.h”
LittleFS_QPINAND myfs; // NAND FLASH 2Gb
The program below uses LittleFS to report the size of the chip. If the chip is brand new, LittleFS will first format it. It then creates a directory and a file within that directory. It writes a string of text and then reopens the file and appends another string of text to the file. Finally it then prints out the file contents and then does a quick format of the chip to erase it. This program will work with any of the supported NAND Flash chips.
Example Program using the NAND Flash memory chip
/* Basic Program to exercise the NAND flash on Teensy 4.1 Based on PJRC teams Flash memory testing work, but pruned down */ #include "LittleFS.h" LittleFS_QPINAND myfs; // NAND FLASH File file; uint64_t fTot, totSize1; //=============================================================================== // Initialization //=============================================================================== void setup() { while (!Serial) ; // wait for serial port to open Serial.println("QSPI NAND Flash Memory Test"); delay(5); if (!myfs.begin()) { // try to open instance of myfs Serial.printf("Error starting QSPI Disk"); while( 1 ); // if can't open, print error and stop } Serial.printf("TotalSize (Bytes): %dn", myfs.totalSize()); // total Flash bytes Serial.printf("TotalSize (Bits): %dn", myfs.totalSize()*8); // total Flash bits delay(1000); Serial.println("nCreate directory and file in directory - directory1/file1.txt"); myfs.mkdir("directory1"); // make a directory file = myfs.open("file1.txt", FILE_WRITE); // create & open a file delay(10); file.println("The quick brown fox"); file.close(); file = myfs.open("file1.txt", FILE_WRITE); // reopen file and append to it delay(10); file.println("jumped over the lazy dogs back."); file.close(); File dataFile = myfs.open("file1.txt"); // open the file. Serial.print("nPrint contents of file1.txt: "); if (dataFile) { // if the file is available, Read from it: while (dataFile.available()) { Serial.write(dataFile.read()); } Serial.print("File size:"); Serial.println(dataFile.size(), DEC); dataFile.close(); } else { Serial.println("error opening file1.txt"); } Serial.printf("nDisk Usage:n"); Serial.printf("Bytes Used: %llu, Bytes Total:%llun", myfs.usedSize(), myfs.totalSize()); Serial.println("nErasing Flash"); myfs.quickFormat(); Serial.printf("nDisk Usage:n"); Serial.printf("Bytes Used: %llu, Bytes Total:%llun", myfs.usedSize(), myfs.totalSize()); } //=============================================================================== // Main //=============================================================================== void loop() { }
FURTHER READING:
LEARN – Working with Teensy 4.1 Memory – Overview of the Teensy 4.1 memory architecture including the optional PSRAM and Flash memories.
Notes:
- These chips are not available in Tape & Reel, so they are packaged individually loose in a high quality ESD bag. Since there are no external leads on the chip package, this doesn’t cause a problem.
Technical Specifications
Operational Ratings | ||
Vcc | 2.7V – 3.6V | |
Clock Rate | Maximum | 104/208/416MHz |
Package Type | Plastic body, 8-pad WSON 8x6mm | |
Datasheet | Winbond | W25N02KV |