RT1020 - SDRAM and SWD debugging problems

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

RT1020 - SDRAM and SWD debugging problems

1,506 Views
rshipman
Contributor V

Hi,

I hope you are all well.

I have configured the evkmimxrt1020_hello_world project to run entirely from SDRAM on the RT1020-EVK.

The three changes I made to the default demo are:

1. In 'Properties | C/C++ Build | MCU settings': I moved BOARD_FLASH to the bottom of the table. (Normally BOARD_FLASH is at the top.)

2. In 'Properties | C/C++ Build | Settings | Tool Settings tab | MCU Linker | Managed Linker Script':  I checked the box for 'Link application to RAM'. (Normally this is unchecked.)

3. I changed the .launch file to use the redlink script I created from the dcd data in xip/evkmimxrt1020_sdram_ini_dcd.c.

FYI: This is how I did that. After running debug to create a .launch file (debug will fail the first time until you change the redlink script), I double-clicked the .launch file, selected the 'LinkServer Debugger' tab, clicked 'Workspace...' and selected my .scp file.

This project is attached as a zip archive.

The program runs ok - I get the 'hello world' on the uart and I can enter characters.

I run into problems when using the debugger. If I want to step through code it does not behave correctly and generally seems unstable.

Try these:

1.

Run debug and it will stop at the call to BOARD_ConfigMPU() in main. As you would expect.

Click on 'Step Into' and the program will just run to completion as if I had clicked on Run/Resume.

2.

Run debug and it will stop at the call to BOARD_ConfigMPU() in main. As you would expect.

Click on 'Step Over' and the debugger will stop at the next function call to BOARD_InitPins(). As you would expect.

Click on 'Step Over' again and the program just hangs, running, but not doing anything. Click on pause and it always stops at the same call (to BOARD_InitPins()).

To be clear, if I do not use the debugger, except to just run the whole demo from the beginning, it runs ok. It is when I try to step or pause or whatever that it goes wrong. And only when running from SDRAM. The debugger seems to work fine (more or less) running from XIP flash (the default setup).

Is there anything I should be aware of that could be causing this? How do I fix this?

Many thanks.

Labels (1)
0 Kudos
5 Replies

1,252 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello, 

Please refer to the following community thread: SDRAM debug with LinkServer (DAPLink) issues. Did you define the two symbols that my co-worker mentioned in this post (XIP_BOOT_HEADER_DCD_ENABLE=1 SKIP_SYSCLK_INIT)? 

Regards,

Victor 

0 Kudos

1,252 Views
rshipman
Contributor V

Hi Victor,

Thank you for your reply.

I can confirm that XIP_BOOT_HEADER_DCD_ENABLE=1 SKIP_SYSCLK_INIT are both set as shown.

However the setting XIP_BOOT_HEADER_DCD_ENABLE=1 is not applicable in this case, because we are not using flash (and so not booting from flash and running flash XIP etc). The debugger downloads the image to sdram and jumps to the app. The DCD should not be relevant in this case. The sdram is being initialised by a redlink script that is derived from the DCD found in the demo code. It's all in the zip I attached.

In fact the image does not contain an IVT or DCD because I have selected 'Link application to RAM'.

Please note that the app runs correctly and I can use the debugger to access sdram (0x80000000 addresses) ok. It is when I try to step over/into functions (see my examples above) that it goes wrong.

Kind regards

Ronnie

0 Kudos

1,252 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hi Ronnie, 

Please take a look into the following community post: MCUXpresso and RT1050 download and debug in SDRAM

Here a co-worker mentioned that this behavior is due to the caches so you need to put your application at the non-cacheable section of the SDRAM. I made some tests on my side and everything went fine. 

I took the hello_world example and the only modifications that I made were the followings: 

On the MCU settings, I put the NCACHE_REGION at the second spot. 

On the Managed Linker Script settings, I selected the Link applications to RAM option. 

On the defined symbols window I changed symbol XIP_EXTERNAL_FLASH to zero (XIP_EXTERNAL_FLASH=0). 

Regards, 

Victor 

0 Kudos

1,252 Views
rshipman
Contributor V

Hi Victor,

Thank you for the information.

I tried exactly as you described in a totally fresh hello_world project.

Here is the memory usage:

Memory region Used Size Region Size %age Used
BOARD_FLASH: 0 GB 8 MB 0.00%
NCACHE_REGION: 25760 B 2 MB 1.23%
BOARD_SDRAM: 0 GB 30 MB 0.00%
SRAM_DTC: 0 GB 64 KB 0.00%
SRAM_ITC: 0 GB 64 KB 0.00%
SRAM_OC: 0 GB 128 KB 0.00%
Finished building target: evkmimxrt1020_hello_world_run_from_sdram_nxp_settings.axf

As you can see it is all in NCACHE_REGION.

If found that the debugger behaviour has changed, but is not fixed. Stepping over seems to work now. Stepping IN to functions fails. E.g. click 'Step Into' when it first breaks at BOARD_ConfigMPU and it just runs to end, and I can see the expected output etc.

BTW what redlink script did you use to set up the SDRAM please?

Regards,

Ronnie

0 Kudos

1,252 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hi Ronnie, 

I'm glad to hear that you were able to move forward. The behavior of the stepping IN is a limitation of the SEMC interface (this is the interface that is used to connect the SDRAM on the RT1020-EVK). As a work-around, you can add a breakpoint inside the function you want to go inside and then click on Step IN. 

Regarding the script, since I'm using the onboard debugger with CMSIS firmware on it, I didn't make any modifications to the debug configurations. 

Regards, 

Victor