SD Card Boot Testing - to be used as a basis for P2 if successful
Cluso99
Posts: 18,069
in Propeller 1
Here is code to test SD Cards.
You will need to adjust the xtal setting (defaults to 5MHz * PLL16) and the SD pins (defaults to P0=DO, P1=CLK, P2=DI, P3=CSn) and recompile with PropTool or equivalent.
This program does not write to your SD card. It only initialises and reads sector 0 (MBR).
Here is a sample of the expected output...
Note that I have tested on the following microSD cards and all work...
OV MicroSDXC U1 Class 10 64GB
SanDisk Ultra MicroSDHC I Class 10 8GB
Mixza MicroSDHC I U1 8GB
Unbranded MicroSDHC Class 4 8GB
SanDisk MicroSDHC Class 4 8GB
SanDisk MicroSD 2GB
Unbranded MicroSD 1GB
All these cards report as SD V2 (bock or byte address).
I cannot find an SD V1 card so have not been able to test those.
I have not enabled testing of MMC cards.
There are two indications of failure...
"Invalid MBR" message
"SD card: Unknown??" message.
Please post your successes and failures, and the output especially if you find any problems running on your SD cards.
Thanks,
Ray
You will need to adjust the xtal setting (defaults to 5MHz * PLL16) and the SD pins (defaults to P0=DO, P1=CLK, P2=DI, P3=CSn) and recompile with PropTool or equivalent.
This program does not write to your SD card. It only initialises and reads sector 0 (MBR).
Here is a sample of the expected output...
SD testing v103 Parameters used... ; 4404: nCS=1 ; 4408: 00000040 00000000 00000095 000000FF (1) 00000001 ; 4428: 00000048 000001AA 00000087 000000FF (1) 00000001 000001AA ; 444C: nCS=1 ; 4450: 00000077 00000000 00000087 000000FF (1) 00000001 00000069 40000000 00000087 000000FF (1) 00000000 (1059) (5388120) ; 449C: nCS=1 ; 44A0: 0000007A 00000000 00000087 000000FF (1) 00000000 C0FF8000 ; 44C4: nCS=1 ; 44C8: 00000051 00000000 00000087 000000FF (1) 00000000 000000FF (620) 000000FE ; 44F8: CRC..... 0000003B 00000084 nCS=1 ; 4504: <eof> MBR sector 0... 01C0: 03 00 0B E6 DC CA 00 20 00 00 00 E0 ED 00 00 00 ....... ........ 01D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ..............U. Valid MBR PTN 0: Typ=$0B 01BE: 00 82 03 00 0B E6 DC CA 00 20 00 00 00 E0 ED 00 ......... ...... PTN 1: Typ=$00 01CE: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ PTN 2: Typ=$00 01DE: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ PTN 3: Typ=$00 01EE: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ SD card: 3 = SDHC/SD V2(block address)
Note that I have tested on the following microSD cards and all work...
OV MicroSDXC U1 Class 10 64GB
SanDisk Ultra MicroSDHC I Class 10 8GB
Mixza MicroSDHC I U1 8GB
Unbranded MicroSDHC Class 4 8GB
SanDisk MicroSDHC Class 4 8GB
SanDisk MicroSD 2GB
Unbranded MicroSD 1GB
All these cards report as SD V2 (bock or byte address).
I cannot find an SD V1 card so have not been able to test those.
I have not enabled testing of MMC cards.
There are two indications of failure...
"Invalid MBR" message
"SD card: Unknown??" message.
Please post your successes and failures, and the output especially if you find any problems running on your SD cards.
Thanks,
Ray
Comments
Patriot Micro SD HC Class 10 16GB
Patriot Micro SD HC Class 10 8GB
Samsung Micro SD HC Class 4 4GB
Samsung Micro SD HC Class 6 8GB
Samsung EVO Micro SD HC-I Class 10 16GB
UPDATE:
Monster Digital SD HC Class 10 32GB (full size SD)
Patriot SD HC Class 4 4GB (full size SD)
dgately
Dane-Elec SD 256MB
Results:
Dane-Elec SD 256MB
We need to be sure that this works reliably so that it can be included as the basis for P2 booting from SD.
Attached:
Dane-Elec Class 10 microSDHC 16GB (Has ISO9660 fs written to it) - reports "Not MBR", and SD Card: Unknown ???
Gigaware Class 2 Full-size SDHC 4GB (fat32, used on prop boards) - OK, no errors
SanDisk microSDHC 4GB (Roku fs) - reports "Not MBR" (expected), and 3=SDHC/SD V2(block address)
SanDisk v1 microSD 1GB (fat32, used on prop platform El Jugador) - reports 1=V1
Cheers,
Jesse
Thanks heaps for checking this for me.
I see 3 of the 4 were diagnosed correctly. They initialised and found no MBR identifier "$55 $AA" in the last positions of the MBR sector 0.
The Dane-Elec SDHC bothers me because it fails the primary initialisation command. I will think a bit more about this and post a new test code for you to try please.
Thanks again,
Ray
Could you try this version on the failed card please?
More output this time, but still unidentified.
Just as a sanity check, I verified that the card functions properly, i.e. can be mounted, read from, written to, and all is ok.
Cheers,
Jesse
Can you try this please?
After reset, CMD0 is supposed to respond with $01. This card is responding with $00.
As some subsequent commands expect a $00 response, I am trying this, to see if the card then works correctly.
Ray
Still Unknown.
Cheers,
Jesse
ie is this a SD hardware level issue (more serious), or a card content issue (less serious) ?
Does this card have a known-valid MBR tag ?
Can host software be used so this card first confirms as invalid, and then can be made valid ?
This is the above output txt No. The problem is with the initialisation.
The previous one did not acknowledge the CMD0 sequence correctly with a $01.
This one, while still acknowledging CMD0 with $00, accepts the next sequence, CMD8 but instead of $01 $000001AA gives $00 (and maybe $00000000). This causes my code to report FAIL01 (the $3333_0001).
We haven't got anywhere near reading the MBR yet (hence all $99 which is what I prefill it with).
FWIW this is the flow chart that I have drawn for the SD SPI sequence
I always recommend SanDisk since these seem to always work.
So I don't think it's worth bothering with any more.
Thanks Jesse for testing these cards. It was worth seeing where any problems are.
Since these are really legacy cards these days, I had decided not to support MMC in my initialisation. I only support SD cards V1 & both V2 (byte and block address) versions.
I think any card less than 1GB should be ignored. SanDisk micro SDHC Class 10 8GB with an microSD-SD adapter are A$6 (~US$4.50) in single quantities from retail shops such as OfficeWorks. Its the smallest they stock.
FWIW, dgately's Dane-Elec was 256MB, but mine is a 16GB SDHC.
Happy to continue testing if desired.
Cheers,
Jesse
Any idea of the age ?
Can you read the MBR ok with other tools ?
My 256MB Dane-Elec is an old card that I had used in a digital camera (probably 8-9 years old). It was formatted as FAT by the Nikon camera, initially. Is the problem with Jesse's card that it was formatted in some other way? Like, using DD on a Linux/Unix box? Thus, no MBR and just a single unix-type partition?
dgately
Once we can get it working we can then reconsider our options.
We are not getting thru the initialisation process. We are nowhere near reading the MBR.
BTW while i report if the MBR meets specs (55aa) in the last 2 bytes, i display the partition table too. All 99s means I didnt get that far.
in the last test, it responded incorrectly to CMD0 which i accepted, then incorrectly to CMD8. You can see the flow char I posted.
In my testing I happened to run it without a card socketed and got the following result: (cut'n'pasted from the PropellerIDE terminal)
I do believe that's an exact duplicate of what Jesse is getting. The problem might wrong wiring.
Thanks Evan.
Jesse,
Can you confirm the SD card is wired correctly? Are you using the same pcb and socket for all card tests?
It could be that the card does not support the SPI interface. At one stage, SPI support was reported to be optional but I believe that changed.
All the same good results from multiple cards including an old 32MB that came with my 2002 model Canon camera. And even some cards that don't show up as readable on the PC and had been filed as faulty - all have cracked casings after having sat on them in my back pocket. Surprisingly, they all checked out as readable on the Prop1. MBR's looked ordinary for example.
Anyway, here's the dump from my 32MB card:
I hadn't been using the same boards. For all except the Gigaware card, which is full-size SDHC, I'd used the Prop Activity board (non-WX). For the Gigaware card, I used Rayman's PTP v1, which has a full-size socket. I'll repeat all the tests on the PTP and let you know if anything changes.
Cheers,
Jesse
Good catch - don't know why I didn't think of doing that. I think the only reason I tended to use the Activity board as opposed to my other boards is it can be powered by USB, so less cables.
For reference, I've attached the SD portion of the schematic of Rayman's PTP (couldn't find it on his site anymore - it's here http://www.rayslogic.com/Propeller/Products/PTP/PTP.htm) in case that's a source of issue. I don't have the Activity board schematic handy.
Cheers,
Jesse
EDIT: Tried revisions v103 and v104 and they also work with this card on the PTP.
On the subject of the Activity Board not working - taking a wild stab here ... by any chance you didn't set the SD pin-out for it? Cluso's default is P0-P3, which happens to exactly match the PTP pin-out - http://www.rayslogic.com/Propeller/Products/PTP/PTP_Propeller_Sched.png
Activity board pin-out is P22-P25 as attached -