FLEXSPI_Init (mostly FLEXSPI_SoftwareReset) causes a hardfault while trying to initialize FlexSPI

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

FLEXSPI_Init (mostly FLEXSPI_SoftwareReset) causes a hardfault while trying to initialize FlexSPI

Jump to solution
3,202 Views
Lukaz
Contributor III

Hello,
I am building my own module to access an external flash memory using a MIMXRT1061CVL5B controller. It is built on the example in the SDK flexspi_nor_polling_transfer, I keep running into a hardfault that is caused by the FLEXSPI_Init, and I am almost sure it is from the function call FLEXSPI_SoftwareReset.

I tried to add the object files to the RAM in the .icf file as it is in the SDK example but that didn't help
Can anybody help me?

Thanks in advance.

Labels (1)
0 Kudos
Reply
1 Solution
3,146 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Lukaz ,

  Ok, I know, your issue is caused by other code, eg, PIT.

  I think you enable the PIT interrupt, right?

   This should be the key point, when do the flash operation, it should not be interrupted by other moduld, so you need to disable the PIT interrupt before you do the flexSPI operation, after it is finished, you can enable the PIT interrupt again.

  Please help to check it, I think it is root reason.

Best Regards,

kerry

View solution in original post

14 Replies
3,184 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Lukaz ,

   Thank you for your interest in the NXP MIMXRT product, I would like to provide service for you.

flexspi_nor_polling_transfer is used to the external flash is QSPI flash, in fact, it is for: IS25WP064AJBLE.

  So, in your own RT1061 board, which detail flash you are using now? Different external flash have different configuration.

  Even you use the same qspi flash IS25WP064AJBLE, in the first time, as your QSPI flash is new, and QE bit is not enabled, you need to run it from internal flash, otherwise, you will meet the boot issues.

  If you use other flash, you also meet issues.

  So, at first, please let us know your used external flash, and the connection to the RT1061 board.

 

Best Regards,

Kerry

 

0 Kudos
Reply
3,177 Views
Lukaz
Contributor III

Hello Kerry,

I am aware of the difference between the flashes. I am using winbond W25Q64JVSSIQ, and I am able to boot from it with no problem. The QE bit is by default enabled (actually can't be cleared in this flash). Can you please give an example of how could the configuration for the initialization be different? I customized all my functions and the LUT to be compatible with the flash I am using, only the initialization is the same as the one in the flexspi_nor_polling_transfer example. Please see below my init function.

Lukaz_0-1660114074830.pngLukaz_1-1660114110768.png

 

0 Kudos
Reply
3,167 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Lukaz ,

Thanks for your updated information.

Now, run this code in the internal RAM:

SDK_2_12_0_EVK-MIMXRT1060\boards\evkmimxrt1060\driver_examples\flexspi\nor\polling_transfer

You need to modify the code for your winbond chip:

  1. Modify LUT 

1). From:

/* Erase Sector */
[4 * NOR_CMD_LUT_SEQ_IDX_ERASESECTOR] =
FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xD7, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18),

To:

/* Erase Sector */
[4 * NOR_CMD_LUT_SEQ_IDX_ERASESECTOR] =
FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0X20, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18),

 

2). From

/* Enable Quad mode */
[4 * NOR_CMD_LUT_SEQ_IDX_WRITESTATUSREG] =
FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x01, kFLEXSPI_Command_WRITE_SDR, kFLEXSPI_1PAD, 0x04),

to:

/* Enable Quad mode */
[4 * NOR_CMD_LUT_SEQ_IDX_WRITESTATUSREG] =
FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x31, kFLEXSPI_Command_WRITE_SDR, kFLEXSPI_1PAD, 0x04),

3) QE bit

kerryzhou_0-1660119271921.png

app.h

From

#define FLASH_QUAD_ENABLE 0x40

to:

#define FLASH_QUAD_ENABLE 0x02

 

 

2. Please also check your hardware

DQS pin, I mean this pin:

GPIO_SD_B1_05

You need to leave it as float, otherwise, it will influence the flexSPI frequency.

 

Then test the code in the RAM, whether you can do the external flash erase, read, write or not?

Best Regards,

Kerry

 

0 Kudos
Reply
3,165 Views
Lukaz
Contributor III

Hi Kerry,
thanks for the reply, I understand all that you are asking me to do, except running the code from the internal RAM, what exactly do u mean?

Thanks in advance.

0 Kudos
Reply
3,162 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Lukaz ,

   Thanks very easy if you are using the MCUXPresso IDE, just do the following configuration:

kerryzhou_0-1660121238224.png

I need to use the RAM code to test your external flash totally works at first.

You can check the printf information with the UART, or you can check it in console if you enable the semihost:

kerryzhou_1-1660121308434.png

Please test it on your side, and share me your printf information after the code modification.

Please also make sure the DQS pin is float, otherwise, you need to cut down the flexSPI frequency to 60Mhz, and set :

Dummy read strobe generated by FlexSPI controller and looped back internally
(FlexSPIn_MCR0[RXCLKSRC] = 0x0)

Best Regards

Kerry

 

 

0 Kudos
Reply
3,153 Views
Lukaz
Contributor III

Hello Kerry,
I used the linker file that comes with the flexspi_nor_polling_transfer SDK example and was able to run the application from the RAM and it works successfully.

Lukaz_0-1660123078948.png

 

0 Kudos
Reply
3,150 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Lukaz ,

   Good!

   So, from your printf log, you are totally works OK.

   So, it already pass the the software reset you mentioned.

   Please help to check it, I think your issue is solved now.

   If you still have issues, just kindly let me know.

Best Regards,

Kerry

0 Kudos
Reply
3,148 Views
Lukaz
Contributor III

Hi Kerry
Thank you for your help, that is what I exactly thought that the issue is now solved, but it wasn't.
I could track it tho and I know now what is causing this hardfault, but I don't know why.

In my project I use the PIT module as well, I kept tracking things in my project and long story short, when I eliminate the PIT initialization from the project everything works fine otherwise I keep running into the hardfault. If you have some idea about why that might be so, I would be grateful.

 

Thanks in advance.

0 Kudos
Reply
3,147 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Lukaz ,

  Ok, I know, your issue is caused by other code, eg, PIT.

  I think you enable the PIT interrupt, right?

   This should be the key point, when do the flash operation, it should not be interrupted by other moduld, so you need to disable the PIT interrupt before you do the flexSPI operation, after it is finished, you can enable the PIT interrupt again.

  Please help to check it, I think it is root reason.

Best Regards,

kerry

3,137 Views
Lukaz
Contributor III

Hi Kerry,
I have one more question please, does this mean when I start any flash operation I should disable all interrupts from other modules? would that be solved if I use the DMA for flash operations?

0 Kudos
Reply
3,131 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Lukaz ,

  Set the flash as the highest level, otherwise, it may meet issues when other interrupt happens.

  BTW, you also can use this ROM API:

SDK_2_12_0_EVK-MIMXRT1060\boards\evkmimxrt1060\driver_examples\fsl_romapi

  Then check, whether it can be influenced by other interrupt.

  This code also can do the flash operation, with the ROM API code.

Best Regards,

Kerry

3,129 Views
Lukaz
Contributor III

I was about to try this interrupt priority, I will also take a look at this ROAM API.

Thanks a lot

3,144 Views
Lukaz
Contributor III

That is EXACTLY it !

Thank you Kerry, have a nice day

 

3,156 Views
Lukaz
Contributor III

Hi Kerry,
I am using IAR, can you tell me how can I do that in IAR?

thanks

0 Kudos
Reply