How to build image with virtual address

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

How to build image with virtual address

1,215 Views
terence_kong
Contributor II

Hi NXP,

Using MCUExpressso, is this possible to build the image use virual address instead of using absolute address?

Means, same image that can be ran in different location.

For example,

With one single image.bin that can be loaded into memory location 1) 0x10000 and 2) 0x20000.

I can use the boot loader to jump to either location 1) or 2)

Labels (1)
0 Kudos
8 Replies

1,067 Views
converse
Senior Contributor V

The simple answer is no.

the (much) more complicated answer is maybe, if you write a boot loader that can hook up the load address and handle all the other fix ups that are necessary. Basically it is normally only possible if you are using an OS that does these things for you.

search for position independent code with GCC on arm for some more information.

0 Kudos

1,067 Views
terence_kong
Contributor II

Hi ConVerse,

In fact I already have the boot loader ready that can jump to different address.  The application built by MCUXpresso is in absolute address..

I am not sure how to build the code in position independent.

0 Kudos

1,067 Views
converse
Senior Contributor V

Thinking more about this, it is not possible in an embedded situation. To provide the relocations and fixups necessary you need access to the .AXF file at load time - you cannot do it with a pure binary image.

0 Kudos

1,067 Views
terence_kong
Contributor II

I don't think it is that difficult.  This feature is supported in IAR, and it is document in NXP document AN5163

That's why I am asking if this supported in MCUXpresso?

0 Kudos

1,067 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello Terence,

You are able to enable position indpendent code in MCUXpresso. Right Click on your project -> Properties

pastedImage_1.png

Have a great day!

Sabina

0 Kudos

1,067 Views
terence_kong
Contributor II

Hi Sabina,

I have tried this function already , and checked the map file, the code compiled appears to be absolute address still.

Is there any document/example regarding on the position independent code feature?

Regards,

Terence

0 Kudos

1,067 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hi Terence,

There is not a document that reviews this feature. However I found other documents that may be of help and you can use as a reference.

https://community.nxp.com/thread/476110 

The last four comments may be of use also, he provides examples code. As well as another link that uses kinetis with fpic.

Best Regards,

Sabina

0 Kudos

1,067 Views
terence_kong
Contributor II

Dear NXP,

I need to know how to build position independent code in MCUXpresso, is there any document or example?

0 Kudos