Reading sectors from SD Memory?

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
The "Invalid Sector" would be an OS message, like the card isn't responding correctly.
Yep that would be my guess too. But since I am reading it with my Pic, it has to be stored on the SD chip somewhere correct? I mean on on earth could the SD chip generate those messages? My Pic software that reads the SD certainly is not doing it.

What I am trying to find is a one for one. I has hoping to find Invalid whatever using the card reader to make sure I am reading the sector is what I think I am reading. For example, if I found some kind of signature with the Pic like "Invalid" found on sector zero but found "Invalid" on sector 10 using the hexeditor on my pc, it probably means I am not reading the sectors correctly.


What I find strange is I have yet to find FAT32 on my SD chip using the Pic but I can see it with the HexEditor on the PC.

What I think you are supposed to do is to take the sector # and multiple by 512 and use that to read the SD Sector. Though I am still not 100% sure of that. I might try not multiplying and see what results I get.

But you would think I would at least be reading sector 0 the same.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
The "Invalid Sector" would be an OS message, like the card isn't responding correctly.

I'd try another card, $5, I'd also try a different card reader, that's one common thing that hasn't changed either.
I have tried like 4 different SD chips now and get different results from each.


This is just insane.
 

thatoneguy

Joined Feb 19, 2009
6,359
Then try a new reader, and if you still get the problem, you have plenty of documentation for a Microchip call.

Oh, try em both on a different computer too, preferably winXP

Was "Accelleration" or "Compression" for the disk enabled when you formatted it?
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Then try a new reader, and if you still get the problem, you have plenty of documentation for a Microchip call.

Oh, try em both on a different computer too, preferably winXP

Was "Accelleration" or "Compression" for the disk enabled when you formatted it?
I think you might misunderstand. I am getting the same results with the HexEditor.

Different results with reading it with my Pic.

Compression was not on when I formatted it.


Not sure I understand, what does this mean? "you have plenty of documentation for a Microchip call"
 

thatoneguy

Joined Feb 19, 2009
6,359
Open a Ticket under support on Microchip.com

Post all the documentation you can.

The phone thing I think is corporate that I don't pay for and it probably isn't cheap, mostly find out errata anyway.
 

davebee

Joined Oct 22, 2008
540
Messages like "Invalid partition table Error loading operating " are normal messages stored in sector 0 which are left over from when the FAT sector 0 was used to boot a computer.

Type them into Google and you'll find plenty of references, such as -

http://bootmaster.filerecovery.biz/appnote4.html

If you're seeing messages like that then I think you're coming very close to success in reading raw sectors from the SD card.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Messages like "Invalid partition table Error loading operating " are normal messages stored in sector 0 which are left over from when the FAT sector 0 was used to boot a computer.

Type them into Google and you'll find plenty of references, such as -

http://bootmaster.filerecovery.biz/appnote4.html

If you're seeing messages like that then I think you're coming very close to success in reading raw sectors from the SD card.
Yep kind of what I expected. But I have an HexEditor software for my PC, I plug the SD into a SD USB reader and plug that into the PC. Browse sector zero and I am NOT seeing those messages. But I am seeing things like FAT32 which I don't see in sector 0 when using the Pic.


So you can understand my confusion. :)
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Open a Ticket under support on Microchip.com

Post all the documentation you can.

The phone thing I think is corporate that I don't pay for and it probably isn't cheap, mostly find out errata anyway.
Not sure what I would send the ticket about. I am not using their library. I could not even get close to get it to work. It initializes the SD too slowly and it fails. I can simulate the failure it in my own code.

The code always bit bangs SPI even though the comments might suggest otherwise, when you get into the code, you can see if you have a 18F chip it uses bit bang no matter what. The comments say it only bit bangs for 18Fs with fast clocks but that is not true.

I have not dug into the FAT stuff but the raw operations on the SD chips are horribly inefficient. They have duplicate code just to read / write at different speeds when simply changing the speed of transmission would be far more efficient.

I might still try and fix their code so it will use the SPI port on my chip instead of bit bang but I am not sure that will get me anywhere.

I contacted the seller of the QL200 and he tells me they do have an example for SD chips. I am trying to see if he can sell me a PIC16F877A that it is built for and maybe a SD chip he knows that works. It would be nice to eliminate any possible error.
 

thatoneguy

Joined Feb 19, 2009
6,359
Are you still having the problem of bits being replaced in bytes ending in 101 and 110 (I forgot which one sequence)?

That alone would be a ticket open, though try it with a formatted SD card that is "known good", see if it works, then add your code, if it breaks, it's something on your system. Perhaps your LIB path has CCS or Hi-Tech for searching for library names before C18? Go to computer, then environment to check.

Or, at a command line do:
<drive>:\ set

look at all the paths and make sure your compiler is first in the environment settings, it may be grabbing a correctly named but not functional enough library from a different compiler, or an older version of yours.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
What would the path of the compiler have to do with it?

Remember I was getting $0F and $04 every 7th and 8th byte from the SD chip and I was able to confirm it with my logic analyzer. So it is the output of the SD memory chip and not the compiler.
 

thatoneguy

Joined Feb 19, 2009
6,359
What would the path of the compiler have to do with it?

Remember I was getting $0F and $04 every 7th and 8th byte from the SD chip and I was able to confirm it with my logic analyzer. So it is the output of the SD memory chip and not the compiler.
Are you still getting the $0F and $04 errors?

The reason I ask about the compiler, is if you had an old or faulty SPI library that is used, but I guess if you are in MPLAB, you specify that, so never mind. Old dev libs is an issue on some *nix systems and windows programming stuff, it was a passing thought.
 
Top