Cannot change linker script path without changing output path?

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

Cannot change linker script path without changing output path?

Jump to solution
3,363 Views
curtis_hendrix
Contributor I

I'm trying to manually manage the linker scripts for a bootloader project, and I'm having a problem with changing the linker script location.

Since all of the configurations (Debug / Release /etc) for my project use the same linker scripts, I want to put them in main project folder.  By default, the linker scripts get generated in the configuration (Debug/Release) folder.  I'm moving the linker scripts up one directory.

I went into the project properties->C/C++ Build->Settings-MCU Linker->Managed Linker Script, unchecked "Manage linker script", put the name of my linker script in for "Linker script", and set "Script path" to "..\", like so.

pastedImage_1.png

That's the only thing I changed in the project properties.

But now the project fails to build with the following error:

arm-none-eabi-gcc.exe: error: RTCP_Host.axf: No such file or directory

I thought the "Script path" only changed where the linker went looking for its script.  Apparently this is not correct.  What exactly does the "Script path" setting change?  And how can I change the linker script location without changing where the output file gets located?

0 Kudos
1 Solution
3,086 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Thanks for your explanation - we'll ponder on whether there is anything we can do in this area for a future release.

Anyway, with regards to your original problem - can you try replacing your "..\" path with ".." or "../". I suspect that one of these will fix the problem (I don't have access to a Windows box right now to check this out though).

[It is always best to stick with Unix style directory separators inside source files and IDE configuration options, even when working on Windows.]

Regards,

MCUXpresso IDE Support

View solution in original post

0 Kudos
4 Replies
3,087 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Thanks for your explanation - we'll ponder on whether there is anything we can do in this area for a future release.

Anyway, with regards to your original problem - can you try replacing your "..\" path with ".." or "../". I suspect that one of these will fix the problem (I don't have access to a Windows box right now to check this out though).

[It is always best to stick with Unix style directory separators inside source files and IDE configuration options, even when working on Windows.]

Regards,

MCUXpresso IDE Support

0 Kudos
3,086 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Can you please post the actual text from the build log in the Console view (probably just the link step from towards the end) showing the full error message and the command that triggered it?

See section 18.8, "The Console View" of the MCUXpresso IDE v10.2 User Guide for details of how to do this.

It might also be useful to understand what you are doing that is causing you to turn off the managed linker script mechanism. It may well be that all you actually need to do is modify that project's memory map in the memory configuration editor.

Regards,

MCUXpresso IDE Support

0 Kudos
3,086 Views
curtis_hendrix
Contributor I

Here's the output from the console where the linker gets invoked:

Building target: RTCP_Host_BL.axf
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -L"C:\Sources\NXPBootloaderPoC\RTCP_Host_BL\libs" -Xlinker -Map="RTCP_Host_BL.map" -Xlinker --gc-sections -Xlinker -print-memory-usage -Xlinker --sort-section=alignment -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -T "RTCP_Host_BL.ld" -L ..\ -o "RTCP_Host_BL.axf"  ./startup/startup_mkv31f51212.o  ./source/Test_Proj.o  ./board/board.o ./board/clock_config.o ./board/peripherals.o ./board/pin_mux.o  ./CMSIS/system_MKV31F51212.o   -larm_cortexM4lf_math
arm-none-eabi-gcc.exe: error: RTCP_Host_BL.axf: No such file or directory
make: *** [RTCP_Host_BL.axf] Error 1

11:26:49 Build Finished (took 3s.866ms)

The reason why I turned off the managed linker script mechanism is to keep the start addresses and lengths of the bootloader and application images in the same space.  If I used the Memory Configuration Editor in the project settings, it would be REALLY easy for a developer later on to change an address or length in one project (application or bootloader) and forget to change the addresses in other project.

I have a common linker file that is included by the main linker scripts for the bootloader and application, like this horrific diagram shows:

pastedImage_3.png

Addresses.ld contains the following:

  __TOTAL_FLASH               = 0x00040000;
    __BOOTLOADER_START          = 0x00000000;
    __BOOTLOADER_LENGTH_BYTES   = 0x00005000;
  __APPLICATION_START         = __BOOTLOADER_START + __BOOTLOADER_LENGTH_BYTES;
  __APPLICATION_LENGTH_BYTES  = __TOTAL_FLASH - __BOOTLOADER_LENGTH_BYTES;
 
MEMORY
{
  /* Define each memory region */
  BOOTLOADER_FLASH (rx) : ORIGIN = __BOOTLOADER_START, LENGTH = __BOOTLOADER_LENGTH_BYTES
  APPLICATION_FLASH(rx) : ORIGIN = __APPLICATION_START, LENGTH = __APPLICATION_LENGTH_BYTES
  SRAM_UPPER (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32K bytes (alias RAM) */  
  SRAM_LOWER (rwx) : ORIGIN = 0x1fffc000, LENGTH = 0x4000 /* 16K bytes (alias RAM2) */  
}

The linker script for the bootloader uses the BOOTLOADER_FLASH memory definition.  The linker script for the application uses the APPLICATION_FLASH memory definition.

This way, a future developer has less of chance of screwing up the memory locations, since the values for the start addresses and lengths are all contained within a common, shared file.  It also eliminates duplication, and duplication drives me up the wall.

0 Kudos
3,086 Views
curtis_hendrix
Contributor I

I think I figured out a workaround:

Start by changing the Command line pattern field to match the following:

pastedImage_1.png

And then add the relative path to the linker script name, like so:

pastedImage_2.png

Keep in mind that the linker script used in the "Linker Script" field will still be local to the configuration directory.  For example, this is my project directory, with a couple of other linker scripts that get included inside of "RTCP_Host.ld"

/root

   /common

       RTCP_memory.ld

   /projectDir

       RTCP_Host_library.ld

       RTCP_Host.ld

I have to use the following inside of RTCP_Host.ld in order for the other 2 linker files to be included directory.

INCLUDE "\..\..\Common\RTCP_memory.ld"
INCLUDE "\..\RTCP_Host_library.ld"

0 Kudos