Linker script conversion fails

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Linker script conversion fails

4,735件の閲覧回数
ingenutec
Contributor III

I have a project from pre-7.9 LPCXpresso that includes a bootloader at address 0x00 and has a jump call at address 0xFF0.  I used the old style linker script to place my jump function at 0xFF0.  I am now needed to make some changes in the code, but when I rebuild in 7.9.2, the linker script is failing.  I tried using Tools-> convert, but it still failed.  I then took a step back to try to verify functionality.  I took the DEFAULT link_template.ld from the Wizards folder, put it in my linkscripts folder and then did Tools-> convert.  It fails - this SHOULD work, I have made NO changes in the linker scripts.  The error I am getting is:

 

The following has evaluated to null or missing:

==> memory  [in template "rodata.ldt" at line 1, column 22]

----

FTL stack trace ("~" means nesting-related):

  - Failed at: ${memory.alias}  [in template "rodata.ldt" at line 1, column 20]

  - Reached through: #include "rodata.ldt"  [in template "linkscript.ldt" at line 27, column 1]

----

 

I found in the FAQs that memory.alias comes from the Alias column of the memory map.  This would imply that the error means I left that blank.  However, here is what my memory map looks like:

 

Type      Name          Alias         Location         Size

Flash     Flash_SBL     Flash         0x0              0x1000

RAM       RamLoc16      RAM           0x10000000       0x3c00

RAM       Ram_FWDATABUF RAM2          0x10003c00       0x400

RAM       RamAHB16      RAM3          0x20007c000      0x4000

 

Is the problem that I renamed the Flash section from the default to Flash_SBL?  If so, how should this be addressed under the new scripting, if not, any explanation of why I'm getting this error and how to resolve it.  My first goal is to just get the basic memory map working, then I'll go back and make sure my jump function is placed at the correct location.

ラベル(1)
11 返答(返信)

4,260件の閲覧回数
thefallguy
Contributor IV

I am rather confused about what you are trying to do. Perhaps it would be easier if you just described the layout of memory that you are trying to achieve.

I would then recommend that you use the memory config editor to divide the memory into named blocks that match the layout. You can then use the 'section macros' to place code or data into those regions. And then let the IDE create the default linker script - without you having to provide any scripts yourself.

See these FAQS

Placing data at an address(Message) By LPCware Support, posted May 17, 2016

Placing code/rodata into different FLASH blocks(Message) By LPCware Support, posted May 17, 2016

0 件の賞賛
返信

4,260件の閲覧回数
ingenutec
Contributor III

Thanks for the help.  Here is what I have and am doing:

Type      Name          Alias         Location         Size

Flash     Flash_USER    Flash         0x4000           0x3bff0

Flash     Flash_CFG     Flash2        0x1000           0x3000

Flash     Flash_FWID    Flash3        0x3fff8          0x8

RAM       RamLoc16      RAM           0x10000000       0x4000

RAM       RamAHB16      RAM2          0x2007c000       0x3000

RAM       Ram_FWDATABUF RAM3          0x10003c00       0x1000

The space from 0x0000 to 0x0FFF is not listed.  This is in the bootloader project and written by that project so my project omits that section of memory

Flash_USER is my code space

Flash_FWID contains a firmware ID, used by the bootloader to verify that the code image is valid

Flash_CFG is for configuration data.  Currently, there is exactly one symbol in this memory block: cfgBuffer.  This buffer is defined in the code for all the default data, but during operation, it can be overwritten via a serial port and IAP Flash programming routines (NOT debug or FlashMagic, but update routines that are part of my application).  Because it can be updated during operation AND because I want to add a couple of more symbols in the same Flash_CFG block, I want the symbols at fixed addresses.  Specifically, I want cfgBuffer at 0x1000 and I want cfgList at 0x3000 and cfgData at 0x3800.

Currently, since I have only one symbol assigned to that block, it automatically gets placed at 0x1000 but I want the linker forced to place it at 0x1000 and once I add the other symbols I need to be able to specify their locations as well.

0 件の賞賛
返信

4,260件の閲覧回数
thefallguy
Contributor IV

Normally, in forums, 'bump' is used to set an activity date on a thread to ensure the thread appears near the top in the 'most recent posts' list. I guess this is what they have done.

Regarding the change you need to make to your linker script:

1. take a copy of Wizards/linker/text_section.ldt and place it into the 'linkscripts' directory of your project. This should be the only file in that directory

2. add you changes to the start or end of the file (depending on whether you want you change before the standard text section or after. Your change will looks something like this (almost identical to your current changes)

    .text : ALIGN(${text_align})

    {

        FILL(0xff)

         *(.text*)

         . = 0x00002800 ;

         *(.dataBuffer1*)

    } > ${CODE}

3. build your application (making sure that the project is set up to generate linker scripts)

p.s. I would recommend updating to latest 8.1.4 version of LPCXpresso, which has removed a few 'wrinkles' from the new freemarker templates

Hope that helps

4,260件の閲覧回数
ingenutec
Contributor III

I added this to the very beginning of the text_section.ld script (BEFORE ANY of the original script content):

    .text_Flash2 : ALIGN(${text_align})

    {

       . = 0x00001000 ;

       *(.cfgBuffer*)

  } > Flash_CFG

Flash_CFG (Flash2) is defined as a 12K block starting at 0x1000 (0x1000 - 0x3FFF), code (Flash_USER) starts at 0x4000. My project does nothing with 0x0000 - 0x0FFF (that's where the bootloader is, which is another project).

This works, sort-of.  It creates 1K of 0xFF fill and puts cfgBuffer at 0x2000.  I had the *(.text*) lines and the FILL lines in and that didn't seem to change anything.

The output linker script also duplicates the Flash_CFG section later in the file, I'm not sure if that's correct or not.  I think it may be the second Flash_CFG section that's causing the problem, but I don't know how to prevent it from being created.

Here is the script:

-----------------

    .text_Flash2 : ALIGN(${text_align})

    {

       . = 0x00001000 ;

       *(.cfgBuffer*)

  } > Flash_CFG

<#if configMemory?has_content>

<#list configMemory as memory>

<#if memory.flash && !memory.defaultFlash>

<#if slaves?has_content>

  <#include "text_section_multicore.ldt" >

<#elseif slavesError??>

    ${slavesError}

</#if>

    .text_${memory.alias} : ALIGN(${text_align})

    {

       FILL(0xff)

<#include "text.ldt" >

<#include "rodata.ldt" >

    } > ${memory.name}

</#if>

</#list>

</#if>

-----------------

Here is the output:

-----------------

SECTIONS

{

    .text_Flash2 : ALIGN(4)

    {

       . = 0x00001000 ;

       *(.cfgBuffer*)

  } > Flash_CFG

    .text_Flash2 : ALIGN(4)

    {

       FILL(0xff)

    *(.text_Flash2*) /* for compatibility with previous releases */

    *(.text_Flash_CFG*) /* for compatibility with previous releases */

    *(.text.$Flash2*)

    *(.text.$Flash_CFG*)

    *(.rodata.$Flash2*)

    *(.rodata.$Flash_CFG*)

    } > Flash_CFG

    .text_Flash3 : ALIGN(4)

    {

       FILL(0xff)

    *(.text_Flash3*) /* for compatibility with previous releases */

    *(.text_Flash_FWID*) /* for compatibility with previous releases */

    *(.text.$Flash3*)

    *(.text.$Flash_FWID*)

    *(.rodata.$Flash3*)

    *(.rodata.$Flash_FWID*)

    } > Flash_FWID

    /* MAIN TEXT SECTION */

    .text : ALIGN(4)

    {

0 件の賞賛
返信

4,260件の閲覧回数
ingenutec
Contributor III

Thanks,  I'll try that out.

0 件の賞賛
返信

4,260件の閲覧回数
lpcware
NXP Employee
NXP Employee
bump
0 件の賞賛
返信

4,260件の閲覧回数
ingenutec
Contributor III

what does 'bump' mean?  is this a message to LPCX Support to raise the priority?

0 件の賞賛
返信

4,260件の閲覧回数
thefallguy
Contributor IV

I can reproduce your problem... But I don't think this is what you want to do.

The new linker templates are much more flexible than the old scheme, but without seeing the changes you want to make to the linker script, I can't tell you what you need to do. However, if you read the doc pointed to by LPCXpresso Support, and reading the supplied templates in Wizards/linkscripts you should see it is fairly trivial to make changes. If you get stuck, tell me what change you need to make to your linker script and I will tell you how to do it.

Note to LPCXpresso support: To reproduce the issue, just copy the link_template.ld from the Wizard directory into your project/linkscripts directory, use Tools->convert to freemarker, and then build the project.

0 件の賞賛
返信

4,260件の閲覧回数
ingenutec
Contributor III

My original plan was to SPLIT the code space, but I don't think that is possible: originally, my code started at 0x1000 and went up from there.  I have a secondary boot loader at 0x0000.  I need to add some fixed data blocks (8K worth) and I thought I could keep the SBL pointing to 0x1000 (and hence my code starting at 0x1000) and then put my data block from 0x2000 to 0x3FFF, then continue code from 0x4000.  This does not appear to be possible - at least I haven't figured out how to do it.  So, what I did was to put the 8K block at 0x1000 and move my code to 0x3000 which, unfortunately, required a change in my SBL.  Currently, this data block starts at 0x1000 and goes to 0x2FFF.  Without using a custom linker script, I know how to, and am able to get the linker to put my data structures into this block.  Where the linker script comes in is that I need to have the data structures at specific addresses in the block.  For example, one data structure will be at 0x1000, one will be at 0x2800 and one at 0x2C00.  This is done so that I can write data into these locations during run time.  By fixing the locations, I can manage the erasing of the pages, the backing up (and read/modify/write) of the data and the application will always be able to access the correct data because the pointer used to access it is always pointing to a fixed location.

The way I did this in the previous linker script was to add the following into my link_template.ld:

    .text : ALIGN(${text_align})    <------ original

    {

         *(.text*)

        /* INSERT RODATA */

       

        /* INSERT CPP_INFO */

    } > ${CODE}

    .text : ALIGN(${text_align})    <---- my new entry

    {

        FILL(0xff)

         *(.text*)

       

        . = 0x00002800 ;

        *(.dataBuffer1*)

    } > ${CODE}

    /* INSERT EXDATA */     <---- original next section

However, because the conversion to the freemarker templates doesn't seem to be working, I can't seem to figure out how to do this using the free marker approach.

0 件の賞賛
返信

4,260件の閲覧回数
lpcxpresso_supp
NXP Employee
NXP Employee

In your linker script, check to see if you have a linker output section with no corresponding named memory. Otherwise you're subject to the default behavior. It's possible the message you see is a side effect of a translation, but I can't be sure without your project. You should update to the latest LPCXpresso installation. LPCXpresso 7.9.2 introduced transitional support for the Freemarker template engine while keeping the legacy linker template mechanism in place.

See https://community.nxp.com/message/630611

0 件の賞賛
返信

4,260件の閲覧回数
ingenutec
Contributor III

My linker script is the link_template.ld copied to a linkscripts folder in my project, then converted using the tools->convert to freemarker as described by Fall Guy below.  I have read through all of the various linker scripting articles in the community.  That's what I used to create the linker script for another similar project, but without the freemarker support.  It's the freemarker stuff that is causing the problem.

I cannot update to the latest release.  We are working on a project going into a certification and changing tools, even an update, is not appropriate at this time.

0 件の賞賛
返信