Embedded Design Handbook

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

4.2.3.3.5. Files and File Systems

The HAL provides two simple file systems and an API for dealing with file data. The HAL uses the GNU newlib library's file access routines, found in file.h, to provide access to files. In addition, the HAL provides the following file systems:

  • Host-based file system—Enables a Nios® II system to access the host workstation's file system
  • Read-only zip file system—Enables simple access to preconfigured data in the Nios® II system memory

Several more conventional file systems that support both read and write operations are available through third-party vendors. For up-to-date information about the file system solutions available for the Nios® II processor, visit the Nios II Processor page of the Intel website, and look for Intel FPGA Embedded Alliance.

To make either of these software packages visible to your application, you must enable it in the BSP. You can enable a software package either in the BSP Editor, or from the command line. The names that specify the host-based file system and read-only zip file system packages are altera_hostfs and altera_ro_zipfs, respectively.

The Host-Based File System

The host-based file system enables the Nios® II system to manipulate files on a workstation through a JTAG connection. The API is a transparent way to access data files. The system does not require a physical block device.

Consider the following points about the host-based file system before you use it:

  • Communication speed—Reading and writing large files to the Nios® II system using this file system is slow.
  • Debug use mode—The host-based file system is only available during debug sessions from the Nios® II debug perspective. Therefore, you should use the host-based file system only during system debugging and prototyping operations.
  • Incompatibility with direct drivers—The host-based file system only works if the HAL BSP library is configured with direct driver mode disabled. However, enabling this mode reduces the size of the application image. For more information, refer to “Software Application Optimization”.

For more information about the host file system, refer to “Using File Subsystems” in the Developing Programs Using the Hardware Abstraction Layer chapter of the Nios® II Gen2 Software Developer’s Handbook.

Read-Only Zip File System

The read-only zip file system is a lightweight file system for the Nios® II processor, targeting flash memory.

Consider the following points about the read-only zip file system before you use it:

  • Read-Only—The read-only zip file system does not implement writes to the file system.
  • Configuring the file system—To create the read-only zip file system you must create a binary file on your workstation and use the Nios® II flash programmer utility to program it in the Nios® II system.
  • Incompatibility with direct drivers—The read-only zip file system only works if the HAL BSP library is configured with direct driver mode disabled. However, enabling this mode reduces the size of the application image. For more information, refer to “Software Application Optimization”.

For more information, refer to the Read-Only Zip File System and Developing Programs Using the Hardware Abstraction Layer chapters of the Nios® II Gen2 Software Developer's Handbook. Also the read-only zip file system Nios® II software example design listed in “ Nios® II Design Example Scripts” in the Nios® II Software Build Tools Reference chapter of the Nios® II Gen2 Software Developer’s Handbook.