Closed grafzahl12345 closed 1 year ago
Hi @grafzahl12345,
I appreciate the thorough description of the problem.
I don't see anything wrong in the information you have provided (other than the "COMMAND ERROR" or course). I assume you have modified the sd.asm code because there is currently no support for an SIO. I was not able to get anything meaningful from the PulseView data.
There are a couple things that might help me tell what is wrong:
In this case "COMMAND ERROR" indicates that the result code sent from the SD Card indicates an error. The trace output will show what the error is.
Thanks,
Wayne
Hello Wayne,
sorry i have forgotten to mention i use the development tree von RomWBW and there is PIO included. I never used SIO as you mentioned. The code is in directory \RomWBW\Source\HBIOS\ sd.asm line 285
Here is the output of SDTRACE=3
SD: MODE=PIO IO=0xA1 DEVICES=1 SD0: CMD 40 00 00 00 00 95 --> RC=01 SD0: CMD 48 00 00 01 AA 87 --> RC=7F SD0: COMMAND ERROR [48000001AA877F00] SD0: CMD 77 00 00 00 00 FF --> RC=05 SD0: COMMAND ERROR [7700000000FF0500] SD0: CMD 41 00 00 00 00 FF --> RC=7F SD0: COMMAND ERROR [4100000000FF7F00]
and the updates pulseview spi log. SD_command_error.zip
thx sebastian
Hi @grafzahl12345,
Actually, I need to apologize. I forgot that @etchedpixels had added an SD driver mode called PIO. I'm sure it worked for him, but I have not personally put together the hardware to try it (although it is on the todo list). When I said SIO, it was a typo. I meant PIO.
Looking at your trace output, the first command (40), seems to go OK. This is the command to put the card in idle state and should return 0x01, which it does. Good. However, everything after that looks way off. The next command (48) looks like the card is not even selected and MISO is just sitting at a high value. The next command (77) returns a resulting indicating illegal command which probably means the prior command (48) was not successful.
I am going to review the PulseView snapshot and see if that reveals anything. I am also going to look at the 4PIO vs. the Gluino w/ Arduino shield (which is what Alan coded for). I have a feeling that the Zilog PIO (from the 4PIO) is not being properly initialized because that would require a different initialization than the Gluino+Arduino shield.
Thanks,
Wayne
So, after looking at @etchedpixels Gluino, it does use a Zilog PIO and so the initialization should be OK. You are using an SD Card adapter instead of an Arduino shield, but I don't see why that would be a problem as long as the signals are mapped correctly. I was unable to successfully open the Gluino schematic, so I am having trouble figuring out the specific pins it is using.
I still need to look at the PulseView dump.
-Wayne
Well, I am able to make more sense out of this PulseView dump than the prior one. The initial GO_IDLE command looks OK (which is verified by the trace). However, the next command (48) has an extraneous byte (value 0x00) prior to the command byte. This is wrong and causes the SD Card to interpret the command as 00 instead of 48. All command after the initial GO_IDLE have the extraneous null byte in front which is causing the commands to be misunderstood by the SD Card.
So, the problem to be solved is why an extraneous null byte is appearing before all command bytes. I'll take a look at the code.
Thanks,
Wayne
I think I see what is causing this. I am attaching a slightly updated version of the sd.asm file to this message. Can you try building with this file and let me know what happens. I don't want to check this in without some confirmation it is working.
Thanks,
Wayne
There's nothing particularly magical about the PIO SD driver, it's just a direct connect to the 5v adapters on the arduino. The gluino is just a formfactor adapter really.
Hallo Wayne,
thanks for your work . Installing the changed code works. It reads and boots now form SD Card over my PIO4 card.
SD: MODE=PIO IO=0xA1 DEVICES=1 SD0: CMD 40 00 00 00 00 95 --> RC=01 SD0: CMD 48 00 00 01 AA 87 --> RC=01 SD0: CMD 77 00 00 00 00 FF --> RC=01 SD0: CMD 69 40 00 00 00 FF --> RC=01 SD0: CMD 77 00 00 00 00 FF --> RC=01 SD0: CMD 69 40 00 00 00 FF --> RC=01 SD0: CMD 77 00 00 00 00 FF --> RC=01 SD0: CMD 69 40 00 00 00 FF --> RC=00 SD0: CMD 7A 00 00 00 00 FF --> RC=00 SD0: SD CARD TYPE ID=02 SD0: CMD 50 00 00 02 00 FF --> RC=00 SD0: CMD 49 00 00 00 00 FF --> RC=00 TOK=FE SD0: CSD = 00 26 00 32 5F 59 83 C8 BE FB CF FF 92 40 40 D7 SD0: SDSC SD0: CMD 4A 00 00 00 00 FF --> RC=00 TOK=FE SD0: CID = 03 53 44 53 44 30 31 47 80 90 1B C3 99 00 6C DB NAME=SD01G BLOCKS=0x001E4600 SIZE=968MB
Unit Device Type Capacity/Mode
Char 0 UART0: RS-232 38400,8,N,1 Disk 0 MD0: RAM Disk 256KB,LBA Disk 1 MD1: ROM Disk 896KB,LBA Disk 2 PPIDE0: CompactFlash 61056MB,LBA Disk 3 PPIDE1: Hard Disk -- Disk 4 SD0: RAM Floppy 968MB,LBA Sound 0 SND0: SN76489 3+1 CHANNELS Sound 1 SND1: YM2612 6+0 CHANNELS
Very glad to hear this. I will close this issue when I check-in the fixed file.
Thanks,
Wayne
So what was the actual problem for reference ?
So what was the actual problem for reference ?
The driver maintains a shadow register (OPRVAL) for the operations register (OPRREG). It was not initialized with the default value during driver initialization which resulted in some very subtle anomalies. Primarily, MOSI was not being kept high during MISO operations. I suspect the effect of this would vary depending on the SD Card.
If you get a chance, I would appreciate it if you could confirm my changes do not break your Gluino + Shield configuration. My changes are not checked in yet. I will post to this thread again once they are.
Thanks,
Wayne
The fix is now checked in with commit faaba69.
Closing this issue.
Hello, i try to use SD card with the 4PIO card on the SBC V2-005i (4,8 & 10 Mhz) , but i all ways get an command error at boot up.
My config at sd.asm
pin layout
boot log
RetroBrew SBC [SBC_10] Boot Loader
I use the B port of the first z84c2010 at ioport $A1 and a cheep microsd card adapter HW-125. It use the same level shifting as the Gluino card shield. As a second try i used sd card from spi display with no pullups and a TXS0108 module for level shifting with the same results. After some logging the spi protocol with pulseview i didn't got any clue because my lack of knowledge. Maybe someone got a clue out of my data and a fix for the source code.
thx sebastian
https://sigrok.org/wiki/PulseView
spi_command_error.zip