Part 1
요약·해설
네 build 조합, DATAFLASH_1 출력과 optional chip 오류를 보존합니다.
AT45DB321E
nRF9160 DK
DATAFLASH_1
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
C361C5EAAB33B5EDDF6EC81F1648458FC1D18F3ED638A1656CD792A079B21231
.. zephyr:code-sample:: spi-flash-at45
:name: AT45 DataFlash driver
:relevant-api: flash_interface
Use the AT45 family DataFlash driver to interact with the flash memory over SPI.
Overview
********
This sample shows how to use the AT45 family DataFlash driver and how to
specify devicetree nodes that enable flash chip instances to be handled
by the driver (an overlay with two sample nodes is provided).
The sample writes a defined test region in the flash memory with bytes of
increasing (and overflowing at the 8-bit range) values and then reads it back
to check if the write was successful. The starting value is also increased
in consecutive runs of the sample.
The sample have two config overlays.
The :zephyr_file:`samples/drivers/spi_flash_at45/overlay-pm.conf` enables the
device power management API which allows set device into a low power state.
The :zephyr_file:`samples/drivers/spi_flash_at45/overlay-page_layout.conf`
enables the flash page layout API which allow show the flash information.
In the default configuration, the AT45 flash driver is configured to use
the Read-Modify-Write functionality of DataFlash chips and does not perform
page erasing, as it is not needed in this case. This can be modified by
simply disabling the :kconfig:option:`CONFIG_SPI_FLASH_AT45_USE_READ_MODIFY_WRITE` option.
Requirements
************
This sample has been tested on the Nordic Semiconductor nRF9160 DK
(nrf9160dk/nrf9160) board with the AT45DB321E chip connected.
It can be easily adjusted to be usable on other boards and with other
AT45 family chips by just providing a corresponding overlay file.
Building and Running
********************
The code can be found in :zephyr_file:`samples/drivers/spi_flash_at45`.
To build and flash the application:
.. zephyr-app-commands::
:zephyr-app: samples/drivers/spi_flash_at45
:board: nrf9160dk/nrf9160
:goals: build flash
:compact:
To build and flash with device power management enabled:
.. zephyr-app-commands::
:zephyr-app: samples/drivers/spi_flash_at45
:board: nrf9160dk/nrf9160
:gen-args: -DEXTRA_CONF_FILE=overlay-pm.conf
:goals: build flash
:compact:
To build and flash with flash page layout enabled:
.. zephyr-app-commands::
:zephyr-app: samples/drivers/spi_flash_at45
:board: nrf9160dk/nrf9160
:gen-args: -DEXTRA_CONF_FILE=overlay-page_layout.conf
:goals: build flash
:compact:
Finally, to build and flash with both device power management and flash page
layout enabled:
.. zephyr-app-commands::
:zephyr-app: samples/drivers/spi_flash_at45
:board: nrf9160dk/nrf9160
:gen-args: -DEXTRA_CONF_FILE="overlay-pm.conf overlay-page_layout.conf"
:goals: build flash
:compact:
Sample Output
=============
This is a typical output when both device power management and flash page
layout are enabled:
.. code-block:: console
DataFlash sample app on nrf9160dk_nrf9160
Using DATAFLASH_1, chip size: 4194304 bytes (page: 512)
Reading the first byte of the test region ... OK
Preparing test content starting with 0x01.
Writing the first half of the test region... OK
Writing the second half of the test region... OK
Reading the whole test region... OK
Checking the read content... OK
Putting the flash device into low power state... OK
The sample is supplied with the overlay file that specifies two instances
of AT45 family chips but only the one labeled "DATAFLASH_1" is required
for the sample to work. If the other chip is not connected, the following
log message appears, but apart from that the behavior of the sample stays
unaffected.
.. code-block:: console
[00:00:00.000,000] <err> spi_flash_at45: Wrong JEDEC ID: ff ff ff, expected: 1f 24 00
Part 3
한국어 전문 번역
개요
이 sample은 AT45 family DataFlash driver를 사용하는 방법과, flash chip instance를 driver가 처리하도록 활성화하는 devicetree node 지정 방법을 보여줍니다. Sample node 두 개가 들어 있는 overlay도 제공합니다.
Flash memory의 정해진 test 영역에 8-bit 범위에서 증가하다 overflow하는 byte 값을 쓰고 다시 읽어 write 성공 여부를 확인합니다. Sample을 연속 실행할 때마다 시작 값도 증가합니다.
Sample에는 config overlay 두 개가 있습니다. samples/drivers/spi_flash_at45/overlay-pm.conf는 device를 low-power state로 설정할 수 있는 device power management API를 활성화합니다. samples/drivers/spi_flash_at45/overlay-page_layout.conf는 flash 정보를 표시할 수 있는 flash page layout API를 활성화합니다.
기본 설정에서 AT45 flash driver는 DataFlash chip의 Read-Modify-Write 기능을 사용하며 이 경우 필요하지 않은 page erase는 수행하지 않습니다. CONFIG_SPI_FLASH_AT45_USE_READ_MODIFY_WRITE를 비활성화하면 이 동작을 바꿀 수 있습니다.
요구 사항
이 sample은 AT45DB321E chip을 연결한 Nordic Semiconductor nRF9160 DK(nrf9160dk/nrf9160)에서 시험되었습니다. 해당 overlay file만 제공하면 다른 board와 다른 AT45 family chip에도 쉽게 맞출 수 있습니다.
Build와 실행
Code는 samples/drivers/spi_flash_at45에 있습니다.
Application을 build하고 flash합니다.
west build -b nrf9160dk/nrf9160 samples/drivers/spi_flash_at45
west flash
Device power management를 활성화하여 build하고 flash합니다.
west build -b nrf9160dk/nrf9160 samples/drivers/spi_flash_at45 -- -DEXTRA_CONF_FILE=overlay-pm.conf
west flash
Flash page layout을 활성화하여 build하고 flash합니다.
west build -b nrf9160dk/nrf9160 samples/drivers/spi_flash_at45 -- -DEXTRA_CONF_FILE=overlay-page_layout.conf
west flash
Device power management와 flash page layout을 모두 활성화하여 build하고 flash합니다.
west build -b nrf9160dk/nrf9160 samples/drivers/spi_flash_at45 -- -DEXTRA_CONF_FILE="overlay-pm.conf overlay-page_layout.conf"
west flash
Sample 출력
Device power management와 flash page layout을 모두 활성화했을 때의 일반적인 출력은 다음과 같습니다.
DataFlash sample app on nrf9160dk_nrf9160
Using DATAFLASH_1, chip size: 4194304 bytes (page: 512)
Reading the first byte of the test region ... OK
Preparing test content starting with 0x01.
Writing the first half of the test region... OK
Writing the second half of the test region... OK
Reading the whole test region... OK
Checking the read content... OK
Putting the flash device into low power state... OK
Sample과 함께 제공되는 overlay file은 AT45 family chip instance 두 개를 지정하지만, sample 동작에는 DATAFLASH_1 label의 instance만 필요합니다. 다른 chip을 연결하지 않으면 다음 log가 나타나지만 그 밖의 sample 동작에는 영향을 주지 않습니다.
[00:00:00.000,000] <err> spi_flash_at45: Wrong JEDEC ID: ff ff ff, expected: 1f 24 00
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.