Skip to content

oyama/pico-filesystem-examples

Repository files navigation

Example of pico_filesystem library for pico-sdk.

This project is a demonstration codes of the pico_filesystem library, which was added independently to pico-sdk 1.5 develop branch. The library adds a POSIX file API compliant file manipulation API that allows access to Pico's on-board flash memory and SD card. The project requires a forked pico-sdk. Check it out and specify it in PICO_SDK_PATH:

Pull requests to pico-sdk are as follows: raspberrypi/pico-sdk#1715

Examples

App Description
hello_world File writing and reading
auto_init Transparently perform file system initialisation.
ram_disk RAM disk with Heap block device.
benchmark Data transfer tests with different block devices and different file system combinations.
unittest Unit tests
usb_msc_logger Data logger that mounts littlefs and FAT on flash memory and shares it with a PC via USB mass storage class.
custom_blockdevice Add your own block devices. Useful for debugging file systems.

How to build forked pico-sdk

git clone --branch filesystem_support https://github.com/oyama/pico-sdk.git
cd pico-sdk
git submodule update --init

Build samples

Go to the directory of each sample code:

mkdir build; cd build
PICO_SDK_PATH=/path/to/forked/pico-sdk cmake ..
make

If no SD card device is connected, the WITHOUT_BLOCKDEVICE_SD option can be specified to skip the SD card manipulation procedure from the examples:

PICO_SDK_PATH=/path/to/forked/pico-sdk cmake .. -DWITHOUT_BLOCKDEVICE_SD=YES

Running examples of using SD cards

If an SD card is to be used, a separate circuit must be connected via SPI. As an example, the schematic using the Adafruit MicroSD card breakout board+ is as follows

adafruit-microsd

The spi and pin used in the block device argument can be customised. The following pins are used in the demonstration.

Pin PCB pin Usage description
GP18 24 SPI0 SCK SPI clock
GP19 25 SPI0 TX SPI Master Out Slave In
GP16 21 SPI0 RX SPI Master In Slave Out
GP17 22 SPI0 CSn SPI Chip select

More details

The pico_filesystem library is based on the pico-vfs library. See the pico-vfs repository for more information on the available APIs, file systems, etc.

About

Example of flexible file system support for pico-sdk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published