Altera_Forum
Honored Contributor
15 years agoRead host PC data using HAL
I've spent the past 8 hours trying to read data from my host Windows PC using a C program running on NIOSII. And finally I found light with that Host File System business! I thought it would be good to share this with you because the settings are not that obvious, and I am sure there are many beginners like me who will struggle to find this on NIOSII SBT 10.1.
So here goes. Go to NIOSII->BSP Editor -> Software Packages -> altera_hostfs and enable it! It will tell you /mnt/host/ as default. Just leave it as such. Then copy your data file (e.g testb.txt) in the folder where the C code is. Next you can insert the following lines in your C code to read the file: FILE* finput; finput = fopen ("/mnt/host/testb.txt", "r"); and then run it in debug mode in NIOSII hardware. OK, now my other question is: How to enter data from the host PC to the NIOS CPU when not in debug mode? Is that possible? Or do I have to copy data first to a memory or sd card available on my development kit and then try to access it from the code?