Specifications
add_memory_region onchip_ram $slave_desc $offset $new_span
add_memory_region onchip_special $slave_desc $split_offset $split_span
If you pass this Tcl script to nios2-bsp, it runs after the default Tcl script runs and sets up a linker region
named onchip_ram0. You pass the Tcl script to nios2-bsp as follows:
nios2-bsp hal my_bsp --script reserve_1024_onchip_ram.tclr
Note: Take care that one of the new memory regions has the same name as the original memory region.
If you run nios2-bsp again to update your BSP without providing the --script option, your BSP reverts
to the default linker memory regions and your onchip_special memory region disappears. To preserve
it, you can either provide the --script option to your Tcl script or pass the DONT_CHANGE keyword to the
default Tcl script as follows:
nios2-bsp hal my_bsp --default_memory_regions DONT_CHANGEr
Altera recommends that you use the --script approach when updating your BSP. This approach allows
the default Tcl script to update memory regions if memories are added, removed, renamed, or resized.
Using the DONT_CHANGE keyword approach does not handle any of these cases because the default Tcl
script does not update the memory regions at all.
For more information about using the --script argument, refer to the “Calling a Custom BSP Tcl Script”
chapter.
Related Information
• Calling a Custom BSP Tcl Script on page 4-26
• Nios II Software Build Tools Reference on page 15-1
• Nios II Software Build Tools Reference on page 15-1
For an explanation of each Tcl command used in this example, refer to the "Nios II Software Build
Tools Reference" chapter.
Creating a Custom Linker Section
The Nios II SBT provides a Tcl command, add_section_mapping, to create a linker section.
The default Tcl script creates these default sections for you using the add_section_mapping Tcl
command:
• .entry
• .exceptions
• .text
• .rodata
• .rwdata
• .bss
• .heap
• .stack
Creating a Linker Section for an Existing Region
To create your own section named special_section that is mapped to the linker region named
onchip_special, use the following command to run nios2-bsp:
nios2-bsp hal my_bsp --cmd add_section_mapping special_section onchip_specialr
When the nios2-bsp-generate-files utility (called by nios2-bsp) generates the linker script linker.x, the
linker script has a new section mapping. The order of section mappings in the linker script is determined
4-12
Creating a Custom Linker Section
NII5V2
2015.05.14
Altera Corporation
Nios II Software Build Tools
Send Feedback