Forum Discussion

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

Problem about the NIOS II IDE c code

I don't know, dose anyone have the same problem with me??

MY problem is this...

I want to printf the data from my NIOS II IDE to the *.txt file

I try to use the "fopen" like this...

---------------------------------------------------------------

FILE *fpl;

fpl=fopen("..\\qq.txt","w");

fprintf(fpl,"111 %d\n",velocity);

fclose(fpl);

---------------------------------------------------------------

But, it is not workable.

Should I have to set anything in the SOPC builder or NIOS II IDE??

So, Does anyone could help me??

Thank you very much...

9 Replies

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

    Take a look at the host filing system for Nios II. It only works when debugging and is quite slow, but might suit your needs.

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

    right click on project,

    System Library Properties->Software Components->Altera Host Based File System , check "Add this software component"

    File will be created in chosen mount point.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    right click on project,

    System Library Properties->Software Components->Altera Host Based File System , check "Add this software component"

    File will be created in chosen mount point.

    --- Quote End ---

    Thank you for your suggest.

    But, How to assign the mount-point??

    Does that mean the file that I creat??
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Take a look at the host filing system for Nios II. It only works when debugging and is quite slow, but might suit your needs.

    -slacker

    --- Quote End ---

    Thank you for your suggest, but could you tell me how to use this method??

    or

    Do you have any document,

    could you give me some advice??
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Choose a writable mount point (user folder), folder must exist, and run your Application

    
    FILE *fpl;
    fpl=fopen("qq.txt","w");
    fprintf(fpl,"111 %d\n",velocity);
    fclose(fpl);
    

    File qq.txt should reside there.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Choose a writable mount point (user folder), folder must exist, and run your Application

    
    FILE *fpl;
    fpl=fopen("qq.txt","w");
    fprintf(fpl,"111 %d\n",velocity);
    fclose(fpl);
    

    File qq.txt should reside there.

    --- Quote End ---

    Thank you.

    I have to try this code, but it seill doesn't work.

    May I ask some question, Should I have to set up anything in NIOS II or file??

    MY verisonal is NIOS II 9.0v, and I try that code directly.

    I write in my c file of NIOS II, But it doesn't work.

    and I try to Build the *.txt file first.

    It sill doesn't work . Could you help me other advice. Thanks
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Did you activate the host file system?

    right click on project,

    System Library Properties->Software Components->Altera Host Based File System , check "Add this software component"

    After running your program file will be created in chosen mount point.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Did you activate the host file system?

    right click on project,

    System Library Properties->Software Components->Altera Host Based File System , check "Add this software component"

    After running your program file will be created in chosen mount point.

    --- Quote End ---

    I just find the file of Host file system.

    Because my NIOS II IDE is 9.0v

    So, I never used that you said.

    And, may I ask you??

    Do you have any example?

    I try to find the example,but I didn't find that.

    and I try to use the Host file system.

    that open another project file.

    Dose that mean I have to write my c-code to the Host file system file???

    Or, I can build blank project and include the Host file system project or write the Host file into the function?

    And then, call the function in main function?

    Thank you for your help, Thank you.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Just activate Host File System in your project as I explained. After this, your program should work.