添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
善良的莴苣  ·  Solved: Query/issue ...·  5 天前    · 
害羞的毛豆  ·  How to add a .lib ...·  6 天前    · 
俊逸的柠檬  ·  Solved: ...·  1 周前    · 
乖乖的感冒药  ·  Simple VoIP client od ...·  3 周前    · 
奔放的竹笋  ·  关于新型冠状病毒 ...·  4 月前    · 
有胆有识的红豆  ·  * 2024-05-15 ...·  5 月前    · 
考研的围巾  ·  ESM Support | ts-jest·  7 月前    · 

Using linker script and GCC variable attribute

char stack[100] __attribute__ ((section (".DTCMRAM"))) = { 0 };

we can define the location of variables. But I have pre compiled function. I've looked at it's source:

void arm_lms_norm_f32(arm_lms_norm_instance_f32 * S,const float32_t * pSrc,float32_t * pRef,float32_t * pOut,float32_t * pErr,uint32_t blockSize)
  float32_t *pState = S->pState;                 /* State pointer */
  float32_t *pCoeffs = S->pCoeffs;               /* Coefficient pointer */
  float32_t *pStateCurnt;                        /* Points to the current sample of the state */
  float32_t *px, *pb;                            /* Temporary pointers for state and coefficient buffers */
  float32_t mu = S->mu;                          /* Adaptive factor */
  uint32_t numTaps = S->numTaps;                 /* Number of filter coefficients in the filter */
  uint32_t tapCnt, blkCnt;                       /* Loop counters */
  float32_t energy;
...

As you can see we have variables with auto type (no matter static or auto) that I want is to place function variables to my desired memory section, how can I do that? Ia there any way?

I can use attribute to manage location of input variables, but not the variables inside function.

Function arguments and local non-static variables are on the stack - by definition, not "forced"; you cannot change this. More or less temporarily they may be (and are) placed by the compiler in processor's registers. No attribute may influence this behavior.

The section attribute may change the placement of code and static data only, where "static" means something different from static keyword in C language and includes all the items declared outside the functions, at file scope.

You can do it for static variables declared inside of a function but it requires slightly bigger effort. .DTCMRAM is not a section name. You should modify the linker script, create a section which will be put into DTCMRAM. You should also modify the startup module to initialize your new data section.

Local non-static variables are on the stack. There is one stack used by all the functions within a thread. It's a good idea to put stack in DTCM and you may do it easily by fiddling with .ld file. Static variables normally go to .data or .bss section. If you don't use DMA with these varaibles, they could also go to DTCM. You may easily put all the variables to DTCM by editing the .ld file but if you want to do it selectively (having some in DTCM and others in ordinary RAM), you need to apply section atributes, modify .ld file and modify the startup module to zero and/or initialize the extra sections you have added.

It might be a good idea to move all "normal" data to DTCM and to use normal RAM only for DMA buffers and big data structures by using section attributes only with them. Then maybe there will be no need to modify startup as you may probably initialize these big items explicitly in your code or maybe they don't need to be initialized at all.

Function arguments and local non-static variables are on the stack - by definition, not "forced"; you cannot change this. More or less temporarily they may be (and are) placed by the compiler in processor's registers. No attribute may influence this behavior.

The section attribute may change the placement of code and static data only, where "static" means something different from static keyword in C language and includes all the items declared outside the functions, at file scope.

STM32U5 : GPDMA sort of double buffering with LLI and buffer looping in STM32 MCUs Products BLE Operation in Low Power Modes on STM32WB in STM32 MCUs Wireless Zigbee Traces No Output in STM32 MCUs Wireless STM32F103RB AF bit of I2C1_SR1 don't work in STM32 MCUs Products STM32H7 Series TCP Client with LWIP in STM32 MCUs Embedded software