Reading sd card
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"
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??
have you mounted the SD card to a mount point first? e.g.:
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).
mount -t <filesystem> /dev/mmcblk0p1 /mnt/sdcard
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.
Thanks atreyu. how we will know which filesystem we want to mount??
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.
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.
uh-huh...so what's the problem? can you do this in a shell? i.e.
# copy from nand to sd card
# copy from sd card to nand
cp /tmp/file.txt /mnt/sdcard/file.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.
cp /mnt/sdcard/file.txt /tmp/file2.txt