Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

File access in uCLinux on NIOS II

I have sort of an elementary question. If I build a program that runs on uCLinux which is running on NIOS II, how can use file I/O? I mean where should the file be stored so it can be accessed at run-time? Obviously, you have to specify the path to the file in the source code or get in from the user at run-time, but how do I get the file to the FPGA, and where should it be stored?

Thank you.

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    regarding user space, NIOS Linux is not different from any other Linux, so you can consult any Linux literature available on this.

    A nice booting strategy for Linux NIOS (I suppose it's the default in the distr) is to use the INITRAMFS and just keep it up. With that, when starting, the Kernel creates a RAM based file system and initializes it from a compressed data stream that is stored within the Kernel-executable (and freed when not needed any more). Thus the booting strategy is just loading the Kernel-executable int RAM and start it.

    The distr provides means to create files in the INITRAMFS when designing the Kernel. The "vendor" directory is used to hold definitions for that, you might want to create your own subdirectory within "vendor" for your purposes.

    As INITRAMFS can be written to at runtime, you in many cases don't need another file system. If you want to store data permanently, you should use an additional FLASH based file system such as JFFS2.

    -Michael
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Is there a tutorial showing how to use INITRAMFS for linux nios2?

    EDIT: Can I simply copy over the files from the NIOS II command line?