how to place the function in a specified addrss

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to place the function in a specified addrss

1,443件の閲覧回数
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,412件の閲覧回数
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,394件の閲覧回数
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,389件の閲覧回数
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 件の賞賛
返信