Tool/software:
I copied flash API code into RAM in application code, after that I tried to write flash bank 7 with fee functions. I got an prefetch error when I tried to write data on flash bank 7.
There is my configurations below.
-FAPI code region start adress on RAM is 0x0807E000.
-FAPI code region end adress on RAM is 0x0807FFFF
-FAPI code region size is 8KB.
-FAPI code region type is NORMAL OINC SHARED
-FAPI code region permission is RW_RW_EXEC.
- I'm using total of 10 MPU regions. FAPI MPU region number is 7 and after that the REGION 7 there is no MPU configuration related to RAM (So other mpu regions after that regiosn must not affect the REGION 7)
- I'm using Freertos. My task configurable region number is 3.
- My HCLK frequency is 150 Mhz, GCLK frequency is 300 Mhz.
- My flash data wait state is 3 (its automatically created from halcogen)
- My linker configurations is compatible with my MPU configurations.
- I'm using "F021_API_CortexR4_BE_L2FMC_V3D16.lib" and I configurated at linker like below (ignore typos I can't upload my real code here)
FAPI_RAM (RW): origin=0x0807E000 lenght=0x2000
flashAPI:
{
Fapi_UserDefinedFunctions.obj(.text,.data)
--library = F021_API_CortexR4_BE_L2FMC_V3D16.lib(.text,.data)
}palign=8 load=FLASH, run=FAPI_RAM, LOAD_START(apiloadstart), RUN_START(apirunstart),SIZE(apiloadsize)
Firstly I examined the fault source, I found that the cause of fault is instruction adress at 0x0807e7e4. When I disassembled the adress, I found that Fapi_doBlankCheck function. This address is from my FAPI_RAM region, this region is executable so I shouldn't get prefetch error. After the error, I configured all 512 KB ram region as executable region but I got prefetch error again, so I think that the error should not related with MPU configurations. (I checked the mpu permission and type when I got fault)
I tried it on baremetal project and I didn't get any problem.
What is the source of the fault ? How can I fix this error ? Is it related with data wait states ?