Specifications

# and return immediately.
if { [regexp .*stdio.* $module_name] } {
return $slave_desc
}
# Assume it is a JTAG UART if the module class name contains
# the string "jtag_uart". In that case, return the first one
# found.
if { [regexp .*jtag_uart.* $module_class_name] } {
if {$first_jtag_uart == "none"} {
set first_jtag_uart $slave_desc
}
}
# Track last character device in case no JTAG UARTs found.
if { [is_char_device $slave_desc] } {
set last_stdio $slave_desc
}
}
if {$first_jtag_uart != "none"} {
return $first_jtag_uart
}
return $last_stdio
}
# Call routine to determine stdio
set default_stdio [choose_default_stdio]
# Set stdio settings to use results of above call.
set_setting hal.stdin $default_stdio
set_setting hal.stdout $default_stdio
set_setting hal.stderr $default_stdio
# Select a device connected to the processor as the default STDIO device.
# It returns the slave descriptor of the selected device.
# It gives first preference to devices with stdio in the name.
# It gives second preference to JTAG UARTs.
# If no JTAG UARTs are found, it uses the last character device.
# If no character devices are found, it returns "none".
# Procedure that does all the work of determining the stdio device proc
choose_default_stdio {}
{
set last_stdio "none" set first_jtag_uart "none"
# Get all slaves attached to the processor.
set slave_descs [get_slave_descs] foreach slave_desc $slave_descs
{
# Lookup module class name for slave descriptor.
set module_name [get_module_name $slave_desc]
set module_class_name [get_module_class_name $module_name]
# If the module_name contains "stdio", we choose it
# and return immediately.
if { [regexp .*stdio.* $module_name] }
{
return $slave_desc
}
# Assume it is a JTAG UART if the module class name contains
# the string "jtag_uart". In that case, return the first one
# found.
if { [regexp .*jtag_uart.* $module_class_name] }
{
4-28
Tcl Script to Examine Hardware and Choose Settings
NII5V2
2015.05.14
Altera Corporation
Nios II Software Build Tools
Send Feedback