Problem using the method esp_flash_get_size

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

Problem using the method esp_flash_get_size

Postby ThomasESP32 » Fri Jan 13, 2023 1:29 pm

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

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: Problem using the method esp_flash_get_size

Postby mbratch » Sat Jan 14, 2023 2:50 pm

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.
Last edited by mbratch on Mon Jan 16, 2023 5:38 pm, edited 1 time in total.

ujurmsde
Posts: 38
Joined: Tue Jan 19, 2021 6:37 am

Re: Problem using the method esp_flash_get_size

Postby ujurmsde » Sun Jan 15, 2023 4:58 pm

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.

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

Re: Problem using the method esp_flash_get_size

Postby ThomasESP32 » Mon Jan 16, 2023 3:37 pm

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

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: Problem using the method esp_flash_get_size

Postby mbratch » Mon Jan 16, 2023 6:31 pm

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.

Who is online

Users browsing this forum: No registered users and 135 guests