Skip to content
Permalink
Browse files

samples: fs: Added FS shell sample

Added file system shell sample

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
  • Loading branch information...
vanwinkeljan authored and nashif committed Jan 14, 2019
1 parent a90c000 commit 265b195369205282efe69942927606a1a1ba958d
@@ -0,0 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(fs_shell)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
@@ -0,0 +1,152 @@
.. _shell-fs-sample:

File system shell example
#########################

Overview
********

This example provides shell access to a NFFS file system partition in flash.

Requirements
************

A board with NFFS file system support and UART console

Building
********

Native Posix
============

Before starting a build, make sure that the i386 pkconfig directory is in your
search path.

.. code-block:: console

export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig

.. zephyr-app-commands::
:zephyr-app: samples/subsys/shell/fs
:board: native_posix
:goals: build
:compact:

See :ref:`native_posix` on how to connect to the UART.

Reel Board
==========

.. zephyr-app-commands::
:zephyr-app: samples/subsys/shell/fs
:board: reel_board
:goals: build
:compact:

Running
*******

Once the board has booted, you will be presented with a shell prompt.
All file system related commands are available as sub-commands of fs.

Begin by mounting the NFSS file system.

.. code-block:: console

fs mount nffs /nffs

Files System Shell Commands
===========================

Mount
-----

Mount a file system partition to a given mount point

.. code-block:: console

fs mount (nffs|fat) <path>

Ls
--

List all files and directories in a given path

.. code-block:: console

fs ls [path]

Cd
--

Change current working directory to given path

.. code-block:: console

fs cd [path]

Pwd
---

List current working directory

.. code-block:: console

fs pwd

Write
-----

Write hexadecimal numbers to a given file.
Optionally a offset in the file can be given.

.. code-block:: console

fs write <path> [-o <offset>] <hex number> ...

Read
----

Read file and dump in hex and ASCII format

.. code-block:: console

fs read <path>

Trunc
-----

Truncate a given file

.. code-block:: console

fs trunc <path>

Mkdir
-----

Create a directory

.. code-block:: console

fs mkdir <path>

Rm
--

Remove a file or directory

.. code-block:: console

fs rm <path>

Flash Host Access
=================

For the Native POSIX board the flash partitions can be accessed from the host
Linux system.

By default the flash partitions are accessible through the directory *flash*
relative to the directory where the build is started.


@@ -0,0 +1,2 @@
CONFIG_FUSE_FS_ACCESS=y

@@ -0,0 +1,2 @@
CONFIG_MPU_ALLOW_FLASH_WRITE=y

@@ -0,0 +1,17 @@
CONFIG_FLASH=y

CONFIG_LOG=y

CONFIG_HEAP_MEM_POOL_SIZE=16384

CONFIG_SHELL=y

CONFIG_FLASH=y

CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FILE_SYSTEM_SHELL=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="flash_ctrl"

CONFIG_LOG=y

@@ -0,0 +1,6 @@
sample:
description: FS shell sample
name: FS shell
tests:
test_fs_shell:
platform_whitelist: reel_board
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2019 Jan Van Winkel <jan.van_winkel@dxplore.eu>
*
* SPDX-License-Identifier: Apache-2.0
*/


#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(app);

void main(void)
{
}
@@ -0,0 +1,10 @@
.. _shell-samples:

Shell System Samples
####################

.. toctree::
:maxdepth: 1
:glob:

**/*

0 comments on commit 265b195

Please sign in to comment.
You can’t perform that action at this time.