cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 ITCM testing for improved performance

robertnoble9
Associate III
Posted on July 05, 2018 at 00:44

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: 0xb890

Disassembly in FLASH load address area

when running from ITCM

ldrb.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 #itcm
15 REPLIES 15
Posted on July 05, 2018 at 01:26

Suggest after copying that you

SCB_CleanDCache();

SCB_InvalidateICache();
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on July 05, 2018 at 11:15

Hi Clive Two.Zero,

Just tried this, no imporvement.  Exactly the same bevahiour.

Thanks

Posted on July 05, 2018 at 14:52

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.

Posted on July 05, 2018 at 15:03

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?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on July 05, 2018 at 15:13

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?

Posted on July 05, 2018 at 15:21

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

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Khouloud GARSI
Lead II
Posted on July 05, 2018 at 18:01

Hello

Noble.Robert.002

,
  • The scatter loader should perform the copy from flash to RAM so there is no need to copy the code manually.
  • For further debug, could you share the linker file or a project reproducing the encountered behavior. 

Khouloud.

Posted on July 05, 2018 at 18:03

Hi

Turvey.Clive.002

‌,

Just for your information, the Cache has no effect on ITCM interface.

Khouloud.

Abdelhamid GHITH
ST Employee
Posted on July 05, 2018 at 21:39

Hi all,

Some links that can help to map application on scattered memory:

 Br,

Abdel