Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Custom component for stdout

Altera_Forum
Honored Contributor II
1,676 Views

Hi, 

 

I believe the answer to this question must be pretty straight forward. I just don't get it... 

 

I try to use my own Uart component as stdout, stdin and stderr device for my Nios 2 SOPC. 

Where is the setting in my custom component files that tells the BSP editor to let it be choosable in the stdout, stdin, stderr combo box? 

 

I read many HAL driver development docs and application notes. I found that the HAL does know of different hardware classes for drivers. 

So I thought there must be a way to declare my driver as character module. Most likely in the *SW.tcl file. But I did not find any hint on how to do it. 

 

My driver files are according to the requirements for a char device driver. However, BSP editor does not offer me my custom component in the the drop down boxes for the STD streams.... 

 

Thanks, 

Maik
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
920 Views

Sounds like a simple request but I can't tell how to do it either! 

https://www.altera.com/content/dam/altera-www/global/en_us/pdfs/literature/hb/nios2/n2sw_nii5v2.pdf 

 

Search for choose_default_stdio and read what it does. The nice way of doing it would be to figure out what you need to say to get "is_char_device" to return true for your module, but I can't figure it out. 

So in your shoes, I'd probably fake it by putting "stdio" in the module name or something. 

 

Good luck
0 Kudos
Altera_Forum
Honored Contributor II
920 Views

Hi ted, 

 

thanks for the hint. At least putting stdio into the components name would be a way to go. Not my favorite solution, but at least something... 

 

Thanks again and apologize that I was not able to find that piece of information myself. 

 

Regards, 

Maik
0 Kudos
Altera_Forum
Honored Contributor II
920 Views

Hi, 

 

it seems as if I'm not finished, yet.... 

 

I renamed my UART from uart_1 to stdio_1 in SOPC builder (I'm using Quartus 9.1 for this project). 

 

Now, while building the BSP on the command line, I get the message 

 

SEVERE: [Error] altera_systemh_generator: <b>hal.stderr</b> out of range 

SEVERE: [Error] altera_systemh_generator: <b>hal.stdin</b> out of range 

SEVERE: [Error] altera_systemh_generator: <b>hal.stdout</b> out of range 

 

Hmm, I dig into it, but maybe somebody has an idea how to solve this issue? (or at least, what it means in the first place?) 

 

Regards, 

Maik
0 Kudos
Altera_Forum
Honored Contributor II
920 Views

Just guessing, but did you check the base address that you defined on Qsys, if it is needed to manually setup/change somewhere in any file ?

0 Kudos
Altera_Forum
Honored Contributor II
920 Views

Hi, 

 

the address defined in SOPC builder was quiet high in the first place. It was just the same as the before used UART. 

 

Since it said "out of range" I rearranged the address to a lower one right after the reset vector. Didn't help...... 

 

Currently, I'm using the FIFOed UART from the Altera WIKI. It worked immediately by using the same address and name. 

 

I think, I stuck with this one for now, since it is working (although already found a bug in the FIFO depth definition, but was able to solve it for now). 

 

Really, I don't know, where all those error messages come from and how to determine a solution for them..... 

 

Regards, 

Maik
0 Kudos
Altera_Forum
Honored Contributor II
920 Views

 

--- Quote Start ---  

Hi, 

 

it seems as if I'm not finished, yet.... 

 

I renamed my UART from uart_1 to stdio_1 in SOPC builder (I'm using Quartus 9.1 for this project). 

 

Now, while building the BSP on the command line, I get the message 

 

SEVERE: [Error] altera_systemh_generator: <b>hal.stderr</b> out of range 

SEVERE: [Error] altera_systemh_generator: <b>hal.stdin</b> out of range 

SEVERE: [Error] altera_systemh_generator: <b>hal.stdout</b> out of range 

 

Hmm, I dig into it, but maybe somebody has an idea how to solve this issue? (or at least, what it means in the first place?) 

 

Regards, 

Maik 

--- Quote End ---  

 

 

I'm running into a very similar issue. my error message is "[Error] hal: <b>hal.stdin</b> "uart_0" is out of range: "none", "lcd", "jtag_uart_1"" 

It seems like the range isn't related to address space, but to a list of acceptable interfaces. I'm not sure where that list is defined, since I don't have a module labeled "lcd" in the project.
0 Kudos
Altera_Forum
Honored Contributor II
920 Views

 

--- Quote Start ---  

Hi, 

 

it seems as if I'm not finished, yet.... 

 

I renamed my UART from uart_1 to stdio_1 in SOPC builder (I'm using Quartus 9.1 for this project). 

 

Now, while building the BSP on the command line, I get the message 

 

SEVERE: [Error] altera_systemh_generator: <b>hal.stderr</b> out of range 

SEVERE: [Error] altera_systemh_generator: <b>hal.stdin</b> out of range 

SEVERE: [Error] altera_systemh_generator: <b>hal.stdout</b> out of range 

 

Hmm, I dig into it, but maybe somebody has an idea how to solve this issue? (or at least, what it means in the first place?) 

 

Regards, 

Maik 

--- Quote End ---  

 

 

Keeping in mind that I'm not that familiar with Altera tools yet, and I'm using a different version than you, I did find the solution to my problem. When running nios2-bsp I passed it the arguments "--set hal.stdout uart_0 --set hal.stdin uart_0 --set hal.stderr uart_0". My description from yesterday was about a project that has multiple .sopcinfo files and I thought I was using one, when in fact I was using a different one that did have and lcd module, but didn't have the uart module. 

 

I believe editing bsp-set-defaults.tcl and lwhal-set-defaults.tcl and changing 'set default_stdio "CHOOSE_DEFAULT"' to 'set default_stdio "uart_0"' would achieve the same results, but it would mean all of your projects would have to have a uart_0 defined or you'll get the out of range errors.
0 Kudos
Reply