FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
5890 Discussions

NIOS : fopen command only works if using the NIOSII Debug tool

VCham
New Contributor I
454 Views

I am trying to read a file using NIOS with the eventual goal of loading that readdata into an EEPROM.

 

I have followed the instructions outlined in : https://www.intel.com/content/www/us/en/programmable/documentation/mwh1416947091611.html

 

I have gone to the BSP editor -> Software Packages and enabled altera_hostfs. The hostfs_name is /mnt/host

 

My code (included below) gets stuck at fopen but if I use the NIOSII debugger, I am able to step through the whole program and readout "Hello World" into the console. Any suggestions would be appreciated.

 

#include <stdio.h>

#include <alt_types.h>

#include <io.h>

#include <string.h>

#include <stdlib.h>

#include <unistd.h>

#define BUF_SIZE (12)

void main()

{

FILE* fp;

char buffer[BUF_SIZE];

 

printf("start\n");

fp = fopen("/mnt/host/read_test.txt", "r");

printf("fopen command\n");

if (fp == NULL)

{

printf ("connot open file for reading\n");

exit(1);

}

fread(buffer, BUF_SIZE, 1, fp);

fclose(fp);

printf("%s", buffer);

}

0 Kudos
3 Replies
Ahmed_H_Intel1
Employee
198 Views

Hi,

I see the following reference is useful for you, please let me know if it isn't useful:

https://fpgacloud.intel.com/devstore/platform/18.0.0/Standard/generic-serial-flash-interface-intel-f...

BTW, please make sure you flush the cash to be able to see the output.

Regards,

 

VCham
New Contributor I
198 Views

It was confirmed by an FAE that fopen will only work while using the Debug tool.

 

Thanks anyway.

Ahmed_H_Intel1
Employee
198 Views

Thanks Valentina for your confirmation, Please let me know if you need help.

Reply