|
| 1 | +.. _fs_shell-sample: |
| 2 | + |
| 3 | +File system shell example |
| 4 | +######################### |
| 5 | + |
| 6 | +Overview |
| 7 | +******** |
| 8 | + |
| 9 | +This example provides shell access to a NFFS file system partition in flash. |
| 10 | + |
| 11 | +Requirements |
| 12 | +************ |
| 13 | + |
| 14 | +A board with NFFS file system support and UART console |
| 15 | + |
| 16 | +Building |
| 17 | +******** |
| 18 | + |
| 19 | +Native Posix |
| 20 | +============ |
| 21 | + |
| 22 | +Before starting a build, make sure that the i386 pkconfig directory is in your |
| 23 | +search path. |
| 24 | + |
| 25 | +.. code-block:: console |
| 26 | +
|
| 27 | + export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig |
| 28 | +
|
| 29 | +.. zephyr-app-commands:: |
| 30 | + :zephyr-app: samples/subsys/fs/shell |
| 31 | + :board: native_posix |
| 32 | + :goals: build |
| 33 | + :compact: |
| 34 | + |
| 35 | +See :ref:`native_posix` on how to connect to the UART. |
| 36 | + |
| 37 | +Reel Board |
| 38 | +========== |
| 39 | + |
| 40 | +.. zephyr-app-commands:: |
| 41 | + :zephyr-app: samples/subsys/fs/shell |
| 42 | + :board: reel_board |
| 43 | + :goals: build |
| 44 | + :compact: |
| 45 | + |
| 46 | +Running |
| 47 | +******* |
| 48 | + |
| 49 | +Once the board has booted, you will be presented with a shell prompt. |
| 50 | +All file system related commands are available as sub-commands of fs. |
| 51 | + |
| 52 | +Begin by mounting the NFSS file system. |
| 53 | + |
| 54 | +.. code-block:: console |
| 55 | +
|
| 56 | + fs mount nfss /nffs |
| 57 | +
|
| 58 | +Files System Shell Commands |
| 59 | +=========================== |
| 60 | + |
| 61 | +Mount |
| 62 | +----- |
| 63 | + |
| 64 | +Mount a file system partition to a given mount point |
| 65 | + |
| 66 | +.. code-block:: console |
| 67 | +
|
| 68 | + fs mount (nffs|fat) <path> |
| 69 | +
|
| 70 | +Ls |
| 71 | +-- |
| 72 | + |
| 73 | +List all files and directories in a given path |
| 74 | + |
| 75 | +.. code-block:: console |
| 76 | +
|
| 77 | + fs ls [path] |
| 78 | +
|
| 79 | +Cd |
| 80 | +-- |
| 81 | + |
| 82 | +Change current working directory to given path |
| 83 | + |
| 84 | +.. code-block:: console |
| 85 | +
|
| 86 | + fs cd [path] |
| 87 | +
|
| 88 | +Pwd |
| 89 | +--- |
| 90 | + |
| 91 | +List current working directory |
| 92 | + |
| 93 | +.. code-block:: console |
| 94 | +
|
| 95 | + fs pwd |
| 96 | +
|
| 97 | +Write |
| 98 | +----- |
| 99 | + |
| 100 | +Write hexadecimal numbers to a given file. |
| 101 | +Optionally a offset in the file can be given. |
| 102 | + |
| 103 | +.. code-block:: console |
| 104 | +
|
| 105 | + fs write <path> [-o <offset>] <hex number> ... |
| 106 | +
|
| 107 | +Read |
| 108 | +---- |
| 109 | + |
| 110 | +Read file and dump in hex and ASCII format |
| 111 | + |
| 112 | +.. code-block:: console |
| 113 | +
|
| 114 | + fs read <path> |
| 115 | +
|
| 116 | +Trunc |
| 117 | +----- |
| 118 | + |
| 119 | +Truncate a given file |
| 120 | + |
| 121 | +.. code-block:: console |
| 122 | +
|
| 123 | + fs trunc <path> |
| 124 | +
|
| 125 | +Mkdir |
| 126 | +----- |
| 127 | + |
| 128 | +Create a directory |
| 129 | + |
| 130 | +.. code-block:: console |
| 131 | +
|
| 132 | + fs mkdir <path> |
| 133 | +
|
| 134 | +Rm |
| 135 | +-- |
| 136 | + |
| 137 | +Remove a file or directory |
| 138 | + |
| 139 | +.. code-block:: console |
| 140 | +
|
| 141 | + fs rm <path> |
| 142 | +
|
| 143 | +Flash Host Access |
| 144 | +================= |
| 145 | + |
| 146 | +For the Native POSIX board the flash partitions can be accessed from the host |
| 147 | +Linux system. |
| 148 | + |
| 149 | +By default the flash partitions are accessible through the directory *flash* |
| 150 | +relative to the directory where the build is started. |
| 151 | + |
| 152 | + |
0 commit comments