• im Projektverzeichnis ein Unterverzeichnis linkscripts erstellen (Name muss genau so heißen, ansonsten findet die MCUxpresso das Script nicht).
  • in dieses Verzeichnis die Datei memory.ldt aus dem Github-Repository kopieren.
  • in MCUXpresso eine neue Buildkonfiguration erstellen, dabei ist es wichtig, dass der Name der neuen Buildkonfiguration mit Flashstart 0xWXYZ beginnt. Wobei 0xWXYZ für die hexadezimale Startadresse der Applikation steht und bei Bedarf auch geändert werden kann. Beispiel für einen gültigen Konfigurationsnamen: Flashstart 0x3000 Debug o8 4t ha

Ursprüngliche Idee von https://mcuoneclipse.com/2019/10/06/linking-bootloader-applications-with-eclipse-and-freemarker-scripts/

Alternativ kann man auch eine leere Datei memory.ldt im Unterverzeichnis linkscripts erstellen und folgendes in diese kopieren:

 <#--
This linker script will, depending on the MCUxpresso build configuration name
move the memory position of the application start in flash, reduce the flash size accordingly,
change the RAM location and RAM size so that the resulting *.hex file
can be used with the Selfbus PC_updater_tools -fileName parameter.
(https://github.com/selfbus/software-arm-lib/tree/main/Bus-Updater/PC_updater_tool)

If the build configuration name starts with "Flashstart 0xWXYZ"
it changes flash start to 0xWXYZ (WXYZ application start address in hexadecimal),
move RAM start by +0xc0 and reduze RAM size accordingly.

E.g. from build configuration name 'Flashstart 0x3000 Debug o8 4t' 0x3000 will be extracted.
On a LPC1115 MFlash64 flash start will be changed to 0x3000 and flashsize reduzed to 0xD000.
RamLoc8 start will be changed to 0x100000c0 and size reduced to 0x1f40

This file must be placed into a subfolder named "linkscripts" of your project (application).
The subfolder MUST be named "linkscripts", otherwise MCUxpresso won't find the file and build the project
as normal.
-->
<#include "user.ldt" >
<#include "user_memory.ldt" ignore_missing=true>
<#include "header.ldt" >

<#assign selfbus_custom_memory_layout = false>  <#-- set no offsets by default-->
<#assign application_offset = 0>                <#-- set no application offset by default-->
<#assign ram_offset = 0>                        <#-- set no RAM offset by default-->
<#assign default_ram_offset = 192>              <#-- change this in case bus-updater copies more bytes in "void jumpToApplication(unsigned int start)" -->

<#-- check if build config starts with FLASHSTART and we have a custom memory configuration (like in MCUxpresso) -->
<#if buildConfig?upper_case?starts_with("FLASHSTART ") && configMemory?has_content>
    <#assign splittedName = buildConfig?split(" ")>     <#-- spilt buildConfig name at spaces -->
    <#assign application_offset = splittedName[1]> <#-- the second spilt is our offset in hex (count starts from 0) -->
    <#assign ram_offset = default_ram_offset>           <#-- new ram_offset -->
    <#assign selfbus_custom_memory_layout = true>
</#if>

<#--
All lines below are mostly a "copy and paste" of [MCUxpresso-Installdir]/MCUXpressoIDE[VERSION]/ide/Wizards/linker/memory.ldt
adding our ${application_offset} and ${ram_offset} to modify memory layouts.
-->
MEMORY
{
    /* Define each memory region */
<#-- loop all memory configurations -->
<#list configMemory as memory>
  <#if selfbus_custom_memory_layout && memory.flash && memory.defaultFlash>
    <#-- add custom selfbus memory configuration for default flash -->
    /******************************************************************
     * Selfbus Flash configuration using build config: ${buildConfig} *
    /******************************************************************/
    ${memory.name} (${memory.linkerMemoryAttributes}) : ORIGIN = ${memory.location} + ${application_offset}, LENGTH = ${memory.size} - ${application_offset}
  <#elseif selfbus_custom_memory_layout && memory.RAM && memory.defaultRAM>
    <#-- add custom selfbus memory configuration for default RAM -->
    /****************************************************************
     * Selfbus RAM configuration using build config: ${buildConfig} *
    /****************************************************************/
    ${memory.name} (${memory.linkerMemoryAttributes}) : ORIGIN = ${memory.location} + ${ram_offset}, LENGTH = ${memory.size} - ${ram_offset}
  <#else>
    <#-- no change of memory settings -->
    ${memory.name} (${memory.linkerMemoryAttributes}) : ORIGIN = ${memory.location}, LENGTH = ${memory.size}
  </#if>
</#list>
}

      /* Define a symbol for the top of each memory region */
<#list configMemory as memory>
  <#if selfbus_custom_memory_layout && memory.flash && memory.defaultFlash>
      <#-- put some comments in the resulting .ld linker file -->
      /******************************************************************
       * Selfbus Flash configuration using build config: ${buildConfig} *
      /******************************************************************/
      __base_${memory.name} = ${memory.location} + ${application_offset}; /* ${memory.name} */
      __base_${memory.alias} = ${memory.location} + ${application_offset}; /* ${memory.alias} */
      __top_${memory.name} = ${memory.location} + ${memory.size} - ${application_offset};
      __top_${memory.alias} = ${memory.location} + ${memory.size} - ${application_offset};
  <#elseif selfbus_custom_memory_layout && memory.RAM && memory.defaultRAM>
      <#-- put some comments in the resulting .ld linker file -->
      /****************************************************************
       * Selfbus RAM configuration using build config: ${buildConfig} *
      /****************************************************************/
      __base_${memory.name} = ${memory.location} + ${ram_offset}; /* ${memory.name} */
      __base_${memory.alias} = ${memory.location} + ${ram_offset}; /* ${memory.alias} */
      __top_${memory.name} = ${memory.location} + ${memory.size} - ${ram_offset};
      __top_${memory.alias} = ${memory.location} + ${memory.size} - ${ram_offset};
  <#else>
      __base_${memory.name} = ${memory.location}; /* ${memory.name} */
      __base_${memory.alias} = ${memory.location}; /* ${memory.alias} */
      __top_${memory.name} = ${memory.location} + ${memory.size}; /* ${memory.sizek} */
      __top_${memory.alias} = ${memory.location} + ${memory.size}; /* ${memory.sizek} */
  </#if>
</#list>