how to place the function in a specified addrss

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

how to place the function in a specified addrss

1,452 次查看
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

标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

1,421 次查看
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 项奖励
回复

1,403 次查看
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 项奖励
回复

1,398 次查看
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 项奖励
回复