Access partition example

chromebin
Posts: 77
Joined: Wed Feb 07, 2018 3:53 pm

Access partition example

Postby chromebin » Tue Sep 25, 2018 8:01 pm

Hello, I'm looking for example code that allows me:

- to random access bytes within the partition (with caching, as code has)

- to write the partition from the start up to some size (basically store a file in it)

So this partition should act and feel like constants, similar to const in code. It is basically just some code that is constant between OTA's.

Despite this seemingly being a common request, I could not find any direct answers (and only suggestions, no code).

Use case: I need to store up to 300k of fonts (my partition is 300k and is named "fonts"). Thanks!

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

Re: Access partition example

Postby ESP_Sprite » Wed Sep 26, 2018 1:10 am

I think the esp_partition_* API can help you out there. Mmap the partition to access the data as memory, erase/program it if you want to rewrite.

chromebin
Posts: 77
Joined: Wed Feb 07, 2018 3:53 pm

Re: Access partition example

Postby chromebin » Wed Sep 26, 2018 6:00 pm

ESP_Sprite wrote:I think the esp_partition_* API can help you out there. Mmap the partition to access the data as memory, erase/program it if you want to rewrite.
More precisely: https://docs.espressif.com/projects/esp ... ables.html Right?

The best info I got so far is from:

https://github.com/espressif/esp-idf/bl ... est_mmap.c

Maybe I should read up on OTA partitions, it seems I just want one without the OTA part.


Note that I understand all the terms you use. But I know NOTHING about how THE ESP32 implements those things and what ACTUAL ADDRESSES, CONVENTIONS and MECHANICS it uses. The docs (or posts) don't deal with that, it's secret knowledge.

Other peripherals have examples, but apparently this one is so simple.. it doesn't need one. I'm sure all it takes is just a handful of lines.



Suggestion: please give us a partition type "mmap" (in partitions.csv) and have this working out of the box.
Because: there is memory, I just want to use it...

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Access partition example

Postby ESP_igrr » Thu Sep 27, 2018 1:26 am

You can map into memory (mmap) any kind of partition, its type in the partition table does not matter.

Basic workflow is:
1. Define the partition in the partition table.
2. Call esp_partition_find to get the pointer to esp_partition_t stucture describing this partition
3. Call esp_partition_mmap with the obtained pointer. This will give you two outputs: void* pointer to memory location where partition was mapped, and a handle which you can later use to unmap the partition.

Have captured you request for the example, will put it on our plan.

Who is online

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