2018-07-04 03:44 PM
Hi all,
EDIT:
Intention,
I would like to test if there is any performance gain to be had by running functions tat are called inside interrupts from ITCMRAM rather than flash on an STM32H7 MCU.
I'm working with an STM32H7 nucleo 144 board. I have some functions I would like to test running from ITCM RAM rather than FLASH but I'm having some issues. I have managed to set up my linker script to place one of my function in the ITCMRAM memory section, then using linker symbols and memcpy, copy the function from FLASH to the ITCMRAM area at the start if the main function.
I'm using Atollic TrueStudio.
I know the function works, but when I try to run it from ITCMRAM I get a hard fault caused by an attempt to execute and undefined instruction. Does anyone know what would cause this? Below is the C and disassembly that is causing the fault. This occurs with optimisation off and on. there is something going on with the copy from flash to ram but I don't understand what it could be.
Any help would be great.
Thanks
Rob
C
if (signals->I_term_reset == 1)
Disassembly in ITCM area when running from ITCM
; <UNDEFINED> instruction: 0xb890Disassembly in FLASH load address area
when running from ITCMldrb.w r5, [r0, &sharp36] ; 0x24
Disassembly when running normally from FLASH
ldrb.w r5, [r0, &sharp36] ; 0x24
EDIT: THIS IS WRONG!
I have found that after the copy, the ITCMRAM code is correct. Its not until the function stored in ITCMRAM is entered that the data becomes corrupt.
EDIT:
Using a watch point I have found that when the __HAL_UNLOCK macro is used the ITCMRAM address where the error is occurring is being modified.
#stm32h7 #stm32 #itcm2018-07-04 04:26 PM
Suggest after copying that you
SCB_CleanDCache();
SCB_InvalidateICache();2018-07-05 04:15 AM
Hi Clive Two.Zero,
Just tried this, no imporvement. Exactly the same bevahiour.
Thanks
2018-07-05 07:52 AM
Using a watch point I have found that when the __HAL_UNLOCK macro is used the ITCMRAM address where the error is occurring is being modified.
2018-07-05 08:03 AM
Does the code you copied have any relative branches or literal pools? Are these built with an awareness of where in memory the code in question is going to be placed?
2018-07-05 08:13 AM
Apologies for the 'noob' questions. What exactly do you mean by relative branches and literal pools?
The function in question is running inside an interrupt and is a few levels into other functions above. It does not have any functions called from it.
I'm not sure exactly if that's what you're asking.
How can I check this?
2018-07-05 08:21 AM
>>How can I check this?
Look at a complete disassembly of what you are copying into RAM
>>What exactly do you mean by relative branches and literal pools?
Calls and branches tend to be relative, to other code in close proximity. If you move some of the code to an entirely different location it might not be able to reach the things you didn't copy.
Literal pools store constants that won't fit in normal immediate load forms of the instructions. Something like 0xDEADBEEF would need to pull from a literal pool, where as 0x12 would not.
http://www.keil.com/support/man/docs/armasm/armasm_dom1359731147760.htm
Google perhaps 'ARM Literal Pools'
2018-07-05 09:01 AM
Hello
Noble.Robert.002
,Khouloud.
2018-07-05 11:03 AM
Hi
Turvey.Clive.002
,Just for your information, the Cache has no effect on ITCM interface.
Khouloud.
2018-07-05 12:39 PM
Hi all,
Some links that can help to map application on scattered memory:
https://www.st.com/en/embedded-software/x-cube-perf-h7.html
: X-CUBE-PERF-H7 STM32H7 performance software expansion for STM32Cube (AN4891)Br,
Abdel