Atmel Studio 7 - Use different linker scripts

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I use Atmel Studio to program the ATSAME70N21B. When I want to flash the compiled code direct (with Atmel-ICE) to the controller I have to use the standard linker script "flash.ld", located in:

...\src\asf\sam\utils\linker_scripts\same70\same70n21\gcc

 

But when I want to flash the code with our custom bootloader, I first have to change the memory space definitions in the linker script (flash.ld). This very annoying when I always have to edit this file in dependency of the flasher device. And I can't see, with which memory options the output hex file was compiled/linked.

 

So I wanted to do this:

1) In the Atmel Studio configuration manager add "Bootloader". So I could choose in the project properties between the default "Release", "Debug" and my "Bootloader". So the output files should have own folders.

2) Create two linker scripts: flash_debug.ld (= the original flash.ld) and flash_bootloader.ld (with other memory settings).

2.1) I renamed the flash.ld to flash_debug.ld. The original flash.ld is deleted.

3) In the project properties use the flash_default at configuration Release/Debug and use the flash_bootloader.ld at configuration Bootloader.

3.1) I changed Properties->Toolchain->ARM/GNU Linker->Miscellanous->Linker Flags to:

-Wl,--entry=Reset_Handler -Wl,--cref -mthumb -T../src/ASF/sam/utils/linker_scripts/same70/same70n21/gcc/flash_debug.ld

 

But when I compile, it aborts with "Build Failed"... In the output I found this line:

        make: *** No rule to make target '../src/ASF/sam/utils/linker_scripts/same70/same70n21/gcc/flash.ld', needed by 'MLS_LightSlave_S4P2e_S12P4e.elf'.  Stop.

So Atmel Studio it tried to use the old linker script and not the renamed I set at 3.1).

 

I looked into the auto generated makefile of Atmel Studio and found the line:

LINKER_SCRIPT_DEP+=  \
../src/ASF/sam/utils/linker_scripts/same70/same70n21/gcc/flash.ld

 

I can't change this line because Atmel Studio restores it at every compile process. But I find no option to change the makefile generation in Atmel Studio, so it uses my desired linker script...

 

Can somebody help me?

 

Best regards,

Andre

This topic has a solution.
Last Edited: Fri. Jan 25, 2019 - 12:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In step 2.1 do you also delete the old flash.ld from the solution (in the solution explorer), could be a problem if it's still there generating a dependency.

/Lars

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for the response!

 

But the linker should not use the old file. It can not work if it uses two linker scripts with different memory settings? Or does it?

 

Is not there a central place where the linker script path is stored? From some reason Atmel Studio knows and uses the old path. So it has to be defined somewhere...

 

 

Last Edited: Fri. Jan 25, 2019 - 11:51 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Found the problem.

 

The flash.fd file was included in the project tree (no idea why). After renaming ("deleting") it, Atmel Studio was no more able to find this file. I don't know what really happened while compiling, but after removing the linker script file from the tree everything works fine. I've now two configurations and every configuration uses its own linker script. The output file is created in the Debug or Bootloader folder.

 

I'm happy :-)