docs: Update translation for flash erase

This commit is contained in:
Zhang Shuxian
2026-01-09 14:12:25 +08:00
parent 7dca5f208f
commit 1ae27538a0
2 changed files with 10 additions and 2 deletions
+4 -2
View File
@@ -104,10 +104,12 @@ If NVS encryption is not used, it is possible for anyone with physical access to
The library does try to recover from conditions when flash memory is in an inconsistent state. In particular, one should be able to power off the device at any point and time and then power it back on. This should not result in loss of data, except for the new key-value pair if it was being written at the moment of powering off. The library should also be able to initialize properly with any random data present in flash memory.
Unstable power conditions
Unstable Power Conditions
-------------------------
When NVS is used in systems powered by weak or unstable energy sources (such as solar or battery), flash-erase operations may occasionally remain incomplete without being detected by the application. This can create a mismatch between the actual flash contents and the expected layout of reserved pages. In rare cases, especially during unexpected power loss, this may lead to exhaustion of available NVS pages and cause partition initialization to fail with the error ``ESP_ERR_NVS_NO_FREE_PAGES``. To address this issue, the Kconfig option ``:ref:NVS_FLASH_VERIFY_ERASE`` enables verification of flash-erase operations by reading back the affected page. If the page is not fully erased to ``0xFF`` after ``flash_erase``, the erase operation is retried until the page is correctly cleared. The total number of erase attempts, including the initial attempt, is controlled by the Kconfig option ``:ref:NVS_FLASH_ERASE_ATTEMPTS``.
When NVS is used in systems powered by weak or unstable energy sources (such as solar or battery), flash erase operations may occasionally fail to complete without being detected by the application. This can create a mismatch between the actual flash contents and the expected layout of reserved pages. In rare cases, especially during unexpected power loss, this may exhaust the available NVS pages and cause partition initialization to fail with the error ``ESP_ERR_NVS_NO_FREE_PAGES``.
To address this issue, the Kconfig option :ref:`CONFIG_NVS_FLASH_VERIFY_ERASE` enables verification of flash erase operations by reading back the affected page. If the page is not fully erased to ``0xFF`` after a ``flash_erase`` operation, the erase is retried until the page is correctly cleared. The total number of erase attempts, including the initial attempt, is controlled by the Kconfig option :ref:`CONFIG_NVS_FLASH_ERASE_ATTEMPTS`.
.. _nvs_encryption:
@@ -104,6 +104,12 @@ NVS 迭代器
当 flash 处于不一致状态时,NVS 库会尝试恢复。在任何时间点关闭设备电源,然后重新打开电源,不会导致数据丢失;但如果关闭设备电源时正在写入新的键值对,这一键值对可能会丢失。该库还应该能够在 flash 中存在任何随机数据的情况下正常初始化。
电源不稳定状态
-------------------------
当 NVS 用于弱电源或不稳定电源系统(如太阳能或电池供电系统)时,flash 擦除操作可能偶尔无法彻底完成,而应用程序无法检测到这一问题。这会导致实际 flash 内容与预留页面的预期布局不一致。在极少数情况下(特别是在意外断电时),可能造成可用 NVS 页面耗尽,导致分区初始化失败并返回 ``ESP_ERR_NVS_NO_FREE_PAGES`` 错误。
为解决此问题,可通过 Kconfig 选项 :ref:`CONFIG_NVS_FLASH_VERIFY_ERASE` 启用 flash 擦除操作的验证机制,通过回读受影响页面进行检测。若在 ``flash_erase`` 操作后页面未完全擦除为 ``0xFF``,系统将重试擦除操作直至页面被正确清空。包括首次尝试在内的擦除尝试总次数可通过 Kconfig 选项 :ref:`CONFIG_NVS_FLASH_ERASE_ATTEMPTS` 进行配置。
.. _nvs_encryption: