File System Shell Example¶
The File System Shell Example demonstrates shell access to a LittleFS file system partition in flash.
You will be presented with a shell prompt. All file system related commands are available as sub-commands of
Before you start building, the Zephyr development environment should be set up correctly:
Build the example¶
You can find the source code and the project file of the example in the following folder: examples/zephyr/shell/fs.
Build the example by performing the following steps:
Open terminal and navigate to the
m2devkitdirectory created in the Setup the toolchain section:
westto build the example:
west build -b nrf52840_m2 nrf52840-m2-devkit/examples/zephyr/shell/fs
If a build system is present, make the build folder pristine before building:
west build -t pristine
Flash the example¶
After compiled successfully, the firmware is located in
m2devkit/build/zephyr with the name
Connect the debugger USB port to your PC using the provided USB-C Cable. A disk drive called M2-DOCK will be automatically detected by the computer.
Run the following command to flash the board:
Test the File System Shell Example application by performing the following steps:
Connect the debugger USB port to your PC
screen /dev/cu.usbmodem14102 115200
Press RESET button, and You will be presented with a shell prompt.
fsto to print the available subcommands:
uart:~$ fs fs - File system commands Subcommands: cd :Change working directory ls :List files in current directory mkdir :Create directory mount :<Mount fs, syntax:- fs mount <fs type> <mount-point> pwd :Print current working directory read :Read from file rm :Remove file statvfs :Show file system state trunc :Truncate file write :Write file
Try the file system related commands. For example, mount the LittleFS file system:
fs mount littlefs /lfs
Create an Issue¶
Interested in contributing to this project? Want to report a bug? Feel free to click here: