Moving Function from flash to ITCM cause hard fault on sTM32H743
Hi,
I am following the guide lines to move some functions from flash to ITCM .
1st I modified the linker file , then add itcm section parameters as extern variables in main file and after that I copied this function code after start up from flash to itcm section and finaly used section attribute to tell the linked to move this function to itcm section.
Always I get a hard fault at exiting from the moved function.
after some investigations I found that the called function push {lr} only when it's called on the other hand at the end of the function it pop {r4,r7,pc} and hard fault is caused at this point.
If I don't move this function to itcm section it will push {r4,r7,lr} and pop {r4,r7,pc} and will not cause any fault.
If I modified the stack so it pops the correct values in pc , it didn't cause hard fault.
in the generated list file I found that it push {r4,r7,lr} which is not consistent with actual assembly.
code is compiled from c with g3 and o0 options for debugging and optimizations.
How I can overcome this problem?
Thanks