UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 15292

MicroBlaze - LMB and OPB Instruction Memory

Description

Keywords: linker, GNU, LMB, OPB, instruction, memory, segmented, code

Urgency: Standard

General Description:
How do I create an ".elf" file that places my CRT0 and application code in separate text sections (i.e., LMB and OPB)?

Solution

The following linker script solves this problem. To use the linker script, the following options must be added to the mb-gcc command line:

--save-temps
-Wl,--script linker_script

/*
* Define the memory layout, specifying the start address and size of the different memory regions.
*/
MEMORY
{
LMB : ORIGIN = 0x00000000, LENGTH = 2K
OPB : ORIGIN = 0x00800000, LENGTH = 4K
}

/*
* Specify the default entry point to the program
*/
ENTRY(_start)

/*
* Define the sections, and where they are mapped in memory
*/

SECTIONS
{

/*
* Specify that the .text section from all input object files will be placed
* in LMB memory into the output file section .text. Note that mb-gdb expects
* the executable to have a section called ".text".
*/
.text : {
*(EXCLUDE_FILE(system.o).text)
} >LMB

/* Define space for the stack and heap */
/* Note that variables _heap must be set to the beginning of this area */
/* and _stack set to the end of this area */
. = ALIGN(4);
_heap = .;

.bss : {
_STACK_SIZE = 0x400;
. += _STACK_SIZE;
. = ALIGN(4);
} >OPB
_stack = .;

/* */
/* Start of OPB memory */
/* */

/* The following line adds an executable section into opb memory */
.opb_text : {
system.o(.text)
} >OPB
. = ALIGN(4);

.rodata : {
*(.rodata)
} >OPB
/* Alignments by 8 to ensure that _SDA2_BASE_ on a word boundary */
. = ALIGN(8);
_ssrw = .;

.sdata2 : {
*(.sdata2)
} >OPB
. = ALIGN(8);
_essrw = .;
_ssrw_size = _essrw - _ssrw;
_SDA2_BASE_ = _ssrw + (_ssrw_size / 2 );
. = ALIGN(4);

.data : {
*(.data)
} >OPB
/* Alignments by 8 to ensure that _SDA_BASE_ on a word boundary */
/* Note that .sdata and .sbss must be contiguous */
. = ALIGN(8);
_ssro = .;

.sdata : {
*(.sdata)
} >OPB
. = ALIGN(4);

.sbss : {
*(.sbss)
} >OPB
. = ALIGN(8);
_essro = .;
_ssro_size = _essro - _ssro;
_SDA_BASE_ = _ssro + (_ssro_size / 2 );
. = ALIGN(4);

.opb_bss : {
*(.bss) *(COMMON)
} > OPB
. = ALIGN(4);
_end = .;
}
AR# 15292
Date Created 07/31/2002
Last Updated 04/28/2006
Status Archive
Type General Article