Hi,
I would like to use the external flash to store a binary image for a connected processor. Can someone give me some example code on how I can do that. The maximum size I need is 1 MByte.
Thanks
Imtiaz
External Flash usage
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: External Flash usage
But seriously, you can do this multiple ways nowadays. The most elegant way probably is to use a custom partition table and declare an 1MB partition there. Then use the partition API to map that partition into memory and do what you want with the data in it.
Re: External Flash usage
Hi @ ESP_Sprite,@ESP_AngusBut seriously, you can do this multiple ways nowadays. The most elegant way probably is to use a custom partition table and declare an 1MB partition there. Then use the partition API to map that partition into memory and do what you want with the data in it.
I am trying to memory map a region of external flash into a data region . It finds my partition and maps the region succesfully. However program crashes if I write data to it. Can you check this code .. I couldnt find any examples so Im probably doing something wrong. How are you supposed to read/write data to the mapped partition?
Code: Select all
const esp_partition_t *p = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, 0x80, NULL);
if(p != NULL)
{
TRACE_D("MMap partition found\n");
}
else
{
TRACE_D("MMap partition NOT found\n");
}
uint32_t *mmap_data;
spi_flash_mmap_handle_t mmap_handle;
if( esp_partition_mmap(p, 0, 2048000, SPI_FLASH_MMAP_DATA,
(const void **)&mmap_data, &mmap_handle) == ESP_OK)
{
TRACE_D("Memory mappped\n");
}
else
{
TRACE_D("Memory map fail\n");
}
mmap_data[0] = 12345678; //This line causes crash
if(mmap_data[0] == 12345678)
{
TRACE_D("test Pass\n");
}
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: External Flash usage
Memory-mapped flash is read-only because flashing doesn't happen transparently. (If anything because doing that would either make the hardware horrenduously complicated and/or non-power-fail-safe because of the way flash works.) Please use the normal SPI calls (esp_partition_erase_range/esp_partition_write) if you need to modify flash. See http://esp-idf.readthedocs.io/en/latest ... table-apis for the API reference for those, if you need it.
Who is online
Users browsing this forum: No registered users and 231 guests