FlexRAM and Linker Problem

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

FlexRAM and Linker Problem

7,599 Views
david_huwyler
Contributor III

I want to run an application on a i.mx rt1052 with the following RAM config:

DTCM: 256k, ITCM: 128k, OC: 128k (default values: DTCM: 128k, ITCM: 128k, OC: 256k)

I want to reconfigure the FlexRAM at runtime, not with the fuses...

I tired the SDK example evkbimxrt1050_flexram_ram_allocate which works fine. In this example, the memory details in the Project properties (Linker settings) are configured to the default values of the FlexRAM, not the values to which the RAM is finally reconfigured in code. This way i can only use the default RAM space at compiletime, because otherwise the linker complains (not enough space in RAM).

But as soon as i reconfigure the Memory details in the Project Property window to fit my needs, the linker is happy, but I get debugger errors at startup (not all RAM accessible). Because the RAM is not jet reconfigured (no code is executed jet).

Any Idea how to get around this problem?

Some infos:

I need the DTCM for heap memory (200k)

I tried different debugging probes (J-Link & LPC-Link2)

IDE: MCUExpresso

Labels (1)
29 Replies

1,684 Views
david_huwyler
Contributor III

Thanks for your answer Kerry.

Yes i read the mentioned document. But as far is i saw there is no information about my problem in the AN12077.

Dave

0 Kudos

978 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David Huwiler,

  Thanks for your updated information.

  You said:  but I get debugger errors at startup (not all RAM accessible).

Could you also give me a screenshot about it, I will find time to test your situation, and give you reply later.

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

978 Views
david_huwyler
Contributor III

Sure:

I changed the Linkerfile Memorymap to DTCM: 256k, ITCM: 128k, OC: 128k:

(I use a seeed studio arch mix board with 8M qspi flash)

pastedImage_4.png

Now i set a breakpoint at the 1. executed Codeline in the startup code and start the debugger. The debugging actually works until now: 

pastedImage_2.png

If I now do a "step into (F5)" the following error occurs:

pastedImage_3.png

 

0 Kudos

978 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David Huwiler

  Please upload your modified project directly, I will help you to check it on my side.

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

978 Views
david_huwyler
Contributor III

Ok project is attached.

But its the same with any project. As soon as i change values in the linker memory section to non default ones...

Dave

0 Kudos

978 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David Huwiler and   Takashi Kashiwagi,

  After checking with our MCUXpresso IDE expert, the following workaround may help you:

---------------------------------------------------------------------------------

1 - Moving memory 'under the feet' of a running application is very dangerous, and should only be attempted if the user really understands how their application is using memory. Particularly for Stack and initialised variables. 

 

This is especially true when you consider how flexRAM actually works. If the sizes of regions is changed, the new region may not contains any of the old RAM blocks.

 

Making any changes i main() is really too late, they should be made within the Startup code before any other action.

 

2 Describing a memory view for application generation that does not actually match the target (at the time debug is performed) is also very dangerous and can lead to the sort of problem you report, 

 

A way to work around this would be to make use of a LinkServer Connect Script to setup the FlexRAM - the example below actually restores the default values but could be changed to set the new values required. 

 

360 REM ====== Configure FlexRAM ======

370 print "Configure FlexRAM for 256KB OC RAM, 128KB I-TCM, 128KB D-TCM"

380 REM TCM CTRL Poke 0x400B0000 - to force RAM clocking and set wait states = b100

390 Poke32 this 0x400B0000 0x4

400 REM IOMUXC_GPR17 0x400AC044 - this sets bitfield allocation of FlexRAM 32KB banks to OC 256KB b01, I 128KB b11, D 128KB b10

410 Poke32 this 0x400AC044 0x5555FFAA

420 REM IOMUXC_GPR16 0x400AC040 - this sets enables for I and DTCM and the source of the TCM config = 0x200007

430 Poke32 this 0x400AC040 0x200007

440 print "Finished"

450 REM ===============================

 

The connect script can then be referenced within the projects LinkServer launch configuration.

 

Note: this will only work with LinkServer/CMSIS DAP debug.

 

If this is done, then the project can be configured using the projects MCU memory configuration to look something like this:

 1.png

 

The result will be that the Image and the target memory will match for debug operations.

 

If the project memory changes are made within the startup file, the image should also power up correctly (without debug tools).

-----------------------------------------------------------------------------------------

So, if you have time, you can try the item 2 workaround, but just as our expert said, don't modify the flexRAM in the main, if your project really want to reconfigure the flexRAM, I think, if you can, it's better to configure the efuse at first, then create the related project.

Wish it helps you!

Any updated information, 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.
-------------------------------------------------------------------------------

978 Views
david_huwyler
Contributor III

Hi Kerry Zhou

Thanks for your effort!

I tried the workaround you suggested.

Startup Code:

pastedImage_1.png

Linkserver Connect Script:

pastedImage_2.png


And it works as long as I start the target with the debugger attached.
If I start the target without the debugger, the application crashes.
As far as i can see, i do the same tings in the startup code, as in the Linkserver Script.

Any idea why it dosnt work without the debugger?

978 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David Huwiler,

  I will test your situation with and without debugger, and updated information from my side, I will let you know.

  Please wait patiently!

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

978 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David Huwiler,

  I have a MIMXRT1050-EVKB which is using the QSPI, and I also test it, even the simplest led_blinky project.

  I can reproduce the problem, totally the same as you.

  So, the linker file still need to be the default configuration.

  But how to modify the linker file after the RAM reconfiguration, I need to check it with our MCUXpresso IDE team, just let our IDE expert to check whether there has some good method to process it.

  After I get the valuable information, I will let you know.

  Please keep patient, thanks a lot for your understanding.

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