I used the altera host file system to open a file .mp3,, is this a legal operation or not?
if it is legal then why [[FILE *hostfile =fopen ("/mnt/host/song.mp3","rb");]] return NULL!! can any one tell me the exact syntax to access the file and where exactly should the mp3 file"song.mp3" exist? thanks链接已复制
15 回复数
There is no syntax error when using [FILE *hostfile =fopen ("/mnt/host/song.mp3","rb");]. The reason why it returns NULL is that you have placed your song.mp3 at a wrong place.
Suppose your nios2 project is resided in "D:\altera\nios2\examples\vhdl\niosII_cyclone_1c20\standard\software\mymp3\", then you shall place song.mp3 in this directory. Good luck!I built a new program,which I want to write data from PC to DDR2 SDRAM on the development board via JTAG UART. First ,I do an experiment that read file from PC.
When debug, it give " Cannot open file yuv_data.bin". Where I should put the "yuv_data.bin".My project isn'n inside the path you said. Thank you!I recommend becoming familar with and trying out this example: http://www.alterawiki.com/wiki/host_file_system
If that example fails the next logical step would be to have the software attempt to write a file to the file system and then searching the host for that file (so make it a very unique name).--- Quote Start --- I recommend becoming familar with and trying out this example: http://www.alterawiki.com/wiki/host_file_system If that example fails the next logical step would be to have the software attempt to write a file to the file system and then searching the host for that file (so make it a very unique name). --- Quote End --- I have the same problem but I'm using a Cyclone 3c25 FPGA and I'm not using any CFI , only on-chip memory. I've pasted the txt file I want to communicate via jtag uart with in my project folder but it's till doesnt work. Here's an example of the code: char *msg = “hello world”; FILE *fp; fp = fopen (“/mnt/host/test.txt”, “w”); if (fp) { fprintf(fp, “%s”,msg); fclose (fp); } But it gives me errors such as: Compiling topavalon.c... ../topavalon.c: In function `main': ../topavalon.c:33: error: stray '\147' in program ../topavalon.c:33: error: `hello' undeclared (first use in this function) ../topavalon.c:33: error: (Each undeclared identifier is reported only once ../topavalon.c:33: error: for each function it appears in.) ../topavalon.c:33: error: syntax error before "world" ../topavalon.c:33: error: stray '\148' in program ../topavalon.c:35: error: stray '\147' in program ../topavalon.c:35: error: syntax error before '/' token ../topavalon.c:35: error: stray '\148' in program ../topavalon.c:35: error: stray '\147' in program ../topavalon.c:35: error: stray '\148' in program ../topavalon.c:38: error: stray '\147' in program ../topavalon.c:38: error: syntax error before '%' token ../topavalon.c:38: error: stray '\148' in program ../topavalon.c:73: warning: implicit declaration of function `floor' ../topavalon.c:33: warning: unused variable `msg' make: *** [obj/topavalon.o] Error 1 Build completed in 10.312 seconds The software component (mount point) was added as mnt/host, so what could be the problem? Please help...Thanks
--- Quote Start --- You've pasted code that has had its quotes changed. --- Quote End --- I've also used another example which had some quotes changed: int main() // Load and read back filter coefficients two times { FILE * hostfile = fopen("/mnt/host/hello_hostfs.txt", "w"); char buffer[1024]; while (fgets(buffer, sizeof(buffer), hostfile) != null) { fprintf(stdout, "%s", buffer); } fclose(hostfile); printf("That's all folks\n"); and I get error messages such as: Compiling topavalon.c... ../topavalon.c: In function `main': ../topavalon.c:73: warning: implicit declaration of function `floor' Linking epuisant.elf... obj/topavalon.o(.text+0x24): In function `main': ../topavalon.c:33: undefined reference to `fopen' obj/topavalon.o(.text+0x38):../topavalon.c:35: undefined reference to `fgets' obj/topavalon.o(.text+0x64):../topavalon.c:39: undefined reference to `fclose' collect2: ld returned 1 exit status make: *** [epuisant.elf] Error 1 Build completed in 14.0 seconds The only things I've changed in the code ist that I want to read data from a txt file, coz the original code was a C one. I've inserted a the hello_hostfs.txt in the project folder and have the mount name mnt/host. So what could be the problem? Thanks
--- Quote Start --- Are you remembering to include hostFS in your BSP as well as running your code using the debug channel? --- Quote End --- Yes ,I forgot it and it was OK. Now I meet new difficulty. When I read data from file on PC and write to on_chip memory ,it is well. And in normal mode ,large datas of writing and reading DDR2 is OK. But when read data from file on PC and write to DDR2, it is unstable. First time it maybe right, second maybe wrong. And sometimes may give errors as following, "Processor failed to go into debug mode when requested","m_state == STATE_DEBUG" failed: file "nios2debug.cpp" Can you give me some advices? Tahnk you!
thanks for ur fast answer ..
1. but doesn't this only work in debug mode ..? i need to transfer the image to onchip .. and when its done let my own verilog modules handle the processing .. 2. is this correct? void* ptr = (void*) On_chip_base_address then i use fread to write to on_chip? i am new to this, could you please share some code which handles reading /writing?Thanks .. :)
but it seems that my code seems stuck at fopen for no obvious reason .. the host file based system is enabled .. the file is "/mnt/host/filename.bmp" and placed in the same directory as the main c file .. in debug .. fp always returns null