Part 1
요약·해설
native_sim FUSE, board build, 64-byte UART image load와 mount·read·write 명령을 다룹니다.
LittleFS · FAT
flash.bin · FUSE
UART · dd bs=64
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
0168DF2F1EAC9B0074B756A956F5DF017734BEEA2E1233BDF32C1BBEEB6E091E
.. zephyr:code-sample:: shell-fs
:name: File system shell
:relevant-api: file_system_api
Access a LittleFS file system partition in flash using the file system shell.
Overview
********
This example provides shell access to a LittleFS file system partition in flash.
Requirements
************
A board with LittleFS file system support and UART console
Building
********
native_sim
==========
You can build this sample for :ref:`native_sim <native_sim>` with:
.. zephyr-app-commands::
:zephyr-app: samples/subsys/shell/fs
:board: native_sim
:goals: build
:compact:
Which by default will use the flash simulator. The flash simulator will use a file,
:file:`flash.bin`, in the current directory to keep the flash content.
You have several options to control this. You can check them with:
.. code-block:: console
zephyr/zephyr.exe -help
Check the :ref:`native_sim UART documentation <native_ptty_uart>` for information on how to connect
to the UART.
With FUSE access in the host filesystem
---------------------------------------
If you enable the :ref:`host FUSE filsystem access <native_fuse_flash>`
you will also have the flash filesystem mounted and accessible from your Linux host filesystem.
Before starting a build, make sure that the i386 pkgconfig directory is in your
search path and that a 32-bit version of libfuse is installed. For more
background information on this requirement check
:ref:`the native_sim documentation <native_fuse_flash>`.
.. code-block:: console
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
.. zephyr-app-commands::
:zephyr-app: samples/subsys/shell/fs
:board: native_sim
:gen-args: -DCONFIG_FUSE_FS_ACCESS=y
:goals: build
:compact:
Reel Board
==========
.. zephyr-app-commands::
:zephyr-app: samples/subsys/shell/fs
:board: reel_board
:goals: build
:compact:
Particle Xenon
==============
This target is customized to support the same SPI NOR partition table as
the :zephyr:code-sample:`littlefs` sample.
.. zephyr-app-commands::
:zephyr-app: samples/subsys/shell/fs
:board: particle_xenon
:goals: build
:compact:
Flash load
==========
If you want to use the 'flash load' command then build the sample with the
'prj_flash_load.conf' configuration file. It has defined a larger RX buffer.
If the buffer is too small then some data may be lost during transfer of large
files.
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 LittleFS file system.
.. code-block:: console
fs mount littlefs /lfs
Loading filesystem from host PC to flash memory
===============================================
Use command:
.. code-block:: console
flash load <address> <size>
It allows loading the data via UART, directly into flash memory at a given
address. Data must be aligned to a value dependent on the target flash memory,
otherwise it will cause an error and nothing will be loaded.
From the host side file system must be loaded with 'dd' tool with 'bs=64'
(if the file is loaded in chunks greater than 64B the data is lost and isn't
received by the Zephyr shell).
Example in Zephyr console:
.. code-block:: console
flash load 0x7a000 0x5000
Example in the host PC:
.. code-block:: console
dd if=filesystem of=/dev/ttyACM0 bs=64
During the transfer there are printed messages indicating how many chunks are
already written. After the successful transfer the 'Read all' message is
printed.
Files System Shell Commands
===========================
Mount
-----
Mount a file system partition to a given mount point
.. code-block:: console
fs mount (littlefs|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 :ref:`native sim board <native_sim>` 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.
Part 3
한국어 전문 번역
개요
Flash의 LittleFS filesystem partition에 shell로 접근하는 example입니다.
요구 사항
LittleFS filesystem과 UART console을 지원하는 board가 필요합니다.
빌드
native_sim
다음 command로 native_sim용 sample을 build합니다.
west build -b native_sim samples/subsys/shell/fs
기본 설정은 flash simulator를 사용하며 현재 directory의 flash.bin file에 flash content를 유지합니다. Simulator option은 실행 파일의 help에서 확인합니다.
zephyr/zephyr.exe -help
UART 연결 방법은 native_sim UART 문서를 따릅니다.
Host filesystem에서 FUSE로 접근
Host FUSE filesystem access를 활성화하면 simulated flash filesystem이 Linux host filesystem에도 mount되어 직접 접근할 수 있습니다. Build 전에 i386 pkg-config directory를 search path에 넣고 32-bit libfuse를 설치해야 합니다.
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
CONFIG_FUSE_FS_ACCESS=y를 전달해 FUSE access를 포함한 native_sim sample을 build합니다.
west build -b native_sim samples/subsys/shell/fs -- -DCONFIG_FUSE_FS_ACCESS=y
Reel Board
다음 command로 reel_board용 sample을 build합니다.
west build -b reel_board samples/subsys/shell/fs
Particle Xenon
이 target은 LittleFS sample과 같은 SPI NOR partition table을 지원하도록 customization되어 있습니다.
west build -b particle_xenon samples/subsys/shell/fs
Flash load
flash load command를 사용하려면 prj_flash_load.conf configuration으로 sample을 build합니다. 이 configuration은 더 큰 RX buffer를 정의합니다. Buffer가 작으면 큰 file transfer 중 일부 data가 손실될 수 있습니다.
실행
Board boot가 끝나면 shell prompt가 나타나며 filesystem 관련 command는 모두 fs의 subcommand로 제공됩니다. 먼저 LittleFS를 /lfs에 mount합니다.
fs mount littlefs /lfs
Host PC에서 flash memory로 filesystem 로드
UART를 통해 지정한 flash address에 data를 직접 load하는 command 형식입니다.
flash load <address> <size>
Data는 target flash memory가 요구하는 단위에 맞게 alignment되어야 합니다. 맞지 않으면 error가 발생하고 아무것도 load되지 않습니다. Zephyr console example은 address 0x7a000에 size 0x5000을 받습니다.
flash load 0x7a000 0x5000
Host에서는 dd의 block size를 정확히 64 byte로 지정해 filesystem image를 serial device에 씁니다. 64 byte보다 큰 chunk를 사용하면 data가 손실되어 Zephyr shell이 받지 못합니다.
dd if=filesystem of=/dev/ttyACM0 bs=64
Transfer 중에는 이미 기록한 chunk 수가 출력되며 모두 성공적으로 받으면 Read all message가 표시됩니다.
Filesystem Shell 명령
Mount
LittleFS 또는 FAT filesystem partition을 지정한 mount point에 mount합니다.
fs mount (littlefs|fat) <path>
Ls
지정한 path의 file과 directory를 모두 나열합니다.
fs ls [path]
Cd
Current working directory를 지정한 path로 변경합니다.
fs cd [path]
Pwd
Current working directory를 표시합니다.
fs pwd
Write
지정한 file에 hexadecimal number를 씁니다. 선택적으로 file 내부 offset을 지정할 수 있습니다.
fs write <path> [-o <offset>] <hex number> ...
Read
File을 읽어 hexadecimal과 ASCII 형식으로 dump합니다.
fs read <path>
Trunc
지정한 file을 truncate합니다.
fs trunc <path>
Mkdir
새 directory를 만듭니다.
fs mkdir <path>
Rm
File 또는 directory를 제거합니다.
fs rm <path>
Flash Host Access
native_sim board의 flash partition은 Linux host system에서 접근할 수 있습니다. 기본적으로 build를 시작한 directory를 기준으로 한 flash directory에 partition이 표시됩니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.