Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

7.8.1. Host-Based File System

The host-based file system enables programs executing on a target board to read and write files stored on the host computer. The Nios® II SBT for Eclipse transmits file data over the Intel FPGA download cable. Your program accesses the host based file system using the ANSI C standard library I/O functions, such as fopen() and fread(). The host-based file system is a software package which you add to your BSP.

The following features and restrictions apply to the host based file system:

  • The host-based file system makes the Nios® II C/C++ application project directory and its subdirectories available to the HAL file system on the target hardware.
  • The target processor can access any file in the project directory. Be careful not to corrupt project source files.
  • The host-based file system only operates while debugging a project. It cannot be used for run sessions.
  • Host file data travels between host and target serially through the Intel FPGA download cable, and therefore file access time is relatively slow. Depending on your host and target system configurations, it can take several milliseconds per call to the host. For higher performance, use buffered I/O function such as fread() and fwrite(), and increase the buffer size for large files.

You configure the host-based file system using the Nios® II BSP Editor. The host-based file system has one setting: the mount point, which specifies the mount point within the HAL file system. For example, if you name the mount point /mnt/host and the project directory on you host computer is /software/project1, in a HAL-based program, the following code opens the file /software/project1/datafile.dat.:

fopen("/mnt/host/datafile.dat", "r");