This project enables the sharing of data stored on the Raspberry Pi Pico's flash memory, formatted with the littlefs file system, as a USB storage device that can be accessed from a PC. It supports both read and write operations, allowing for easy backup and inspection directly from the PC without the need for specialized tools normally required for such tasks.
The firmware is designed to be deployed in RAM. The total file size that can be shared via USB MSC is limited to the RAM disk size of 64 KB.
Extract the firmware to the Pico's RAM and run it
- Create a RAM disk with FAT and mount it to
/ram
- Mount the onboard flash memory littlefs to
/flash
- Copy the contents of
/flash
to/ram
- Start USB MSC
- Wait for host PC to write.
- When the writing is finished, copy the content from
/ram
to/flash
- Repeat from step 5
When reset, the Pico operates with the original firmware
For those who prefer not to build the firmware from source, pre-built binaries are available under the Releases section of this repository. To use the pre-built firmware, follow these steps:
- Download the latest
sync.uf2
file from the Releases page. - Connect your Raspberry Pi Pico to your PC in BOOTCEL mode (hold the BOOTSEL button while connecting via USB).
- Drag and drop the downloaded
sync.uf2
file onto the RPI-RP2 drive that appears on your computer. - The Pico will automatically reboot and start running the new firmware after the file transfer is complete.
This allows you to quickly test and use the application without needing to set up a development environment.
To compile and install this project, a setup with the pico-sdk is necessary. Please refer to Getting Started with Raspberry Pi Pico to prepare your toolchain. This project incorporates pico-vfs and littlefs as git submodule, which requires an update post-checkout.
git clone https://github.com/oyama/pico-drive-sync.git
cd pico-drive-sync
git submodule update --init --recursive
mkdir build; cd build;
PICO_SDK_PATH=/path/to/pico-sdk cmake ..
make
Successful compilation will generate sync.uf2
. Simply drag and drop this onto the Raspberry Pi Pico and the firmware will be executate from RAM.
Alternatively, it can be performed using picotool:
picotool load --execute sync.uf2 --force
When the file operation on the host PC is finished, restart Pico and it will run with the original firmware from the flash.
Specify the block device size of the littlefs on the flash memory with the option -DFLASH_SIZE
in CMake. If not specified, 1441792
bytes are set. This is a setting consistent with the file system of the MicroPython environment.
PICO_SDK_PATH=/path/to/pico-sdk cmake .. -DFLASH_SIZE=1441792