Page 1 of 1

Accessing the Flash on SPI0 of esp32 -wroom-32

Posted: Mon Feb 17, 2020 6:16 am
by sarapatel
Hello,
I want to access the flash (external) connected with SPI0 bus. I need the APIs which I need to call in order to perform several flash operations(read,write, erase). If possible can anyone guide me using an example?

Re: Accessing the Flash on SPI0 of esp32 -wroom-32

Posted: Mon Feb 17, 2020 11:00 am
by ESP_Sprite
There's a wealth of api functions defined for this in the docs of esp-idf. If you want to use higher-level APIS (like filesystems, NVS etc) there's examples for those here. Does that help?

Re: Accessing the Flash on SPI0 of esp32 -wroom-32

Posted: Wed Feb 19, 2020 7:12 am
by sarapatel
Thank you for your quick response, but I have gone through those API's mentioned in the doc but there is no such api for initializing SPI0 flash as it is the default flash that can be accessed. Lets say for example if I use " esp_err_tspi_bus_add_flash_device(esp_flash_t **out_chip, constesp_flash_spi_device_config_t *config)" then for this SPI0 default flash what should i wrote in the first argument?? and same for other api's.

Re: Accessing the Flash on SPI0 of esp32 -wroom-32

Posted: Wed Feb 19, 2020 8:46 am
by WiFive
It is already initialized and you probably should use partition apis

https://github.com/espressif/esp-idf/tr ... tition_ops

Re: Accessing the Flash on SPI0 of esp32 -wroom-32

Posted: Wed Feb 19, 2020 9:17 am
by sarapatel
Ok. Thanks will try out and will get back with the status.

Re: Accessing the Flash on SPI0 of esp32 -wroom-32

Posted: Wed Feb 19, 2020 11:28 am
by sarapatel
My second question is what will be the user memory available in the external flash which is interfaced with SPI0(internally).

Re: Accessing the Flash on SPI0 of esp32 -wroom-32

Posted: Wed Feb 19, 2020 7:42 pm
by ESP_Sprite
That depends on the partition layout you selected.

Re: Accessing the Flash on SPI0 of esp32 -wroom-32

Posted: Thu Feb 20, 2020 4:58 am
by sarapatel
Thanks. I got my code tested using the partition example you suggested. Now if suppose I need to store data in flah for different tasks so every time in order to write data at a location do I need to do
write "esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage"); " every time? Or is there any alternative way ?

Re: Accessing the Flash on SPI0 of esp32 -wroom-32

Posted: Thu Feb 20, 2020 11:21 am
by sarapatel
I meant if I have a block of data say 512 bytes and I need to store 128 bytes at consecutive address location so for that in the for loop how will I get my next address to write?