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)
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.
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.
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.
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?
Hello Terence,
You are able to enable position indpendent code in MCUXpresso. Right Click on your project -> Properties
Have a great day!
Sabina
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
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
Dear NXP,
I need to know how to build position independent code in MCUXpresso, is there any document or example?