Forum Discussion

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

NIOS2 Print to FIle

Hi,

I was wondering if there is a way to print to output file from NIOS2. I have a program that generates 64K worth of data, and I wanted to print them out for comparison. I am using Nio2 and Quartus 7.2 with sp3.

Thanks.

3 Replies

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

    --- Quote Start ---

    Hi,

    I was wondering if there is a way to print to output file from NIOS2. I have a program that generates 64K worth of data, and I wanted to print them out for comparison. I am using Nio2 and Quartus 7.2 with sp3.

    Thanks.

    --- Quote End ---

    Yes. "Altera Host-Based File System" provides this facility. It is available in "Software Components" in the "System Library Properties" of the project. By default it is not enabled, so you must enable it. Also, it can only be used in the Debug mode.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Yes. "Altera Host-Based File System" provides this facility. It is available in "Software Components" in the "System Library Properties" of the project. By default it is not enabled, so you must enable it. Also, it can only be used in the Debug mode.

    --- Quote End ---

    Thank you for your post. I have enabled "Altera Host-Based File System" in NIOS2 and tried to debug the following code to generate some output:

    
        FILE *fp;
        
        fp = fopen("log.txt", "w");
        
        int i = 0;
        
        for (i = 0; i < 65536; i++)
        {
            fprintf(fp, "%d\n", i);
        }
        
        fclose(fp);
    
    And then I tried to find the log.txt file at the mount point. However, it doesn't matter if I explicitly or implicitly specified the path of the log, ie. "/mnt/host/log.txt" or "log.txt" or used differnet paths "/home/lc2454/Documents/log.txt", I wasn't able to find the generated file. I even tried to create the log.txt file myself and made it chmod a+rw but still it wasn't written. Therefore, I was wondering if you can elaborate on how we can use this or point out a tutorial of some sort. Thanks in advance!