how to place the function in a specified addrss

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to place the function in a specified addrss

571 Views
oceansea
Contributor III

hi

now , i have a problem ,i use S32K146 mcu and the S32DS IDE to development.

i want to place the function    "vExt_UART0_transmit(unsiged char* buff)" in a specified address (0x20000),

i try to use the command __attribute__((at(0x20000))),but it seem have no any effect.

can you help me ,my friend.

haiyang 

08 - 2023

Labels (1)
Tags (1)
0 Kudos
Reply
3 Replies

540 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

this can be done by section attribute and modifying the linker script file (please see attached example).

main.c:

jiri_kral_1-1692710142851.png

Linker script file: 

jiri_kral_2-1692710190734.png

jiri_kral_3-1692710250535.png

.map file: 

jiri_kral_0-1692710035675.png

 

But the question is why you need such function on particular address in the Flash memory? Why you can't use for example pointer to the function? From my point of view it is an unusual approach. 

0 Kudos
Reply

522 Views
oceansea
Contributor III

hi jiri_kral,

thank you reply !

I want five functions to always have the same addresses in the bootloader project, so that my app project can always call those five addresses.

"Why you can't use for example pointer to the function?"  I'm not quite sure what your meaning,

how to use pointer to solve this requirement?can you show me a example?

thanks

oceansea

0 Kudos
Reply

517 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

I see, this make sense. So, you are going to use some functionality (communication) from bootloader in your project. Well, the __attribute__ section is the option.

Other possibility is to have some table on constant known address in bootloader with addresses of the functions you like share with app. When the app starts - it can simply assign these addresses and use it as pointer to function. 

0 Kudos
Reply