I want to configure my FlexRAM for max amount of DTC RAM in runtime, following AN12077. Now I have a working configuration:
DTC 448 KB
ITC 32 KB
OCRAM 32 KB
Thank you!
I followed the code in the post (cleared bit 1 to disable ITC). I've also made sure there are no references to ITC memory in my link script.
It hasn't helped...
Now I'm consistently getting a hardfault inside malloc (at it's first use in the code), dereferencing address 0x00. It makes sense, the address is no longer mapped to any memory (previously it was ITC region), though I have no idea what is causing malloc to do so, as I've only disabled ITC in FlexRAM config, leaving memory and section layout in linker script the same.
To set ITCM/DTCM memory to 0 Bytes you can use FlexRAM partition registers (FLEXRAM_BANK_CFG_SEL and FLEXRAM_BANK_CFG in GPR) without having to write to those xTCM_EN bits.
In case of the malloc function, it is usually not recommended in embedded systems because it uses the default RAM memory, which is limited and may cause issues with the Heap/Stack.
You could change which segment is the default on the Project properties -> C/C++ Build -> MCU Settings.
Best regards,
Omar
I am well aware of malloc limitations in embedded systems.It's working perfectly fine in my project as long as I don't set ITC size to 0.
Maybe there is a bug in malloc and it dereferences 0x00 always, but it doesn't crash when there is ITC memory mapped?
A similar, old issue:
https://community.nxp.com/t5/LPCXpresso-IDE/Bug-in-Redlib-malloc/td-p/597123?profile.language=ja
These fields appear as reserved because it was determined that the user should not modify them.
For testing FlexRAM reallocation I suggest you follow these steps: Reallocating the FlexRAM - NXP Community
Best regards,
Omar