Part 1
요약·해설
Scratch erase/write, 0x3c040000 pointer와 mapped write 금지를 설명합니다.
64 KB pages
Instruction · Data
Mapped read only
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
8C80B60E919986A700B63CD257E4E387D5ADF8F574C0C695DE479D46DD131232
.. zephyr:code-sample:: esp32-flash-memory-mapped
:name: ESP32 Flash Memory-Mapped
:relevant-api: flash_interface
Write data into scratch area and read it using flash API and memory-mapped pointer.
Overview
********
ESP32 features memory hardware which allows regions of flash memory to be mapped into instruction
and data address spaces. This mapping works only for read operations. It is not possible to modify
contents of flash memory by writing to a mapped memory region.
Mapping happens in 64 KB pages. Memory mapping hardware can map flash into the data address space
and the instruction address space. See the technical reference manual for more details and
limitations about memory mapping hardware. For more information, check `_ESP32 Flash Memory-Mapping`.
Supported SoCs
**************
All ESP32 SoCs support flash memory-mapped feature.
Building and Running
********************
Make sure you have your board connected over USB port.
.. code-block:: console
west build -b esp32s3_devkitm samples/boards/esp32/flash_memory_mapped
west flash
Sample Output
=============
To check the output of this sample, run ``west espressif monitor`` or any other serial
console program (e.g., minicom, putty, screen, etc).
This example uses ``west espressif monitor``, which automatically detects the serial
port at ``/dev/ttyUSB0``:
.. code-block:: console
$ west espressif monitor
The sample code erases the scratch area defined in DTS file and writes a 32-bytes data buffer in it.
Next, it prints that region content using flash API read and also using memory-mapped pointer.
Both readings should return the same value. Important to notice that writing using memory-mapped pointer
is not allowed.
.. code-block:: console
*** Booting Zephyr OS build v3.5.0-rc3-10-g3118724fa268 ***
[00:00:00.255,000] <inf> flash_memory_mapped: memory-mapped pointer address: 0x3c040000
[00:00:01.122,000] <inf> flash_memory_mapped: flash read using memory-mapped pointer
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........
[00:00:01.122,000] <inf> flash_memory_mapped: writing 32-bytes data using flash API
[00:00:01.122,000] <inf> flash_memory_mapped: flash read using flash API
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |........ ........
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |........ ........
[00:00:01.122,000] <inf> flash_memory_mapped: flash read using memory-mapped pointer
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |........ ........
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |........ ........
.. _ESP32 Flash Memory-Mapping:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/spi_flash/index.html#memory-mapping-api
Part 3
한국어 전문 번역
Scratch area에 data를 기록하고 flash API와 memory-mapped pointer로 읽는 code sample입니다.
개요
ESP32에는 flash memory region을 instruction address space와 data address space에 mapping할 수 있는 memory hardware가 있습니다. 이 mapping은 read operation에만 사용할 수 있습니다. Mapping된 memory region에 write해 flash memory 내용을 수정할 수는 없습니다.
Mapping은 64 KB page 단위로 이루어집니다. Memory-mapping hardware는 flash를 data address space와 instruction address space에 mapping할 수 있습니다. 자세한 제약은 technical reference manual을 참조하십시오. 추가 정보는 ESP32 Flash Memory-Mapping에서 확인할 수 있습니다.
지원 SoC
모든 ESP32 SoC가 flash memory-mapped 기능을 지원합니다.
Build와 실행
Board가 USB port에 연결되어 있는지 확인하십시오.
west build -b esp32s3_devkitm samples/boards/esp32/flash_memory_mapped
west flash
Sample 출력
출력을 확인하려면 west espressif monitor 또는 minicom, PuTTY, screen 같은 serial console program을 실행합니다. 이 예제의 monitor 명령은 /dev/ttyUSB0를 자동 감지합니다.
$ west espressif monitor
Sample code는 DTS file에 정의된 scratch area를 erase하고 32-byte data buffer를 기록합니다. 이어서 flash API read와 memory-mapped pointer를 각각 사용해 그 region의 내용을 출력합니다. 두 read 결과는 같아야 합니다. Memory-mapped pointer를 이용한 write는 허용되지 않는다는 점이 중요합니다.
*** Booting Zephyr OS build v3.5.0-rc3-10-g3118724fa268 ***
[00:00:00.255,000] <inf> flash_memory_mapped: memory-mapped pointer address: 0x3c040000
[00:00:01.122,000] <inf> flash_memory_mapped: flash read using memory-mapped pointer
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........
[00:00:01.122,000] <inf> flash_memory_mapped: writing 32-bytes data using flash API
[00:00:01.122,000] <inf> flash_memory_mapped: flash read using flash API
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |........ ........
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |........ ........
[00:00:01.122,000] <inf> flash_memory_mapped: flash read using memory-mapped pointer
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |........ ........
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |........ ........
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.