How do I run from BOARD_SDRAM on MIMXRT1020-EVK?

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

How do I run from BOARD_SDRAM on MIMXRT1020-EVK?

9,720 Views
rshipman
Contributor V

Hi,

I've installed MCUXpresso IDE v11.0.0 and SDK_2.x_EVK-MIMXRT1020.

I am connected via the USB debug port to a MIMXRT1020-EVK eval board.

I have loaded and run various demos successfully such as demo_apps/hello_world and iled_blinky using the default settings etc.

What I'm trying to do is run a demo straight from BOARD_SDRAM.

How can I do this (e.g. in MCUXpresso)? What settings do I need to change? Do I need to make changes to the code as well?

I'm struggling to find anything in the various documents that tell me precisely how to do this, or tell me what actually is going on when the default demos above are loaded. (I have the MCUXpresso user guide and the i.MX RT1020 Processor Reference Manual among others.) Is there a basic 'just for beginners' set of tutorials that describe what exactly is going on when a demo is loaded and executed please? I can see the info in the .ld linker files, the auto generated code, and the various places in the code that refer to the vector tables and memory sections and so on, but I don't yet know how this all ties together, which bits are included or not, or how and where MCUXpresso makes the changes (e.g. what settings affect what bit of code).

This is what I have changed so far:

I select 'Link to RAM' and move BOARD_SDRAM up as the second item in the memory configuration list after BOARD_FLASH. Everything else is the same as the default SDK demo settings. After building, the linker tells me that everything is going to be in BOARD_SDRAM, all other memories have zero bytes in them.

BOARD_FLASH: 0 GB 8 MB 0.00%
BOARD_SDRAM: 26212 B 32 MB 0.08%
SRAM_DTC: 0 GB 64 KB 0.00%
SRAM_ITC: 0 GB 64 KB 0.00%
SRAM_OC: 0 GB 128 KB 0.00%

I tried loading/running this but I get an error:

Error in final launch sequence:

Failed to execute MI command:
-target-download
Error message from debugger back end:
Load failed
Failed to execute MI command:
-target-download
Error message from debugger back end:
Load failed

I expected an error of some sort, because I don't know how the boot loader would know to boot from this image in SDRAM. E.g. how and where should I load the IVT table etc? Do I still need to load something into flash that tells boot loader to run from SDRAM?

Is there an easy way to get MCUXpresso to do this please? Or do I need to start editing code and creating separate binary files to load in various places?

Also I'm not entirely sure I understand the different between the two boot configurations serial and internal. As I understand it: MCUXpresso is able to load new code onto the board with the internal setting enabled. So the program gets loaded into flash and the boot loader is made to run from it. In serial mode the boot code comes from the serial channel, so does that mean MCUXpresso first loads the program into flash and then a separate binary to be used by the boot loader?

Also how does MCUXpresso actually invoke the boot loader to start running?

Sorry for the rambling questions. I am basically a complete beginner to MCUXpresso and eclipse generally and to the ARM Mx core chips. (I know these questions probably look stupid.)

Thanks for your help.

Kind regards

24 Replies

7,637 Views
farid_mabrouk
Contributor II

Make sure you have specified a link on your ide to the sdram_init file for the debugger. 

Cheers! 

0 Kudos
Reply

7,637 Views
bopeng
Contributor I

Hello,

I am using MCUexpresso 11.1 and SDK2.7.0. But I still get debugger error even though I use the same setting as Kerry.

Any suggestion?

0 Kudos
Reply

7,663 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Paul Laroide,

  Please check my attached iled_blinky code, you will find it running in the SDRAM.

 In factor, I just do the points which you have mentioned:

1.

pastedImage_14.png

2.

pastedImage_15.png

Then the test result is:

pastedImage_12.png

You can find the code is running in the 0X8000XXXX area, which is the SDRAM address. The above debug is using CMSIS DAP, just the MIMXRT1020-EVK on board debugger.

I also use the JLINK to check the code running status:

pastedImage_356.png

You can find the code still in the SDRAM.

Please check my attached led code which is based on the SDK2.6.1.

Wish it helps you!

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

Kerry

0 Kudos
Reply

7,662 Views
paullaroide
Contributor II

Ok, you did not answer the question: how to debug an application STRAIGTH in SDRAM and not using the SPI flash at all (i.e. by removing it in the memory list and erasing it / by unsoldering it on the board / by setting the switches to "OFF-OFF-OFF-ON" <- read my post another time).

Your project did not and cannot work with the SPI flash fully erased.

- You are using XIP_BOOT_XXXX flags which are useless when you want to debug from SDRAM, (SYSCLK_INIT is mandatory to avoid the application modify the SEMC clock)

- You are using the standard "RT1020_connect.scp" : thus the registers for the SDRAM are not correctly set BEFORE loading the application in SDRAM.

Refer to "clock_config.c":

    /* In SDK projects, SDRAM (configured by SEMC) will be initialized in either debug script or dcd.
     * With this macro SKIP_SYSCLK_INIT, system pll (selected to be SEMC source clock in SDK projects) will be left
     * unchanged. Note: If another clock source is selected for SEMC, user may want to avoid changing that clock as
     * well.*/

and "evkmimxrt1020_iled_blinky LinkServer Debug.launch"

   <stringAttribute key="internal.connect.script" value="RT1020_connect.scp"/>

As you are using the standard "RT1020_connect.scp" and no other debug script, this cannot work!

Loading the application in SDRAM with the SPI flash already programmed with the DCD table (and headers) to initialize the registers has never been a problem to me.

Anyway, I solved this issue and I'm able to load and run an application directly in SDRAM with the IDE and with the SPI flash removed from the board.

7,662 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Paul Laroide,

    Thanks a lot for your updated information, and you already make it works.

    So, could you share your experience in details, and your .scp code?

    My project is debugged, and copy the code from external flash to the SDRAM at first, then run the code from SDRAM, and exit the debug mode to check the code function, and check the code execution status.

    Could you tell me, why you need to debug the code directly in the SDRAM? In the practical usage, normally the code need to download to the external flash, then copy the code to the SDRAM and run it.

   Because you already make it works, if you can share your whole project and the related files,and the steps, it maybe more useful to our other customer, thanks a lot for your contribution.

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

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
Reply

7,662 Views
paullaroide
Contributor II

executeInSdram.jpg

Debugging in SDRAM is the first thing you should try when receiving a new board with a new uP (you should have known it if you were already working in the 80s!).

Moreover, that's important when you are working in a team: some engineers are working on a SPL with multiple capabilities (Y-Modem, with better update possibilities (update throught industrial buses), backup scenarii, updating an application while the previous is running, switch from the previous to the newest application in less than 0.5s, etc. better and more capabilities than the boot rom has; have a look to das u-boot for some use cases), other engineers on the application, others on a recovery partition, others on debugging 3rd parties libraries... They do not have to wait for a complete SPL to develop/debug the application that will be embedded in the flash. That's why the SCP is so important.

Please have a look to :

- i.MX RT1020 Processor Reference Manual

- Overview of using the MIMXRT1050-EVK(B) with MCUXpresso IDE

- scripts stored in /usr/local/mcuxpressoide/ide/binaries/Scripts/

- What commands are supported in Redlink Server? 

- BOARD_BootClockRUN() function

- DCD table provided in the SDK (but not enough/correct if using different clock path/frequencies)

- avoid reconfiguring the clocks mux/div of the SEMC clock path

- erase the flash to avoid the load of the DCD table on reset. Remove it from the Memory list in the project structure (cf. attached screenshot)

- set the registers of the SEMC accordingly to the PLL/SEMC clock frequencies in the script

- use (peek32 then OR/AND) rather than poke32 for some registers

- use soft reset in debug configuration

Take it easy, I'm sure you'll find someone at NXP who will be able to help you or your customers if you do not succeed in writing a correct scp script.

And please, try to understand the applications of your customers/end-users, your remark "In the practical usage, normally the code need to download to the external flash, then copy the code to the SDRAM and run it." is a noobie point of view and not an expert in high reliable embedded systems point of view.

6,670 Views
venkataddagatla
Contributor II

Hi Paullaroide,

I was also working on the same debugging from SDRAM for Imxrt1060. I am using the MCU expresso IDE tool for building the code. Somehow from internet sources, I could able to achieve debug a script to initialize the SDRAM. I am using OpenSDA port for debugging. I can see the breakpoint hitting the main after downloading through the debug port. But, there is a problem i am facing , i can not able to debug in steps i.e. step in or step over. Whenever I do step over after hitting the main, it is running not going to the next step of the line of the code.

Did you face this kind of behavior in debug from SDRAM.

@kerryzhou @paullaroide @farid_mabrouk 

 

 

0 Kudos
Reply

6,658 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @venkataddagatla   

   If you have any issues with the RT SDRAM debug, please create a new question post, then we will help you in your own question post, thanks.

Best Regards,

kerry

0 Kudos
Reply

7,661 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Thanks a lot for your information!


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
Reply

7,662 Views
farid_mabrouk
Contributor II

This is related to iMX RT1060-evk: can someone let me know how to configure the memory settings so that I can ran  this example code from SDRAM: evkmimxrt1060_elcdif_rgb. 

0 Kudos
Reply

7,662 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Andre,

   I will reply you directly on your question post, sorry for my later reply because of weekends and yesterday's community log in problems.

 

Best Regards,

Kerry

0 Kudos
Reply

7,648 Views
farid_mabrouk
Contributor II

Thank you Kerry! I solved my issue. All I was missing was the sdram jtag init file. 

If have any issues related to eLCDIF peripheral I will let you know 

0 Kudos
Reply

7,662 Views
farid_mabrouk
Contributor II

Farid

0 Kudos
Reply

7,662 Views
rshipman
Contributor V

Hi all,

I can confirm that this does work from a fresh copy of the SDK iled_blinky demo, as long as you move BOARD_SDRAM up to top place in MCU Settings. Otherwise just do what Kerry says in steps 1 & 2 (i.e. add those symbols, and link to RAM).

I'm using a completely standard set up on Windows 10, latest MCUXpresso IDE, MIMXRT1020-EVK board, USB connection via USB Debug port, default DAPLink CMSIS-DAP LinkServer debugger.

Thanks,

Ronnie

0 Kudos
Reply

7,662 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ronnie,

    Thanks for your updated information.

    So now, do you still have any further question about the code copy to SDRAM?

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

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
Reply

7,662 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi ronnie.shipman@linea-research.co.uk 

  Please check the following post, it should useful to you:

Overview of using the MIMXRT1050-EVK(B) with MCUXpresso IDE 

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

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.
-------------------------------------------------------------------------------

7,663 Views
rshipman
Contributor V

Hi Kerry,

Thank you for your reply.

I have read the document and it is good, but I need more information.

I have followed the instructions up to page 18. (After that it talks about converting a RAM project to XIP which I do not need at the moment.)

The last line on that page says:

"and of course SDRAM memory will be available for image download."

So how do I download it?

And what am I downloading?

The standard SDK demos for the RT1020 produce an axf file (using MCUXpresso) which I presume is loaded into the XIP board flash and then the bootloader is invoked to read it? If that is correct, does that mean the axf file (from the MIMXRT1020xxxx_Project used in the document) needs to be loaded into SDRAM?

How is this done?

Also what do we load into XIP so the bootloader runs from SDRAM?

I basically need all the steps, from compiling the source to loading the SDRAM and getting the board to run it, including producing debug.

The document tells me how to do some of this but not all.

Thank you for your help.

Kind regards

0 Kudos
Reply

7,663 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Hi Ronnie,

I actually wrote the document referenced by Kerry sometime ago. Please let me explain what I think is occurring...

Essentially there are two steps here:

1 - generating an image that will be linked to run from RAM. From your description you appear to be doing this step correctly.

2 - performing a debug connection to the board, downloading the data and starting the image. MCUXpresso IDE will perform the debug  connection and the necessary SOFT reset to start the image running. The likely problem is that the SDRAM is simply not available because it has not been initialised.

The initialisation of the SDRAM is performed by the BootROM from data contained in Flash Image header (at boot time). This header is part of the XIP (execute in place) data contained in an XIP folder automatically included for images running from Flash.

Note: this initialisation is only required for the external SDRAM and not for the internal FlexRAM (ITCM, DTCM and OCRAM).

Therefore, if you really need to run code from the SDRAM only (i.e. skipping boot from flash), then you will either have to initialise the RAM yourself from a script file or you could persuade the BootROM to do it for you.

Any script file will be different depending on your debug connection.

To persuade the bootROM to do this for you, you could program an image into Flash that includes the XIP header - for example a simple LED Blinky. On Power on reset, this image will run and will initialise the SDRAM and hopefully blink.  Then you should have access to the SDRAM for running example code directly from SDRAM. You will also need to be aware of any peripheral settings made by the image in flash such as to the MPU (regions and cache settings) and be sure you work within these limits or make changes if required.

My advise ... use the internal RAMs unless you have run out of space - the ITCM and DTCM operate between the Core and the Caches so avoid complications.

I hope this helps,

Yours,

MCUXpresso IDE Support

0 Kudos
Reply

7,663 Views
rshipman
Contributor V

Hi,

I forgot to ask. How do I get MCUXpresso to actually download the image to SDRAM?

Thanks.

7,663 Views
paullaroide
Contributor II

Same issue here.

What I've done:

- Debian9 + mcu Xpresso ID v11.0.1 + SDK2.6.1

- iled_blinky project

- Removed Flash from "Projects Settings/Memory" and put BOARD_SDRAM at first

- flags:

XIP_EXTERNAL_FLASH=1 (but this should be not necessary as we consider no flash)

XIP_BOOT_HEADER_ENABLE=0

XIP_BOOT_HEADER_DCD_ENABLE=0

- In "MCU Linker / Managed Linker Script", checked "Link application to RAM"

- Put Stack in "SRAM_DTC"  ("MCU Linker / Managed Linker Script")

- Compiled:

 Memory region         Used Size  Region Size  %age Used
     BOARD_SDRAM:       10736 B        32 MB      0.03%
        SRAM_DTC:          4 KB        64 KB      6.25%
        SRAM_ITC:          0 GB        64 KB      0.00%
         SRAM_OC:          0 GB       128 KB      0.00%
Finished building target: iled_blinky.axf

Disassembly of section .text:
80000000 <__Vectors>:

800002e0 <ResetISR>:

SYMBOL TABLE:

20000000 g       *ABS*    00000000 __base_SRAM_DTC
2000f000 g       .stack    00000000 _vStackBase

20010000 g       .stack    00000000 _vStackTop

- Wrote a script RT1020_connect.scp (based on RT1050_Debug_Connect.scp) to initialize the SDRAM when entering in debug mode

- In Linkserver Debugger, unchecked "Reset on connect" set the connect script to "RT1020_connect.scp", set Reset handling to "SOFT", additional options set to "--no-packed --cachelib libm7_cache.so"

- Put the switches to "OFF-OFF-OFF-ON" to avoid the cpu jumping into flash after a reset

- Lauching a debug session with this "Debug configurations" (with "set Breakpoint" in "Startup" set to "ResetISR" or "main" -> same results)

- the PC is correctly set to "0x800002e0 <ResetISR>" when the breakpoint is set to "ResetISR"

- but THERE IS NO CODE in the SDRAM (see in Disassembly tab and Memory Browser) (values are seen as 0x00000000

WHAT IS WRONG with MCU Xpresso IDE and documentation?

Kerry Zhou, Erich, (and NXP support team) please answer and provide material :

at least a simple project with application and data in SDRAM and associated scripts and Debug configurations + documentation that is referring to i.MX RT1020 EVK and not the other boards.

Our project requires the entire application and some data in SDRAM (old version of IDE and other board) : this mapping cannot be discussed.

That's a shame: NXP does not provide an example to debug (with MCU Xpresso IDE) a simple application that is running in SDRAM of the i.MX RT1020 EVK board.

0 Kudos
Reply