Part 1
요약·해설
신규 file system의 정상 진단, host lfs 절차, volume-name 우선순위를 설명합니다.
storage partition
SDMMC · MMC
Nucleo · nRF52840 · Xenon
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
4222EB75923E9691A50432D848274F3DF736D504BE6E138BD14A30DCC3BFAEE7
.. zephyr:code-sample:: littlefs
:name: LittleFS filesystem
:relevant-api: file_system_api flash_area_api
Use file system API over LittleFS.
Overview
********
This sample app demonstrates use of Zephyr's :ref:`file system API
<file_system_api>` over `littlefs`_, using file system with files that:
* count the number of times the system has booted
* holds binary pattern with properly incremented values in it
Other information about the file system is also displayed.
.. _littlefs:
https://github.com/ARMmbed/littlefs
Requirements
************
Flash memory device
-------------------
The partition labeled "storage" will be used for the file system; see
:ref:`flash_map_api`. If that area does not already have a
compatible littlefs file system its contents will be replaced by an
empty file system. You will see diagnostics like this::
[00:00:00.010,192] <inf> littlefs: LittleFS version 2.0, disk version 2.0
[00:00:00.010,559] <err> littlefs: Corrupted dir pair at 0 1
[00:00:00.010,559] <wrn> littlefs: can't mount (LFS -84); formatting
The error and warning are normal for a new file system.
After the file system is mounted you'll also see::
[00:00:00.182,434] <inf> littlefs: filesystem mounted!
[00:00:00.867,034] <err> fs: failed get file or dir stat (-2)
This error is also normal for Zephyr not finding a file (the boot count,
in this case).
Block device (e.g. SD card)
---------------------------
One needs to prepare the SD/MMC card with littlefs file system on
the host machine with the `lfs`_ program.
.. _lfs:
https://www.thevtool.com/mounting-littlefs-on-linux-machine/
.. code-block:: console
sudo chmod a+rw /dev/sda
lfs -d -s -f --read_size=512 --prog_size=512 --block_size=512 --cache_size=512 --lookahead_size=8192 --format /dev/sda
lfs -d -s -f --read_size=512 --prog_size=512 --block_size=512 --cache_size=512 --lookahead_size=8192 /dev/sda ./mnt_littlefs
cd ./mnt_littlefs
echo -en '\x01' > foo.txt
cd -
fusermount -u ./mnt_littlefs
Building and Running
********************
Flash memory device
-------------------
This example should work on any board that provides a "storage"
partition. Two tested board targets are described below.
You can set ``CONFIG_APP_WIPE_STORAGE`` to force the file system to be
recreated.
Block device (e.g. SD card)
---------------------------
This example has been devised and initially tested on :ref:`Nucleo H743ZI <nucleo_h743zi_board>`
board. It can be also run on any other board with SD/MMC card connected to it.
To build the test:
.. zephyr-app-commands::
:zephyr-app: samples/subsys/fs/littlefs
:board: nucleo_h743zi
:goals: build flash
:gen-args: -DCONF_FILE=prj_blk.conf
:compact:
At the moment, only two types of block devices are acceptable in this sample: SDMMC and MMC.
It is possible that both the `zephyr,sdmmc-disk` and `zephyr,mmc-disk` block devices will be
present and enabled in the final board dts and configuration files simultaneously, the mount
point name for the `littlefs` file system block device will be determined based on the
following logic:
* if the ``CONFIG_SDMMC_VOLUME_NAME`` configuration is defined, it will be used
as the mount point name;
* if the ``CONFIG_SDMMC_VOLUME_NAME`` configuration is not defined, but the
``CONFIG_MMC_VOLUME_NAME`` configuration is defined, ``CONFIG_MMC_VOLUME_NAME`` will
be used as the mount point name;
* if neither ``CONFIG_SDMMC_VOLUME_NAME`` nor ``CONFIG_MMC_VOLUME_NAME`` configurations
are defined, the mount point name will not be determined, and an appropriate error will
apear during the sample build.
NRF52840 Development Kit
========================
On this device the file system will be placed in the SOC flash.
.. zephyr-app-commands::
:zephyr-app: samples/subsys/fs/littlefs
:board: nrf52840dk/nrf52840
:goals: build
:compact:
Particle Xenon
==============
On this device the file system will be placed on the external SPI NOR
flash memory.
.. zephyr-app-commands::
:zephyr-app: samples/subsys/fs/littlefs
:board: particle_xenon
:goals: build
:compact:
Part 3
한국어 전문 번역
개요
Zephyr file system API를 LittleFS 위에서 사용하는 sample application입니다. File system에는 system boot 횟수를 세는 file과 값이 올바르게 증가하는 binary pattern을 담은 file이 있으며, 그 밖의 file system 정보도 함께 표시합니다.
요구 사항
Flash memory device
storage label이 붙은 partition을 file system으로 사용합니다. Partition 배치는 flash map API를 참조하십시오. 이 영역에 호환되는 LittleFS가 없다면 기존 내용은 빈 file system으로 교체됩니다.
새 file system에서는 다음과 같은 진단이 나타납니다.
[00:00:00.010,192] <inf> littlefs: LittleFS version 2.0, disk version 2.0
[00:00:00.010,559] <err> littlefs: Corrupted dir pair at 0 1
[00:00:00.010,559] <wrn> littlefs: can't mount (LFS -84); formatting
Corrupted dir pair와 can't mount (LFS -84); formatting error·warning은 새 file system에서 정상입니다. Mount가 끝나면 다음 메시지가 이어집니다.
[00:00:00.182,434] <inf> littlefs: filesystem mounted!
[00:00:00.867,034] <err> fs: failed get file or dir stat (-2)
여기서 failed get file or dir stat (-2)도 Zephyr가 아직 boot count file을 찾지 못해 발생하는 정상적인 첫 실행 상태입니다.
Block device(예: SD card)
Host machine에서 lfs program을 사용해 SD/MMC card에 LittleFS를 미리 준비해야 합니다. 다음 예는 /dev/sda를 format하고 mount해 foo.txt를 만든 뒤 unmount합니다. 대상 device 이름을 잘못 선택하면 다른 disk의 데이터가 지워질 수 있으므로 실제 device를 먼저 확인하십시오.
sudo chmod a+rw /dev/sda
lfs -d -s -f --read_size=512 --prog_size=512 --block_size=512 --cache_size=512 --lookahead_size=8192 --format /dev/sda
lfs -d -s -f --read_size=512 --prog_size=512 --block_size=512 --cache_size=512 --lookahead_size=8192 /dev/sda ./mnt_littlefs
cd ./mnt_littlefs
echo -en '\x01' > foo.txt
cd -
fusermount -u ./mnt_littlefs
빌드 및 실행
Flash memory device
storage partition을 제공하는 board라면 이 예제를 실행할 수 있습니다. 아래에는 시험된 두 board target이 제시됩니다. CONFIG_APP_WIPE_STORAGE를 설정하면 file system을 강제로 다시 생성할 수 있습니다.
Block device(예: SD card)
Block-device 예제는 처음에 Nucleo H743ZI에서 설계·시험했지만 SD/MMC card가 연결된 다른 board에서도 실행할 수 있습니다. 다음은 prj_blk.conf를 선택해 build하고 flash하는 command입니다.
west build -b nucleo_h743zi samples/subsys/fs/littlefs -- -DCONF_FILE=prj_blk.conf
west flash
현재 이 sample에서 허용하는 block device type은 SDMMC와 MMC 두 가지뿐입니다.
최종 board DTS와 configuration에 zephyr,sdmmc-disk와 zephyr,mmc-disk가 동시에 enable될 수도 있습니다. 이때 LittleFS block device의 mount point 이름은 다음 우선순위로 정합니다.
CONFIG_SDMMC_VOLUME_NAME이 정의되어 있으면 이 값을 사용합니다.- SDMMC 이름은 없고
CONFIG_MMC_VOLUME_NAME이 정의되어 있으면 MMC 값을 사용합니다. - 둘 다 정의되어 있지 않으면 mount point 이름을 정할 수 없으며 sample build 중 적절한 error가 발생합니다.
NRF52840 Development Kit
이 device에서는 file system을 SoC flash에 배치합니다.
west build -b nrf52840dk/nrf52840 samples/subsys/fs/littlefs
Particle Xenon
이 device에서는 file system을 external SPI NOR flash memory에 배치합니다.
west build -b particle_xenon samples/subsys/fs/littlefs
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.