Cornell University ECE4760
microSD card for

Pi Pico RP2040

External memory
PICO RAM is about 260 KB and flash program memory is about 2MB. There is often a need for more storage for audio, video, some simulations, and AI. This page explores ways of connecting external memory to the RP2040 in ways that do not use too many i/o resources, in this case a serial SD card. The interface to the card is handled by a very nice FatFs library adapted for SD card from carlk3. Conviently reading and writing data may require several things, including mounting the drive, opening/closing files, and of course read/write commands. I borrowed a command line interface from tinyUSB examples to test the SD card functions. The SD card is completely handled by FatFs. Compatability with PC formatting seems good.

microSD card on Adafruit #254
The SD card is fast, but as usual, when working on a solderless protoboard, the maximum clock speed you can use is around 20 MHz
because of spurous pin capacitance. The Adafruit carrier board is shown below.
I think that the cheaper Adafruit 4682 or any number of clones will work.

Pin connections are:

The hw_config.c code provides the ability to remap the SPI channel and the gpio pins connected to the SPI channel.

Interactive test for FatFs file system

When the system resets, the driver should print card information to the serial terminal. The serial connection can then be used to issue commands to the file system. In a production system, the interactive interface will probably be replaced by specific code.
It was useful to build a test program that allows a user to fiddle with the file system and test performance.
On a serial terminal you can issue the following commands:

For a binary file contaiing 1000 ints, the write rate is about 17 uSec per int, and the read rate is about 4 uSec per int.

Code, Project Zip, FatFs Zip
Unzip the project folder and the FastFs folder into the same parent folder.

 


Copyright Cornell University April 1, 2024