Forum Discussion

WUnkn's avatar
WUnkn
Icon for New Contributor rankNew Contributor
5 years ago

NIOS2 Host File System not Working

Hi all, please see my code below, I have hostfs enabled in BSP


#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include "system.h"
#include "alt_types.h"


int main ()
{
printf ("HOSTFS step1\n");

FILE *fp;

fp = fopen ("/mnt/host/readme.txt", "a");

printf ("HOSTFS step2\n");

if (fp == NULL)
{
printf ("HOSTFS failed\n");
while (1);
}
else
{
fclose (fp);
printf ("HOSTFS OK\n");
}

return 0;
}

When execute my code on DE10_LITE board, I could only see HOSTFS step1

readme.txt is a very small ASCII file

Any idea it would not fopen readme.txt?

Thank u

6 Replies

  • Hi @WUnkn,

    Thank you for posting and sharing the finding in Intel community forum, hope this message find you well and apologies for the delayed in response.
    If I understand the situation correctly, you would like to read from the 'readme.txt', please try changing the second param for the fopen to r as below and see if it works:
    fp = fopen ("/mnt/host/readme.txt", "r");

    Please do let us know if that helps.

    Best Wishes
    BB

    • BoonBengT_Altera's avatar
      BoonBengT_Altera
      Icon for Moderator rankModerator

      Hi @WUnkn,

      Good day, just checking in to see if there is any further doubts in regards to this matter.
      Please do let us know.

      Best Wishes
      BB

      • BoonBengT_Altera's avatar
        BoonBengT_Altera
        Icon for Moderator rankModerator

        Hi @WUnkn,

        Hope this message find you well and good day, unfortunately as we do not receive any response from you to the previous clarification that we have provided. This thread will now be transitioned to community support. If you have new queries, please feel free to open a new thread to get support from Intel experts. Otherwise, the community users will further help you with doubts in this thread.

        Best Wishes
        BB

  • Hi @WUnkn,

    Hope you are well, glad that you are back with us.
    Quick check did you managed to try on the previous suggestion?
    Please do let us know if there is any further clarification/doubts/issues on the previous steps so that we can better understand the situation.

    Best Wishes
    BB

  • Hi @WUnkn,

    Unfortunately as we still do not receive any response from you to the previous clarification that we have provided, hence would assume problem are closed. With that we will now be transitioned to community support. If you have new queries, please feel free to open a new thread to get support from Intel experts. Otherwise, the community users will further help you with doubts in this thread.

    Best Wishes
    BB