P2 SD card code test...
Cluso99
Posts: 18,069
Attached is a test program for SD Cards. I would appreciate testing this on your SDHC cards formatted as FAT32.
I compiled it with FlexGUI v4.0.6 and downloaded it with LoadP2 v4.0.6 using the windoze command prompt window/program.
It runs on the P2-EVAL Rev B with Rev B silicon and RevA with RevA silicon. (All switches OFF)
It should run on the P2D2 Rev A provided a 10K pullup resistor is connected to pin 25 as it self-identifies the P2-EVAL and P2D2.
It runs at 160MHz.
Below is a sample of the expected output. There is a further debug that can be enabled for SD cards that fail the test (see line 497 of the spin code).
I am particularly interested that SDHC cards are detected (the program will error is you use an old card that uses byte mode addressing), and
That the SD-DO pin reports as being Hi.
Your dump of the sector will be different!
The checkpoints are just prior to that command being sent to the SD card.
I compiled it with FlexGUI v4.0.6 and downloaded it with LoadP2 v4.0.6 using the windoze command prompt window/program.
It runs on the P2-EVAL Rev B with Rev B silicon and RevA with RevA silicon. (All switches OFF)
It should run on the P2D2 Rev A provided a 10K pullup resistor is connected to pin 25 as it self-identifies the P2-EVAL and P2D2.
It runs at 160MHz.
Below is a sample of the expected output. There is a further debug that can be enabled for SD cards that fail the test (see line 497 of the spin code).
I am particularly interested that SDHC cards are detected (the program will error is you use an old card that uses byte mode addressing), and
That the SD-DO pin reports as being Hi.
Your dump of the sector will be different!
The checkpoints are just prior to that command being sent to the SD card.
spin
73K
Comments
Initialise
ReadCSDCID
ReadSector
WriteSector
are all callable. At the end of each of these, the pins are tristated, and a successful result is NC and Z.
I have these routines almost ready to replace the PASM code drivers that we used in P1 where it ran in its own cog. Kye’s spin code will need converting tho.
Mike
Once loaded and running the first thing it does is initialise the serial port and output the P2-EVAL or P2D2 message and this occurs before the SD card code runs.
I presume you don’t have anything connected to P25?
I just power my board from the USB port (the serial port) as my PC supplies power just fine.
I’ll post the little bat file i use to compile and load and run tomorrow.
Results from my P2-EVAL Rev B:
My python load script does this:
dgately
Yes, you need the -SINGLE option.
What may not have been obvious from my screenshot is that f406 is flexgui v4.0.6 renamed and similarly l406 is loadp2.
BTW, the reason that loadp2 -CHIP doesn't work is that there's a typo in the loadp2 fast loader code which causes all of memory to be erased at load time, including the debug area (it was not supposed to touch memory above $7c000, but it does). You can avoid this by passing -NOZERO to loadp2, or, obviously, -SINGLE.
I hadn't realized that -SINGLE doesn't clear RAM but apparently it doesn't -- in the course of testing this I wrote a little program to poke data into HUB and it persists across loads with -SINGLE.
Without an SD card loaded, it runs with passes various checkpoints, null data
When I put a Sandisk Ultra 16GB card in the slot, it doesn't run.
There may be a .bix on the card that takes it down a different path?? Should that matter?
Note I have formatted some of my cards with non default cluster sizes
I would think that if it boots from the card then it won't be possible to load anything via serial, which would explain the "binary failed to load" message.
Checkpoint is not a "PASS" but rather that will now be tested, Your card failed the very first command (checkpoint 0 = command 0).
Of course, since there is no SD card, it will fail command 0. Perhaps I need to check for pullup on SD_CS (from the card). I don't need to do this in the ROM because when I get passed control from Chip's booter he has already confirmed that there is a pullup (ie a card).
Different cluster sizes should be fine.
F406.exe is fastspin.exe v4.0.6 renamed
L406.exe is loadp2.exe v4.0.6 renamed Note that I call my .spin2 files .spin as I still edit with PropTool.
I get "Error in startup scrip".
To load the binary I used bin\loadp2 SD204.binary -b115200 -t -SINGLE
program completes normally and works just fine.
Mike
I think @Cluso99 mistyped; he meant "fastspin" rather than "flexgui". flexgui is the graphical interface; fastspin is the actual compiler. Also, that second argument is probably a lower case L rather than the digit 1 (not sure from the font which you typed). It's the fastspin flag to produce a listing file and is optional anyway, only the "-2" (for P2 output) really matters.
Mike
The P2D2 doesn't have any pull-ups on any ports under P56 where P56,57 are I2C. There must be a better way to check for hardware and so detecting pullups on these two pins might help.
I added the pullup on P25 because it was easy to plug a pullup resistor into my P2D2 as i have female pins on my board. IIRC 3V3 is 0.3 or 0.4” away from P25 making it easy to plug in a pullup.
I couldnt see any other easy way to do an auto test.