Hard/Bus Fault while running AN12255SW flash_remap_test

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hard/Bus Fault while running AN12255SW flash_remap_test

Jump to solution
435 Views
schafbo
Contributor III

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);

...

}

Labels (1)
0 Kudos
Reply
1 Solution
406 Views
MultipleMonomials
Contributor IV

You _definitely_ need to be running out of RAM when calling FLEXSPI_Init() and FLEXSPI_SetFlashConfig(). IIRC, in between those two function calls, the FLEXSPI peripheral will have no LUT sequences, so it won't be able to read anything out of flash.

 

Maybe try wrapping your main() function in AT_QUICKACCESS_SECTION_CODE() and see if that helps?

 

Also, if it's useful, here's how we did this in Mbed OS: https://github.com/mbed-ce/mbed-os/blob/master/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMX...

View solution in original post

6 Replies
333 Views
schafbo
Contributor III

How can I set the fuse bits as outlined in AN12255 section 3.2.1?

0 Kudos
Reply
388 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @schafbo 

Thank you for reaching out!

It seems that are you running the demo located in AN1225SW> SW\src\boards\evkmimxrt1060\use_case\flash_remap_test\nor\polling_transfer\, correct ?

If yes, which scatter (icf) file did you selected? Below an example for more context.  

diego_charles_0-1737672371654.png

It is expected that the AN12255 SW was working well when it was released, but this occurred  released sometime ago (2018), I do not know if latest IAR and compiler settings and version are affecting. 

Diego

 

 

 

 

 

0 Kudos
Reply
335 Views
schafbo
Contributor III

Hello Diego,

I'm using MCUXpresso and not IAR, is it required for using this example?

0 Kudos
Reply
407 Views
MultipleMonomials
Contributor IV

You _definitely_ need to be running out of RAM when calling FLEXSPI_Init() and FLEXSPI_SetFlashConfig(). IIRC, in between those two function calls, the FLEXSPI peripheral will have no LUT sequences, so it won't be able to read anything out of flash.

 

Maybe try wrapping your main() function in AT_QUICKACCESS_SECTION_CODE() and see if that helps?

 

Also, if it's useful, here's how we did this in Mbed OS: https://github.com/mbed-ce/mbed-os/blob/master/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMX...

334 Views
schafbo
Contributor III

Thank you. I placed the FlexSPI functions into RAM using a similar method to the 'flexspi_nor_polling' example and I no longer had hard faults. I'm thinking the linker for this example was set up a different way that would have done this for me, but I'm not sure how/if it can work with MCUXpresso.

The flash remap test uses the same drivers as the flex spi example (just adding the steps to set the GPR), so I pulled the code in to test it and the remap seemed to work just fine.

0 Kudos
Reply
433 Views
schafbo
Contributor III

I'm using an iMXRT1062.