I'm having trouble running the flash remap test from AN12255SW. Once I finish initializing FlexSPI, I receive a bus fault BFARVALID (7) BusFault Address Register (BFAR) valid flag and PRECISERR (1) Precise data bus error in addition to a forced hard fault.
I needed to modify the clock configuration, otherwise the debugger would stop working - I believe this config is correct as I've used it with another flexspi flash example and my debugger remained active afterwards.
I'm not sure if maybe I should be setting additional options for the AHB buffer?
Also in the flexspi flash example, the flexspi flash driver code is run out of RAM instead of Flash using a linker script, but it doesn't look like that is needed here?
int main {
uint32_t i = 0;
flexspi_config_t config;
status_t status;
uint8_t vendorID = 0;
BOARD_ConfigMPU();
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
CLOCK_SetMux(kCLOCK_FlexspiMux, 0x2); /* Choose PLL2 PFD2 clock as flexspi source clock. 396M */
CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2); /* flexspi clock 133M. */
SCB_DisableDCache();
// Flash remap registers not used at this point
//IOMUXC_GPR->GPR30 = 0;
//IOMUXC_GPR->GPR31 = 0;
//IOMUXC_GPR->GPR32 = 0;
PRINTF("\r\nFLEXSPI example started!\r\n");
/*Get FLEXSPI default settings and configure the flexspi. */
FLEXSPI_GetDefaultConfig(&config);
/*Set AHB buffer size for reading data through AHB bus. */
config.ahbConfig.enableAHBPrefetch = true;
config.rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackFromDqsPad;
FLEXSPI_Init(EXAMPLE_FLEXSPI, &config);
// BUS FAULT OCCURS HERE
/* Configure flash settings according to serial flash feature. */
FLEXSPI_SetFlashConfig(EXAMPLE_FLEXSPI, &deviceconfig, kFLEXSPI_PortA1);
...
}