Specifications
by the order in which the add_section_mapping command creates the sections. If you use nios2-bsp, the
default Tcl script runs before the --cmd option that creates the special_section section.
If you run nios2-bsp again to update your BSP, you do not need to provide the add_section_mapping
command again because the default Tcl script only modifies section mappings for the default sections
listed inthe Nios II Default Section Names table.
Dividing a Linker Region to Create a New Region and Section
This example works with any hardware design containing an on-chip memory named
tightly_coupled_instruction_memory connected to a Nios II instruction master.
Example 4–2. To Create a Section named .isrs in the tightly_coupled_instruction_memory on-chip
memory
# Get region information for tightly_coupled_instruction_memory memory region.
# Returned as a list.
set region_info [get_memory_region tightly_coupled_instruction_memory]
# Extract fields from region information list.
set region_name [lindex $region_info 0]
set slave [lindex $region_info 1]
set offset [lindex $region_info 2]
set span [lindex $region_info 3]
# Remove the existing memory region.
delete_memory_region $region_name
# Compute memory ranges for replacement regions.
set split_span 1024
set new_span [expr $span-$split_span]
set split_offset [expr $offset+$new_span]
# Create two memory regions out of the original region.
add_memory_region tightly_coupled_instruction_memory $slave $offset $new_span
add_memory_region isrs_region $slave $split_offset $split_span
add_section_mapping .isrs isrs_region
The above Tcl script splits off 1 KB of RAM from the region named tightly_coupled_instruc-
tion_memory, gives it the name isrs_region, and then calls add_section_mapping to add the .isrs
section to isrs_region.
Using the Create a New Region and Section Tcl Script
To use such a Tcl script, you would execute the following steps:
1. Create the Tcl script as shown in the example, above.
2. Edit your create-this-bsp script, and add the following argument to the nios2-bsp command line:
--script <script name>.tcl
3. In the BSP project, edit timer_interrupt_latency.h. In the timer_interrupt_latency_irq()
function, change the .section directive from .exceptions to .isrs.
4. Rebuild the application by running make.
Excerpts from Object Dump Files
After make completes successfully, you can examine the object dump file, <project name>.objdump. The
object dump file shows that the new .isrs section is located in the tightly coupled instruction memory.
This object dump file excerpt shows a hardware design with an on-chip memory whose base address is
0x04000000.
Example 4–3. Excerpts from Object Dump File
NII5V2
2015.05.14
Dividing a Linker Region to Create a New Region and Section
4-13
Nios II Software Build Tools
Altera Corporation
Send Feedback