SPI_FLASH_MMAP_INST Exception

elix22
Posts: 2
Joined: Wed Feb 22, 2017 11:47 pm

SPI_FLASH_MMAP_INST Exception

Postby elix22 » Wed Feb 22, 2017 11:55 pm

I am trying to memory map a flash region using spi_flash_mmap() , starting address 0x300000 , 1 MB in size .
I am trying to memory map it to the instruction memory space (SPI_FLASH_MMAP_INST) .
However I am getting an exception while trying to do that .
"Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled."

I am successful in memory mapping to the data memory space(SPI_FLASH_MMAP_DATA)

Are there any restrictions while memory mapping to the instruction memory space ?

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

Re: SPI_FLASH_MMAP_INST Exception

Postby ESP_Angus » Thu Feb 23, 2017 12:51 am

Hi Elix22,

The main restriction with mapping to the instruction space is that all reads from this space have to be 4 byte aligned word reads. LoadStoreError will occur on an unaligned or non-4-byte read from instruction space (you would expect LoadStoreAlignment exception instead, but for some reason it's not that.)

If that doesn't fix the problem, could you please post the full exception dump and the output of spi_flash_mmap_dump(), and maybe a code snippet? Thanks.

Angus

elix22
Posts: 2
Joined: Wed Feb 22, 2017 11:47 pm

Re: SPI_FLASH_MMAP_INST Exception

Postby elix22 » Thu Feb 23, 2017 7:10 am

Hi Angus .
Thanks for the quick reply.

Attached a small example that triggers the exception.
Both the address and the size are 4 bytes aligned .
Looks like a genuine issue.

Code: Select all

#include "freertos/FreeRTOS.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "driver/gpio.h"
#include <esp_log.h>
#include <esp_err.h>
#include <esp_spi_flash.h>


#define ADDR 0x300000
#define MEMMAP_SIZE (1024*1024)

static char tag[] = "memmap_test";

static spi_flash_mmap_handle_t handle;

static uint32_t pInstrPtr = 0;

void app_main(void)
{
    nvs_flash_init();
    tcpip_adapter_init();
	spi_flash_init();

	esp_err_t rc = spi_flash_mmap((uint32_t) ADDR, MEMMAP_SIZE, SPI_FLASH_MMAP_INST, (const void **)&pInstrPtr, &handle);
	
	if (rc != ESP_OK) {
		ESP_LOGE(tag, "rc from spi_flash_mmap: %d", rc);
	}
	else
	{
		ESP_LOGD(tag, "spi_flash_mmap success");
	}
}


Who is online

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