Thread: C program under Debian Linux and USB drive

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    4,156

    C program under Debian Linux and USB drive

    I am going to start an embedded C project under Debian Linux in the near future.
    And, I am thinking of trying to use an USB drive to store data.

    What should I use as the size of buffer to save the data from memory to a file on the USB drive?

    Is there a way to query the USB drive to get the size?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,328
    > I am going to start an embedded C project under Debian Linux in the near future.
    Sounds like a regular project to me - if you mean the target runs Debian.

    Or are you developing using Debian, and the target is bare metal (or an RTOS).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,156
    BeagleBoard.org - bone

    Beaglebone Black Industrial running Linux Debian unknown version.

    Edit2: I am just starting and the Debian version is working on being updated; not sure if I will wait till after the upgrade or use the current version.

    Tim S.
    Last edited by stahta01; 05-16-2022 at 12:31 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    4,623
    What should I use as the size of buffer to save the data from memory to a file on the USB drive?
    IMO, this depends on the type of data being collected. But I would say that for a single "chunk" somewhere around 256 mb would probably be a good starting place since your board only has 512 mb of memory for both the OS and your program.

    Is there a way to query the USB drive to get the size?
    You could start by simply piping the results of "df" (disk free) to your program or a file. And don't forget that you have a 4gb EEMC memory "card" built into the hardware.

    I am just starting and the Debian version is working on being updated; not sure if I will wait till after the upgrade or use the current version.
    I doubt that the actual version will make much difference, and you should be able to upgrade the OS after you obtain the hardware.

  5. #5
    Registered User
    Join Date
    Feb 2019
    Posts
    1,017
    Use 'statvfs' syscall.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,156
    Thank you for the responses; I hope to start work on the project in the near future. I will likely learn enough to ask more questions.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Embedded Debian Linux: Use cross or native compiler?
    By stahta01 in forum Linux Programming
    Replies: 5
    Last Post: 12-08-2021, 12:21 AM
  2. Debian Linux install from a 4Gb USB stick
    By mynickmynick in forum Linux Programming
    Replies: 4
    Last Post: 12-02-2008, 03:54 PM
  3. Rebuilding Debian AMD64 with ACPI/APM support, Debian DRI on XFree86
    By kawk in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 06-02-2006, 01:36 PM
  4. installing debian linux
    By X PaYnE X in forum Tech Board
    Replies: 2
    Last Post: 05-10-2005, 04:43 AM
  5. Linux - Second Hard Drive
    By MethodMan in forum Tech Board
    Replies: 5
    Last Post: 12-22-2002, 02:46 AM

Tags for this Thread