kopia lustrzana https://github.com/espressif/esp-idf
Docs: update CN translation for external-ram.rst
rodzic
db5a2638dd
commit
85970f8cf7
|
@ -10,7 +10,7 @@ Introduction
|
|||
============
|
||||
{IDF_TARGET_PSRAM_VADDR_SIZE:default="Value not updated", esp32="4 MB", esp32s2="10.5 MB", esp32s3="32 MB"}
|
||||
|
||||
{IDF_TARGET_NAME} has a few hundred kilobytes of internal RAM, residing on the same die as the rest of the chip components. It can be insufficient for some purposes, {IDF_TARGET_NAME} has the ability to use up to {IDF_TARGET_PSRAM_VADDR_SIZE} of virtual addresses for external PSRAM (Psuedostatic RAM) memory. The external memory is incorporated in the memory map and, with certain restrictions, is usable in the same way as internal data RAM.
|
||||
{IDF_TARGET_NAME} has a few hundred kilobytes of internal RAM, residing on the same die as the rest of the chip components. It can be insufficient for some purposes, so {IDF_TARGET_NAME} has the ability to use up to {IDF_TARGET_PSRAM_VADDR_SIZE} of virtual addresses for external PSRAM (Psuedostatic RAM) memory. The external memory is incorporated in the memory map and, with certain restrictions, is usable in the same way as internal data RAM.
|
||||
|
||||
.. only:: esp32s3
|
||||
|
||||
|
@ -55,7 +55,7 @@ ESP-IDF fully supports the use of external RAM in applications. Once the externa
|
|||
Integrate RAM into the {IDF_TARGET_NAME} Memory Map
|
||||
---------------------------------------------------
|
||||
|
||||
Select this option by choosing "Integrate RAM into memory map" from :ref:`CONFIG_SPIRAM_USE`.
|
||||
Select this option by choosing ``Integrate RAM into memory map`` from :ref:`CONFIG_SPIRAM_USE`.
|
||||
|
||||
This is the most basic option for external RAM integration. Most likely, you will need another, more advanced option.
|
||||
|
||||
|
@ -71,7 +71,7 @@ It is recommended to access the PSRAM by ESP-IDF heap memory allocator (see next
|
|||
Add External RAM to the Capability Allocator
|
||||
--------------------------------------------
|
||||
|
||||
Select this option by choosing "Make RAM allocatable using heap_caps_malloc(..., MALLOC_CAP_SPIRAM)" from :ref:`CONFIG_SPIRAM_USE`.
|
||||
Select this option by choosing ``Make RAM allocatable using heap_caps_malloc(..., MALLOC_CAP_SPIRAM)`` from :ref:`CONFIG_SPIRAM_USE`.
|
||||
|
||||
When enabled, memory is mapped to data virtual address space and also added to the :doc:`capabilities-based heap memory allocator </api-reference/system/mem_alloc>` using ``MALLOC_CAP_SPIRAM``.
|
||||
|
||||
|
@ -83,7 +83,7 @@ To allocate memory from external RAM, a program should call ``heap_caps_malloc(s
|
|||
Provide External RAM via malloc()
|
||||
---------------------------------
|
||||
|
||||
Select this option by choosing "Make RAM allocatable using malloc() as well" from :ref:`CONFIG_SPIRAM_USE`. This is the default option.
|
||||
Select this option by choosing ``Make RAM allocatable using malloc() as well`` from :ref:`CONFIG_SPIRAM_USE`. This is the default option.
|
||||
|
||||
In this case, memory is added to the capability allocator as described for the previous option. However, it is also added to the pool of RAM that can be returned by the standard ``malloc()`` function.
|
||||
|
||||
|
@ -105,7 +105,7 @@ Allow .bss Segment to Be Placed in External Memory
|
|||
|
||||
Enable this option by checking :ref:`CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY`.
|
||||
|
||||
If enabled, a region of the data virtual address space where the PSRAM is mapped to will be used to store zero-initialized data (BSS segment) from the lwIP, net80211, libpp, and bluedroid ESP-IDF libraries.
|
||||
If enabled, the region of the data virtual address space where the PSRAM is mapped to will be used to store zero-initialized data (BSS segment) from the lwIP, net80211, libpp, and bluedroid ESP-IDF libraries.
|
||||
|
||||
Additional data can be moved from the internal BSS segment to external RAM by applying the macro ``EXT_RAM_BSS_ATTR`` to any static declaration (which is not initialized to a non-zero value).
|
||||
|
||||
|
@ -122,7 +122,7 @@ Remaining external RAM can also be added to the capability heap allocator using
|
|||
Allow .noinit Segment to Be Placed in External Memory
|
||||
--------------------------------------------------------------
|
||||
|
||||
Enable this option by checking :ref:`CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY`. If enabled, a region of the data virtual address space where the PSRAM is mapped to will be used to store non-initialized data. The values placed in this segment will not be initialized or modified even during startup or restart.
|
||||
Enable this option by checking :ref:`CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY`. If enabled, the region of the data virtual address space where the PSRAM is mapped to will be used to store non-initialized data. The values placed in this segment will not be initialized or modified even during startup or restart.
|
||||
|
||||
By applying the macro ``EXT_RAM_NOINIT_ATTR``, data could be moved from the internal NOINIT segment to external RAM. Remaining external RAM can still be added to the capability heap allocator using the method shown above, :ref:`external_ram_config_capability_allocator`.
|
||||
|
||||
|
|
|
@ -8,23 +8,26 @@
|
|||
|
||||
简介
|
||||
============
|
||||
{IDF_TARGET_PSRAM_SIZE:default="Value not updated", esp32="4 MB", esp32s2="10.5 MB", esp32s3="16 MB"}
|
||||
{IDF_TARGET_PSRAM_VADDR_SIZE:default="Value not updated", esp32="4 MB", esp32s2="10.5 MB", esp32s3="32 MB"}
|
||||
|
||||
{IDF_TARGET_NAME} 提供了好几百 KB 的片上 RAM,可以满足大部分需求。但有些场景可能需要更多 RAM,因此 {IDF_TARGET_NAME} 另外提供了高达 {IDF_TARGET_PSRAM_SIZE} 的片外 SPI RAM 存储器供用户使用。片外 RAM 已经集成到内存映射中,在某些范围内与片上 RAM 使用方式相同。
|
||||
{IDF_TARGET_NAME} 提供了好几百 KB 的片上 RAM,可以满足大部分需求。但有些场景可能需要更多 RAM,因此 {IDF_TARGET_NAME} 另外提供了高达 {IDF_TARGET_PSRAM_VADDR_SIZE} 的虚拟地址,供片外 PSRAM(伪静态随机存储器)存储器使用。片外 RAM 已经集成到内存映射中,在某些范围内与片上 RAM 使用方式相同。
|
||||
|
||||
.. only:: esp32s3
|
||||
|
||||
{IDF_TARGET_PSRAM_VADDR_SIZE} 虚拟地址与 flash 指令和 rodata 共享。
|
||||
|
||||
硬件
|
||||
========
|
||||
|
||||
{IDF_TARGET_NAME} 支持与 SPI flash 芯片并联的 SPI PSRAM(伪静态随机存储器)。虽然 {IDF_TARGET_NAME} 支持多种类型的 RAM 芯片,但 ESP-IDF 当前仅支持乐鑫品牌的 PSRAM 芯片,如 ESP-PSRAM32、ESP-PSRAM64 等。
|
||||
{IDF_TARGET_NAME} 支持与 SPI flash 芯片并联的 PSRAM。虽然 {IDF_TARGET_NAME} 支持多种类型的 RAM 芯片,但 ESP-IDF 当前仅支持乐鑫品牌的 PSRAM 芯片,如 ESP-PSRAM32、ESP-PSRAM64 等。
|
||||
|
||||
.. note::
|
||||
|
||||
PSRAM 芯片的工作电压分为 1.8 V 和 3.3 V。其工作电压必须与 flash 的工作电压匹配。请查询您 PSRAM 芯片以及 {IDF_TARGET_NAME} 的技术规格书获取准确的工作电压。对于 1.8 V 的 PSRAM 芯片,请确保在启动时将 MTDI 管脚设置为高电平,或者将 {IDF_TARGET_NAME} 中的 eFuses 设置为始终使用 1.8 V 的 VDD_SIO 电平,否则有可能会损坏 PSRAM 和/或 flash 芯片。
|
||||
PSRAM 芯片的工作电压分为 1.8 V 和 3.3 V。其工作电压必须与 flash 的工作电压匹配。请查询相应 PSRAM 芯片以及 {IDF_TARGET_NAME} 的技术规格书获取准确的工作电压。对于 1.8 V 的 PSRAM 芯片,请确保在启动时将 MTDI 管脚设置为高电平,或者将 {IDF_TARGET_NAME} 中的 eFuses 设置为始终使用 1.8 V 的 VDD_SIO 电平,否则有可能会损坏 PSRAM 和/或 flash 芯片。
|
||||
|
||||
.. note::
|
||||
|
||||
乐鑫同时提供模组和系统级封装芯片,集成了兼容的 PSRAM 和 flash,可直接用于终端产品 PCB 中。如需了解更多信息,请前往乐鑫官网。
|
||||
乐鑫同时提供模组和系统级封装芯片,集成了兼容的 PSRAM 和 flash,可直接用于终端产品 PCB 中。如需了解更多信息,请前往乐鑫官网。注意,ESP-IDF SDK 可能与定制的 PSRAM 芯片不兼容。
|
||||
|
||||
有关将 SoC 或模组管脚连接到片外 PSRAM 芯片的具体细节,请查阅 SoC 或模组技术规格书。
|
||||
|
||||
|
@ -43,8 +46,8 @@ ESP-IDF 完全支持将片外 RAM 集成到您的应用程序中。在启动并
|
|||
* :ref:`external_ram_config_malloc` (default)
|
||||
* :ref:`external_ram_config_bss`
|
||||
:esp32: * :ref:`external_ram_config_noinit`
|
||||
:esp32s2 or esp32s3: * :ref:`external_ram_config_instructions`
|
||||
:esp32s2 or esp32s3: * :ref:`external_ram_config_rodata`
|
||||
:SOC_SPIRAM_XIP_SUPPORTED: * :ref:`external_ram_config_instructions`
|
||||
:SOC_SPIRAM_XIP_SUPPORTED: * :ref:`external_ram_config_rodata`
|
||||
|
||||
.. _external_ram_config_memory_map:
|
||||
|
||||
|
@ -52,15 +55,15 @@ ESP-IDF 完全支持将片外 RAM 集成到您的应用程序中。在启动并
|
|||
集成片外 RAM 到 {IDF_TARGET_NAME} 内存映射
|
||||
-------------------------------------------
|
||||
|
||||
{IDF_TARGET_PSRAM_ADDR_START:default="Value not updated", esp32="0x3F800000", esp32s2="0x3F500000", esp32s3="0x3D000000"}
|
||||
|
||||
在 :ref:`CONFIG_SPIRAM_USE` 中选择 "Integrate RAM into memory map(集成片外 RAM 到 {IDF_TARGET_NAME} 内存映射)" 选项。
|
||||
在 :ref:`CONFIG_SPIRAM_USE` 中选择 ``Integrate RAM into memory map`` 选项,以集成片外 RAM 到 {IDF_TARGET_NAME} 内存映射。
|
||||
|
||||
这是集成片外 RAM 最基础的设置选项,大多数用户需要用到其他更高级的选项。
|
||||
|
||||
ESP-IDF 启动过程中,片外 RAM 被映射到以 {IDF_TARGET_PSRAM_ADDR_START} 起始的数据地址空间(字节可寻址),空间大小正好为 SPI RAM 的大小 ({IDF_TARGET_PSRAM_SIZE})。
|
||||
ESP-IDF 启动过程中,片外 RAM 被映射到数据虚拟地址空间,该地址空间是动态分配的,其长度为 PSRAM 大小和可用数据虚拟地址空间大小之间的最小值。
|
||||
|
||||
应用程序可以通过创建指向该区域的指针手动将数据放入片外存储器,同时应用程序全权负责管理片外 SPI RAM,包括协调 Buffer 的使用、防止发生损坏等。
|
||||
应用程序可以创建指向该区域的指针,手动将数据放入片外存储器,并全权负责管理片外 RAM,包括协调缓存占用、防止发生损坏等。
|
||||
|
||||
建议通过 ESP-IDF 堆内存分配器访问 PSRAM(见下一小节)。
|
||||
|
||||
.. _external_ram_config_capability_allocator:
|
||||
|
||||
|
@ -68,9 +71,9 @@ ESP-IDF 启动过程中,片外 RAM 被映射到以 {IDF_TARGET_PSRAM_ADDR_STAR
|
|||
添加片外 RAM 到堆内存分配器
|
||||
----------------------------
|
||||
|
||||
在 :ref:`CONFIG_SPIRAM_USE` 中选择 "Make RAM allocatable using heap_caps_malloc(..., MALLOC_CAP_SPIRAM)" 选项。
|
||||
在 :ref:`CONFIG_SPIRAM_USE` 中选择 ``Make RAM allocatable using heap_caps_malloc(..., MALLOC_CAP_SPIRAM)`` 选项。
|
||||
|
||||
启用上述选项后,片外 RAM 被映射到地址 {IDF_TARGET_PSRAM_ADDR_START},并将这个区域添加到携带 ``MALLOC_CAP_SPIRAM`` 标志的 :doc:`堆内存分配器 </api-reference/system/mem_alloc>` 。
|
||||
启用上述选项后,片外 RAM 被映射到数据虚拟地址空间,并将这个区域添加到携带 ``MALLOC_CAP_SPIRAM`` 标志的 :doc:`堆内存分配器 </api-reference/system/mem_alloc>` 。
|
||||
|
||||
程序如果想从片外存储器分配存储空间,则需要调用 ``heap_caps_malloc(size, MALLOC_CAP_SPIRAM)``,之后可以调用 ``free()`` 函数释放这部分存储空间。
|
||||
|
||||
|
@ -80,13 +83,13 @@ ESP-IDF 启动过程中,片外 RAM 被映射到以 {IDF_TARGET_PSRAM_ADDR_STAR
|
|||
调用 malloc() 分配片外 RAM
|
||||
---------------------------------
|
||||
|
||||
在 :ref:`CONFIG_SPIRAM_USE` 中选择 "Make RAM allocatable using malloc() as well" 选项,该选项为默认选项。
|
||||
在 :ref:`CONFIG_SPIRAM_USE` 中选择 ``Make RAM allocatable using malloc() as well`` 选项,该选项为默认选项。
|
||||
|
||||
启用此选项后,片外存储器将被添加到内存分配程序(与上一选项相同),同时也将被添加到由标准 ``malloc()`` 函数返回的 RAM 中。
|
||||
|
||||
应用程序因此可以使用片外 RAM,无需重写代码就能使用 ``heap_caps_malloc(..., MALLOC_CAP_SPIRAM)``。
|
||||
|
||||
如果某次内存分配偏向于片外存储器,您也可以使用 :ref:`CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL` 设置分配空间的大小阈值,控制分配结果:
|
||||
如果某次内存分配偏向于片外存储器,也可以使用 :ref:`CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL` 设置分配空间的大小阈值,控制分配结果:
|
||||
|
||||
- 如果分配的空间小于阈值,分配程序将首先选择内部存储器。
|
||||
- 如果分配的空间等于或大于阈值,分配程序将首先选择外部存储器。
|
||||
|
@ -102,7 +105,7 @@ ESP-IDF 启动过程中,片外 RAM 被映射到以 {IDF_TARGET_PSRAM_ADDR_STAR
|
|||
|
||||
通过勾选 :ref:`CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY` 启用该选项。
|
||||
|
||||
启用该选项后,从 {IDF_TARGET_PSRAM_ADDR_START} 起始的地址空间将用于存储来自 lwip、net80211、libpp 和 bluedroid ESP-IDF 库中零初始化的数据(BSS 段)。
|
||||
启用该选项后,PSRAM 被映射到的数据虚拟地址空间将用于存储来自 lwip、net80211、libpp 和 bluedroid ESP-IDF 库中零初始化的数据(BSS 段)。
|
||||
|
||||
通过将宏 ``EXT_RAM_BSS_ATTR`` 应用于任何静态声明(未初始化为非零值),可以将附加数据从内部 BSS 段移到片外 RAM。
|
||||
|
||||
|
@ -119,7 +122,7 @@ ESP-IDF 启动过程中,片外 RAM 被映射到以 {IDF_TARGET_PSRAM_ADDR_STAR
|
|||
允许 .noinit 段放入片外存储器
|
||||
-------------------------------------
|
||||
|
||||
通过勾选 :ref:`CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY` 启用该选项。启用该选项后,外部 RAM 中提供的地址空间区域将用于存储未初始化的数据。即使在启动或重新启动期间,放置在该段中的值也不会被初始化或修改。
|
||||
通过勾选 :ref:`CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY` 启用该选项。启用该选项后,PSRAM 被映射到的数据虚拟地址空间将用于存储未初始化的数据。即使在启动或重新启动期间,放置在该段中的值也不会被初始化或修改。
|
||||
|
||||
通过应用 ``EXT_RAM_NOINIT_ATTR`` 宏,可以将数据从内部 NOINIT 段移到片外 RAM。剩余的片外 RAM 也可以通过上述方法添加到堆分配器中,具体请参考 :ref:`external_ram_config_capability_allocator`。
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue