cancel
Showing results for 
Search instead for 
Did you mean: 

ITCM and DTCM with STM32F7 Discovery

benoit2399
Associate II
Posted on March 30, 2016 at 15:16

Hello,

I am fairly new to embedded development and I am trying to setup a project (using Eclipse GNU ARM environment) to use ITCM and DTCM on a STM32F7 Discovery board. It seems the default linker script already uses DTCM by defining a global RAM section starting at the DTCM address 0x20000000 (although I would like to decide which data to put in the DTCM as my data is larger than the DTCM). But, more importantly, I am having trouble enabling ITCM. I have looked at the ''Performance test'' example & notes as well as the template examples from the STM32F7 firmware, plus forum pages about the subject... but it seems I couldn't find the correct answer, or at least it is not working for me. I have also looked at other parties linker scripts and tried applying them to the STM32F7, with no luck. Here is what I would ideally like to achieve: 1) put specific part of the code (or an entire object functions) into ITCM 2) put specific data into the DTCM I added the following section to the mem.ld linker script

ITCM_RAM(xr): ORIGIN = 0x00000000, LENGTH = 16K

Then, I understand there are two ways of putting code into the ITCM: 1) by including the entire .o code into a ''section'' allocated to the ITCM

.code_TCM 0x00000000:
AT ( _itcm_lma )
{
_sitcm = .;
myobject.o (.text.*)
myobject.o (.rodata)
_eitcm = .;
} > ITCM_RAM

Also adding this to the _startup.c method, right before the main(..) call (I was not sure yet if the _startup.c code was handling this situation, and I assume this is not a problem to do perform the copy again):

/* copy code_TCM from flash to ITCM */
volatile char *dst = &_sitcm;
volatile char *src = &_itcm_lma;
while(dst < &_eitcm){
*dst++ = *src++;
}

2) by tagging methods using the __attribute__((section(''.code_TCM''))) e.g.

void __attribute((section(''.code_TCM''))) Run() {
/*
code here
*/
}

And the following linker script:

.code_TCM :
{
. = ALIGN(4);
*(.code_TCM) /* .section_name section */
*(.code_TCM*) /* .section_name* sub-sections if any */
. = ALIGN(4);
} >ITCM_RAM AT> FLASH

When adding the object into the ITCM section (method 1), I am having linking errors with duplicate definitions ... If I tag a method into the ITCM (method 2) and try to call this method, I get a hard fault ... I am currently testing this using C methods but my engine is mostly written in C++ so my first question is: can I use C++ classes and put their member functions into ITCM? In the ideal case, would somebody have an example of a linker script that allows __attribute__ use to put data/code into DTCM/ITCM? Any help is greatly appreciated !! Thank you #stm32f7-dtcm-itcm
7 REPLIES 7
Nesrine M_O
Lead II
Posted on March 30, 2016 at 16:42

Hi bens,

I recommend you to have a look to the

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00169764.pdf

.

This application note is provided with the

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1920/PF262415#

embedded software package that includes a project which has seven configurations that have been provided to select data and code locations.

-Syrine-
Radosław
Senior II
Posted on March 30, 2016 at 16:55

Goody ST.  ITCM in any tamplete project for F7 for gcc isn't correct.

FOr ITCM interface you nedd add next region for  it and 

change   VMA for rom section.  

.text

{

..

} ITCM at AXIM

This enables ITCM interface for code.

From where you get  addresses for you function? I can see in linker declaration od them.

Newbe ? so what you try to do if you need  ITCM ram performence?

benoit2399
Associate II
Posted on March 30, 2016 at 17:11

Hello Syrine,

Thank you for your answer.

I have looked at the  

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1920/PF262415#

 example and the 

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00169764.pdf

. The problem is it using a scatter file and I am trying to set this up with the GNU ARM eclipse environment which use a .ld linker file format. I looked at the XML+scatter files of the project but I had no luck ''translating'' them to my environment. I am on a Mac and would like to get this to work in Eclipse / GNU ARM.

While I am testing currently with C functions, I was also wondering if C++ methods can be put in the ITCM... It's not a problem to convert my code to pure C code but I wanted to know first if this was required in order to use ITCM as well.

Thanks so much for helping

benoit2399
Associate II
Posted on March 30, 2016 at 17:50

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6jv&d=%2Fa%2F0X0000000buM%2F0xBF1.p1CZ0jHoe_IwsnWTJftVD67ytrw3tbzte8O7Q&asPdf=false
Radosław
Senior II
Posted on March 30, 2016 at 19:18

Now it's clear.  Your program works on AXIM, not ITCM.

ST PROVIDE BAD PROJECT TEMPLATE FOR ICTM INTERFACE.

 

 

1.  create configuration to execute code by ITCM interface.

Create region on 0x00200000 with FLASH size. 

Change like I show in last post text and all acording section.

(read topic on AC6 forum about CCRAM).

Then you can this about usage od ITCM_RAM,

PS. you linker file is for FREESCALE so no one can guarante id it is correct.

I see that the startup must be complementary for this. (special  data and bss initialization).

Nesrine M_O
Lead II
Posted on March 31, 2016 at 13:17

Hi dembek.radoslaw.001,

Thanks for highlighting this issue.It is a known bug, but the fix has not yet been released on the web. 

It will be available in coming releases.

-Syrine-

Radosław
Senior II
Posted on March 31, 2016 at 14:01

I hope so. Becose it isn't first critical bug that i report which is still not fixed.

I notice that GCC is new for ST, but  ST solution for GCC, is to bad. Many aplication notes still miss GCC solution, specially in days when GCC goes much more popular.  Like STM32F7 performance aplication.  Only users with licence can run this software.

Acording ITCM.  PM for F7 family says that ITCM interface can be enabled not only by software but automaticly on power on. I can find any information about this. Register for this in SCB have wrong reset values.   

My test shows that ITCM interface is always ON.  This is only begining of problems with this topic. 

 

Amazing is count of critical bugs in the lowest layes. Startup, linker script/scatter file. system configuration.  This bugs drives to each higher layes of software.  AMAZING.