cancel
Showing results for 
Search instead for 
Did you mean: 

Move specific function to ITCM ram from library

SeyyedMohammad
Senior III

I want to move some function from library (DSP cmsis) to ITCM of MCU. I can't move it's myLib.o completely since it's big. I mean *myLib.a:*(.text .text*) (copied from AN4296). what is the right output-section-command to do my job?

Assume I want to move `void arm_lms_f32(.....)` and the objdump -t output of library file is:

arm_lms_norm_f32.o:   file format elf32-little
 
SYMBOL TABLE:
00000000 l  df *ABS* 00000000 arm_lms_norm_f32.c
00000000 l  d .text 00000000 .text
00000000 l  d .data 00000000 .data
00000000 l  d .bss  00000000 .bss
00000000 l  d .text.arm_lms_norm_f32 00000000 .text.arm_lms_norm_f32
00000000 l    .text.arm_lms_norm_f32 00000000 $t
00000000 l  d .debug_info  00000000 .debug_info
00000000 l  d .debug_abbrev 00000000 .debug_abbrev
00000000 l  d .debug_loc   00000000 .debug_loc
00000000 l  d .debug_aranges 00000000 .debug_aranges
00000000 l  d .debug_ranges 00000000 .debug_ranges
00000000 l  d .debug_line  00000000 .debug_line
00000000 l  d .debug_str   00000000 .debug_str
00000000 l  d .debug_frame  00000000 .debug_frame
00000000 l  d .comment    00000000 .comment
00000000 l  d .ARM.attributes    00000000 .ARM.attributes
00000000     *UND* 00000000 __aeabi_fmul
00000000     *UND* 00000000 __aeabi_fsub
00000000     *UND* 00000000 __aeabi_fadd
00000000     *UND* 00000000 __aeabi_fdiv
00000001 g   F .text.arm_lms_norm_f32 000002b2 arm_lms_norm_f32
 
 
arm_lms_init_q31.o:   file format elf32-little
 
SYMBOL TABLE:
00000000 l  df *ABS* 00000000 arm_lms_init_q31.c
00000000 l  d .text 00000000 .text
.
.
.

I have write the linker script for general movement of newly defined functions in .c file and required startup modification:

_sifastcode = LOADADDR(.fastcode);
  .fastcode :
  {
	  . = ALIGN(4);
	  _sfastcode = .;
	  *(.fastcode)
	  *(.fastcode*)
      /*IN BETWEEN*/
	  . = ALIGN(4);
	  _efastcode = .;
  } >ITCMRAM AT> FLASH

I just need the required command to place in between.

There is a code copied from CCM RAM application not:

*myLib.a:*(.text .text.arm_lms_norm_f32)

I've found a way to do this by:

libarm_cortexM7lfdp_math.a:arm_fir_f32.o(.txt .txt*)

But whats wrong? Since I think this doesn't work.

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief II
     /* Exclude file(s) from NewLib libc.a from .text.* section  */     
     *(EXCLUDE_FILE (*libc.a:lib_a-memcpy-stub.o) .text*)   

all info HOWTO: Execute a library function from RAM memory ... - NXP Community

View solution in original post

11 REPLIES 11
MM..1
Chief II
     /* Exclude file(s) from NewLib libc.a from .text.* section  */     
     *(EXCLUDE_FILE (*libc.a:lib_a-memcpy-stub.o) .text*)   

all info HOWTO: Execute a library function from RAM memory ... - NXP Community

Hi @MM..1​ 

But I think I don't need to exclude. I can include what I want in this manner, Am I right?

libarm_cortexM7lfdp_math.a:arm_fir_f32.o(.txt .txt*)

you need exclude from text section and include into ram section as describ ein NXP.

section is .text and

Note

If you are placing a function into RAM always consider to add sub-functions called by that function (typically located in a different object file).

Hi @MM..1​ 

I've replaced:

.text :
{
.=ALIGN(4);
*(.text*) ->
*(EXCLUDE_FILE (*arm_cortexM7lfdp_math.a:arm_*.o) .text*)
 
/*IN BETWEEN*/ ->
*arm_cortexM7lfdp_math.a:arm_*.o(.text*)

these to move all cmsis dsp code to ITCMRAM and worked just fine, thank you kindely.

Hi again @MM..1​ 

What will happen if not placing some subfunctions? I've seen some wired symbols apperas with postfix _veneer for those not moved functions!

Hi @MM..1​ 

It worked but I wonder why AN4296 about CCM RAM doesn't mentioned anything about excluding the including ones?

If you use  __attribute__((section or full lib exclude isnt required.

But normal default place for ... is flash , then one function need excl.

Hi @MM..1​ 

That doc introduced to add library to project. Not only using __attribute__ !!

What isnt clean? Libs cant be defined with attribute then require include exclude in linker.

Exclude only if part of lib is in flash and other parts in other place.