Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17259 Discussions

NIOS II & Eclipse: Unresolved Inclusion Error

Altera_Forum
Honored Contributor II
3,813 Views

Hi! 

 

I'm using NIOS II SBT. When i attemt to build project which uses libraries "system.h", "alt_types.h" or "io.h" 

it gives me "Unresolved inclusion system.h" error. Code from Altera's uart example. 

 

How i can fix this error? 

 

thanks,  

George 

 

# include <stdio.h># include <stdlib.h># include "alt_types.h"# include "system.h"# include <io.h> /* Include alt_log logging facility for debugging. MACROS are used to bypass * the driver and access the peripheral directly, so that messages can be * printed during boot before devices get initialized. * * Set hal.log_port to the desired logging device, using the name as specified * in SOPC Builder, such as jtag_uart or uart1 for the AN459 example HW design. * system.h will be generated to * set the following parameters to use alt_log with jtag_uart: * * alt_log_port_base = "JTAG_UART_BASE"; * alt_log_port_type = "altera_avalon_jtag_uart"; * * The SOF image does not need to be regenerated in SOPC Builder or * recompiled in Quartus. Only the application and board support package * need to have their makefiles modified and to be recompiled. This can * be accomplished by using the following * switches to the nios2-bsp command in a create-this-bsp script: * * --set hal.log_flags 3 * --set hal.log_port jtag_uart * * The hal.log_port and hal.log_flags settings will cause the following * build flags to be specified in the public.mk makefile fragment shared by * app and bsp projects: * * -DALT_LOG_ENABLE * -DALT_LOG_FLAGS=3 * * ALT_LOG_FLAGS valid value range is -1 to 3. * (3 is the most verbose, 0 is boot messages only, -1 is silent.) * * The writes are blocking by default, so a terminal (such as the * nios2-terminal command) needs to accept the alt_log output in order for * the Nios II application to complete boot initialization. * * You can add alt_log diagnostic messages to your code by invoking * ALT_LOG_PRINTF(), a macro that handles most printf options except for * floating point (%f or %g). */ # include "sys/alt_log_printf.h" void BitBangUartReceive() { /* uart_status is used to hold the value read from the UART status register. */ int uart_status; /* Define an array of characters used to test transmission over the UART. */ char input_request = "\nPress any key: \0"; /* index is used to select the next character from the input_request array. */ int index; /* incoming_character is used to hold the value of a character received on * the UART. */ char incoming_character; /* Clear any errors on the UART by zeroing the status register. */ IOWR(UART1_BASE, 2, 0); /* Transmit the input_request characters over the UART. */ for (index = 0; input_request != '\0'; index++) { /* Wait for TRDY transmit ready bit to go high (bit 6 of status register). */ while (!(uart_status = IORD(UART1_BASE, 2) & 0x40)); /* Write the next input_request character to the txdata register. */ IOWR(UART1_BASE, 1, input_request); } /* Wait for incoming data by polling the RRDY bit of the UART status * register. RRDY (bit 7) will go high when the uart's rxdata register * (offset 0x1 from the uart's memory mapped register base) receives * a character. */ while (!(uart_status = IORD(UART1_BASE, 2) & 0x80)); /* A receive character is ready, so read it from the rxdata register. */ incoming_character = IORD(UART1_BASE, 0); /* Echo the key pressed on the UART. */ /* Wait for TRDY transmit ready bit to go high (bit 6 of status register). */ while (!(uart_status = IORD(UART1_BASE, 2) & 0x40)); /* Write the pressed input character to the txdata register. */ IOWR(UART1_BASE, 1, incoming_character); } /* Test UART transmission via direct peripheral register manipulation. */ void BitBangUartTransmit() { /* uart_status is used to hold the value read from the UART status register. */ int uart_status; /* Define an array of characters used to test transmission over the UART. */ char bitbang = "BIT BANG\0"; /* index is used to select the next character from the bitbang array. */ int index; /* Clear any old existing errors on the UART by zeroing the status register. */ IOWR(UART1_BASE, 2, 0); /* First, try direct manipulation of the peripheral registers. * The UART1_BASE address comes from system.h, generated from the definition * in SOPC Builder for the base address of the Altera_Avalon_Uart peripheral * named uart1. For the Nios II Embedded Evaluation Kit, hardware reference * design included with this application note# 459, this UART's memory mapped * register base address is 0x80. */ for (index = 0; bitbang != '\0'; index++) { /* Wait for TRDY transmit ready bit to go high (bit 6 of status register). * This initial device test assumes no flow control for simplicity. * Configure the terminal connected to the other end of the UART * to not use flow control. */ while (!(uart_status = IORD(UART1_BASE, 2) & 0x40)); /* Write the next bitbang character to the txdata register. */ IOWR(UART1_BASE, 1, bitbang); } /* The following UART txdata register writes (offset 1 from the UART's * memory mapped register base) will cause a transmitter overrun * by successive writes of an 'A', 'S', and 'H' to the txdata register * immediately after writing a 'B' to the txdata register, without checking * that the UART has had time to move the 'B' into the transmitter shift * register. This results in a UART status register value of 0x0170. */ IOWR(UART1_BASE, 1, 'B'); IOWR(UART1_BASE, 1, 'A'); IOWR(UART1_BASE, 1, 'S'); IOWR(UART1_BASE, 1, 'H'); /* Place a breakpoint here after the line which writes an 'H' to the txdata * register. When this breakpoint is hit, view the value of the UART status * register in the Nios II Software Build Tools for Eclipse memory window at * address 0x88. (register offset 2, byte offset 8, from uart1's memory * mapped register base). * The exception bit (bit 8) and toe bit (bit 4) of the UART status register * are set by the UART to indicate transmission overrun. */ uart_status = IORD(UART1_BASE, 2); /* At this point, the Nios II Software Build Tools for Eclipse Variables window * will also show the transmitter overrun via the variable named uart_status. */ /* NOTE: Characters can be transmitted over the UART by directly writing * to txdata register via the Nios II Software Build Tools for Eclipse * memory view. */ /* NOTE: Peripheral memory mapped registers bypass the data cache. * Therefore, the status register value displayed in the memory window will * reflect any changes to the status bits made by the peripheral. IOWR() * and IORD() macros always bypass the cache also. */ } int main(void) { ALT_LOG_PRINTF("Calling BitBangUartTransmit.\n"); BitBangUartTransmit(); ALT_LOG_PRINTF("Calling BitBangUartReceive.\n"); BitBangUartReceive(); ALT_LOG_PRINTF("Done. Looping forever.\n"); while(1); return 0; }
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
2,710 Views

The system.h file is created when you generate the board support files. You either aren't generating them or haven't tied your application to them. This can be caused by creating your project as a Linux application rather than as a stand alone project. There are several written and video tutorials on creating NIOS software that you should take a look at.

0 Kudos
Reply