Hi folks, I’m trying to get my code to identify how much flash memory is on the (ESP32-based) ESP-WROVER-B module I have (4MB, 8MB, other) and am running into issues calling the esp-idf functions to get it. There is a function in esp-idf to do this (esp_flash_get_chip_size(), declared in esp_spi_flash.h) and somewhere a data structure called g_rom_flashchip.chip_size which may also contain that information:
size_t chip_size = esp_flash_get_chip_size();
LOG(LL_INFO, ("%s - flash: %uM", __FUNCTION__, g_rom_flashchip.chip_size / 1048576));
It seems like the way to access ESP-IDF functions is to add the esp-idf component’s folder name to the mos.yml config - I couldn’t find any docs, but there is an example with bluetooth someone’s pointed to a couple of times. That doesn’t seem to work with spi_flash, it results in a “recursive inclusion” error and stops (see log below).
Perhaps someone can help me out – how can I access ESP-IDF functions (in general) and what am I doing wrong with spi_flash? Thanks!
Here’s my modification to mos.yml – I’ve only added the “spi_flash” part. Without that, it all works.
build_vars:
MGOS_ROOT_FS_SIZE: 0x70000 # 448kB
ESP_IDF_EXTRA_COMPONENTS: ${build_vars.ESP_IDF_EXTRA_COMPONENTS} libsodium spi_flash
ESP_IDF_SDKCONFIG_OPTS: >
${build_vars.ESP_IDF_SDKCONFIG_OPTS}
CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_LOG_COLORS=n
CONFIG_TCPIP_TASK_STACK_SIZE=6144
CONFIG_SPIRAM_SUPPORT=y
CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_CACHE_WORKAROUND=y
CONFIG_SPI_MASTER_IN_IRAM=y
CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST=y
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192
CONFIG_SPIRAM_MEMTEST=y
And here is the build failure:
/opt/Espressif/esp-idf/make/project.mk:552: warning: overriding recipe for target ‘component-spi_flash-build’
/opt/Espressif/esp-idf/make/project.mk:552: warning: ignoring old recipe for target ‘component-spi_flash-build’
/opt/Espressif/esp-idf/make/project.mk:552: warning: overriding recipe for target ‘component-spi_flash-clean’
/opt/Espressif/esp-idf/make/project.mk:552: warning: ignoring old recipe for target ‘component-spi_flash-clean’
/opt/Espressif/esp-idf/make/project.mk:552: warning: overriding recipe for target ‘/c/projects/the_proj/build/objs/spi_flash’
/opt/Espressif/esp-idf/make/project.mk:552: warning: ignoring old recipe for target ‘/c/projects/the_proj/build/objs/spi_flash’
/opt/Espressif/esp-idf/make/project.mk:552: warning: overriding recipe for target ‘/c/projects/the_proj/build/objs/spi_flash/libspi_flash.a’
/opt/Espressif/esp-idf/make/project.mk:552: warning: ignoring old recipe for target ‘/c/projects/the_proj/build/objs/spi_flash/libspi_flash.a’
/opt/Espressif/esp-idf/make/project.mk:552: warning: overriding recipe for target ‘/c/projects/the_proj/build/objs/spi_flash/component_project_vars.mk’
/opt/Espressif/esp-idf/make/project.mk:552: warning: ignoring old recipe for target ‘/c/projects/the_proj/build/objs/spi_flash/component_project_vars.mk’
/c/Projects/the_proj/deps/modules/mongoose-os/platforms/esp32/Makefile.build:186: warning: overriding recipe for target ‘defconfig’
/opt/Espressif/esp-idf/make/project_config.mk:82: warning: ignoring old recipe for target ‘defconfig’
/c/Projects/the_proj/deps/modules/mongoose-os/platforms/esp32/Makefile.build:186: warning: overriding recipe for target ‘menuconfig’
/opt/Espressif/esp-idf/make/project_config.mk:69: warning: ignoring old recipe for target ‘menuconfig’
/c/Projects/the_proj/deps/modules/mongoose-os/platforms/esp32/Makefile.build:228: warning: overriding recipe for target ‘clean’
/opt/Espressif/esp-idf/components/app_update/Makefile.projbuild:48: warning: ignoring old recipe for target ‘clean’
make: Warning: File ‘/c/projects/the_proj/build/gen/vars.mk’ has modification time 24248 s in the future
GENCONFIG
/opt/Espressif/esp-idf/Kconfig:206: recursive inclusion detected. Inclusion path:
current file : ‘/opt/Espressif/esp-idf/Kconfig’
included from: ‘/opt/Espressif/esp-idf/components/tcpip_adapter/Kconfig:0’
included from: ‘/opt/Espressif/esp-idf/components/vfs/Kconfig:0’
included from: ‘/opt/Espressif/esp-idf/components/spiffs/Kconfig:0’
included from: ‘/app/components/libsodium/Kconfig:0’
included from: ‘/opt/Espressif/esp-idf/components/spi_flash/Kconfig:2’
make: *** No rule to make target ‘/c/projects/the_proj/build/objs/include/config/auto.conf’, needed by ‘/c/projects/the_proj/build/objs/bootloader/bootloader.bin’. Stop.