Align section linker

cancel
Showing results for 
Search instead for 
Did you mean: 

Align section linker

Jump to solution
520 Views
biafra
Contributor V

Hi everyone,

I'm writing a bootloader using MCUXpresso v10.1.1_606 and MK66FN2M0VMD18 device.

I found a problem in the flash programming phase.

Based on the device reference manual, the flash must be programmed on a 64 bit aligned phrases (flash start addresses [2:0] = 000, 8 byte length).
The problem rises from the output file of the application, here is an extract (S19):

S21402C4D030313233343536373839616263646566F3
S20802C4E000FFFFFF54
S21402C4E400B00640000000008025000000000100A5

The first two record are programmed fine, but the third generates an access error because it isn't 64 bit aligned, due to the 4 bytes length of the previous record. Although the two records are contiguous, the linker keeps them separate because there is the division of two different sections, text and data.


I think that the solution could be keeping the application sections aligned on 8 bytes boudary: I searched how to tell the linker to do this, but I didn't find any procedure to configure it.

Have anyone some suggestions?

Many thanks
Biafra

1 Solution
190 Views
lpcxpresso_supp
NXP Employee
NXP Employee

The SDK configuration data for this part really ought to be setting the alignment to 8 to avoid the problem in the circumstance you detail. Unfortunately it looks like this is not being done. However you can make the change manually for yourself.

First of all, go to the "Installed SDKs" view inside MCUXpresso IDE and right click on the SDK for your part. On the assumption that the SDK is installed in ZIP form, select "Unzip archive".

Once the unzip operation completes, right click again on your SDK in the "Installed SDKs" view and select "Open Location".

Now open the manifest file in a text editor. This will be named along the lines of "FRDM-K66F_manifest_v3_2.xml". Note that if there are several files with "manifest" in their filename, pick the one with the highest version number. [Note you may want to take a backup first!]

Now look for lines as follows:

<linker property="text_align" value="4"/>
<linker property="data_align" value="4"/>
<linker property="bss_align" value="4"/>

And change the value from "4" to "8". Note that there will be 2 instances of the above 3 lines, one for C projects and one for C++ projects. Change both!  After making these changes, save the file again.

Now back in the IDE's "Installed SDKs" view, click on the "Recreate and reload part support info" button (in the top right of the view).

Now clean your project and rebuild and the generated linker script should now pick up the 8 byte alignment setting.

Please let us know if this resolves your issue.

Regards,

MCUXpresso IDE Support

View solution in original post

3 Replies
191 Views
lpcxpresso_supp
NXP Employee
NXP Employee

The SDK configuration data for this part really ought to be setting the alignment to 8 to avoid the problem in the circumstance you detail. Unfortunately it looks like this is not being done. However you can make the change manually for yourself.

First of all, go to the "Installed SDKs" view inside MCUXpresso IDE and right click on the SDK for your part. On the assumption that the SDK is installed in ZIP form, select "Unzip archive".

Once the unzip operation completes, right click again on your SDK in the "Installed SDKs" view and select "Open Location".

Now open the manifest file in a text editor. This will be named along the lines of "FRDM-K66F_manifest_v3_2.xml". Note that if there are several files with "manifest" in their filename, pick the one with the highest version number. [Note you may want to take a backup first!]

Now look for lines as follows:

<linker property="text_align" value="4"/>
<linker property="data_align" value="4"/>
<linker property="bss_align" value="4"/>

And change the value from "4" to "8". Note that there will be 2 instances of the above 3 lines, one for C projects and one for C++ projects. Change both!  After making these changes, save the file again.

Now back in the IDE's "Installed SDKs" view, click on the "Recreate and reload part support info" button (in the top right of the view).

Now clean your project and rebuild and the generated linker script should now pick up the 8 byte alignment setting.

Please let us know if this resolves your issue.

Regards,

MCUXpresso IDE Support

View solution in original post

190 Views
biafra
Contributor V

Hi,

Now it seems to work.

Many thanks

Biafra

190 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Biafra,

You can have a look at this thread :

Aligning S19 Records to 64-bit Boundaries | MCU on Eclipse  

The SRecord tool can easily align the S19 files.

Hope it helps

Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------