Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

redirecting printf in HAL

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

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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