cancel
Showing results for 
Search instead for 
Did you mean: 

How to place some part of code in ITCM and DTCM in stm32h745 ?

psiva.13
Associate II

Hi ,

I am using stm32h745 and I am new to this dual core processor. I have some doubts with this processor access:

1)Do both the processors mutually controllable i.e., can we start and stop cortex M4 using cortex M7 and vice versa .. ?

2)I want to place some part of code in the ITCM and DTCM ,and here my question is that how can I configure this ITCM and DTCM and place some part of my code in ITCM and DTCM.

Thanks and regards,

Parvathi.P

2 REPLIES 2

Typically you'd use the link script or scatter file to describe the regions/sections, make the code and data with __attributes__ ((section(.xyz))) and have startup or scatterloader code to copy the pieces in place.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
SF??r
Associate III
  /* used by the startup to initialize data */
  _siitcmram = LOADADDR(.itcmram);
  
  .itcmram :
  {
    . = ALIGN(4);
    _sitcmram = .;        /* create a global symbol at data start */
    *(.itcmram)           /* .data sections */
    *(.itcmram*)          /* .data* sections */
 
 
	  *Src/stm32h7xx_it.o(.text .text*)
	  *Drivers/STM32H7xx_HAL_Driver/Src/*.o(.text .text*)
	  *Middlewares/Third_Party/FreeRTOS/Source/*.o(.text .text*)
	  *Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.o(.text .text*)
	  *Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.o(.text .text*)
	  *Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/*.o(.text .text*)
	  
    . = ALIGN(4);
    _eitcmram = .;        /* define a global symbol at data end */
  } >ITCMRAM AT> FLASH

Linker script place whole C files to the ITCM section.

Now your startup file has to copy the code from the Flash to the ITCM RAM.

/**
 * @brief  This is the code that gets called when the processor first
 *          starts execution following a reset event. Only the absolutely
 *          necessary set is performed, after which the application
 *          supplied main() routine is called. 
 * @param  None
 * @retval : None
*/
 
    .section  .text.Reset_Handler
  .weak  Reset_Handler
  .type  Reset_Handler, %function
Reset_Handler:  
  /* Enable SRAM clocks early */
  ldr r0,=0x580244dc
  ldr r3,[r0]
  orr r3, r3, #3758096384 /* 0xE0000000 */
  str r3,[r0]
 
  ldr   sp, =_estack      /* set stack pointer */
 
/* Copy the data segment initializers from flash to SRAM */  
  movs  r1, #0
  b  LoopCopyDataInit
 
CopyDataInit:
  ldr  r3, =_sidata
  ldr  r3, [r3, r1]
  str  r3, [r0, r1]
  adds  r1, r1, #4
    
LoopCopyDataInit:
  ldr  r0, =_sdata
  ldr  r3, =_edata
  adds  r2, r0, r1
  cmp  r2, r3
  bcc  CopyDataInit
  movs r1, #0
  b  LoopCopyDataInitITCM
/* Zero fill ITCM ram section with source code */
CopyDataInitITCM:
  ldr r3, =_siitcmram
  ldr r3, [r3, r1]
  str r3, [r0, r1]
  adds r1, r1, #4
LoopCopyDataInitITCM:
  ldr r0, =_sitcmram
  ldr r3, =_eitcmram
  adds r2, r0, r1
  cmp r2, r3
  bcc CopyDataInitITCM
  ldr  r2, =_sbss
  b  LoopFillZerobss
/* Zero fill the bss segment. */  
FillZerobss:
  movs  r3, #0
  str  r3, [r2], #4
    
LoopFillZerobss:
  ldr  r3, = _ebss
  cmp  r2, r3
  bcc  FillZerobss
 
/* Call the clock system intitialization function.*/
  bl  SystemInit   
/* Call static constructors */
    bl __libc_init_array
/* Call the application's entry point.*/
  bl  main
  bx  lr    
.size  Reset_Handler, .-Reset_Handler