Hello,
I'm trying to add a FlexSPI driver to my project to read/write a portion of my SPI flash. This SPI flash also runs the program code, but the data space will be located in a separate region. I'm using an i.MXRT1062. I was able to run the example "flexspi_nor_polling_transfer" successfully, so now trying to adapt this example to my project.
I see that one of the requirements when using this driver, at least for initialization, is that the program code needs to run in RAM somewhere, as the flash is reset during initialization and this would cause problems with the app execution. I've set up the linker script the same as the example:
data.ldt
< # if memory.name=="SRAM_ITC">
*flexspi_nor_flash_ops.o(.text*)
*fsl_flexspi.o(.text*)
</#if>
main_text.ldt
*(EXCLUDE_FILE(*flexspi_nor_flash_ops.o *fsl_flexspi.o) .text*)
I wasn't able to place the .bss portion into SRAM_OC like in the example bc it wouldn't fit, but maybe this is not necessary if nothing is accessed in the .bss region during initialization.
After importing the driver into my project, I'm able to execute everything in flexspi_nor_flash_init(FLEXSPI_Type *base) up until FLEXSPI_Init(base, &config) has finished, then I receive a hard fault - Instruction access violation flag.
I'm not sure why this is happening at this point, I would think every instruction should be contained inside the files flexspi_nor_flash_ops.c & fsl_flexspi.c within SRAM_ITC. Are there any other pitfalls when using this example within a larger project? Or is there a better example flexspi example to use for spi flash?
Thanks
Solved! Go to Solution.
I'm also using FreeRTOS in this project.
The issue seems to be fixed after setting a critical section when flexspi_nor_flash_init() is called. This is probably needed whenever the spi flash code is called. Please refer to the forum post on this:
I'm also using FreeRTOS in this project.
The issue seems to be fixed after setting a critical section when flexspi_nor_flash_init() is called. This is probably needed whenever the spi flash code is called. Please refer to the forum post on this: