How to write structure in FLEXSPI1 QSPI flash

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

How to write structure in FLEXSPI1 QSPI flash

Jump to solution
1,470 Views
vasudhevan
Contributor V

Hi,

     Board = IMXRT1064EVK

     I am using evkmimxrt1064_flash_component_nor example code.

     If i try to write structure in  Nor_Flash_Page_Program api every time void HardFault_Handler(void) isr trigger if i do step by step debugging this api returns 7001 status code.

     If we write string writing fine and reading also fine.

     How to solve this issue ?

     This method will work ?

Thanks & Regards

        Vasu

Labels (1)
0 Kudos
1 Solution
1,315 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Vasudhevan G,

  Thanks so much for your updated information, and let me know you already make it works.

  I let you disable the cache, just to make sure it is not related to the cache, because I'm afraid your question is related to the cache conflict when you use different modules, you may find more detail in this application note:

https://www.nxp.com/docs/en/application-note/AN12042.pdf 

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

0 Kudos
8 Replies
1,315 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Vasudhevan G ,

  Do you run this code:

SDK_2.7.0_EVK-MIMXRT1064\boards\evkmimxrt1064\driver_examples\flexspi\nor\polling_transfer

 directly?

  Do you download it to the internal RAM and run it?

  Do you modify some code, or just running it directly?

  This is my debug result:

pastedImage_1.png

   Please try the debug, and run it again.

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,315 Views
vasudhevan
Contributor V

Hi Kerry Zhou,

     Thank you for your reply.

     I am using evkmimxrt1064_flash_component_nor example code and polling_transfer both are similar code.

     

elm_net_cfg.state = 1;
elm_net_cfg.device = "Ethernet"
elm_net_cfg.mode = 1;   //dhcp


elm_flash_write((uint8_t*)&elm_net_cfg, sizeof(elm_net_cfg), ELM_INPUT_CFG, 0);


uint8_t v_flash_write(uint8_t *data_buffer, unsigned int data_size, unsigned int info_type, unsigned int offset)
{
     int i;
     for (i = 0; data_buffer[i] != '\0'; i++)
     {
        PRINTF("Data - %c \r\n", data_buffer[i]);
     } 
  
     status = Nor_Flash_Page_Program(&norHandle, 0, data_buffer);  // hardfault error
}


Debug Output:
 Data - 
Data - E 
Data - t 
Data - h 
Data - e 
Data - r 
Data - n 
Data - e 
Data - t 
Data - 

Please see attached code why hardfault isr triggered ?

If i write string or array of data working fine.

Thanks & Regards,

        Vasu

0 Kudos
1,315 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Vasudhevan G,

  Please also share the working write string or array of data to me on your side, thanks!

  If you just use the SDK code, it also works on your side, right?

 

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,315 Views
vasudhevan
Contributor V

Hi Kerry Zhou,

     Now i tested with evkmimxrt1064_flash_component_nor example code working with structure but some time debug mode when starts debugger coming out automatically showing program run of the memory.

    CLOCK_InitUsb1Pll(&g_ccmConfigUsbPll);
    CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 24);   /* Set PLL3 PFD0 clock 360MHZ. */
    CLOCK_SetMux(kCLOCK_FlexspiMux, 0x3); /* Choose PLL3 PFD0 clock as flexspi source clock. */
    CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2);   /* flexspi clock 120M. */

      These four lines only giving error.

     I imported free_rtos_dhcp example code then added evkmimxrt1064_flash_component_nor example if i add above clock setting giving same error.

    Below line i added avoid error but hardfault isr triggered.       

    CLOCK_SetMux(kCLOCK_FlexspiMux, 0x2); /* Choose PLL2 PFD2 clock as flexspi source clock. 396M */
    CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2);   /* flexspi clock 133M. */

     Now whenever calling 

Nor_Flash_Page_Program

   Hard fault error accorded.

 

   How to set clock for flexspi1 to avoid error ? 

   Why same code i am getting hard fault error ?

   Why program run out of memory debug error is coming ? 

Thanks & Regards

        Vasu

0 Kudos
1,315 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Vasudhevan G,

1. When you tested with evkmimxrt1064_flash_component_nor example code

   Where you located the code? internal RAM or the internal flash?

   Please try to run your code in the internal ITCM, whether you still have problems or not?

  You mentioned: "but some time debug mode when starts debugger coming out automatically showing program run of the memory."

 Could you give me some picture about it? Do you mean the debugger disconnect or meet problems?

2. imported free_rtos_dhcp example code

  Please try to disable the cache function, then test it again.

  BOARD_ConfigMPU function, modify the last code from:

/* Enable I cache and D cache */
SCB_EnableDCache();
SCB_EnableICache();

to 

SCB_DisableICache();

SCB_DisableDCache();

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,315 Views
vasudhevan
Contributor V

Hi Kerry zhou,

     I disabled SCB_DisableICache and SCB_DisableDCache cache.

     Major issue is before calling vTaskStartScheduler() i called flexspi read and write apis giving hard fault error.

     Now working fine.

     Why we need to disable SCB_DisableICache and SCB_DisableDCache ?

Thanks & Regards

       Vasu

0 Kudos
1,316 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Vasudhevan G,

  Thanks so much for your updated information, and let me know you already make it works.

  I let you disable the cache, just to make sure it is not related to the cache, because I'm afraid your question is related to the cache conflict when you use different modules, you may find more detail in this application note:

https://www.nxp.com/docs/en/application-note/AN12042.pdf 

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,315 Views
vasudhevan
Contributor V

Hi Kerry,

    Thank you.

0 Kudos