Hi.I'm wondering if is possible to read contents from a text file in a NIOS2 software, either downloading that file to a SDRAM, or reading it from the hard disk via JTAG. is that possible?? Or I'm just crazy?? Thanks a lot.
You are not crazy.you can not read text file unless your board has storage and file-system. Depends on what you want, you can do same thing. Such as, to write data into FLASH memory including EEPROM. You can read and write to flash as memory but not like text file as FAT-file system.
If you have installed the Altera Zip Read Only File System the normal read operations for stream io (fscant, fget...) will work normaly.One of my applications reads so some configuration files. Writing is of course not possible on this system.
Another alternative is to use host file system (HostFS). You have to run the debugger for it to work. It allows you to read/write/modify files located on your host machine from your application code running on Nios II. Search for "host file system" on altera.com or alterawiki.com (I forget where it lives now) to learn more.
If you are doing a real project, then you need to decide how the file will get onto the target system. If you are going to include it in the code/data image the just arrange for it to a data block and access as an array.You can convert a text/binary file to an object file using 'objcopy', I think you need:
objcopy -I binary -O nios2 -B nios2 mydata.txt mydata.oYou might want to add:
--rename-section .data=.rodata.mydata,alloc,load,readonly,data,contentsI use this to insert the code and data of by nios program into the data area of the ppc program that loads and interfaces with it. The ppc program is also linked with the symbol table of the nios program. This removes all the problems of mismatched versions!
HiI record a tutorial on how to mount text file using NIOS II Processor and hostfs feature which enables us to mount files (such as text file) and perform read and write operation on that file http://youtu.be/kbicxwtfbiy