Page 1 of 1

Problem using the method esp_flash_get_size

Posted: Fri Jan 13, 2023 1:29 pm
by ThomasESP32
Good afternoon,

I started a project on a ESP32S3 using the ESP32-S3-DevKitC-1 and created a new project using hello_world
as an example.

In the app_main, the function esp_flash_get_size is executed (It is the same in the hello_world project) using the arguments :
if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
printf("Get flash size failed");
return;
}

However, in my project, the compiler send me the error Invalid argument on this line. So I get an error in my project.
In the hello_world project, I do not have this error..

Could you please help me ??
Maybe I have to add a component or something ??

Best regards

Re: Problem using the method esp_flash_get_size

Posted: Sat Jan 14, 2023 2:50 pm
by mbratch
ThomasESP32 wrote:
Fri Jan 13, 2023 1:29 pm

Code: Select all

    if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
        printf("Get flash size failed");
        return;
    }
According to the documentation, the first argument is a `esp_flash_t *chip` where `chip` is:
chip – Pointer to identify flash chip. Must have been successfully initialised via `esp_flash_init()`
It says here that `chip` must be successfully initialized first by calling `esp_flash_init`. It doesn't say anything about passing a NULL.

Re: Problem using the method esp_flash_get_size

Posted: Sun Jan 15, 2023 4:58 pm
by ujurmsde
I do not think it could be a component problem but ofcouse in your CMake file you must have nvs component. Then remember to initialise the flash with esp_flash_init() or nvs_flash_init().

This could be a problem in your code.
For example wifi functions will not work without the intialization of nvs flash memory of esp as it stores calibration data.

Re: Problem using the method esp_flash_get_size

Posted: Mon Jan 16, 2023 3:37 pm
by ThomasESP32
Ok thank you,
could you please explain me how to use the esp_flash_init function ?

I have a ESP32-S3-DevKitC-1 kit, I just would like to get the flash memory available.
Do you have any example or something ?

Best regards

Re: Problem using the method esp_flash_get_size

Posted: Mon Jan 16, 2023 6:31 pm
by mbratch
I guess I should have asked this initially to be sure... are you using external SPI flash component? There are different manufacturers and there are differences in the SPI commands in some cases. Thus, there's a bit of work required on your part to configure it to your specific needs. The documentation for SPI Flash API discusses this to some extent. Unfortunately, I don't see any examples from Espressif for any specific component using this API.