P2 DUAL uSD FAT32 and FLASH Filesystem (spin2/pasm2)
Stephen Moraco
Posts: 442
New P2 Dual Filesystem Driver — SD FAT32 + Flash in One Cog
Version 1.0.0
This is the first public release of a unified dual-filesystem driver for the P2 Edge Module. It gives you simultaneous access to both the onboard 16 MB Flash chip and a microSD card through a single worker cog and a single API — every file operation takes a device parameter, so you can read, write, and copy across both devices seamlessly.
Incorporates P2 uSD FAT32 FS v1.3.1 and P2 FLASH FS v2.0.0
What's in the box
- Unified Driver (dual_sd_fat32_flash_fs.spin2) — SD FAT32 and Flash filesystems managed by one dedicated cog with automatic SPI bus switching, hardware lock serialization, 6 simultaneous file/directory handles (configurable), 3 of which can be flash files (configurable), per-cog working directories, and cross-device copyFile() / moveFile()
- 7 Utilities — SD and Flash format, audit, and fsck (with auto-repair for SD), plus an SD card characterizer for benchmarking and card identification
- Demo Shell — Interactive dual-device terminal with sd/fl device switching, dir, cd, type, hexdump, copy, format, fsck, audit, bench, and more
- 4 Example Programs — Basic read/write, cross-device copy, data logger, and SD manifest reader copy to flash
- Full Documentation
Testing: 1,308 regression tests across 29 suites (SD, Flash, cross-device, dual-device, multi-cog), all validated on P2 hardware.
Known limitations:
- 8.3 filenames only (no LFN)
- SPI mode only, 25 MHz maximum
Compiles with pnut/pnut-ts.
Set up to compile with FlexSpin and Spin Tools IDE, but needs testing.
(Working through issues with FlexSpin; watch for a point release shortly.)
Hardware: P2 Edge Modules P2-EC and P2-EC32MB (both have built-in microSD socket and onboard 16 MB Flash chip).
Need only one device? Standalone alternatives produce smaller binaries: P2 FLASH FS and P2 uSD FAT32 FS.
Visit the Repo for full documentation, including a driver tutorial, theory of operations, and utilities guide.
The release package can be downloaded from the Release page as dual-fs-driver-{version}.zip.
If you find issues, please file them at the Issues.
Enjoy!
Stephen

Comments
This sounds great! Thanks.
Is this flash file system compatible with the one Chip made?
Yes, it is the very same as the release in my repo quite a while ago. (links in the announcement post to the repo's)