Using and correctly configuring ITCM RAM for data on STM32H7 within STM32CubeIDE
I'm using a Nucleo STM32H743ZI2 and reallocating variables to different domains to leverage the maximum availability and as such have made changes to both STM32H7ZITX_FLASH.ld and STM32H7ZITX_RAM.ld. This is shown below as:
.
.
.
.
.myD2memory :
{
. = ALIGN(4);
*(.myD2memory)
. = ALIGN(4);
} >RAM_D2
.myD3memory :
{
. = ALIGN(4);
*(.myD3memory)
. = ALIGN(4);
} >RAM_D3
.myDTCmemory :
{
. = ALIGN(4);
*(.myDTCmemory)
. = ALIGN(4);
} >DTCMRAM
.myITCmemory :
{
. = ALIGN(4);
*(.myITCmemory)
. = ALIGN(4);
} >ITCMRAM
/* Remove information from the compiler libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}I then apply the designations to the variables as:
uint16_t varDTC[sizeDTC] __attribute__ ((section(".myDTCmemory")));
uint32_t varITC[sizeITC] __attribute__ ((section(".myITCmemory")));
uint32_t varD2[sizeD2] __attribute__ ((section(".myD2memory")));
uint32_t varD3[sizeD3] __attribute__ ((section(".myD3memory")));
.
.
int main(void)
{
/* Initialise prior to use just in case */
memset(varITC[0], sizeof(varITC), 0);
.
.
}I'm using STM32CubeIDE to develop my application and in the CORTEX_M7 section, both CPU ICACHE and DCACHE are disabled, as is the MPU. I'm not using MDMA but I do use DMA.
Everything works fine once I've reflashed the program on to the Nucleo board and run it, using the reset button as and when needed. I can also confirm the allocation of memory to the respective areas from the Build Analyzer.
However, if I power-cycle the board, then it appears that I can no longer use ITCM_RAM as it seems to producing pseudo garbage results, as if there's noise on the bus. The area in the TCM areas are used as processor only access; I use this area to process data (graphics) stored in other areas and subsequently store the processed data into D2_RAM domain where I can use timed DMA to shift it to peripherals. While I've tried mitigating existing garbage / noise with memset, this has no affect and is not required on any of the other memory areas; memory in any domain other than AXI_SRAM (default D1_RAM) is read in externally and is not prestored in any way. If I rebuild / reflash the chip using the IDE then full functionality is restored.
I've read through https://www.st.com/resource/en/reference_manual/dm00314099-stm32h742-stm32h743-753-and-stm32h750-value-line-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf and https://www.st.com/resource/en/application_note/dm00306681-stm32h72x-stm32h73x-and-singlecore-stm32h74x75x-system-architecture-and-performance-stmicroelectronics.pdf but cannot see anything the appears relevant to this, other than while the DTCM is for data only while ITCM can be used for both data and instructions.
The only thing I can think of is that when the unit is being flashed by the IDE tool / onboard debugger, it's configuring the ITCM in such a way that it allows the functionality I want. However, when the unit is power cycled, this configuration is lost as it's not being stored as a configuration within the program.
I also note that for using the D2_RAM domain their respective SRAM {1, 2, 3} clocks should be pre-enabled (as documented in my second link), this has not been done by my program yet still works regardless; albeit there are no pre-configured variables in this area. However, I cannot find similar instruction for the ITCM.
Any help and suggestions how to move this forward would be greatly appreciated.
