FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Read host PC data using HAL

Altera_Forum
Honored Contributor II
929 Views

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?
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
117 Views

It may not possible to send file to CPU if it is not in the debug mode. 

Just because this method is using gdb. 

 

This function only available when you use the debug mode.
Altera_Forum
Honored Contributor II
117 Views

 

--- Quote Start ---  

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? 

--- Quote End ---  

 

 

Hi 

 

I have a problem with the fopen, fclose, getc commands when I build my project, but I followed your instructions. Do you know what could be the problem? Did you have "small_c_library" enabled? 

 

Please help, i'm so desperate....
Reply