Forum Discussion
Altera_Forum
Honored Contributor
9 years agoI thought it is not necessary to open a new thread because this post is problem-related.
To configure my bsp file system:- At the BSP Editor, I enabled the hostfs, leaving the /mnt/host as the default and clicked at the generate button
- After this, I right-clicked my bsp project, went to the Nios option, and perfomed the generate/compile (I don´t remember exactly) command
- And, finnaly I compiled my code with success
# include <stdio.h>
# include <string.h>
int main()
{
char *msg = "hello to file";
FILE *fp;
printf("before fopen...\n"); /* it freezes here */
fp = fopen("/mnt/host/myfile.txt", "w");
printf("after fopen\n");
if(fp != NULL){
printf("inside if...\n");
fprintf(fp, "%s", msg);
fclose(fp);
printf("file closed\n");
}
else printf("Error during opening file\n");
printf("Hello from JTAG CONSOLE Nios II!\n");
return 0;
}
any tip why i only can run via debug and can´t run directly?