How can I locate a lib funktion in RAM ?

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I locate a lib funktion in RAM ?

686 Views
koehlerl
Contributor IV

Hello,

I use S32K144 with ammc lib in S32DS 2018.R1.

How can I locate a function from the lib in the RAM, that this function ist executed from RAM.

For my functions I use " void RAM_function( void ) __attribute__ ((section(".code_ram")));"

Does it work, when I use this attribute for a lib function ?

BR

Lutz

0 Kudos
5 Replies

152 Views
stanish
NXP Employee
NXP Employee

Hello Lutz,

you need to explicitly assign a library code into .code ram section in linker file. See below the example for acos() function. It works as expected only if I move ".code" section block in front of the default .text section:

__DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
 __CODE_ROM = __DATA_END; /* Symbol is used by code initialization. */
 .code : AT(__CODE_ROM)
 {
 . = ALIGN(4);
 __CODE_RAM = .;
 __code_start__ = .; /* Create a global symbol at code start. */
 *(.code_ram) /* Custom section for storing code in RAM */
 *S32K14x_AMMCLIB.a:GFLIB_Acos_c.o(.text)
 . = ALIGN(4);
 __code_end__ = .; /* Define a global symbol at code end. */
 } > m_data
__CODE_END = __CODE_ROM + (__code_end__ - __code_start__);‍‍‍‍‍‍‍‍‍‍‍‍‍



  /* The program code and other data goes into internal flash */
  .text :
  {
    . = ALIGN(4);
    *(.text)                 /* .text sections (code) */
    *(.text*)                /* .text* sections (code) */
    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
    *(.glue_7)               /* glue arm to thumb code */
    *(.glue_7t)              /* glue thumb to arm code */
    *(.eh_frame)
    KEEP (*(.init))
    KEEP (*(.fini))
    . = ALIGN(4);
  } > m_text‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

In the map file I can see this:

        ...
.code   0x1fff8000 0x1f0 load address 0x000006cc
        0x1fff8000 . = ALIGN (0x4)
        0x1fff8000 __CODE_RAM = .
        0x1fff8000 __code_start__ = .
 *(.code_ram)
 *S32K14x_AMMCLIB.a:GFLIB_Acos_c.o(.text)
 .text  0x1fff8000 0x1bc C:/NXP/S32DS_ARM_v2018.R1/S32DS/S32K14x_AMMCLIB_v1.1.11/lib/gcc\S32K14x_AMMCLIB.a(GFLIB_Acos_c.o)
        0x1fff8000 GFLIB_Acos_F32
        0x1fff80a0 GFLIB_Acos_F16
        0x1fff814c GFLIB_Acos_FLT
 *fill* 0x1fff81bc 0x4 
 .text.__stub 0x1fff81c0 0x30 linker stubs
        0x1fff81f0 . = ALIGN (0x4)
        0x1fff81f0 __code_end__ = .
        0x000008bc __CODE_END = (__CODE_ROM + (__code_end__ - __code_start__))

.text   0x00000410 0x2bc
        0x00000410 . = ALIGN (0x4)
 *(.text)
 .text  0x00000410 0x44 ./Project_Settings/Startup_Code/startup_S32K144.o
        0x00000410 Reset_Handler
        ...
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope it helps.

Stan

0 Kudos

152 Views
koehlerl
Contributor IV

Hello Stan,

thanks for your answer, but I want do something else.

I use the ammc lib von nxp. From this lib I want to relocate a function in the RAM.

I only have the include file with the declaration

“extern tFloat GFLIB_ControllerPIpAW_FLT(tFloat fltInErr,GFLIB_CONTROLLER_PIAW_P_T_FLT * const pParam);”

I tried to add “tFloat GFLIB_ControllerPIpAW_FLT(tFloat fltInErr,GFLIB_CONTROLLER_PIAW_P_T_FLT * const pParam) __attribute__ ((section(".code_ram")));” before,

but the function wasn’t located in the RAM.

BR Lutz

Von: stanish

Gesendet: Montag, 19. Februar 2018 17:31

An: Köhler, Lutz <lutz.koehler@acd-antriebstechnik.de>

Betreff: Re: - Re: How can I locate a lib funktion in RAM ?

NXP Community <https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg>

Re: How can I locate a lib funktion in RAM ?

reply from Stanislav Sliva<https://community.nxp.com/people/stanish?et=watches.email.thread> in S32 Design Studio - View the full discussion<https://community.nxp.com/message/988147?commentID=988147&et=watches.email.thread#comment-988147>

0 Kudos

152 Views
stanish
NXP Employee
NXP Employee

Hi Lutz,

Sorry I noticed I didn't answer your question. I had changed it after I posted it.

Could you read it again and let me know if it addresses the issue?

Please just replace the linker file line:

 *S32K14x_AMMCLIB.a:GFLIB_Acos_c.o(.text)

to:

 *S32K14x_AMMCLIB.a:GFLIB_ControllerPIpAW_c.o(.text)

Regards,

Stan

0 Kudos

152 Views
koehlerl
Contributor IV

Hi Stan,

I changed my linker file, but then I get an error massage, because I located the sections for m_data in front of .text sections.

Can you help me, to bring the linker file in the correct form, that its run?

BR Lutz

Von: stanish

Gesendet: Dienstag, 20. Februar 2018 10:20

An: Köhler, Lutz <lutz.koehler@acd-antriebstechnik.de>

Betreff: Re: - Re: How can I locate a lib funktion in RAM ?

NXP Community <https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg>

Re: How can I locate a lib funktion in RAM ?

reply from Stanislav Sliva<https://community.nxp.com/people/stanish?et=watches.email.thread> in S32 Design Studio - View the full discussion<https://community.nxp.com/message/988264?commentID=988264&et=watches.email.thread#comment-988264>

0 Kudos

152 Views
stanish
NXP Employee
NXP Employee

Seems the issue is related to the linker symbol " __DATA_ROM"

This is actually pointer into ROM memory where is located ROM image of the data section(s).

Startup uses this symbol to perform ROM-to-RAM copydown.

This symbol should be located behind the last Flash/ROM section (beginning of free flash space)

In your .ld its very first symbol in the section. Please move it after __etext:

__etext = .; /* Define a global symbol at end of code. */
 __DATA_ROM = .; /* Symbol is used by startup for data initialization. */

Note: If you don't want to move with .code section you can exclude library object file from standard .text:

.text :
 {
 . = ALIGN(4);
 *(EXCLUDE_FILE(GFLIB_ControllerPIpAW_c.o) .text) /* .text sections (code) */
 *(EXCLUDE_FILE(GFLIB_ControllerPIpAW_c.o) .text*) /* .text* sections (code) */
 *(.rodata) /* .rodata sections (constants, strings, etc.) */
 *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
 *(.glue_7) /* glue arm to thumb code */
 *(.glue_7t) /* glue thumb to arm code */
 *(.eh_frame)
 KEEP (*(.init))
 KEEP (*(.fini))
 . = ALIGN(4);
 } > m_text‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope it helps.

Stan

0 Kudos