PDA

View Full Version : How to find the address of stored data on a SD memory card?



Byte_Butcher
- 24th February 2010, 18:03
I've got a 2GB SD memory card that's formatted for FAT16, and I've put some data on it (just drag 'n' drop from windows) and now I need to read it back with my "device".
The catch is, I can't look up the data by filename... I need to know the physical memory address to retrieve the goods.

Is there an easy way (some kind of cute little utility?) that will tell me the starting addresses of the data items on my card?


Thanks!

steve

mackrackit
- 24th February 2010, 18:25
If you are using SDFS from MeLabs here is a snippet that might help.


SDOPEN_W:
' Open a file for write
FAT_mode = "A" ' Write mode
Gosub FSfopen ' Open file pointed to by Byte array FAT_FileName

Serout2 PORTC.6, 16572, ["Open for write Error: ", Dec FAT_error, $d, $a]

Serout2 PORTC.6, 16572, [ "FILE NAME ", STR FAT_FileName\11, $d, $a]
Serout2 PORTC.6, 16572, [ "DISK_fat ", Dec DISK_fat, $d, $a]
Serout2 PORTC.6, 16572, [ "DISK_buffer ", Dec DISK_buffer, $d, $a]
Serout2 PORTC.6, 16572, [ "SDC_sector_addr ", Dec SDC_sector_addr, $d, $a]
Serout2 PORTC.6, 16572, [ "FAT_ccls ", Dec FAT_ccls, $d, $a]
Serout2 PORTC.6, 16572, [ "LAST_CLUSTER ", Dec LAST_CLUSTER, $d, $a]
Serout2 PORTC.6, 16572, [ "FAT_c ", Dec FAT_c, $d, $a]
Serout2 PORTC.6, 16572, [ "DISK_maxcls: ", Dec DISK_maxcls, $d, $a]

Byte_Butcher
- 24th February 2010, 18:51
If you are using SDFS from MeLabs here is a snippet that might help.

Errr... welll... no... I'm not using SDFS. In fact I had to do a search just now to find out what the heck you're talking about. :o

But I've downloaded the files and have the SDReadme.txt open in front of me now and it looks like this is going to be very helpful for me. :)

It looks like I've got some reading to do... will be back later with more questions I'm sure.


Thanks Dave!!

steve

mackrackit
- 24th February 2010, 18:59
If you want to get into FAT32???
http://www.picbasic.co.uk/forum/showthread.php?t=11700
The new link to the file is near the end of the thread..

Byte_Butcher
- 25th February 2010, 02:43
Thanks Dave, but I can't use FAT32. The SD card lives inside another device that doesn't play FAT32.

Still researching my options....


steve

mackrackit
- 25th February 2010, 04:56
The origional SDFS is FAT16.
A cool thing about the SDFS32 is if you build your own card reader thingy it will be able to read or write to either one. It detects the format for you.

rsocor01
- 3rd March 2010, 20:26
mackrackit,

I have been trying to figure out for a while how to send FAT16 or FAT32 files to a SD memory card like Byte_Butcher is trying to do. But using SDFS seems to do the job. Thank you for your help. I also didn't have any idea what SDFS is for.

The file SDReadme.txt shows a serial connection between the MCU and the PC computer. Now my question for you, can this serial connection be replaced by a USB connection by using for example a PIC18F4550? Have anybody achieved this SDFS with a USB connection? Thank you all for your help.

Robert

mackrackit
- 3rd March 2010, 20:54
All the serial connection is for is dubugging/monitor want is going on. Once you are happy with the setup all of those lines can be deleted.

USB... I have not played with USB but I do not see why you could not use it for debugging if the PC has a terminal that will work with it.

rsocor01
- 4th March 2010, 13:07
Thank you mackrackit for your response.

Yes, I guess USB can be used for dubugging and monitor what is going on with the MCU. But, what I really had in mind was to be able to see the information in the SD card through a USB connection as a thumbdrive. This might be a challenging project for me, but like everybody else in this forum I am up to the challenge! :D

Robert

mackrackit
- 4th March 2010, 14:11
Thank you mackrackit for your response.

Yes, I guess USB can be used for dubugging and monitor what is going on with the MCU. But, what I really had in mind was to be able to see the information in the SD card through a USB connection as a thumbdrive. This might be a challenging project for me, but like everybody else in this forum I am up to the challenge! :D

Robert
That would be an interesting project. Probably make you pull your hair out though...
I go to walmart and get a SD/USB reader for less than $10. Saves my hair :)

Byte_Butcher
- 4th March 2010, 15:34
Yep. For $10 you get a 2GB SD card, 2 "othersize adapters", and a USB adapter for the card. (and a little plastic carrying case, not shown)

No hair pulling at all. Just stick the card in the adapter, shove it in yer USB slot and copy files to and from...


steve


http://www.weirdstuffwemake.com/sweetwatergems/geek/images/sd_stuff_025.jpg

rsocor01
- 4th March 2010, 20:25
Well, what I have been working on is a data logging project that loads the data into a SD card. In this project, the user can interface with the system using a graphic LCD display and data is constantly loaded into the 2GB card. So, I thought that instead of having to remove the SD card all the time to be able to read its contents, it would be very nice been able to read the SD card using a USB connection and read the whole thing like a thumbdrive. There are many devices out there in the market that perform a similar function, like for example your photo camera.

An easy way to achieve this seems to be using the FTDI Vinculum VDIP1 modules. BrianT explains how to set this chip up in the next thread.

http://www.picbasic.co.uk/forum/showthread.php?t=7700

I've just been trying to stay away from adding more chips to my circuit but probably the FTDI Vinculum is the best way to go for the project that I am working on. At least, it seems to be the easiest way. :confused:

Robert

mackrackit
- 4th March 2010, 21:20
Yes, SDFS can be used for reading a file and send that info out. It can be done serially so if you know how to use USB then it shoulf also work with that.

In my opinion for data logging stay away from the VDIP stuff and use a SD card.
I spent more time trying to use the VDIP than I did learning to use SDFS.

So, in the SDFS docs look at SDFS_READ command.