Skip to content
Permalink
Browse files

native_posix: Added support to access flash via FUSE

Added support to access flash device partitions from host through
FUSE.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
  • Loading branch information...
vanwinkeljan authored and nashif committed Jan 14, 2019
1 parent 3815ae6 commit a90c0007901754a3a8e275c4a8e9b0029cff3fe8
Showing with 591 additions and 0 deletions.
  1. +1 −0 CODEOWNERS
  2. +38 −0 boards/posix/native_posix/doc/index.rst
  3. +10 −0 subsys/fs/CMakeLists.txt
  4. +6 −0 subsys/fs/Kconfig
  5. +536 −0 subsys/fs/fuse_fs_access.c
@@ -320,6 +320,7 @@
/subsys/debug/ @nashif
/subsys/fs/ @nashif
/subsys/fs/fcb/ @nvlsianpu
/subsys/fs/fuse_fs_access.c @vanwinkeljan
/subsys/fs/nvs/ @Laczen
/subsys/logging/ @nordic-krch
/subsys/mgmt/ @carlescufi @nvlsianpu
@@ -554,6 +554,9 @@ The following peripherals are currently provided with this board:
configuration. In case the file does not exists the driver will take care of
creating the file, else the existing file is used.

The flash content can be accessed from the host system, as explained in the
`Host based flash access`_ section.

UART
****

@@ -626,3 +629,38 @@ development by integrating more seamlessly with the host operating system:
A backend/"bottom" for Zephyr's CTF tracing subsystem which writes the tracing
data to a file in the host filesystem.
More information can be found in :ref:`Common Tracing Format <ctf>`

Host based flash access
***********************

If a flash device is present, the file system partitions on the flash
device can be exposed through the host file system by enabling
:option:`CONFIG_FUSE_FS_ACCESS`. This option enables a FUSE
(File system in User space) layer that maps the Zephyr file system calls to
the required UNIX file system calls, and provides access to the flash file
system partitions with normal operating system commands such as ``cd``,
``ls`` and ``mkdir``.

By default the partitions are exposed through the directory *flash* in the
current working directory. This directory can be changed via the command line
option *--flash-mount*. As this directory operates as a mount point for FUSE
you have to ensure that it exists before starting the native POSIX board.

On exit, the native POSIX board application will take care of unmounting the
directory. In the unfortunate case that the native POSIX board application
crashes, you can cleanup the stale mount point by using the program
``fusermount``::

$ fusermount -u flash

Note that this feature requires a 32-bit version of the FUSE library, with a
minimal version of 2.6, on the host system and ``pkg-config`` settings to
correctly pickup the FUSE install path and compiler flags.

On a Ubuntu 18.04 host system, for example, install the ``pkg-config`` and
``libfuse-dev:i386`` packages, and configure the pkg-config search path with
these commands::

$ sudo apt-get install pkg-config libfuse-dev:i386
$ export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig

@@ -19,3 +19,13 @@ endif()

add_subdirectory_ifdef(CONFIG_FCB ./fcb)
add_subdirectory_ifdef(CONFIG_NVS ./nvs)

if(CONFIG_FUSE_FS_ACCESS)
zephyr_library_named(FS_FUSE)
find_package(PkgConfig REQUIRED)
pkg_search_module(FUSE REQUIRED fuse)
zephyr_include_directories(${FUSE_INCLUDE_DIR})
zephyr_link_libraries(${FUSE_LIBRARIES})
zephyr_library_compile_definitions(_FILE_OFFSET_BITS=64)
zephyr_library_sources(fuse_fs_access.c)
endif()
@@ -51,6 +51,12 @@ config FILE_SYSTEM_SHELL
This shell provides basic browsing of the contents of the
file system.

config FUSE_FS_ACCESS
bool "Enable FUSE based access to file system partitions"
depends on ARCH_POSIX
help
Expose file system partitions to the host system through FUSE.

menu "FatFs Settings"
visible if FAT_FILESYSTEM_ELM

0 comments on commit a90c000

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