Accessing the Flash on SPI0 of esp32 -wroom-32

sarapatel
Posts: 8
Joined: Mon Feb 17, 2020 6:07 am

Accessing the Flash on SPI0 of esp32 -wroom-32

Postby sarapatel » Mon Feb 17, 2020 6:16 am

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?

ESP_Sprite
Posts: 3253
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Mon Feb 17, 2020 11:00 am

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?

sarapatel
Posts: 8
Joined: Mon Feb 17, 2020 6:07 am

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

Postby sarapatel » Wed Feb 19, 2020 7:12 am

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.

WiFive
Posts: 2887
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Wed Feb 19, 2020 8:46 am

It is already initialized and you probably should use partition apis

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

sarapatel
Posts: 8
Joined: Mon Feb 17, 2020 6:07 am

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

Postby sarapatel » Wed Feb 19, 2020 9:17 am

Ok. Thanks will try out and will get back with the status.

sarapatel
Posts: 8
Joined: Mon Feb 17, 2020 6:07 am

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

Postby sarapatel » Wed Feb 19, 2020 11:28 am

My second question is what will be the user memory available in the external flash which is interfaced with SPI0(internally).

ESP_Sprite
Posts: 3253
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Wed Feb 19, 2020 7:42 pm

That depends on the partition layout you selected.

sarapatel
Posts: 8
Joined: Mon Feb 17, 2020 6:07 am

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

Postby sarapatel » Thu Feb 20, 2020 4:58 am

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 ?

sarapatel
Posts: 8
Joined: Mon Feb 17, 2020 6:07 am

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

Postby sarapatel » Thu Feb 20, 2020 11:21 am

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?

Who is online

Users browsing this forum: MSN [Bot] and 71 guests