Page 1 of 1
Selecting spi_flash_mmap address
Posted: Thu Jul 13, 2017 2:06 pm
by AndrewDojo
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.
Re: Selecting spi_flash_mmap address
Posted: Thu Jul 13, 2017 11:53 pm
by AndrewDojo
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.
Re: Selecting spi_flash_mmap address
Posted: Fri Jul 14, 2017 12:43 am
by kolban
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.
Re: Selecting spi_flash_mmap address
Posted: Fri Jul 14, 2017 2:13 am
by ESP_Angus
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.
Re: Selecting spi_flash_mmap address
Posted: Fri Jul 14, 2017 7:07 am
by AndrewDojo
Thanks all. Had already discovered and switched over to using esp_partition_mmap().