JustusJohnston
Newbie
- Joined
- Jun 22, 2023
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 125
55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 55 aa
55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 55 aa
49 e2 6a a9 21 76 51 fe d2 81 1f 60 1f 7b b1 bc
6c 10 1a 7f 39 05 f5 8b 0b c8 ef 3e 9b 41 7d d9
64 d3 78 77 59 5a d5 d5 1d 4f 82 65 b8 93 c4 fc
41 e2 e2 d0 41 d6 bc c8 9c b9 be 42 e0 2e 9b 54
dd e8 52 4e a5 ea 83 47 04 3e 98 68 9a c4 98 28
76 50 0d 58 ae a3 85 e7 3f 2d 76 a7 02 db 47 1a
fc ce 2c 54 15 98 fe 69 eb 72 ff ff a5 58 57 56
fc 72 a1 56 c9 8d 3b 54 64 5f 8d ff 71 3b fe 4d
bd 7b d1 e7 2f ff a3 ad 33 e1 4e 44 da 56 55 47
dd 30 b4 fc be 61 1c 12 a2 2c e0 da eb d7 41 3d
20 73 cd bc b0 f5 89 e2 12 3a ae ec 53 34 87 43
3b ed 0a e2 ce ab bf eb 24 15 18 7a ab d3 ed 90
23 91 4b 62 a6 dd 7g 42 a2 97 f4 ab c7 59 b8 85
a0 b0 cd 64 c6 15 a6 82 5c f1 b8 4d f1 88 91 43
b9 25 17 01 22 2c 3b 85 40 f9 ca c9 95 d3 41 4c
94 e3 e4 e2 c9 ec 1a 89 0c e2 bd 61 f2 02 0e e9
e2 be 63 e2 27 13 93 8c 4e b7 58 55 a5 c2 a3 58
d2 ea 53 b8 b1 72 94 45 15 d1 50 6a 1d 3c 71 32
e2 98 19 59 45 8f bf 1e 6e ae 1d bc da 4c 24 19
f2 f0 9c 7d bf 9a 29 d3 73 33 05 19 62 bb 54 1e
74 fe bc d4 a4 05 b2 fa 2d 99 38 76 2f a4 ad f2
51 6b 39 e2 b5 b6 40 4b 38 12 6d 65 23 16 2d 15
02 78 b5 7c 61 35 55 19 55 0e 4a 99 a3 7f d6 b4
4b 06 53 63 f1 29 a0 03 33 1c fd 7f 87 d4 c6 90
0e c2 8c 3b 9a 8b d9 fc b6 a6 e2 53 40 45 32 df
ce 77 0b 5f a0 0d 5c bf c5 0c b5 ee 39 7e c8 0d
26 e9 87 67 7a 57 a3 b1 5b 40 46 92 c6 ee 1a 6b
70 88 f0 0a 27 33 45 0n 1e 0a 64 62 cb ed 47 e3
6a 1b 7c 3a 2e c6 54 97 15 a7 80 d9 c7 7b f6 af
fd 31 7c ca 85 e3 93 9a 5d 97 3b 19 dc b9 44 be
CRC16: b3 3b
As no one else has replied to you I thought that I would have a go at sorting out your problem. I think that your problem is due to the address that you are sending to the SD card being 512 times the sector number you want to read. There are various SD card standards notably in this case version 1 and version 2 you should read and understand both versions. The standard version 1 normally applies to SD cards less than 2GB and version 2 to SD cards greater than 2GB, 2GB cards are normally version 2 but they could be version 1.
The SD card version that you have written the software for is for version 1 SD cards. to test if the SD card is version 1 or 2 you should issue a command 8 and if you get an illegal command then the SD card is version 1 and if you get a valid response then it is version 2. If you were to try your software with a small SD card (much less than 2GB) then I think your software will work.
CMD16 is not needed in either case as 512 is the default sector size and for version 2 SD cards the sector size must be 512 bytes. The address sent to the SD card for version 1 cards must have the bottom 9 bits set to zero whereas for version 2 SD cards the address starts at bit zero.
The CRC is not required for commands apart from cmd0, and cmd8 and it is recommended to include the CRC for the encryption commands.
As your SD card does not give an illegal command response to a CMD8 instruction then it is a version 2 SD card and the change sector size will not work which is why you are getting an error with CMD17, even if you have a version 1 SD card in which you can change the sector size it is not recommended that you do so for various reasons.First off, thank you for taking the time and effort to read through my problem, think it through, and give a response. I really appreciate it! It sounds like you have some relevant experience to share, as well.
So, if I'm understanding you correctly, if it's "version 2" then address should be block address and not byte address then? I'm pretty sure my card is in fact version 2 because I am sending the CMD8 as part of my initialization, and it is giving a valid R1 (a 0x01 when done before ACMD41 and an 0x00 when done after, I've tried it both ways).
While testing, I have for the most part just tried to read at address 0, but I have tried a few others too. I will note that I get an error on CMD17's R1 when I send an address that isn't a multiple of 0x200 (512 decimal), which leads me to believe that the addressing is in fact byte addressing, not block addressing, for this card. On the FPGA design when I send a (valid) address of any kind, the response is ALWAYS the bytes from my first post, regardless of the address sent. On the uP implementation however, address 0 returns exactly what I expect, which is four hundred something bytes of 0s (as the card is not formatted bootable with bootstrap code), a single 16-byte partition record, and the 0x55 0xAA signature.
Something else I tried just for fun was setting the block size to 2 bytes, since after all I ultimately want to just read one 16-bit audio sample at a time in the end. The card will let me do it, and will then let me try to read addresses that are multiples of 2 with CMD17, which indeed will only return 2 bytes, and those bytes are always 0x55 0xAA, the first two bytes from my first post, no matter what address I use.
I'll also note that since my previous post, I have changed my FPGA design to mimic the CMD sequence I saw from the uP implementation, including the CRC, but sadly, I'm still getting the same mysterious data back. The only difference in the electrical signals being generated are now just a few of the dummy bytes and the uP's clock stretching.
I hadn't thought this significant until just now, but I am using a different microSD breakout board with the FPGA than I am with the uP. I'd normally dismiss worrying about that out of hand, since the boards both LOOK like they just break the card pins straight out with just some current limiting resistors and decoupling capacitors added. But just now I looked up the page for the board I'm using with the FPGA (can't seem to share links, but it's the micro SD breakout from SB components)
and it has some odd bullet points that claim things like "4 bit ADPCM format support" and "FAT file system SD carrier support". That's probably just marketing nonsense, right? They wouldn't have hid some processor under the card socket that's futzing around with the data...right? This issue's made me so crazy I think I need to try swapping out the breakouts, ha ha!
Also, I like your suggestion of trying a smaller card. I'll have to see if I can get a hold of a few. Looks like 128 MB cards are decently available. Is that a good size to try?
Hi,
The problem with your posts is they are too lenghty.
Better focus on one item, post schematic, draft, diagrams, photos...
Klaus
I’m not actually getting an error with the CMD17. The R1 response is 0x00. In fact, great news: I have actually solved my mystery!As your SD card does not give an illegal command response to a CMD8 instruction then it is a version 2 SD card and the change sector size will not work which is why you are getting an error with CMD17, even if you have a version 1 SD card in which you can change the sector size it is not recommended that you do so for various reasons.
As it is a version 2 card then when you set the sector to read with CMD17 the address should start at bit 0, for a version 1 card the address starts at bit 10 with the bottom 9 bits being set to zero.
Another gotcha that you should be aware of is that different manufacturers implement the SD card standard in slightly different ways, some manufacturers require no pause between instructions whereas others require an 8-clock period dummy read between instructions. The solution is to always have an 8-clock dummy read before every instruction.
I have included the correct initialization drawing for an SD card note that you don't have to repeat the CMD58 command but get the CCS flag the first time you issue it.
View attachment 183572
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?