Selecting spi_flash_mmap address

AndrewDojo
Posts: 3
Joined: Thu Jul 13, 2017 1:55 pm

Selecting spi_flash_mmap address

Postby AndrewDojo » Thu Jul 13, 2017 2:06 pm

Code: Select all

esp_err_t spi_flash_mmap(size_t src_addr, size_t size, spi_flash_mmap_memory_t memory, const void **out_ptr, spi_flash_mmap_handle_t *out_handle)
Is there a "correct" method of selecting an address as the target of the mmap? i.e. how do I select a value for the "memory" parameter?

I have a custom flash partition table with a custom data image successfully loaded at 0x320000.

AndrewDojo
Posts: 3
Joined: Thu Jul 13, 2017 1:55 pm

Re: Selecting spi_flash_mmap address

Postby AndrewDojo » Thu Jul 13, 2017 11:53 pm

Solved. I didn't realise the "memory" parameter was an enum for the TYPE of memory being addressed. Thought it was an actual memory address that was to be where the map is located. Insufficient coffee.

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

Re: Selecting spi_flash_mmap address

Postby kolban » Fri Jul 14, 2017 12:43 am

From my notes, the source address (i.e. where in flash you can start to read from) must be on a 64K boundary. The memory parameter can be either:

* SPI_FLASH_MMAP_DATA - Map the flash to data address bus.
* SPI_FLASH_MMAP_INST - Map the flash to instruction address bus.

The outPtr is set to be a pointer in the address space of the device (thus accessible to your application) where the mapped data can be found.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Selecting spi_flash_mmap address

Postby ESP_Angus » Fri Jul 14, 2017 2:13 am

As an addendum to the above (which is 100% correct), please consider using esp_partition_mmap() whereever possible. It doesn't have the 64KB alignment requirement, and it allows you to use partition-local offsets which are simpler in most cases.

AndrewDojo
Posts: 3
Joined: Thu Jul 13, 2017 1:55 pm

Re: Selecting spi_flash_mmap address

Postby AndrewDojo » Fri Jul 14, 2017 7:07 am

Thanks all. Had already discovered and switched over to using esp_partition_mmap().

Who is online

Users browsing this forum: No registered users and 77 guests