How to edit linker files for projects which MCU's are installed into MCUXpresso IDE from an SDK

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

How to edit linker files for projects which MCU's are installed into MCUXpresso IDE from an SDK

Jump to solution
5,562 Views
MAPC
Senior Contributor I

Hello,

I'm developing a project and I need to modify the parameters of memory allocation in my application code and bootloader code itself. That was easy in KDS, because the linker file was editable. I saw that linker files are no more editable in MCUXpresso. I had a look at MCUXpresso IDE User Guide and it says I should provide one or more modified template files locally within "\linkscripts" subdirectory of project directory structure, but, for MCUs installed into MCUXpresso IDE from an SDK, the definition of the memory map is loaded from manifest file within the SDK structure and "\linkscripts" subdirectory is not created within the project.

Well, firstable, I haven't unzipped my SDK folder when I imported it to my workspace and, second, my project is based on an existing SDK demo code that I have modified. If I open my zipped SDK folder, I can see that manifest file, but I can't save it in the zipped SDK folder after modifying the memory configurations. And even if I could, I guess this would change all my projects linker files that are in the workspace, wouldn't it?

That is a little confusing to me. Can you help me on this please?

Marco Aurelio P. Coelho

DFAE - Siletec Eletronica 

1 Solution
3,485 Views
lpcxpresso_supp
NXP Employee
NXP Employee

You actually can edit linker script files manually if you really need to - by turning off the managed linker script mechanism. Generally we recommend that you don't though.

Many things that historically users have hand modified linker scripts can be achieved by, for example, using the memory configuration editor, or the heap & stack editor - which are available through the Project Properties.

With regards to the linkscripts subdirectory, then you are correct, this does not exist in projects by default - as the built in templates are used to create the linker scripts that are autogenerated into the Debug/Release subdirectories created when you do a build. It is only if you have a specific need to change those default templates that you should then create a linkscripts subdirectory, and put the modified version of the specific template you want to change.

This might seem a little strange coming from the KDS mechanism of completely manual linker scripts - but what is provided by MCUXpresso IDE is a system that has evolved, with much customer usage and feedback, over the last 10 years or so. And it means that many users never need to touch the underlying GNU linker scripts with their somewhat esoteric syntax by hand at all.

For more details, please look at the "Memory Configuration and Linker Scripts" chapter of the MCUXpresso IDE User Guide.

Regards,

MCUXpresso IDE Support

View solution in original post

4 Replies
3,485 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Without seeing you actual project and the settings you have actually used, it is hard to tell what you might have done.

But if all you want to do is change the start address of your image in flash, then the simplest way to do this is to modify the start address and length in the memory configuration editor (as described in section 12.8, "Using the Memory Configuration Editor", of the MCUXpresso IDE v10.0.0 User Guide).

I would strongly recommend that you make sure that the start address is aligned with a start of a sector in flash though (check the user manual for your part to confirm sector sizes). Otherwise any flash programming of you application is likely to erase whatever is before your application image in flash.

You can look at the map file generated by the linker to confirm what addresses have been used to build your image. See section 12.5, "Examining the layout of the generated image", of the MCUXpresso IDE v10.0.0 User Guide for more details

Note that with regards to the heap & stack editor, this will only help if you keep the default managed linker script mechanism switched on.

Regards,

MCUXpresso Support

0 Kudos
3,485 Views
MAPC
Senior Contributor I

I just found what was causing my issue. My bootloader was returning a message that it could not program the last application memory block and the reason is that my last application memory block received by the MCU is 284 bytes, number not divisible by 8 bytes, which is the programmable unit size for Kinetis with 1MB Flash like MK64FN1M0. I added a little adjustment in my code in order to program the unused remaining bytes with "FF" and now it is working!

Anyway, your tip about Memory Configuration Editor was very helpful and answered my original question.

Thank you very much!

Marco Coelho

DFAE - Siletec Eletronica

0 Kudos
3,486 Views
lpcxpresso_supp
NXP Employee
NXP Employee

You actually can edit linker script files manually if you really need to - by turning off the managed linker script mechanism. Generally we recommend that you don't though.

Many things that historically users have hand modified linker scripts can be achieved by, for example, using the memory configuration editor, or the heap & stack editor - which are available through the Project Properties.

With regards to the linkscripts subdirectory, then you are correct, this does not exist in projects by default - as the built in templates are used to create the linker scripts that are autogenerated into the Debug/Release subdirectories created when you do a build. It is only if you have a specific need to change those default templates that you should then create a linkscripts subdirectory, and put the modified version of the specific template you want to change.

This might seem a little strange coming from the KDS mechanism of completely manual linker scripts - but what is provided by MCUXpresso IDE is a system that has evolved, with much customer usage and feedback, over the last 10 years or so. And it means that many users never need to touch the underlying GNU linker scripts with their somewhat esoteric syntax by hand at all.

For more details, please look at the "Memory Configuration and Linker Scripts" chapter of the MCUXpresso IDE User Guide.

Regards,

MCUXpresso IDE Support

3,485 Views
MAPC
Senior Contributor I

Thanks a lot for your fast response! 

I Trier to turn off the managed linker script mechanism and modify Flash Starting Address and size in xxxxmemory.LD file, but the generated hex file keeps starting from 0, as if I hadn't modified it. I don't know if I have missed something.

The heap and stack editor I have found in Project Properties, bit I don't remember to have seen Memory Configuration Editor, but I will check it again and read the User Guide with a special attention on this chapter.

Best regards,

Marco Coelho

0 Kudos