- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I'm running uClinux (noMMU) on DE0 Nano. I'm trying to create a file and write to it via a C program. Example code: int main(void) { FILE * fp; fp = fopen("test.txt","w+"); . . } As soon as I run this the OS hangs. If I add a printf after the FILE * fp; command, nothing is printed. The OS hangs at the file declaration. Any ideas?Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That can't be. Most likely fopen is dead-locked and preventing the stdout from flushing out the printf. Try doing a fflush (stdout) after the printf and before the fopen. I am assuming that main is getting called and that if the fopen call is not there, you do see the printf output.
If the fopen is hanging, something must be wrong with the device it is trying to access. I am not too familiar with the uClinux/DE0 setup combination.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I was going to try your suggestions but first thought I would remove ALL other code in the program. It worked!! Beginner mistake. I'll have to start adding my code and see where the train comes off the tracks. If it is relevant to this post I'll report back. Thanks for your reply.
BTW, for other readers, the following code creates a text file and opens it for editing... int main(void) { FILE * fp; fp = fopen("/bin/test_data.txt","w+"); //your code here fclose(fp); }
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page