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
I'm facing similar problem with PE Micro debugger after changing flexram not able to debug.
Can you please guide what to do for PE Micro debugger?
Hi jtro 9,
Do you also refer to Jack Jing's reply in:
I have tested it, it works.
About the PE Micro debugger question, could you please create a new question post? Then we will help you in your own question post, thanks.
Wish it helps you!
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.
-----------------------------------------------------------------------------
Hi Kerry,
I have the same issue when I tried to modify the RAM size. I can reproduce it on a imxrt1060 eval board with a SDK example(free RTOS). I followed all the settings advise in this post, so the basic LED blink works fine. But when you use a free RTOS and a lwip example, it gives a hardfault! (BFARVALID, IMPRECISERR). It is failing at
malloc() inside pvPortMalloc() while creating a thread! Could you please check this? I also updated the
BOARD_ConfigMPU() as per another post!
Thanks & Regards,
Rajani
Hello Rajani Kolani,
To your new question, could you please create the new question post?
Then I will help you to check it in your own question post.
Thanks a lot for your cooperation and understanding.
Best Regards,
Kerry
Hello Rajani Kolani,
Thanks a lot for your cooperation.
Please double check your case number, I didn't find 1306258 case number in the system.
Best Regards,
Kerry
Hi David Huwiler,
I have reproduced your problems, I will do more research, please wait patiently, thank you!
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.
-------------------------------------------------------------------------------
Hi Kerry. Do you have any news regarding this issue?
Hi David,
So sorry for my later reply.
I get some information from our internal expert side, but I still don't have time to test it.
Please follow this suggestion, and test it on your side at first.
---------------------------------------------------------------------------------
So the basic question is - why does a system work under debug but fail on Power On Reset. The answer turns out to be a stack access performed by the ResetISR function before the flexRAM reconfigure is performed. See the disassembly of the ResetISR function...
00000000 <ResetISR>:
0: b510 push {r4, lr} // this stack access causes a fault
2: b672 cpsid i
4: 4b1a ldr r3, [pc, #104] ; (70 <ResetISR+0x70>)
6: 6b9a ldr r2, [r3, #56] ; 0x38
8: f442 0210 orr.w r2, r2, #9437184 ; 0x900000
c: 639a str r2, [r3, #56] ; 0x38
e: 4a19 ldr r2, [pc, #100] ; (74 <ResetISR+0x74>)
10: 645a str r2, [r3, #68] ; 0x44
12: 6c1a ldr r2, [r3, #64] ; 0x40
14: f042 0207 orr.w r2, r2, #7
18: 641a str r2, [r3, #64] ; 0x40
1a: 2300 movs r3, #0
1c: e000 b.n 20 <ResetISR+0x20>
1e: 4613 mov r3, r2
The very first instruction (at the entry point of the application) is a push to the stack - and at this point, put the memory in place for the first stack access.
There are a number of potential fixes to this problem.
1 - you could re-write the resetISR function in assembler
2 - you could set the fuses with the FlexRAM settings
3 - or you could leave the project memory configuration for the Stack to be in available memory (for the very first push) and then make a change to the new value. This first push is not necessary since we will never return from this function.
So - if the project memory is left like this:
You can then simply poke a new SP value. I tested this with the code as below:
My test code fragment:
__attribute__ ((section(".after_vectors.reset")))
void ResetISR(void) {
// Disable interrupts
__asm volatile ("cpsid i");
IOMUXC_GPR->GPR14 |= (9 << 20);
IOMUXC_GPR->GPR17 = 0x55FFAAAA;
IOMUXC_GPR->GPR16 |= 7;
__asm volatile ("mov r12, #0x20000000"); // here I reset the stack to the value I wanted at 0x20040000
__asm volatile ("orr r12, #0x40000");
__asm volatile ("mov sp, r12");
This asm code puts the Stack at 0x2004000 after the FlexRAM memory has been set correctly.
This is a bit 'nasty' and I think we need to investigate a better solution to this problem. I will raise a Jira to investigate the issue of ResetISR pushing data to the stack.
Please confirm that this 'fix' also works in your environment.
------------------------------------------------------------------------------------
Please help to check it, whether it works.
When I have time, I will also test it.
Any test result from yourside, please kindly let me know.
BTW, please note, when you divide the ITCM DTCM size, you need to meet the following demand:
The Arm Cortex-M7 specifications require the size of ITCM/DTCM to be a power-of-two number, which can conflict with the FlexRAM configuration capability (see configurations 7, 10, 11 in Table 1).
AN12077.
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.
-------------------------------------------------------------------------------
Hi Kerry.
Thanks a lot for your effort.
I tried your potential fix number 3:
No success. Same as without the extra lines.
I dont want to burn the flexram fuses so fix number 2 dosnt suit my needs.
So is the only solution for me to rewrite the resetIST in assembler?
Regards,
Dave
Hi David Huwiler,
Thanks for your updated information.
I will contact with our IDE expert, and seek more help.
Any updated information from my side, I will let you know.
Really thanks so much for your patience.
Best Regards,
Kerry
I was able to change the project to locate stack at the beginning of the DTCM memory section instead of the default at the end.
This allows the stack to be used by ResetISR in a valid memory range before the FlexRAM is reconfigured.
Really, good
It seems able to make full use of the memory, however, it comes up a hard fault when I try to run if my DTC RAM usage is over 25%, which is default 128K.
Not sure how to solve the issue please.
Regards!
Ping
Hi Jack King,
I didn't get the feedback anymore.
But, just as our IDE expert said:
2 - you could set the fuses with the FlexRAM settings
This maybe the useful way if you really want to modify the flexRAM in your product.
But, you said your program also have problems, you need to modify the script, please check the reply on on Nov 29, 2019 12:59 AM.
Now, the mainly problem is download and debug OK, POR has problems, so we still recommend the customer to use the fuse modify, it will be more useful.
Best Regards,
Kerry
Kerry,
Please see my update above... moving the stack to the beginning of the memory range fixes my issue.
Hi Jack King,
Thanks so much for your sharing, and it's good to hear you make it work by moving the stack.
Could you please also give a screen about your stack modification? It will be more useful to the other customer.
Thank you!
Best Regards,
Kerry
OK, I updated my previous post with some screenshots.
Perfect, I will also find time to test it on my side. Thanks for your contribution.
Best Regards,
Kerry
Is there any update on this?
I have the exact same issue. I am trying to set DTCM to 512k, with my stack located in DTCM.
The ASM flexRAM settings work, but the program will crash on entry into ResetISR if the linker is configured with 512k DTCM in the project
My DTCM usage is greater than the default, so the linker will error if I set the project to the default memory.
Hi David Huwiler ,
Do you have read this flexRAM application note?
https://www.nxp.com/docs/en/application-note/AN12077.pdf
If not, please read it at first, it may useful to your question.
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.
-------------------------------------------------------------------------------