Find the answer to your Linux question:
Results 1 to 6 of 6

Thread: Reading sd card

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Reading sd card


    Hi,
    I am working on DM355-leopard board having kernel 2.6.10. Now i am trying to read sd card.
    i copied file.txt in sd card and i gave following command in the application program but i am getting "open:no such directory"
    int fd=open("/dev/mmcblk0/file.txt",O_RDWR);
    so i tried with int fd=open("/dev/mmcblk0",O_RDWR);
    then its reading some nonsence values

    I want to open file .txt how will i do that?? If anyone knows plz help me??

    Thanks

  2. #2
    have you mounted the SD card to a mount point first? e.g.:

    Code:
    mount -t <filesystem> /dev/mmcblk0p1 /mnt/sdcard
    The file located at /dev/mmcblk0 refers to a special block device used by the kernel to allow userland tools to access the drive as a filesystem, i.e., you don't want to be messing with that (unless you know what you are doing).

    If you have it mounted somewhere, then you should be able to access via that mount point, and create files such as /mnt/sdcard/file.txt.

  3. #3
    Thanks atreyu. how we will know which filesystem we want to mount??

  4. $spacer_open
    $spacer_close
  5. #4
    Did you format the card yourself first? If not, it probably came straight from the factory formatted as FAT-something. so try 'vfat' as the filesystem to pass to mount.

  6. #5
    I could mount the card and opened the file.txt ,but i want to copy the files from sd card to some location and want to save some files from nand to sd card.

  7. #6
    uh-huh...so what's the problem? can you do this in a shell? i.e.

    # copy from nand to sd card
    Code:
    cp /tmp/file.txt /mnt/sdcard/file.txt
    # copy from sd card to nand
    Code:
    cp /mnt/sdcard/file.txt /tmp/file2.txt
    or do you mean you want to do this within a C program? If so, I'd have to look up some old code...but if you have a working bit of code, and need help with that, post what you've got so far and specific errors that you are experiencing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •