Results 1 to 6 of 6
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 ...
- 01-18-2012 #1Just Joined!
- Join Date
- Nov 2011
- Posts
- 62
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
- 01-18-2012 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,818
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).Code: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.
- 01-18-2012 #3Just Joined!
- Join Date
- Nov 2011
- Posts
- 62
Thanks atreyu. how we will know which filesystem we want to mount??
- 01-18-2012 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,818
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.
- 01-19-2012 #5Just Joined!
- Join Date
- Nov 2011
- Posts
- 62
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.
- 01-19-2012 #6Linux Guru
- Join Date
- May 2011
- Posts
- 1,818
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 nandCode: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.Code:cp /mnt/sdcard/file.txt /tmp/file2.txt


Reply With Quote
