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++

redirecting printf in HAL

Altera_Forum
Honored Contributor II
1,229 Views

Hi 

 

I have a Nios System that allows me to remotely download (through Ethernet Only) the FPGA data & code  

without using the Ethernet Blaster Cable / EPCS Devices on a Altera NDK 1s10(Stratix).  

 

Now i want to redirect outputs from printf to my function.  

I notice that in system library properties , there is a list of devices to which i can redirect my output. 

I am guessing that inorder to redirect my output, i have to change some HAL settings file to add my function/device here. 

 

any suggestions?? 

 

regards 

Pavan
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
528 Views

I believe the way in which the IDE/HAL determines if a device can accept stdin/stdout is through a setting in the component's class.ptf file. For instance, the following snippet is from the jtag_uart: 

 

        SYSTEM_BUILDER_INFO {            Bus_Type = "avalon";            Is_Printable_Device = "1"; 

 

You may, however, be able to use alt_io_redirect() to redirect output to your "device". That's how the HAL does it just prior to entering main(). You'd have to create your own device driver (and perhaps, an actual hardware component) first, however. Since I've no idea what, exactly, you're trying to do, that's about all the advice I can offer. 

 

Cheers, 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
528 Views

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

Hi 

 

I have a Nios System that allows me to remotely download (through Ethernet Only) the FPGA data & code  

without using the Ethernet Blaster Cable / EPCS Devices on a Altera NDK 1s10(Stratix).  

 

Now i want to redirect outputs from printf to my function.  

I notice that in system library properties , there is a list of devices to which i can redirect my output. 

I am guessing that inorder to redirect my output, i have to change some HAL settings file to add my function/device here. 

 

any suggestions?? 

 

regards 

Pavan[/b] 

--- Quote End ---  

 

 

You will need to write a character mode device driver for your device. See chapter 5 of the Nios II Software Developer&#39;s Handbook.  

 

Slacker is also correct once you have done this you will need the Is_Printable_Device entry in your PTF file, for your device to be available in the IDE for use as stdout.
0 Kudos
Altera_Forum
Honored Contributor II
528 Views

Thanks slacker & rugbybloke 

 

Let me try it out. 

 

 

regards 

Pavan
0 Kudos
Reply