Nios II Classic Software Developer’sHandbookSubscribeSend FeedbackNII5V22015.05.14101 Innovation DriveSan Jose, CA 95134www.altera.com
alt_alarm_start()... 14-10alt_a
Copied BSP FilesTable 4-7: Copied BSP FilesFile Name FunctionHAL Directory Contains HAL source code files. These are all copied files. The src directo
HAL BSP After BuildHAL BSP After Buildmy_hal_bspsettings.bsppublic.mklinker.xmemory.gdbmem.init.mksystem.halt_sys_init.clinker.hMakefileHALsrc (*.c,*.
Linker Map ValidationWhen a BSP is generated, the SBT validates the linker region and section mappings, to ensure that theyare valid for a HAL project
For more information, refer to an example of custom Tcl script usage in the “Creating Memory Initializa‐tion Files” chapter.Note: Any settings you spe
# and return immediately. if { [regexp .*stdio.* $module_name] } { return $slave_desc}# Assume it is a JTAG UART if the module class name
if {$first_jtag_uart == "none"} { set first_jtag_uart $slave_desc } } # Track last character device in case no JTAG UARTs
Related InformationRegenerating Your BSP on page 4-30How to Rebuild Your BSPIn the Nios II SBT for Eclipse, right-click the BSP project and click Buil
• You change your hardware design, but all BSP system-dependent settings remain consistent with thenew .sopcinfo file. The following are examples of s
Updating Your BSPWhen you update a BSP, you recreate the BSP settings file based on the current hardware definition andprevious BSP settings.Note: You
For more information about preserving all settings, including the default settings, use the DONT_CHANGEkeyword, described in the “Top Level Tcl Script
fork()...14
By recreating the BSP settings file with a Tcl script that specifies all BSP settings, you can reproduce theoriginal BSP while ensuring that system-de
Script Level Summarybsp-timer-utils.tcl Helper Specifies system timer device setting.bsp-linker-utils.tcl Helper Specifies memory regions and section
The bsp-set-defaults.tcl script sets the following defaults:• stdio character device (bsp-stdio-utils.tcl)• System timer device (bsp-timer-utils.tcl)•
finds no slave descriptors fitting either description, it chooses the last character device slave descriptorconnected to the Nios II processor. If bsp
• hal.linker.allow_code_at_reset• hal.linker.enable_alt_load_copy_rodata• hal.linker.enable_alt_load_copy_rwdata• hal.linker.enable_alt_load_copy_exce
specific procedure in the helper scripts, if you want to invoke some of the default Tcl functionality withoutrunning the entire default Tcl script.The
Table 4-11: Memory Types Recognized when Making Decisions about Your Boot Configura‐tionMemory Type Examples IsFlash IsNonVolatileStorageFlash Common
Run from Initialized Memory ConfigurationThe reset address points to the beginning of the application in memory (no boot loader). The resetmemory must
For more information about how each GUI is primarily a thin layer providing graphical control of thecommand-line tools, refer to “The Nios II Command-
plugins for access to the Nios II SBT, enabling you to create applications based on the Altera HAL, anddebug them using the JTAG debugger.You can laun
nios2-bsp-console...15-21alt-file
For more information, refer to the “GNU Compiler Tool Chain” chapter.For more information about launching the Nios II Command Shell, refer to the &quo
Nios II Software Build ToolsThe Nios II SBT utilities and scripts provide the functionality underlying the Nios II SBT for Eclipse. Youcan create, mod
Utility Descriptionelf2dat Converts a .elf file to a .dat file format appropriate for VerilogHDL hardware simulators.elf2flash Converts a .elf file to
Tool Descriptionjtagconfig Allows you configure the JTAG server on the hostmachine. It can also detect a JTAG chain and set up thedownload hardware co
Date Version ChangesMay 2008 8.0.0• Advanced exceptions added to Nios II core.• Added instructions for writing instruction-related exceptionhandler.•
Overview of the Hardware Abstraction Layer52015.05.14NII5V2SubscribeSend FeedbackThe HAL is a lightweight embedded runtime environment that provides a
For more information about creating a new project with the Nios II SBT, refer to the Getting Started fromthe Command Line chapter of the Nios II Softw
developers. Device drivers communicate directly with hardware through low-level hardware accessmacros.For further details about the HAL, refer to the
hardware, rather than calling your driver routines directly. Therefore, the usage of your driver is alreadydocumented as part of the HAL API.C Standar
• Character mode devices• UART core• JTAG UART core• LCD 16207 display controller• Flash memory devices• Common flash interface compliant flash chips•
Overview of Nios II Embedded Development12015.05.14NII5V2SubscribeSend FeedbackThe Nios II Software Developer's Handbook has been divided into tw
For more information about Altera-provided peripherals, refer to the Embedded Peripherals IP UserGuide.Related InformationEmbedded Peripherals IP User
Date Version ChangesMarch 2009 9.0.0• Reorganized and updated information and terminology to clarifyrole of Nios II Software Build Tools.• Corrected m
Developing Programs Using the HardwareAbstraction Layer62015.05.14NII5V2SubscribeSend FeedbackThis chapter discusses how to develop embedded programs
Related Information• The system.h System Description File on page 6-3• Getting Started with the Graphical User Interface on page 2-1• Nios II Software
For more information about how the SBT keeps your BSP up-to-date with your hardware system, refer to“Revising Your BSP” in the "Nios II Software
Data Widths and the HAL Type DefinitionsFor embedded processors such as the Nios II processor, it is often important to know the exact width andprecis
• ioctl()• isatty()• kill()• lseek()• open()• read()• sbrk()• settimeofday()• stat()• usleep()• wait()• write()The most commonly used functions are th
The HAL file infrastructure also allows you to manipulate character mode devices with UNIX-style pathnames. The HAL registers character mode devices a
Example 6–3. Hello World#include <stdio.h>int main (){printf ("Hello world!");return 0;}When using the UNIX-style API, you can use th
printed in response to several conditions. Altera logging can be enabled and disabled independently ofany normal stdio output, making it a powerful de
Nios II Software Development EnvironmentThe Nios II EDS provides a consistent software development environment that works for all Nios IIprocessor sys
completes initialization, run the nios2-terminal command from the Nios II Command Shell toaccept the Altera logging output.Extra Logging OptionsIn add
Name DescriptionJTAG startuplogPurpose At JTAG UART driver initialization, print out a line with thenumber of characters in the software transmit buff
Name DescriptionBoot logPurpose Prints out messages tracing the software boot process. The boot logis turned on by default when Altera logging is enab
Example: Creating a BSP with Logging• System clock log• JTAG startup log• JTAG interval log, logging twice a second• No write echoExample 6–6. Creati
Location File Namecomponents/altera_hal/HAL/src/ alt_log_printf.ccomponents/altera_nios2/HAL/src/ alt_log_macro.SNote: All file locations are relative
The following features and restrictions apply to the host based file system:• The host-based file system makes the Nios II C/C++ application project d
At runtime, you can obtain the current value of the system clock by calling the alt_nticks() function.This function returns the elapsed time in system
.../* The alt_alarm must persist for the duration of the alarm. */static alt_alarm alarm;...if (alt_alarm_start (&alarm,alt_ticks_per_second(),my_
printf ("time in func1 = %u ticks\n",(unsigned int) (time2 - time1));printf ("time in func2 = %u ticks\n",(unsigned int) (time3 -
Simple Flash AccessThis interface consists of the functions alt_flash_open_dev(), alt_write_flash(),alt_read_flash(), and alt_flash_close_dev().For mo
The Nios II SBT for Eclipse is based on the popular Eclipse framework and the Eclipse C/C++ develop‐ment toolkit (CDT) plugins. The Nios II SBT create
Then the second write begins, but before writing to the second block, the block is erased. At this point,t(3), the flash contains 4 KB of 0xAA and 4 K
return 0;}alt_get_flash_info()alt_get_flash_info() gets the number of erase regions, the number of erase blocks in each region, andthe size of each er
int alt_erase_flash_block ( alt_flash_fd* fd, int offset, int length )The flash memory is identified by the handle fd. The block is identified as bein
return 0;}alt_lock_flash()Prototypeint alt_lock_flash(alt_flash_dev * flash_info,alt_u32 sectors_to_lock)Commonly Called ByC/C++ programsDevice driver
Using DMA DevicesThe HAL provides a device abstraction model for direct memory access (DMA) devices. These areperipherals that perform bulk data trans
DMA Transmit ChannelsDMA transmit requests are queued using a DMA transmit device handle. To obtain a handle, use thefunction alt_dma_txchan_open(). T
alt_dma_rxchan_prepare() function to post receive requests. The prototype foralt_dma_rxchan_prepare() is:typedef void (alt_rxchan_done)(void* handle,
} else { /* Post the receive request */ if (alt_dma_rxchan_prepare (rx, buffer, 1024, dma_done, NULL) < 0)
Null)) < 0){printf ("Failed to post transmit request, reason = %i\n", rc);exit (1);}/* Post the receive request */if ((rc = alt_dma_rxcha
Enable Compiler OptimizationsTo enable compiler optimizations, use the -Os command-line option for the nios2-elf-gcc compiler. The-Os option sets a co
Nios II Software Project TypesApplication ProjectA Nios II C/C++ application project consists of a collection of source code, plus a makefile. A typic
input through stdin. You can control the assignment of stdin, stdout, and stderr channels bymanipulating BSP settings.Use a Smaller File I/O LibraryUs
Limitation Functions AffectedNo support for opening/closing FILE *. Only pre-openedstdout, stderr, and stdin are available. The functions listedare no
For more information about the GCC small newlib C library, refer to the newlib documentation installedwith the Nios II EDS. On the Windows Start menu,
but all other library functionality is available. You can refer to stdin, stdout, and stderr as you would toany other file descriptor. You can also re
alt_getchar()Equivalent to getchar(). In conjunction with the lightweight device driver API, this function furtherreduces code footprint. In the absen
Eliminate All Exit CodeMany embedded systems never exit at all. In such cases, exit code is unnecessary. You can eliminate allexit code through a BSP
Boot Sequence for HAL-Based ProgramsSystem Initialization Code Boot SequenceThe HAL provides system initialization code in the C runtime library (crt0
Function alt_main() calls function main(). After main() returns, the default alt_main() enters aninfinite loop. Alternatively, your custom alt_main()
In a memory device containing the reset or exception address, the linker creates a normal (nonreserved)memory section above the .entry or .exceptions
• .text—All remaining code• .rodata—The read-only data• .rwdata—Read-write data• .bss—Zero-initialized dataYou can control the placement of .text, .ro
Name DescriptionHost file system Refer to the "Developing Programs Using theHardware Abstraction Layer" chapter.Related Information• Etherne
representation of memory showing unused or overlapping regions. You start the BSP Editor fromthe Nios II Command Shell. For details about using the BS
Figure 6-4: Small Global Data SectionsRAM.rwdata.bss.sbss2.sbss.sdata2.sdataIf the total size of the small global data structures is more than 64 KB,
Boot ModesThe processor’s boot memory is the memory that contains the reset vector. This device might be anexternal flash or an Altera EPCS serial con
For more information about what happens when you regenerate a BSP, refer to “Revising your BSP” inthe "Nios II Software Build Tools" chapter
Date Version ChangesMay 2007 7.1.0• Added table of contents to “Introduction” section.• Added Referenced Documents section.March 2007 7.0.0 Maintenanc
Developing Device Drivers for the HardwareAbstraction Layer72015.05.14NII5V2SubscribeSend FeedbackEmbedded systems typically have application-specific
The HAL Peripheral-Specific APIIf the peripheral does not belong to one of the HAL generic device model classes, you need to provide adevice driver wi
Nios II Hardware Design ConceptsThis section discusses some basic concepts behind the Altera Qsys and SOPC Builder system integrationtools. These conc
The _regs.h header file defines the following access macros for the component:• Register access macros that provide a read and/or write macro for each
Creating Embedded Drivers for HAL Device ClassesThe HAL supports a number of generic device model classes. By writing a device driver as described int
Each BSP example directory contains a create-this-bsp script. After this script is run, each softwareexample directory contains the following files:•
For more information about open(), close(), read(), write(), lseek(), fstat(), and ioctl(), refer tothe "HAL API Reference" chapter of the N
Function Default Behaviorwrite Calls to write() for this device always fail.lseek Calls to lseek() for this device always fail.fstat The device identi
int alt_fs_reg (alt_dev* dev)This function takes a single input argument, which is the device structure to register. A negative returnvalue indicates
Flash Device DriversCreate a Flash DriverFlash device drivers must provide an instance of the alt_flash_dev structure, defined in sys/alt_flash_dev.h.
Register a Flash DeviceAfter creating an instance of the alt_flash_dev structure, you must make the device available to theHAL system by calling the f
The prepare() function must be defined. If the ioctl field is set to null, calls toalt_dma_rxchan_ioctl() return -ENOTTY for this device.After creatin
Layered Software ModelArchitectural Layers of a Nios II MicroC/OS-II software applicationApplication Application-specific system initialization Niche
You need not edit the NicheStack TCP/IP Stack source code to implement a NicheStack-compatibledriver. Nevertheless, Altera provides the source code fo
net structure internally to define its interface to device drivers. The net structure is defined in net.h, in<iniche path>/src/downloads/30src/h
Related Information• Header Files and alt_sys_init.c on page 7-28• Provide a Software Initialization Function on page 7-15Provide a Software Initializ
The Nios II Processor Reference Handbook defines the processor hardware architecture and features,including the instruction set architecture.The Embed
Assumptions and RequirementsTypically, you are developing a device driver or software package for eventual incorporation in a BSP. Thedriver or packag
The Nios II BSP GeneratorThis section describes the process by which the Nios II BSP generator adds device drivers and softwarepackages to your BSP. T
No Specific RequestsIf no specific device driver is requested, and no compatible device driver is located for a particularhardware module, the BSP gen
Driver and Software Package Tcl Script CreationThis section discusses writing a Tcl script to describe your software package or driver. The exact cont
Figure 7-1: Example Device Driver File Hierarchy and NamingHardware system generation filescustom_component_sw.tclcustom_component_regs.hHALinccustom_
Creating and Naming the Driver or PackageThe first command in any driver or software package Tcl script must be the create_driver orcreate_sw_package
Specifying an Operating SystemMany drivers and software packages do not require any particular operating system. However, you canstructure your softwa
To support this functionality in Nios II BSPs, you must set the set_sw_property command’sauto_initialize argument to true using the following Tcl comm
Device drivers (but not software packages) can use the min_compatible_hw_version andspecific_compatible_hw_version arguments to establish compatibilit
Table 7-4: Data Type SettingsData Type Setting Value NotesBooleandefinitionboolean_define_onlyA definition that is generated whentrue, and absent when
ContentsOverview of Nios II Embedded Development... 1-1Prerequisites for Understanding the Nios II Em
Date Version ChangesFebruary 2011 10.1.0 Removed "Referenced Documents" section.July 2010 10.0.0 Installation method changed; Nios II EDS al
Table 7-5: Destination File SettingsDestination File Setting Value Notessystem.h system_h_defineThis destination file is recommended in mostcases. You
Related InformationNios II Software Build Tools Reference on page 15-1Setting DescriptionThe description argument of add_sw_setting contains a brief d
Creating a Custom Device Driver for the HALThis section describes how to provide appropriate files to integrate your device driver in the HAL.For more
altera_avalon_jtag_uart.h Defining MacrosFor example, altera_avalon_jtag_uart.h must define the macros ALTERA_AVALON_JTAG_UART_INSTANCE andALTERA_AVAL
Provide Reduced Footprint DriversThe HAL defines a C preprocessor macro named ALT_USE_SMALL_DRIVERS that you can use in driversource code to provide a
• ALT_DRIVER_READ(instance, buffer, len, flags)• ALT_DRIVER_WRITE(instance, buffer, len, flags)• ALT_DRIVER_IOCTL(instance, req, arg)These macros are
Overriding the HAL Default Device DriversAll components can elect to provide a HAL device driver.For more information, refer to Integrating a Device D
Date Version ChangesMarch 2009 9.0.0• Reorganized and updated information and terminology to clarifyrole of Nios II Software Build Tools.• Incorporate
Exception Handling82015.05.14NII5V2SubscribeSend FeedbackThis chapter discusses how to write programs to handle exceptions in the Nios® II processor a
• Application context—The status of the Nios II processor and the HAL during normal programexecution, outside of exception funnels and handlers.• Cont
Getting Started with the Graphical UserInterface22015.05.14NII5V2SubscribeSend FeedbackThe Nios II Software Build Tools (SBT) for Eclipse is a set of
• Software exception—An exception caused by a software condition; that is, any exception other than ahardware interrupt. This includes unimplemented i
When an external hardware interrupt occurs, the Nios II processor transfers control to an individualvector address, which can be unique for each inter
Latency and Response TimeException (interrupt) latency, as defined in the previous section, is the time required for the hardware torespond to an exce
The processor’s response to hardware interrupts depends on which interrupt controller is implemented.The following sections describe the hardware beha
When you create a board support package (BSP) project, the build tools include all needed device drivers.You do not need to write HAL ISRs unless you
In determining the interrupt API to use, the SBT ignores any devices whose interrupts are not connectedto the Nios II processor associated with the BS
The SBT inserts the following symbol definitions in system.h, indicating the configuration of theprocessor’s interrupt-related hardware options:• NIOS
• alt_irq_register()• alt_irq_disable()• alt_irq_enable()• alt_irq_disable_all()• alt_irq_enable_all()• alt_irq_interruptible()• alt_irq_non_interrupt
HAL ISR RestrictionsWhen your system has an EIC, the HAL interrupt support imposes the following restrictions:• Nonmaskable hardware interrupts must u
The HAL funnel code is called from the vector table.Running in a Restricted EnvironmentISRs run in a restricted environment. A large number of the HAL
Any number of editors can be open at once, but only one can be active at a time. The main menu bar andtoolbar for the workbench window contain operati
Registering an ISR with the Enhanced Interrupt APIBefore the software can use an ISR, you must register it by calling alt_ic_isr_register(). Theprotot
For more information about alt_ic_isr_register(), refer to the "HAL API Reference" chapter.Note: The HAL legacy interrupt API provides a dif
The driver for an EIC can provide specialized functions to manage any implementation-specific featuresof the EIC. An example would be modifying interr
• Button is pressed, generating an IRQ.• The ISR gains control.• With the IIC, the HAL general exception funnel gains control of the processor, and di
Table 8-2: HAL Interrupt Legacy and Enhanced API Functions toLegacy API Function Enhanced API Functionalt_irq_register() alt_ic_isr_register()alt_irq_
Implement Time-Intensive Algorithms in HardwareProcessor-intensive tasks must often transfer large amounts of data to and from peripherals. A general-
• Cache and Tightly-Coupled MemoryUse a Separate Exception StackThe HAL implements two types of separate exception stack. Their availability depends o
Table 8-3: Separate Exception Stack UsageInterrupt ControllerBSP SettingsApplicationStackGeneralExceptionStackHardware InterruptStackSeparateGeneralEx
Use Nested Hardware InterruptsBy default, the HAL disables interrupts when it dispatches an ISR. This means that only one ISR canexecute at any time,
Related InformationManaging Pre-Emption on page 8-12Locate ISR Body in Vector TableIf you are using a vectored EIC, and you have a critical ISR of sma
Related InformationSpecifying the BSP on page 2-3For more information about how the SBT also creates a folder to contain BSP project files.Specifying
Use Vectored Hardware InterruptsBy default, the Nios II processor has a nonvectored IIC. The HAL provides software to dispatch eachhardware interrupt
Add a DMA ControllerA DMA controller performs bulk data transfers, reading data from a source address range and writing thedata to a different address
generally invalid by the time you return the processor to normal execution. You must reset the processorto return the system to a valid state.With the
With an EIC, the general exception funnel handles only software exceptions. An IRQ causes the processorto transfer control to one of the interrupt fun
Figure 8-1: HAL Exception Handling System with the Internal Interrupt ControllerHardwareinterruptsenabled?Hardwareinterruptspending?Handlesoftware exc
Interrupt Funnels for External Interrupt ControllersWith the EIC interface, the Nios II processor supports a potentially unlimited number of hardwarei
Software exception handling depends on options selected in the BSP. If you have enabled unimplementedinstruction emulation, the software exception fun
Note: An exception handler must never execute an unimplemented instruction. The HAL exceptionhandling system does not support nested software exceptio
For more information, refer to the “The Nios II Instruction-Related Exception Handler” chapter for adescription of the instruction-related exception h
• Instruction Set Reference• Programming ModelInvalid InstructionsAn invalid instruction word contains invalid codes in the OP or OPX field. For norma
BSP in the list. The Create and Import buttons to the right of the existing BSP list provide convenientways to add BSPs to the list.Creating the Proje
alt_u32 addr, alt_u32 bad_addr );The instruction-related exception handler’s return value is a flag requesting that the HAL either re-execute the ins
Exception CauseCodeCause Symbol (8)Supervisor-only InstructionAddress9 NIOS2_EXCEPTION_SUPERVISOR_ONLY_INST_ADDRSupervisor-only Instruction 10 NIOS2_E
For more information, refer to “Settings Managed by the Software Build Tools” in the "Nios II SoftwareBuild Tools Reference" chapter of the
Date Version ChangesMay 2008 8.0.0 Maintenance release.October 2007 7.2.0 Maintenance release.May 2007 7.1.0• Added table of contents to “Introduction
Cache and Tightly-Coupled Memory92015.05.14NII5V2SubscribeSend FeedbackNios II embedded processor cores can contain instruction and data caches. This
Related InformationNios II Core Implementation DetailsDefining Cache PropertiesThe details for a particular Nios II processor system are defined in th
Assembly Code to Initialize the Instruction CachePlace the initi instruction in a loop that executes initi for each instruction cache line address.Exa
For HAL UsersThe HAL provides the C-language macros IORD and IOWR that expand to the appropriate assemblyinstructions to bypass the data cache. The IO
stw r4, 0(r5)flushd 0(r5)flushi r5flushpNote: Notice that this example uses the stw/flushd pair instead of the stwio instruction. The stwioinstruction
Bit-31 cache bypass is only provided in the Nios II/f core, and must not be used with other Nios II cores.The other Nios II cores limit their maximum
The project directory for your hardware design contains an SRAM Object File (.sof) along withthe .sopcinfo file. The .sof file contains the hardware d
Date Version ChangesMay 2011 11.0.0 No changeFebruary 2011 10.1.0 Removed “Referenced Documents” section.July 2010 10.0.0 Maintenance release.November
MicroC/OS-II Real-Time Operating System102015.05.14NII5V2SubscribeSend FeedbackOverview of the MicroC/OS-II RTOSMicroC/OS-II is a popular real-time ke
LicensingAltera distributes MicroC/OS-II in the Nios II Embedded Design Suite (EDS) for evaluation purposesonly.Note: Micrium offers free licensing fo
Figure 10-1: Architecture of MicroC/OS-II Programs in Relation to the HAL APIUser ProgramC Standard LibraryHAL APIDeviceDriverDeviceDriver...DeviceDr
Related Information• Developing Device Drivers for the Hardware Abstraction LayerFor more information about developing device drivers.• Developing Dev
Macro Defined inHeaderMicroC/OS-II Implementation Single-ThreadedHAL Implementa‐tionALT_FLAG_POST(group,flags, opt)os/alt_flag.h Call OSFlagPost() wit
In addition, the MicroC/OS-II implementation provides appropriate task locking to ensure that heapaccesses (calls to malloc() and free()) are also thr
Date Version ChangesNovember 2009 9.1.0• Introduced the Nios II Software Build Tools for Eclipse.• Remove tables of Nios II IDE-specific setting names
Ethernet and the NicheStack TCP/IP Stack -Nios II Edition112015.05.14NII5V2SubscribeSend FeedbackThe NicheStack TCP/IP Stack - Nios II Edition is a sm
Related Information• Overview of Nios II Embedded DevelopmentFor more information about the Nios II Embedded Design Suite (EDS).• MicroC/OS-II Real-Ti
To debug a software project, right-click the application project name, point to Debug As, and click NiosII Hardware. This command carries out the foll
Related InformationNios II Processor Documentation PageFor more information about the reference manual for the NicheStack TCP/IP Stack page of the Alt
• The system hardware must include an Ethernet interface with interrupts enabled.• The BSP must be based on MicroC/OS-II.• The MicroC/OS-II RTOS must
netmain()netmain() is responsible for initializing and launching the NicheStack tasks. The prototype fornetmain() is:void netmain(void)netmain() retur
The prototype for get_mac_addr() is in the header file <iniche path><iniche path>/inc/alt_iniche_dev.h. TheNET structure is defined in the
To assign a static IP address, include the lines:*use_dhcp = 0;The prototype for get_ip_addr() is in the header file <iniche path>/inc/alt_inich
Note: There is no error checking in this example. In a real application, you might need to return -1 onerror.The prototype is defined in <iniche pa
Option DescriptionMAC interface If the IP stack has more than one network interface, thisparameter indicates which interface to use.Related Informatio
Related Information• Using the NicheStack TCP/IP Stack - Nios II Edition TutorialFor more information about the Altera NicheStack implementation• Lite
Read-Only Zip File System122015.05.14NII5V2SubscribeSend FeedbackAltera provides a read-only zip file system for use with the hardware abstraction lay
Programming the Zip File to FlashFor your program to access files in the zip file subsystem, you must first program the zip data to flash. Aspart of t
Console ViewJust as when running a program, Eclipse displays program output in the Console view of Eclipse. TheConsole view maintains a terminal I/O c
Publishing Component Information toEmbedded Software132015.05.14NII5V2SubscribeSend FeedbackThis document describes how to publish hardware component
Tcl Assignment StatementsA component publishes information by including Tcl assignment statements in its component descriptionfile, <component_name
set_module_assignment embeddedsw.CMacro.BAUD_RATE \[get_parameter_value BAUD_RATE_PARAM]Generated Macro in system.hExample 13–3. Generated Macro in s
Configuration Data TypesTable 13-2: Configuration Data Types and Corresponding FormatConfiguration Data Type Formatboolean 1, 032-bit integer 123, -50
Memory-Mapped Slave InformationTable 13-4: Avalon Memory-Mapped Slave Information - Assign with set_interface_assignmentConfiguration Name Type Defaul
Configuration Name Type Default Meaning ExamplesisFlash boolean 0 The memorydevice is a flashmemory device.If isFlash istrue, you mustalso setisMemory
Configuration Name Type Default Meaning ExamplesaffectsTransaction-sOnMastersstring emptystringA list of masternames delimitedby spaces, forexample m1
Configuration Name Type Default Meaning ExamplestransportsInterrupts-FromReceivers (12)string emptystringA list of interrupt receiverinterface names d
Note: Quotation marks are not required.Table 13-8: Memory Initialization Information - Assign with set_module_assignment CommandMemory InitializationN
Date Version ChangesNovember 2009 9.1.0 Add the following Avalon-ST interface settings, to support externalinterrupt controllers:• embeddedsw.configur
1. Enable the Run Time Stack Checking in the BSP project from NIOS II SBT for Eclipce Nios II BSPEditor. From the BSP project, right-click and navigat
HAL API Reference142015.05.14NII5V2SubscribeSend FeedbackThis chapter provides an alphabetically ordered list of all the functions in the hardware abs
Include<unistd.h>DescriptionThe newlib exit() function calls the _exit() function to terminate the current process. Typically,exit() calls this
alt_dcache_flush()Prototypevoid alt_dcache_flush (void* start, alt_u32 len)Commonly Called ByC/C++ programsDevice driversThread-safeYes.Available from
Device driversThread-safeYes.Available from ISRYes.Include<sys/alt_cache.h>DescriptionThe alt_dcache_flush_all() function flushes, that is, writ
Include<sys/alt_cache.h>DescriptionThe alt_dcache_flush_no_writeback() is called to flush the data cache for a memory region of length "len
• alt_remap_cached() on page 14-7• alt_remap_uncached() on page 14-7• alt_uncached_free() on page 14-6alt_uncached_free()Prototypevoid alt_uncached_fr
alt_remap_uncached()Prototypevolatile void* alt_remap_uncached (void* ptr, alt_u32 len);Commonly Called ByC/C++ programsDevice driversThread-safeYes.A
Commonly Called ByC/C++ programsDevice driversThread-safeYes.Available from ISRNo.Include<sys/alt_cache.h>DescriptionThe alt_remap_cached() func
Available from ISRYes.Include<sys/alt_cache.h>DescriptionThe alt_icache_flush_all() function invalidates the entire contents of the instruction
In processors without instruction caches, it has no effect.Return--Related Information• alt_dcache_flush() on page 14-3• alt_dcache_flush_all() on pag
The bgeu and break 3 lines are what is added for the stack overflow checking. If the stack pointerhas grown beyond its limits the break is called.Rela
The HAL waits nticks system clock ticks before calling the callback() function. When the HAL callscallback(), it passes it the input argument context.
DescriptionYou can call the alt_alarm_stop() function to cancel an alarm previously registered by a call toalt_alarm_start(). The input argument is a
ReturnReturns the maximum number of receive requests that can be posted.Related Information• alt_dma_rxchan_close() on page 14-13• alt_dma_rxchan_open
• alt_dma_rxchan_prepare() on page 14-16• alt_dma_rxchan_reg() on page 14-17• alt_dma_txchan_close() on page 14-18• alt_dma_txchan_ioctl() on page 14-
• alt_fs_reg() on page 14-29alt_dma_rxchan_open()Prototypealt_dma_rxchan alt_dma_rxchan_open (const char* name)Commonly Called ByC/C++ programsDevice
alt_dma_rxchan_prepare()Prototypeint alt_dma_rxchan_prepare (alt_dma_rxchan dma, void* data, alt_u32 length, alt_rxchan_done* done, void* handle)Commo
alt_dma_rxchan_reg()Prototypeint alt_dma_rxchan_reg (alt_dma_rxchan_dev* dev)Commonly Called ByC/C++ programsDevice driversThread-safeNo.Available fro
• alt_dma_txchan_reg() on page 14-21• alt_dma_txchan_send() on page 14-27• alt_dma_txchan_space() on page 14-26alt_dma_txchan_close()Prototypeint alt_
alt_dma_txchan_ioctl()Prototypeint alt_dma_txchan_ioctl (alt_dma_txchan dma, int req, void* arg)Commonly Called ByC/C++ programsDevice driversThread-s
• alt_dma_txchan_reg() on page 14-21• alt_dma_txchan_send() on page 14-27• alt_dma_txchan_space() on page 14-26alt_dma_txchan_open()Prototypealt_dma_t
The Project Tab...2-21The T
Figure 2-1: Nios II Debug windowCustom Instruction-Related Exception HandlerFor use outside the debugger, you can register your own instruction-relate
alt_dma_txchan_reg()Prototypeint alt_dma_txchan_reg (alt_dma_txchan_dev* dev)Commonly Called ByC/C++ programsDevice driversThread-safeNo.Available fro
• alt_dma_txchan_open() on page 14-20• alt_dma_txchan_send() on page 14-27• alt_dma_txchan_space() on page 14-26alt_flash_close_dev()Prototypevoid alt
alt_exception_cause_generated_bad_addr()Prototypeint alt_exception_cause_generated_bad_addr ( alt_exception_cause cause)Commonly Called ByC/C++ progra
Device driversThread-safeNo.Available from ISRNo.Include<sys/alt_flash.h>DescriptionThe alt_erase_flash_block() function erases an individual fl
Available from ISRSee description.Include<sys/alt_dma.h>DescriptionThe alt_dma_rxchan_ioctl() function performs DMA I/O operations on the DMA re
Request MeaningALT_DMA_RX_ONLY_OFF Return to the default mode, in which both the receive and transmitsides of the DMA can be under software control.Re
• alt_dma_txchan_ioctl() on page 14-19• alt_dma_txchan_open() on page 14-20• alt_dma_txchan_reg() on page 14-21• alt_dma_txchan_send() on page 14-27al
• alt_dma_rxchan_reg() on page 14-17• alt_dma_txchan_close() on page 14-18• alt_dma_txchan_ioctl() on page 14-19• alt_dma_txchan_open() on page 14-20•
alt_fs_reg()Prototypeint alt_fs_reg (alt_dev* dev)Commonly Called ByDevice driversThread-safeNo.Available from ISRNo.Include<sys/alt_dev.h>Descr
Commonly Called ByC/C++ programsDevice driversThread-safeNo.Available from ISRNo.Include<sys/alt_flash.h>DescriptionThe alt_get_flash_info() fun
• Determining the Cause of Interrupt and Instruction-Related ExceptionsFor more information, refer to the "Determining the Cause of Interrupt and
Available from ISRNo.Include<sys/alt_irq.h>DescriptionThe alt_ic_irq_disable() function disables a single interrupt.The function arguments are a
Thread-safeYes.Available from ISRYes.Include<sys/alt_irq.h>DescriptionThis function determines whether a specified interrupt is enabled.The func
void* flags)Commonly Called ByC/C++ programsDevice driversThread-safeYes.Available from ISRNo.Include<sys/alt_irq.h>DescriptionThe alt_ic_isr_re
• alt_irq_disable() on page 14-36• alt_irq_disable_all() on page 14-38• alt_irq_enable() on page 14-39• alt_irq_enable_all() on page 14-39• alt_irq_en
• alt_irq_cpu_enable_interrupts () on page 14-37• alt_irq_disable() on page 14-36• alt_irq_disable_all() on page 14-38• alt_irq_enable() on page 14-39
A call to alt_instruction_exception_register() replaces the previously registered exception handler,if any. If handler is set to null, the instruction
• alt_ic_isr_register() on page 14-32• alt_irq_cpu_enable_interrupts () on page 14-37• alt_irq_disable_all() on page 14-38• alt_irq_enable() on page 1
• alt_irq_init() on page 14-41• alt_irq_pending () on page 14-42• alt_irq_register() on page 14-43alt_irq_disable_all()Prototypealt_irq_context alt_ir
alt_irq_enable()Prototypeint alt_irq_enable (alt_u32 id)Commonly Called ByC/C++ programsDevice driversThread-safeYes.Available from ISRNo.Include<p
Commonly Called ByC/C++ programsDevice driversThread-safeYes.Available from ISRYes.Include<sys/alt_irq.h>DescriptionThe alt_irq_enable_all() fun
Details of how each makefile is created and maintained vary depending on the project type, and on projectoptions that you control. The authoritative s
Thread-safeYes.Available from ISRYes.Include<sys/alt_irq.h>DescriptionDetermines whether maskable exceptions (status.PIE) are enabled.For more i
Available from ISRYes.Include<sys/alt_irq.h>DescriptionThe alt_irq_init () function calls the initilization macros for all interrupt controllers
Include<sys/alt_irq.h>DescriptionThe alt_irq_pending () function returns a bit list of the current pending interrupts. This is used byalt_irq_ha
DescriptionThe alt_irq_register() function registers an ISR. If the function is successful, the requested interruptis enabled on return.The input argu
Available from ISRYes.Include<sys/alt_llist.h>DescriptionThe alt_llist_insert() function inserts the doubly linked list entry entry in the list
Related Informationalt_llist_insert() on page 14-44alt_load_section()Prototypevoid alt_load_section(alt_u32* from,alt_u32* to,alt_u32* end)Commonly Ca
Commonly Called ByC/C++ programsDevice driversThread-safeYes.Available from ISRYes.Include<sys/alt_alarm.h>DescriptionThe alt_nticks() function.
Thread-safeNo.Available from ISRNo.Include<sys/alt_flash.h>DescriptionThe alt_read_flash() function reads data from flash. length bytes are read
DescriptionOnly the system clock driver may call the alt_tick() function. The driver is responsible for makingperiodic calls to this function at the r
Related Information• alt_alarm_start() on page 14-10• alt_alarm_stop() on page 14-11• alt_nticks() on page 14-46• alt_sysclk_init() on page 14-65• alt
modified icon. To add the resource back into the build, right-click the resource and click Add to Nios IIBuild.Note: Do not use the Eclipse Exclude fr
alt_timestamp_freq()Prototypealt_u32 alt_timestamp_freq (void)Commonly Called ByC/C++ programsThread-safeSee description.Available from ISRSee descrip
Available from ISRSee description.Include<sys/alt_timestamp.h>DescriptionThe alt_timestamp_start() function starts the system timestamp counter.
DescriptionThe alt_write_flash() function writes data to flash. The data to be written is at address src_addr.length bytes are written to the flash fd
Include<sys/alt_flash.h>DescriptionThe alt_write_flash_block() function writes one block of data of flash. The data to be written is ataddress d
DescriptionThe close() function is the standard UNIX-style close() function, which closes the file descriptor fd.Calls to close() are thread-safe only
ReturnThe return value is zero on success, or –1 otherwise. If the call fails, errno is set to indicate the cause ofthe error.Related Information• fcn
fcntl()Prototypeint fcntl(int fd, int cmd)Commonly Called ByC/C++ programsThread-safeNo.Available from ISRNo.Include<unistd.h><fcntl.h>Des
execve()Prototypeint execve(const char *path,char *const argv[],char *const envp[])Commonly Called ByC/C++ programsThread-safeYes.Available from ISRYe
Include<unistd.h>DescriptionThe getpid() function is provided for newlib compatibility and obtains the current process ID.ReturnBecause HAL syst
Related Informationnewlib Library Documentationstat()Prototypeint stat(const char *file_name,struct stat *buf);Commonly Called ByC/C++ programsDevice
Table 2-2: GUI Actions that Modify an Application or a Makefile with User Source ManagementModification Where ModifiedSpecifying the application or us
settimeofday()Prototypeint settimeofday (const struct timeval *t, const struct timezone *tz)Commonly Called ByC/C++ programsThread-safeNo.Available fr
Commonly Called Bynewlib C libraryThread-safeYes.Available from ISRYes.Include<sys/wait.h>Descriptionnewlib uses the wait() function to wait for
ReturnCalls to unlink() always fails with the return code –1 and errno set to ENOSYS.Related Informationnewlib Library Documentationsbrk()Prototypecad
Available from ISRYes.Include<unistd.h>DescriptionThe link() function is only provided for compatibility with newlib.ReturnCalls to link() alway
You can use the following values for the input parameter, whence:• SEEK_SET—The offset is set to ptr bytes.• SEEK_CUR—The offset is incremented by ptr
The expectation is that this function is only called from within alt_sys_init(), that is, while the systemis running in single-threaded mode. Concurre
Not all file systems/devices recognize this option.mode specifies the permissions to use, if a new file is created. It is unused by current file syste
typedef struct {clock_t tms_utime;clock_t tms_stime;clock_t tms_cutime;clock_t tms_cstime;};The structure has the following elements:• tms_utime: the
Include<unistd.h>DescriptionThe read() function reads a block of data from a file or device. read() is wrapper function that passescontrol direc
Include<unistd.h>DescriptionThe write() function writes a block of data to a file or device. write() is wrapper function that passescontrol dire
The Nios II BSP Editor Screen LayoutThe Nios II BSP Editor screen is divided into two areas. The top area is the command area, and thebottom is the co
Include<unistd.h>DescriptionThe usleep() function blocks until at least us microseconds have elapsed.ReturnThe usleep() function returns zero on
flash device being used,and this argument value can be found in the flash device datasheet. The flashdevices can be supported are shown as below:EPCQ1
ReturnThe return value is zero on success. If no system clock is available, the return value is -ENOTSUP.Related Information• alt_alarm_start() on pag
Calls to ioctl() are thread-safe only if the implementation of ioctl() provided by the driver that ismanipulated is thread-safe.Valid values for the f
ReturnThe return value is 1 if the device is a character device, and zero otherwise. If an error occurs, errno is setto indicate the cause.Related Inf
Thread-safeSee description.Available from ISRNo.Include<sys/alt_driver.h><sys/alt_stdio.h><priv/alt_file.h><unistd.h>Descripti
DescriptionThe alt_putstr() function ses the ALT_DRIVER_WRITE() macro to call directly to the driver, if available;otherwise, it uses the newlib provi
• newlib Library Documentationalt_printf()Prototypealt_printf(const char* fmt, ... )Commonly Called ByC/C++ programsDevice driversThread-safeNo.Availa
Date Version ChangesJuly 2010 10.0.0• Clarify purpose of listed C header file for functions.• Correction: alt_irq_enabled() is not a legacy function.N
Nios II Software Build Tools Reference152015.05.14NII5V2SubscribeSend FeedbackThis chapter provides a complete reference of all available commands, op
The Software Packages TabThe Software Packages tab allows you to insert and remove software packages in your BSP, and controlsoftware package settings
Table 15-1: Nios II SBT Logging LevelsLogging Level Descriptionsilent(lowest)No information is provided except for errors and warnings (sentto stderr)
• nios2-lib-generate-makefile on page 15-9• nios2-bsp-editor on page 15-10• nios2-app-update-makefile on page 15-10• nios2-lib-update-makefile on page
• --use-lib-dir <directory>: Specifies the path to a dependent user library directory. The user librarydirectory must contain a makefile fragmen
• --help: Displays basic information about this command and its options.• --jdi <filename>: The location of the JTAG Debugging Information File
nios2-bsp-generate-filesUsagenios2-bsp-generate-files --bsp-dir <directory> [--debug] [--extended-help] [--help] [--librarian-factory-path <
[--script <filename>] --settings <filename> [--show-descriptions] [--show-names] [--silent] [--verbose] [--version]Options• --cmd <t
--settings <filename> [--silent] [--sopc <filename>] [--verbose] [--version]Options• --bsp-dir <directory>: Path to the directory
nios2-lib-generate-makefileUsagenios2-lib-generate-makefile [--bsp-dir <directory>] [--debug] [--extended-help] [--help] [--lib-dir <direct
DescriptionThe nios2-lib-generate-makefile command generates a user library makefile (called Makefile). The pathto a BSP created by nios2-bsp-generate
[--remove-src-dir <directory>] [--remove-src-files <filenames>] [--remove-src-rdir <directory>] [--set <name>] [--set-asfla
• The Main Tab on page 2-15• Embedded Peripherals IP User GuideFor more information about Altera components.The Linker Script TabThe Linker Script tab
• --remove-src-rdir <directory>: Same as --remove-src-dir option but recursively search forsource files in or under <directory>. Multiple
[--remove-lib-dir <directory>] [--remove-public-inc-dir <directory>] [--remove-src-dir <directory>] [--remove-src-files <filena
• --remove-lib-dir <directory>: Remove a path to dependent user library directory• --remove-public-inc-dir <directory>: Remove a include d
• --name: Specify the name of the software project to create.• --sopc-dir: Specify the hardware design directory. Required.• --type: Specify the softw
• --sopcinfo <sopcinfoFile>• --jar <jarFile>• --jdi <jdiFile>• --quartus_project_dir <quartusProjectDir>• --sopc_system_name &
• --sopc_system_name• --profiling_enabled• --simulation_enabledDescriptionExtracts metadata from a .elf file intended for the Nios II soft-core proces
Options• --accept-bad-sysid: Continue even if the system identifier (ID) comparison fails.• --add-bin <fname> <flash-slave-desc> <offse
• --program-flash: Providing this flag causes calls to nios2-flash-programmer to be generated andexecuted. This results in flash targets being program
DescriptionThe nios2-bsp script calls nios2-bsp-create-settings or nios2-bsp-update-settings to create or update aBSP settings file, and the nios2-bsp
Optional arguments:• <sopc>: The path name of the .sopcinfo file. Alternatively, specify a directory containing a .sopcinfo file.In the latter c
• Restore Defaults—restores the memory regions to the default configuration set up at the time of BSPcreation.• Memory Usage—Opens the Memory Device U
DescriptionWhen invoked with no arguments, nios2-bsp-console starts an interactive command-line Tcl interpreterfor creating, editing, and generating A
Nios II Design Example ScriptsThe Nios II SBT includes scripts that allow you to create sample BSPs and applications. This sectiondescribes each scrip
Application Name SummaryZip File System Reads from a file system in flash memoryNote: Some application examples might not be available on some hardwar
Figure 15-1: Software Design Example Directory StructureQuartus II files (e.g. standard.qpf)Hardware system files (e.g. standard.sopcinfo)BSP examples
• Nios II Software Build Tools on page 4-1For more information, refer to the examples about specifying or manipulating settings.Overview of BSP Settin
Setting Context DescriptionAltera BSP Linker Script Generator Settings available if using the Altera BSP linkerscript generator (generates the linker.
Altera Avalon-MM UART Driver SettingsThe Altera Avalon-MM UART driver settings are available if the altera_avalon_uart driver is present.By default, t
hal.enable_small_stack• Identifier: none• Type:Boolean assignment• Default Value: 0• Destination File: public.mk• Description: lwhal.enable_small_stac
ucosii.os_lowest_prio• Identifier: OS_LOWEST_PRIO• Type: Decimal number• Default Value: 20• Destination File: system.h• Description: Lowest assignable
ucosii.miscellaneous.os_sched_lock_en• Identifier: OS_SCHED_LOCK_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Descripti
• The Information tab• The Problems tab• The Processing tabThe Information TabThe Information tab shows a running list of high-level changes you make
ucosii.miscellaneous.os_max_events• Identifier: OS_MAX_EVENTS• Type: Decimal number• Default Value: 60• Destination File: system.h• Description: Maxim
ucosii.task.os_task_create_ext_en• Identifier: OS_TASK_CREATE_EXT_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Descript
ucosii.task.os_task_suspend_en• Identifier: OS_TASK_SUSPEND_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Description: I
ucosii.time.os_time_get_set_en• Identifier: OS_TIME_GET_SET_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Description: I
ucosii.event_flag.os_flag_query_en• Identifier: OS_FLAG_QUERY_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Description:
ucosii.mutex.os_mutex_accept_en• Identifier: OS_MUTEX_ACCEPT_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Description:
ucosii.semaphore.os_sem_set_en• Identifier: OS_SEM_SET_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Description: Includ
ucosii.mailbox.os_mbox_del_en• Identifier: OS_MBOX_DEL_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Description: Includ
ucosii.queue.os_q_accept_en• Identifier: OS_Q_ACCEPT_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Description: Include
ucosii.queue.os_q_post_opt_en• Identifier: OS_Q_POST_OPT_EN• Type: Boolean assignment• Default Value: 1• Destination File: system.h• Description: Incl
Advantages of Command-Line Software Development...3-1Outline of the Nios II SBT
Note: You can select the operating system only at the time you create the BSP. To change operatingsystems, you must create a new BSP.• The operating s
ucosii.memory.os_mem_name_size• Identifier: OS_MEM_NAME_SIZE• Type: Decimal number• Default Value: 32• Destination File: system.h• Description: Size o
ucosii.timer.os_tmr_cfg_max• Identifier: OS_TMR_CFG_MAX• Type: Decimal number• Default Value: 16• Destination File: system.h• Description: Maximum num
altera_avalon_uart_driver.enable_ioctl• Identifier: ALTERA_AVALON_UART_USE_IOCTL• Type: Boolean definition• Default Value: false• Destination File: pu
altera_iniche.enable_ip_fragments• Identifier: IP_FRAGMENTS• Type: Boolean definition• Default Value: true• Destination File: system.h• Description: R
altera_ro_zipfs.ro_zipfs_offset• Identifier: ALTERA_RO_ZIPFS_OFFSET• Type: Hexadecimal number• Default Value: 0x100000• Destination File: system.h• De
hal.linker.enable_alt_load_copy_rodata• Identifier: none• Type: Boolean assignment• Default Value: 0• Destination File: none• Description: Causes the
hal.linker.exception_stack_size• Identifier: none• Type: Decimal number• Default Value: 1024• Destination File: none• Description: Size of the excepti
hal.make.ar_post_process• Identifier: AR_POST_PROCESS• Type: Unquoted string• Default Value: none• Destination File: BSP makefile• Description: Comman
hal.make.bsp_arflags• Identifier: BSP_ARFLAGS• Type: Unquoted string• Default Value: -src• Destination File: BSP makefile• Description: Custom flags o
hal.make.bsp_cflags_optimization• Identifier: BSP_CFLAGS_OPTIMIZATION• Type: Unquoted string• Default Value: -O0• Destination File: BSP makefile• Desc
Run Configurations in the SBT for EclipseEclipse uses run configurations to control how it runs and debugs programs. Run configurations in theNios II
hal.make.bsp_cxx_flags• Identifier: BSP_CXXFLAGS• Type: Unquoted string• Default Value: none• Destination File: BSP makefile• Description: Custom flag
hal.make.cc_post_process• Identifier: CC_POST_PROCESS• Type: Unquoted string• Default Value: none• Destination File: BSP makefile• Description: Comman
hal.make.ignore_system_derived.big_endian• Identifier: none• Type: Boolean assignment• Default Value: 0• Destination File: public.mk• Description: Ena
hal.make.ignore_system_derived.hardware_fp_cust_inst_no_divider_present• Identifier: none• Type: Boolean assignment• Default Value: 0• Destination Fil
hal.make.ignore_system_derived.hardware_mulx_present• Identifier: none• Type: Boolean assignment• Default Value: 0• Destination File: public.mk• Descr
hal.custom_newlib_flags• Identifier: CUSTOM_NEWLIB_FLAGS• Type: Unquoted string• Default Value: none• Destination File: public.mk• Description: Build
hal.enable_gprof• Identifier: ALT_PROVIDE_GMON• Type: Boolean assignment• Default Value: 0• Destination File: public.mk• Description: Causes code to b
hal.enable_reduced_device_drivers• Identifier: ALT_USE_SMALL_DRIVERS• Type: Boolean assignment• Default Value: 0• Destination File: public.mk• Descrip
hal.enable_sopc_sysid_check• Identifier: none• Type: Boolean assignment• Default Value: 1• Destination File: public.mk• Description: Enables system ID
hal.stdin• Identifier: STDIN• Type: Unquoted string• Default Value: none• Destination File: system.h• Description: Slave descriptor of STDIN character
Nios II Hardware v2 (beta)Run configurations and debug configurations have a launch type called Nios II Hardware v2 (beta). Tocreate this launch type,
• CREATE_OBJDUMP—Assign 1 to this variable to enable creation of an object dump file (.objdump) afterlinking the application. The nios2-elf-objdump ut
You can add multiple directories by enclosing them in double quotes, for example --setAPP_LIBRARY_DIRS "../my_libs ../../other_libs".• APP_L
Software Build Tools Tcl CommandsTcl commands are a crucial component of the Nios II SBT. Tcl commands allow you to exercise detailedcontrol over BSP
DescriptionThis command is provided to define a user-defined external memory device, outside the hardware system.Such a device would typically be mapp
are_same_resourceUsageare_same_resource <slave_desc1> <slave_desc2>Options• <slave_desc1>: String with the first slave descriptor to
disable_sw_packageUsagedisable_sw_package <software_package_name>Options• <software_package_name>: String with the name of the software pa
get_assignmentUsageget_assignment <module_name> <assignment_name>Options• <module_name>: Module instance name to query for assignmen
Exampleputs [get_available_sw_packages] Returns: altera_hostfs:7.2 altera_ro_zipfs:7.2get_base_addrUsageget_base_addr <slave_desc>Options• <s
Exampleputs [get_break_slave_desc] Returns: onchip_ram_64_kbytesget_cpu_nameUsageget_cpu_nameOptionsNoneDescriptionReturns the name of the BSP specifi
DescriptionReturns a list of lists for all the current section mappings. Each list represents a section mapping with theformat {section_name memory_re
Your command-line C/C++ application, and its associated BSP, is created on the command line. AnyNios II SBT command-line project is ready to import in
Examples• Example 1:puts [get_driver jtag_uart]Returns:altera_avalon_jtag_uart_driver:7.2• Example 2:puts [get_driver onchip_ram_64_kbytes]Returns:non
get_exception_slave_descUsageget_exception_slave_descOptionsNoneDescriptionReturns the slave descriptor associated with the processor exception addres
DescriptionReturns the slave descriptor associated with the processor fast TLB miss exception address. Only aprocessor with an MMU has such an excepti
get_memory_regionUsageget_memory_region <name>Options• <name>: String with the name of the memory region.DescriptionReturns the linker scr
DescriptionReturns the name of the module instance associated with the slave descriptor. If a module with one slave,or if it has multiple slaves conne
get_section_mappingUsageget_section_mapping <section_name>Options• <section_name>: String with the section name to query.DescriptionReturn
DescriptionReturns a string describing the BSP setting.Exampleputs [get_setting_desc hal.enable_gprof]Returns:"This example compiles the code wit
Examples• Example 1:puts [is_char_device jtag_uart]Returns:1• Example 2:puts [is_char_device onchip_ram_64_kbytes]Returns:0is_connected_interrupt_cont
is_ethernet_mac_deviceUsageis_ethernet_mac_device <slave_desc>Options• <slave_desc>: String with the slave descriptor to query.Description
is_non_volatile_storageUsageis_non_volatile_storage <slave_desc>Options• <slave_desc>: String with the slave descriptor to query.Descripti
1. Start the Nios II SBT for Eclipse.2. On the File menu, click Import. The Import dialog box appears.3. Expand the Nios II Software Build Tools Proje
Examplelog_default "This is a default message."Displays:INFO: Tcl message: "This is a default message."log_errorUsagelog_error <
Examples• Example 1:set_driver altera_avalon_jtag_uart_driver:7.2 jtag_uart• Example 2:set_driver none jtag_uartset_ignore_fileUsageset_ignore_file &l
DescriptionSets the value for the specified BSP setting. Legal values for boolean settings are true, false, 1, and 0. Usethe keyword none instead of a
add_default_memory_regionsUsageadd_default_memory_regionsDescriptionDefaults the BSP to use default linker script memory regions. The default linker s
Options• <bsp_type>: BSP type identifier (e.g. hal, ucosii).• <sopcinfo_path>: SOPC Information File path. Its parent folder might include
Options• <bsp_type>: BSP type identifier (e.g. hal, ucosii).• <sopcinfo_path>: SOPC Information File path. Its parent folder might include
get_bsp_versionUsageget_bsp_versionDescriptionGets the version of the BSP operating system software element.get_cpu_architectureUsageget_cpu_architect
Options• <processor_name>: processor instance name• <sopcinfo_path>: SOPC Information File path. Its parent folder can include custom BSP
DescriptionSaves a new BSP.set_bsp_versionUsageset_bsp_version <version>Options• <version>: Version of BSP type software element to use.De
• BSP initialization• BSP generation• BSP validationNote: Although you can specify a new setting’s value when you create the setting at BSP initializa
User-Managed Source FilesWhen you import a Nios II application or user library project, the Nios II SBT for Eclipse offers theoption of user source ma
add_class_sw_settingUsageadd_class_sw_setting <setting-name> <setting-type>Options• <setting-name>: Name of the setting to persist i
Options• <property-name>: Name of the property to add to the BSP for a module instance• <property-value>: Value of the property to add to
callback script is set in the driver's *_sw.tcl file, using the command set_sw_propertycallback_source_file <filename>.Exampleadd_module_sy
Options• <assignment-name>: Name of the module assignment to retrieve the value for, as defined for themodule instance in the .sopcinfo fileDesc
DescriptionThis command is used on an EIC instance callback to obtain a peripheral slave descriptor connected to aspecific IRQ port number. This comma
Exampleget_peripheral_property jtag_uart supports_preemption;remove_class_systemh_lineUsageremove_class_systemh_line <macro-name>Options• <ma
Options• <setting-name>: Name of the setting to persist in the BSP settings file associated with the driver classof this callback script• <pr
• description• restrictions• groupExampleset_module_sw_setting_property MY_FAVORITE_SETTING default-value '42'Tcl Commands for Drivers and P
add_sw_propertyUsageadd_sw_property <property> <value>Options• <property>: Name of property.• <value>: Value assigned, or appe
• supported_bsp_type—Adds a specific BSP type (operating system) to the list of supported operatingsystems that the driver or software package support
5. Next to Library name, click Add and type the library project name you selected when you createdyour user library.6. Click OK.7. Build your applicat
commands set_setting and get_setting to set or get the setting. The value of the setting persists in theBSP settings file.To create a setting, you mus
type, integer numbers with or without a 0x prefix for the hex_number type, numbers with decimals forfloat_number and double_number types, or an arbitr
This command is required, unless you use the create_driver or create_sw_package commands, asappropriate.create_sw_packageUsagecreate_sw_package <na
This command supports the following properties:• hw_class_name—The name of the hardware class which your device driver supports. The hardwareclass nam
• initialization_callback—This property specifies the name of a Tcl callback function which isintended to run in the following environment:• Run time:
Related InformationNios II Software Build Tools on page 4-1For more information about the legacy and enhanced APIs, refer to "Exception Handling&
Table 15-6: Path Name Format Support for Nios II SBT utilities and makefilesContext Formats supported on Linux (16)Formats supported on Windowswith Cy
Document Revision History for Nios II Software Build Tools ReferenceDate Version ChangesMay 2015 2015.05.14• Maintenance release.• Renamed to Nios II
Date Version ChangesNovember 2009 9.1.0• Support for external interrupt controller.• Add documentation for the following utilities:nios2-lib-update-ma
## example_sw_package_sw.tcl## Create a software package known as "example_sw_package"create_sw_package example_sw_package# The version of t
* This example prints 'Hello from Nios II' to the STDOUT stream. It also * tests inclusion of a user software package. */#include <stdi
When you first open the flash programmer, no controls are available until you open or create a FlashProgrammer Settings File (.flash-settings).Creatin
Specifying the Default stdio Device...4-36Specifying the Def
The Properties button opens the Properties dialog box, which allows you to view and modify informa‐tion about an individual file. In the case of a .el
Program FilesIf you disable this option, the flash programmer generates the programming files and the script, but doesnot program flash. You can use t
1. Right-click the application project.2. Point to Make targets and click Build to open the Make Targets dialog box.3. Select mem_init_install.4. Clic
On the Advanced tab, you can control the following memory characteristics:• The physical memory width.• The device's name in the hardware system.
Related InformationCreating a System with QsysFor more information, refer to the "Qsys Design Flow".Preparing your Software for ModelSimCrea
Related Information• Porting to GCC 4.7For more information about how GNU also provides a porting guide to GCC4.7 to documentcommon issues.• GCC Relea
Eclipse Usage NotesThe behavior of certain Eclipse and CDT features is modified by the Nios II SBT for Eclipse. If youattempt to use these features th
Selecting the Correct Launch Configuration TypeIf you try to debug a Nios II software project as a CDT Local C/C++ Application launch configurationtyp
Table 2-3: Location and Argument to Run Shell Script from EclipsePlatform Location ArgumentWindows ${env_var:QUARTUS_ROOTDIR}\bin\cygwin\bin\sh.exe-c
Table 2-6: Build configurationsUnsupported CDT Feature Alternative Nios II Feature• Right-click project and point to Build Configu‐rations• Debugger t
Altera Logging Functions...6-7Using File
Table 2-9: Window PreferencesUnsupported CDT Feature Alternative Nios II FeatureC/C++• Build scope• Build project configurations• Build Variables• Env
Option Description--list-build-config <config>Returns name of all build configurations.Returns empty string if only one build configura‐tion is
The following shows how the application properties page looks with the new build configuration optionshighlighted in red:Figure 2-2: Nios II Applicati
Note: The BSP project does not support multiple build configurations.Document Revision History for Getting Started with the Graphical UserInterfaceDat
Getting Started from the Command Line32015.05.14NII5V2SubscribeSend FeedbackThe Nios II Software Build Tools (SBT) allows you to construct a wide vari
For more information about the command-line utilities provided by the Nios II SBT, refer to “Altera-Provided Development Tools” in the Nios II Softwar
The default Tcl script is used to set the following system-dependent settings:• stdio character device• System timer device• Default linker memory• Bo
If no command-line arguments are specified, this command returns an exit value of 1 and sends a helpmessage to stderr.create-this-appEach application
• In the Windows operating system, on the Start menu, point to Programs > Altera > Nios II EDS<version>,and click Nios II <version>
Creating Hello_World for an Altera Development BoardIn this section you create a simple “Hello World” project. To create and build the hello_world exa
The Relationship Between the .sopcinfo File and system.h... 7-3Using the System Generation Tool to
The .sof file resides in <projects>, along with your Quartus II Project File (.qpf). You download it bytyping the following commands:cd <proj
Note: If you want to view the BSP source files while debugging, you also need to import the BSPproject into the Nios II SBT for Eclipse.Related Inform
Figure 3-1: Simple Software Project Directory StructureQuartus II files (e.g. standard.qpf)Hardware system files (e.g. standard.sopcinfo)BSP examples
Argument Purpose Further Information--cmd enable_sw_packagealtera_inicheAdds the NicheStack TCP/IP stacksoftware package to the BSPFor more informatio
nios2-bspBSP filesmakeBSP library file (.a) SOPC Builder system file (.sopcinfo)Tcl scriptsCommandline argumentsRelated Information• Nios II Software
Related Information• Nios II Software Build Tools on page 4-1For more information about the software example scripts, refer to “Nios II Design Example
Date Version ChangesMay 2011 11.0.0• Can auto-execute a Command in the Nios II Command Shell• The GCC 3 toolchain is an optional featureFebruary 2011
Nios II Software Build Tools42015.05.14NII5V2SubscribeSend FeedbackThis chapter describes the Nios II Software Build Tools (SBT), a set of utilities a
Road Map for the SBTBefore you start using the Nios II SBT, it is important to understand its scope. This section helps youunderstand their purpose, w
The Nios II SBT creates two kinds of makefiles:• Application or user library makefile—A simple makefile that builds the application or user library wi
General Exception Funnel...8-26Hardware Inter
Table 4-3: Application Makefile TargetsTarget Operationhelp Displays all available application makefile targets.all (default) Builds the associated BS
For a user library, the SBT also generates a public makefile, called public.mk. The public makefile isincluded in the private makefile for any applica
directly, abstracting hardware details from the software application. This abstraction minimizes oreliminates the need to access hardware registers di
Software Build ProcessTo create a software project with the Nios II SBT, you perform several high-level steps:1. Obtain the hardware design on which t
Although this section describes tasks in terms of the SBT command line flow, you can also carry out mostof these tasks with the Nios II SBT for Eclips
Creating BSP by Manually Running nios2-bspIf you create a BSP by running nios2-bsp manually on the command line or by running your own scriptthat call
Related Information• GNU WebsiteFor more information about .d files.• Nios II Embedded Design Suite SupportHanding Off a BSPIn some engineering organi
Table 4-5: mem_init.mk TargetsTarget Operationmem_init_install Generates memory initialization files in the application mem_initdirectory. If the QUAR
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
by the order in which the add_section_mapping command creates the sections. If you use nios2-bsp, thedefault Tcl script runs before the --cmd option t
The NicheStack TCP/IP Stack Files and Directories... 11-2Licensing...
Sections:Idx Name Size VMA LMA File off Algn...6 .isrs 000000c0 04000c00 04000c00 000000b4 2**2CONTENTS, ALLOC, LOAD, READONLY, CODE...9 .tightly_coup
If you run nios2-bsp again to update your BSP, the default Tcl script overrides your default sectionsmapping. To prevent your default sections mapping
chmod -R +w .rThe <projects> directory contains a subdirectory named software_examples/bsp. The bsp directorycontains several BSP example direct
If you are using nios2-bsp, you disable the driver for the uart0 device as follows:nios2-bsp hal my_bsp --cmd set_driver none uart0rUse the --cmd opti
You can control the optimization and debug level through the project makefile, which determines thecompiler options.Example 4–5. Default Application
Details of BSP CreationBSP creation is the same in the Nios II SBT for Eclipse as at the command line. The nios2-bsp-create-settings utility creates a
Figure 4-1: Default Tcl Script and nios2-bsp-generate-files Both Using the .sopcinfo filenios2-bsp-generate-filesBSP filesmakeBSP library file(.a)Hard
BSP Settings File CreationEach BSP has an associated settings file that saves the values of all BSP settings. The BSP settings file is inextensible ma
Figure 4-3: HAL BSP After Generating Filesmy_hal_bspsettings.bsppublic.mklinker.xmemory.gdbmem.init.mksystem.halt_sys_init.clinker.hMakefileHALsrc (*.
File Name Functionsummary.html Provides summary documentation of the BSP. You can view summary.htmlwith a hypertext viewer or browser, such as Interne
Comentarios a estos manuales