Custom partition for storing data

hemant.chaudhari
Posts: 16
Joined: Wed Jun 13, 2018 11:48 am

Custom partition for storing data

Postby hemant.chaudhari » Wed Aug 08, 2018 11:08 am

Hello,

I want to flash a custom partition table.I am having 4MB external flash with esp32.
Can I create custom partition which will store the data.
I am trying to flash
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000
factory, app, factory, 0x10000, 0.90M
ota_0, app, ota_0, , 0.90M
ota_1, app, ota_1, , 0.90M
storage, data, , , 1M

I want storage partition to be custom partition and it should not have subtype as fat or spiffs.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Custom partition for storing data

Postby kolban » Wed Aug 08, 2018 11:52 pm

What you describe should work. If the partitions.csv parser doesn't like a missing subtype, you can always make up your own as an integer value (eg. 0x99). I am presuming you will look up your partition by its label name ("storage").
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

hemant.chaudhari
Posts: 16
Joined: Wed Jun 13, 2018 11:48 am

Re: Custom partition for storing data

Postby hemant.chaudhari » Thu Aug 09, 2018 5:59 am

Thanks Neil,
I have now created a customized partition.

I would also like to know that each location in esp32 flash is of how much bytes. eg. if I am using
spi_flash_write(0x304240 temp, sizeof(temp));
then 0x304240 can store how much bytes?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Custom partition for storing data

Postby kolban » Thu Aug 09, 2018 2:30 pm

I'm not sure I'm following. If we assume that flash is 4MBytes then that means we have 4*1024*1024 bytes maximally available to us.

We write to flash as a function of its offset.

We can "technically" re-write any of the pages of flash where (if I remember correctly) a page is a unit of 4096 bytes.

When you ask "How much data can I store in flash" ... then one answer would be 4MBytes or less. However that is a glib answer as some of the flash is reserved for ESP32 usage and some will be your own application that is running. This is where the partitions table comes into play. Think of it as a map of how you are planning on using flash. It provides a description (not policing) of how you plan to use the flash memory.

We have APIs to query the partition data at runtime. This allows us to find the start of a partition (assuming it wasn't fixed) and its logical size. If you are writing to flash, you should thus allocate a partition for the data and not write past the end of it.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: Baidu [Spider] and 131 guests