How do I initialize MX RT1015-EVK FLEXSPI?

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

How do I initialize MX RT1015-EVK FLEXSPI?

4,269 Views
superoneofone
Contributor I

In order to use external flash of MX RT1015-EVK, I am trying to learn how to use flexspi. First, I use flexspi_nor_polling_transger which is the SDK example of MX RT1015-EVK. When I run this code on my board, and there are no errors. In order to do something in C++, I create a new project which is written by C++ to test flexspi. At first this program had no problems. Once I add BOARD_InitBootPeripherals() in my code and start to debug on my board, there has some hard fault. These errors seem to come from FLEXSPI_Init(). I try to modify the parameters to the same as the example, but problem still exists. Could someone please teach me how to use or initialize flexspi on MX RT1015-EVK? Or could someone please show me some example code about flexspi MX RT1015-EVK?

Labels (1)
Tags (2)
0 Kudos
Reply
20 Replies

3,840 Views
superoneofone
Contributor I

Hello kerryzhou‌,

   When I debug the code in the IDE, the whole screen shot is shown below.

擷取.JPG

   Yes, I can run to line 53. But once I run from line 55 to line 57, the fault happen.

   When the fault happen, the whole screen shot is shown below.

擷取.JPG

Thanks!

0 Kudos
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi superoneofone@gmail.com

  Please upload your project, I will find time to help you to test it.

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
Reply

3,840 Views
superoneofone
Contributor I

Hello kerryzhou‌, 

   Thank you for taking the time to help me. I attach my created project below.

Thanks!

0 Kudos
Reply

3,840 Views
superoneofone
Contributor I

Hello kerryzhou‌, 

   Thanks for your teaching.

   Now I know how to relocate the function and the data, but I still can't relocate the flash operation API to RAM.

   As you know, if I want to use flexSPI to store my audio data to flash, I first need to use "FLEXSPI_init()" function to initialize flexSPI. Since "FLEXSPI_init()" function has been pre-defined by SDK, I have no idea how to relocate them to RAM.

   I have tried to decorate "FLEXSPI_init()" function definition using "__RAMFUNC", as shown in the following formula:

__RAMFUNC(RAM) void FLEXSPI_Init(FLEXSPI_Type *base, const flexspi_config_t *config);

   But an error occurred in the project.

   If you have time, could you advise me how to modify this?

Thanks!

0 Kudos
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Customer, 

   Could you please also share your error log, then I can help you to check it.

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
Reply

3,840 Views
superoneofone
Contributor I

Hello kerryzhou‌, 

   Thank you for taking the time to help me solve my problem.

   In my test, I created a new C project with additional "flexspi" driver.

   In order to operate my project in flash, I didn't tick "Link application to RAM". Since I want to store my audio data to flash,  I decorated "FLEXSPI_Init()" function definition which is defined in "fsl_flexspi.h" using "__RAMFUNC", as shown in the following formula:

__RAMFUNC(RAM) void FLEXSPI_Init(FLEXSPI_Type *base, const flexspi_config_t *config);

   When I built this project with above formula, there are many errors in "fsl_flexspi". As shown below:

擷取.JPG

 

   All errors are like "declaration for parameter 'FLEXSPI_Init' but no such parameter", "declaration for parameter 'FLEXSPI_GetDefaultConfig' but no such parameter". Is it because the way I declared is wrong?

   Other than that, since in this test I only used "FLEXSPI_Init()". If I want to use other flexSPI functions, how do i modify?

Thank!

0 Kudos
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi superoneofone@gmail.com,

   Thanks for your updated information.

   Please read MCUXpresso_IDE_User_Guide.pdf which is located in your IDE install path: 

C:\nxp\MCUXpressoIDE_11.1.0_3209

Chapter 17.13.5 Placing specific functions into RAM Blocks

You need to add the header file:

This placement is controlled via macros provided in a header file which can be pulled into your
project using:
#include <cr_section_macros.h>

I did a simple test:

pastedImage_1.png

It builds without error, do you add the related header file?

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
Reply

3,840 Views
superoneofone
Contributor I

Hello kerryzhou‌,

   Thank you for taking the time to help me solve my problem.

   I found that I put that header file  in the wrong place causing the problem to occur.

   Now I can build my project without error, but it still have some problems when debugging. As shown below:

擷取.JPG

   It still stop at "FLEXSPI_Init()" and have a hard fault. Dose this mean that I still operation the flash in the flash? But I found that "FLEXSPI_Init" function is indeed in the RAM, As shown below:

擷取.JPG

   "0x20000000" is the address in the RAM, as shown below:

擷取.JPG

   If I want to use some basic function like reading and storing memory, Do I need to decorate all functions which are defined in "fsl_flexspi.h" using "__RAMFUNC"?

Thanks!

0 Kudos
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Customer, 

   When you debug the code, can you enter to main or when enter debug mode, the fault happens?

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
Reply

3,840 Views
superoneofone
Contributor I

Hello kerryzhou‌,

   I think that it doesn't enter to main.

   My main code has "PRINTF("Hello World\r\n")", but It doesn't print "Hello World" and the fault happens. As shown below:

擷取.JPG

Thanks!

0 Kudos
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi superoneofone@gmail.com,

  Add breakpoint in Line 3, can you enter it?

  When you debug the code in the IDE, after the debugger mode is entered, give me the whole screen shot.

  If you have the breakpoint in line 3, can you enter it?

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
Reply

3,840 Views
superoneofone
Contributor I

Hello kerryzhou‌, 

   Do you mean I should not tick "Link application to RAM" to run my project,  and the flash operation API need to be put to RAM?

   If you have time, could you teach me how to do the above?

   Now, I can only put the whole project in the RAM or the external flash by modifying "Link application to RAM". I don't know how to use MCUXpresso IDE to place different parts in different memories(RAM and external flash) separately.

Thanks!

0 Kudos
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Customer,

 Please check this IDE sharing:

Relocating Code and Data Using the MCUXpresso IDE 

  It has how to relocate the RAM code.

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
Reply

3,840 Views
superoneofone
Contributor I

Hello kerryzhou,

I mean that I can save my code and data in my board even if my board has no electricity. Since the code and data which are saved in the RAM are lost when there is no electricity.

As shown below. Whether the "flexspi_nor_polling_transfer" example is ticked "Link application to RAM" or not, it can still run successfully. Is their different in that the code and data are stored in the RAM or the FLASH?

Tick "Link application to RAM":

ram.JPG

Non-tick "Link application to RAM":

flash.JPG

But when I create a new code to test flexSPI, it can only run successfully on RAM. If I don't tick "Link application to RAM", the code always has a fault.

If you have time, could you teach me why is there such a difference?

Other than that, since I want to use SAI to record the sound and save a short audio data, I need a big size memory like FLASH to store audio data. Is the flexSPI necessary? Or is there any other way to solve this problem?

Thanks!

0 Kudos
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Customer,

    Tick "Link application to RAM": 

     This will put your app code in the RAM, not the external flash.You can find BOARD_FLASH is no data.

    Non-tick "Link application to RAM":

      This will put your app code in the external flash, so you can find BOARD_FLASH is used.

   If you want to want to save your SAI code to the external flash, you can download your code to the external flash, but when you want to use the flash operation API, please copy that API to the internal RAM, otherwise, you will get hardfault. Because you can't operation the flash when the code already run in the external flash directly, as you know, flash code and your operation code will all operate the flexSPI interface.

     When you want the big size memory to store the audio data, you can define the related flash range, just make sure your code won't mix with your data range.

    

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
Reply

3,840 Views
superoneofone
Contributor I

Hello kerryzhou,

Thanks in advance for your suggestions. When I modified the configuration you said, the flexSPI can initialize properly.

Although I can initialize the flexSPI now,  I have another problem. Why the flexspi_nor_polling_transfer project doesn't tick "Link application to RAM" and can still run the program?

Since I want to do something with this MX RT1015-EVK board, I can plug it in and use it. If I tick "Link application to RAM", once the program restart or  press the reset button on the board, the program can't run successfully.

What can I do to make my program do the above?

Thanks!

0 Kudos
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi superoneofone@gmail.com,

   Do you mean even you don't put the lexspi_nor_polling_transfer code in the RAM, and run it from external flash directly, it still works?

   You can copy the flexSPI operation code to the internal RAM, and run it from RAM, but when you download the code, you can download it to the external flash.

   Take an example, you can generate the RAM project code, and then use the tool(MFGTool or the MCUbootUtility ) download to the external flash, but you need to make sure, your flash operation won't influence the external code area.

  

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
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi customer,

   Welcome to use the MIMXRT product.

   Until now, NXP just provide the RT C code project, so, it's better to use the C project directly, as you know, all the driver is based on the C, not C++.

   If you want to use the C++, you need to migrate it by yourself.

   When you meet the hardfault problems, please make sure your code is downloaded to the internal RAM instead of the external flash directly, you can refer to the C project carefully.

Wish it helps you!

If you still have questions about it, please kindly let me know.

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
Reply

3,840 Views
superoneofone
Contributor I

Hello , thanks for your reply.

As you said, all the driver is based on the C. I have tried using C to test flexspi, but it still has some problems. As shown below.

擷取.JPG

In this test, I use MCUXpresso IDE, and just create a new C project with default board files. When I add flexspi to peripheral drivers, the problems arise. Once I disable flexspi, It's perfectly fine. As shown below.擷取2.JPG

If you have time, could you teach me how to know my code is downloaded to the internal RAM or external flash?

Thanks!

0 Kudos
Reply

3,840 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi superoneofone@gmail.com,

   I have created one new project, and all add the flexSPI, I can debug it without problems.

pastedImage_2.png

put the code in the internal RAM, please do the following configuration:

pastedImage_1.png

I also attach my new created project.

 If you want to add the detail flexSPI operation, please refer to the flexspi_nor_polling_transfer project.

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
Reply