Linker definition

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

Linker definition

1,645件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by guillaumeL on Thu Jun 13 09:17:03 MST 2013
Hello,

I'm working with a LPC1769 and I have a question concerning the linker file. I want to use the 64k of Ram available in the product but I don't think the linker file is well defined. Could you help me to understand this linker file?

[LEFT]MEMORY
{
/* Define each memory region */
MFlash512 (rx) : ORIGIN = 0x0, LENGTH = 0x72000 /* 512k - 28k - 4k*/
RamLoc32 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000 /* 32k */
RamAHB32 (rwx) : ORIGIN = 0x2007c000, LENGTH = 0x8000 /* 32k */[/LEFT]
 
[LEFT]}
/* Define a symbol for the top of each memory region */
__top_MFlash512 = 0x0 + 0x72000;
__top_RamLoc32 = 0x10000000 + 0x8000;
__top_RamAHB32 = 0x2007c000 + 0x8000;[/LEFT]
 
[LEFT]SECTIONS
{[/LEFT]
 
[LEFT]/* MAIN TEXT SECTION */ 
.text : ALIGN(4)
{
FILL(0xff)
KEEP(*(.isr_vector))[/LEFT]
 
[LEFT]/* Global Section Table */
. = ALIGN(4) ;
__section_table_start = .;
__data_section_table = .;
LONG(LOADADDR(.data));
LONG( ADDR(.data)) ;
LONG( SIZEOF(.data));
LONG(LOADADDR(.data_RAM2));
LONG( ADDR(.data_RAM2)) ;
LONG( SIZEOF(.data_RAM2));
__data_section_table_end = .;
__bss_section_table = .;
LONG( ADDR(.bss));
LONG( SIZEOF(.bss));
LONG( ADDR(.bss_RAM2));
LONG( SIZEOF(.bss_RAM2));
__bss_section_table_end = .;
__section_table_end = . ;
/* End of Global Section Table */[/LEFT]
 
 
[LEFT]*(.after_vectors*)[/LEFT]
 
[LEFT]*(.text*)
*(.rodata .rodata.*)
. = ALIGN(4);[/LEFT]
 
[LEFT]} > MFlash512[/LEFT]
 
[LEFT]/*
* for exception handling/unwind - some Newlib functions (in common
* with C++ and STDC++) use this.
*/
.ARM.extab : ALIGN(4)
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > MFlash512
__exidx_start = .;[/LEFT]
 
[LEFT].ARM.exidx : ALIGN(4)
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > MFlash512
__exidx_end = .;[/LEFT]
 
[LEFT]_etext = .;[/LEFT]
 
[LEFT].data_RAM2 : ALIGN(4)
{
FILL(0xff)
*(.data.$RAM2*)
*(.data.$RamAHB32*)
. = ALIGN(4) ;
} > RamAHB32 AT>MFlash512[/LEFT]
 
[LEFT]/* MAIN DATA SECTION */[/LEFT]
 
[LEFT].uninit_RESERVED : ALIGN(4)
{
KEEP(*(.bss.$RESERVED*))
} > RamLoc32[/LEFT]
 
[LEFT].data : ALIGN(4)
{
FILL(0xff)
_data = .;
*(vtable)
*(.data*)
. = ALIGN(4) ;
_edata = .;
} > RamLoc32 AT>MFlash512[/LEFT]
 
 
[LEFT].bss_RAM2 : ALIGN(4)
{
*(.bss.$RAM2*)
*(.bss.$RamAHB32*)
. = ALIGN(4) ;
} > RamAHB32[/LEFT]
 
[LEFT]/* MAIN BSS SECTION */
.bss : ALIGN(4)
{
_bss = .;
*(.bss*)
*(COMMON)
. = ALIGN(4) ;
_ebss = .;
PROVIDE(end = .);
} > RamLoc32[/LEFT]
 
[LEFT]PROVIDE(_pvHeapStart = .);
PROVIDE(_vStackTop = __top_RamLoc32 - 0);[/LEFT]
}
 
0 件の賞賛
返信
5 返答(返信)

1,452件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Wed Jun 19 00:52:54 MST 2013
There is an example of moving the heap and stack up into the second bank of RAM in this FAQ:

http://support.code-red-tech.com/CodeRedWiki/EnhancedManagedLinkScripts

Regards,
CodeRedSupport
0 件の賞賛
返信

1,452件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Jun 18 03:39:00 MST 2013
Not sure what you are trying to do. For using RAM2 it's not necessary to use your own linker script.

LPCXpresso is doing that for you with < cr_section_macros.h >

/*
===============================================================================
 Name        : main.c
 Author      : $(author)
 Version     :
 Copyright   : $(copyright)
 Description : main definition
===============================================================================
*/

#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>

// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

#include <stdio.h>

[COLOR=Red]__DATA(RAM2) uint16_t demo[200];[/COLOR]

int main(void) {
[COLOR=Red]    demo[0] = 0x1234;[/COLOR]
    printf("Hello World\n");
....

0 件の賞賛
返信

1,452件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by guillaumeL on Tue Jun 18 03:00:17 MST 2013
Hi,

My linker file is working fine but the problem is this one.
My program is ~15k ram and during the test program execution, the program allocate RAM area using malloc function. unfortunately, when I reach 32k ram, the malloc function fails. I ty to find a way to use the second 32k RAM bank but I didn't find a solution. I try to use [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]__attribute__((section("RamAHB32"))) [SIZE=3][COLOR=black]but[/COLOR][COLOR=black] it puts all variables in the first RAM bank and not in the second. [/COLOR][/SIZE]
[/COLOR][/SIZE][/COLOR][/SIZE]
0 件の賞賛
返信

1,452件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by stalisman on Fri Jun 14 03:46:46 MST 2013
Linker files like make files are notorious gobldygook to the casual eye.

if you have to change them then there is no alternative to 'biting the bullet' and learning their syntax and meanings.

Good luck.
0 件の賞賛
返信

1,452件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Jun 14 00:30:24 MST 2013
What exactly do you think is wrong?

Information on linker script format can be found in the linker docs, included in the built-in help of LPCXpresso5.

There are also several linker/linker script related FAQs here:
http://support.code-red-tech.com/CodeRedWiki/CodeRedFAQ#Compiler

You might also want to read the introduction to linker scripts available in Building Bare-Metal ARM Systems with GNU: Part 3 at: http://www.embedded.com/design/201000339

Regards,
CodeRedSupport
0 件の賞賛
返信