LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 12-14-2009, 04:50 AM   #1
jcornuz
LQ Newbie
 
Registered: Dec 2009
Location: Switzerland
Distribution: Ubuntu
Posts: 2

Rep: Reputation: 0
Write data stream to SD-Card


My device receives a data stream. I want to write a C program to save this data stream to many files in a SD-Card. The SD-Card is formatted in FAT32 for a compatibility reason. I want to write full page of memory to aim to improve the write efficiency and get longer life of the SD-Card. Is it possible to lock the synchronization between the cache buffer and the storage device until the buffer is as long as the page size ? In other word, flush only full page of data ? Or I have to format the SD-Card to JFFS2 or YAFFS ?

Regards
 
Old 12-15-2009, 03:33 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,297

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Welcome to LQ. If you're writing C, that ought do be doable in your program. If you have to ask, you've failed the exam :-P. The system has it's own mind on matters, and doing that through the system is not on.
 
Old 12-15-2009, 07:24 AM   #3
jcornuz
LQ Newbie
 
Registered: Dec 2009
Location: Switzerland
Distribution: Ubuntu
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for your quick answer.

Yes, I'm writing in C. That was actually my idea to store temporary the data stream in a buffer, and when I have enough data (one page size), write them in the SD-Card :
write (fd, buffer, PAGE_SIZE);

But I was wondering if the OS really flushes the data in one time from the virtual memory to the hardware.

Maybe a other method it to map the memory :
mem = mmap (0, PAGE_SIZE, PROT_WRITE, MAP_SHARED, PAGE_SIZE * pageCounter);
memcpy (mem, buffer, PAGE_SIZE);
munmap (mem, PAGE_SIZE);

But again, my question is the same, does the OS flush in one time from the virtual memory to the hardware ? I hope so with the MAP_SHARED flag.
 
Old 12-16-2009, 03:16 AM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,297

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
If you're writing C make sure to install the info pages from your distro, as they have entries for the various function calls. There is a HOWTO and several guides on programming for linux. People will expect you to have a knowledge of that stuff before you start asking. I will bow out here, as C is not hugely my thing.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
on what should lzw be implemented----GdkPixdata *pixdata or a c source data stream?? sumitshining Programming 0 11-07-2008 07:12 AM
Bash, netcat, redirection and data extraction from stream d1s4st3r Programming 2 11-06-2008 08:51 AM
Read/Write data to SD card physical address by USB Reader in Fedora 7 yuanlaidewo Linux - Newbie 0 07-14-2008 10:18 PM
Sending data to a process along an already open stream. navaburo Linux - Networking 1 03-18-2007 06:51 PM
mplex errors (Stream e0: data will arrive too late) BrianW Linux - Software 0 04-02-2006 01:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 08:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration