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:

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