使用nvs_flash_init()这个函数初始化nvs,能启动这个宏CONFIG_APP_BUILD_TYPE_PURE_RAM_APP吗?

weimeijia
Posts: 3
Joined: Sun Jul 21, 2024 6:47 am

使用nvs_flash_init()这个函数初始化nvs,能启动这个宏CONFIG_APP_BUILD_TYPE_PURE_RAM_APP吗?

Postby weimeijia » Fri Aug 02, 2024 8:38 am

用esp32c6写了一个基于IEEE802.15.4的发送和接收通信功能,其中第一步用nvs_flash_init()这个函数初始化nvs,然后也启动了宏CONFIG_APP_BUILD_TYPE_PURE_RAM_APP,然后会报错并重启。报错显示如下:
[0;32mI (356) main: Initializing NVS from flash...[0m
[0;32mI (360) nvs: init_partition[0m
[0;32mI (364) nvs_partition_mamager: lookup_nvs_partition[0m
[0;32mI (369) partition: Loading the partition table[0m
[0;32mI (374) partition: spi_flash_mmap[0m
[0;32mI (378) mmap: esp_mmu_map[0m
[0;32mI (381) mmap: s_find_available_region[0m
[0;31mE (385) mmap: no such vaddr range[0m
[0;32mI (389) partition: load_partitions returned 0x105[0m
[0;32mI (395) main: test11[0m
ESP_ERROR_CHECK failed: esp_err_t 0x105 (ESP_ERR_NOT_FOUND) at 0x420007f6
file: "applications\main.c" line 83
func: main
expression: err

[16:36:28.382]收←◆
abort() was called at PC 0x4200c40b on core 0
Core 0 register dump:

但如果关闭这个宏选项CONFIG_APP_BUILD_TYPE_PURE_RAM_APP,会卡在应用程序启动流程的 esp_err_t flash_ret = esp_flash_init_default_chip();不往下执行而一直重启。

文档手册中对这个宏的解释如下:
"CONFIG_APP_BUILD_TYPE_PURE_RAM_APP" 是一个配置选项,允许构建一个不支持 SPI_FLASH 和 PSRAM 的应用程序(可以节省 RAM)。
如果启用这个选项,外部存储器及相关外设(如缓存、内存管理单元 MMU、闪存和 PSRAM)将不会被初始化。与此相关的驱动程序也不会被引入。此外,依赖于 spi_flash 组件的组件(例如应用更新功能)也将无法使用。启用这个选项后,大约可以节省 26KB 的 RAM 空间。
所以我想问一下到底需不需要启动这个宏,以及遇到的问题怎么解决?

ESP_rrtandler
Posts: 22
Joined: Wed May 31, 2023 6:54 pm

Re: 使用nvs_flash_init()这个函数初始化nvs,能启动这个宏CONFIG_APP_BUILD_TYPE_PURE_RAM_APP吗?

Postby ESP_rrtandler » Mon Aug 12, 2024 1:51 pm

Hi weimeijia,

The CONFIG_APP_BUILD_TYPE_PURE_RAM_APP disables the SPI_FLASH sub system and therefore it is not possible to use the NVS component as it relies on the working SPI_FLASH. In reward, it releases some 26kB of RAM.

If your application fits into the memory in default setting (without CONFIG_APP_BUILD_TYPE_PURE_RAM_APP), you don't need to set it.

If your application cannot fit into the RAM (without CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) and still needs access to the SPI_FLASH (and or NVS...), then you have to optimise RAM usage of your application.

Who is online

Users browsing this forum: No registered users and 178 guests