Shop OBEX P1 Docs P2 Docs Learn Events
Does Taqoz 2.8 work with 32GB card? — Parallax Forums

Does Taqoz 2.8 work with 32GB card?

Christof Eb.Christof Eb. Posts: 1,213
edited 2023-03-27 14:24 in Forth

Hi,
for a long time I have been using a SanDisk 16GB Ultra SDHC I A1 card, which worked.

Now I tried a SanDisk 32GB Ultra SDHC UHS-I A1 card, and I cannot get it to work. As error message I get "Invalid Partition". Is this not possible or ist there a special procedure necessary formatting it?
Thank you!
Christof

Comments

  • Hi @"Christof Eb."
    I use the same SD card in my P2 EVAL - it should work for you too. I would try formatting as described towards the end of the glossary . Other people have had that message and the correct formatting fixed it.

  • No problems with this same card at my end either. Worked out of the box without the need for formatting. I've had some problems with other (non SanDisk cards) but in all these instances TAQOZ card formatter fixed these issues.

  • Christof Eb.Christof Eb. Posts: 1,213
    edited 2023-03-27 17:50

    @bob_g4bby said:
    Hi @"Christof Eb."
    I use the same SD card in my P2 EVAL - it should work for you too. I would try formatting as described towards the end of the glossary . Other people have had that message and the correct formatting fixed it.

    Thanks, Bob!
    Rather strange. Using the SD-Card-Formatter with Overwrite Format, I was now able to make another 16GB card usable and revive the former 16GB card. But those two 32GB cards, which I purchased at the same time, remain stubborn. Will now try a third of this bundle. Aaah, these things are so very time consuming....

    Edit: Third card does not work too.
    .sd --- CARD: SANDISK SD SD32G REV$85 #230883838 DATE:2022/12

    Do you use 64kB per cluster? The SD card formatter does not have this option. I tried to use 64kB with the Windows formatter and with Taqoz FORMAT without success. Perhaps it is a good idea to discard this recommendation?

  • bob_g4bbybob_g4bby Posts: 440
    edited 2023-03-27 17:51

    Ok @"Christof Eb." , Sorry the 32gb cards aren't working still. I haven't tried 64kb clusters. I will delete that advice from the glossary.

    Might be an idea to store some files on the 32gb cards and see that data can be read, all from the PC. Just in case the SD cards are faulty.

  • Fine 16GB:

    TAQOZ# .sd --- CARD: SANDISK SD SC16G REV$80 #2093716449 DATE:2020/6

                   *** OCR ***
    VALUE........................... $C0FF_8000
    RANGE........................... 2.7V to 3.6V
    
                   *** CSD ***
    CARD TYPE....................... SDHC
    LATENCY......................... 1ms+1400 clocks
    SPEED........................... 50MHz
    CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
    BLKLEN.......................... 512
    SIZE............................ 15,558MB
    Iread Vmin...................... 60ma
    Iread Vmax...................... 80ma
    Iwrite Vmin..................... 35ma
    Iwrite Vmax..................... 35ma
    
                 *** SPEEDS ***
    LATENCY......................... 483us,261us,336us,276us,262us,333us,276us,260us,
    SECTOR.......................... 318us,359us,380us,374us,359us,379us,374us,359us,
    BLOCKS.......................... 4,666kB/s @200MHz ok
    

    TAQOZ# .sd --- CARD: SANDISK SD SD32G REV$85 #3030188542 DATE:2022/12

                   *** OCR ***
    VALUE........................... $C0FF_8000
    RANGE........................... 2.7V to 3.6V
    
                   *** CSD ***
    CARD TYPE....................... SDHC
    LATENCY......................... 1ms+1400 clocks
    SPEED........................... 50MHz
    CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
    BLKLEN.......................... 512
    SIZE............................ 31,178MB
    Iread Vmin...................... 35ma
    Iread Vmax...................... 45ma
    Iwrite Vmin..................... 60ma
    Iwrite Vmax..................... 200ma
    
                 *** SPEEDS ***
    

    ▒BOOTING.... ERROR - INVALID PARTITION00us,389227us,389154us,389081us

    I am wondering, if those Iwrite 200mA are too much for the Kiss board????
    Good idea, to test on another computer. Yes 32 GB works there.

  • bob_g4bbybob_g4bby Posts: 440
    edited 2023-03-28 09:12

    Here's the report from .DISK for my 32 Gbyte Sandisk SD card:-

    TAQOZ# .DISK ---  CARD: SANDISK   SD SD32G REV$85 #3200344782 DATE:2021/1
    
                       *** OCR ***
        VALUE........................... $C0FF_8000
        RANGE........................... 2.7V to 3.6V
    
                       *** CSD ***
        CARD TYPE....................... SDHC
        LATENCY......................... 1ms+1400 clocks
        SPEED........................... 50MHz
        CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
        BLKLEN.......................... 512
        SIZE............................ 31,166MB
        Iread Vmin...................... 35ma
        Iread Vmax...................... 45ma
        Iwrite Vmin..................... 60ma
        Iwrite Vmax..................... 10ma
    
                     *** SPEEDS ***
        LATENCY......................... 272us,291us,310us,289us,292us,311us,289us,292us,
        SECTOR.......................... 356us,392us,410us,390us,392us,410us,391us,392us,
        BLOCKS.......................... 4,664kB/s @200MHz
    
                       *** MBR ***
        PARTITION....................... 0 00 INACTIVE
        FILE SYSTEM..................... FAT32 LBA
        CHS START....................... 0,130,3
        CHS END......................... 1023,254,63
        FIRST SECTOR.................... $0000_2000
        TOTAL SECTORS................... 62,325,760 = 31,910MB
    
    00170: 0000_0000 0000_0001 0002_0000 506F_7250     '............ProP'
    
                      *** FAT32 ***
        OEM............................. MSWIN4.1
        Byte/Sect....................... 512
        Sect/Clust...................... 64 = 32KB
        FATs............................ 2
        Media........................... F8
        Sect/Track...................... 63
        Heads........................... 255
        Hidden Sectors.................. 8,192 = 4MB
        Sect/Part....................... 62,325,760 = 31,910MB
        Sect/FAT........................ 7,607 = 3MB
        Flags........................... 0
        Ver............................. 00 00
        ROOT Cluster.................... $0000_0002 SECTOR: $0000_6000
        INFO Sector..................... $0001 = $0000_2001
        Backup Sector................... $0006 = $0000_2006
        res............................. 00 00 00 00 00 00 00 00 00 00 00 00
        Drive#.......................... 128
        Ext sig......................... $29 OK!
        Part Serial#.................... $BC48_FBC7 #3158899655
        Volume Name..................... TAQOZ      FAT32    ok
    

    So I notice that 'Iwrite Vmax' is 10mA not 200mA, whatever that means.

    There is the possibility that at least your 32 Gbyte SD cards are fake of course - there are many such devices - see youtube. The fakes will report the size on the label, but fail when subject to a 'capacity test' program. They can be smaller capacity devices than advertised.

    I tend to buy SD cards from a large computer shop just outside my home town to minimise the chance of buying a fake..

  • @bob_g4bby
    Thanks again! 128 sectors / 65KB Cluster works on 16GB.
    32GB cards had been bought at and from Amazon. H2testw on PC reports OK, no errors.

    I will try to get a better understanding of FILE.FTH as I need to read and write ( audio ) data files, which I had not done up to now....

  • Any further ideas on this? I have tried every SD on the bench <=32GB. invalid partition every time. P2 Edge w/ 32MBram. Tried various formats etc. very intermittent functioning.

  • @"frank freedman" said:
    Any further ideas on this? I have tried every SD on the bench <=32GB. invalid partition every time. P2 Edge w/ 32MBram. Tried various formats etc. very intermittent functioning.

    Hi, since I switched back to 16GB, it works here. Did not yet investigate further.
    Christof

  • bob_g4bbybob_g4bby Posts: 440
    edited 2023-04-05 15:05

    I bought a Sandisk Ultra Plus 32gb SD card from Currys today - the smallest they sell now. (They are our local electronics chain store) Without formatting it, I plugged it into the P2-Eval and used BU to save the system onto the card. Taqoz booted up when the reset button was pressed. Here's what .DISK reported:-

    TAQOZ# .DISK ---  CARD: SANDISK   SD SK32G REV$80 #3783272017 DATE:2022/7
    
                       *** OCR ***
        VALUE........................... $C0FF_8000
        RANGE........................... 2.7V to 3.6V
    
                       *** CSD ***
        CARD TYPE....................... SDHC
        LATENCY......................... 1ms+1400 clocks
        SPEED........................... 50MHz
        CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
        BLKLEN.......................... 512
        SIZE............................ 31,166MB
        Iread Vmin...................... 35ma
        Iread Vmax...................... 45ma
        Iwrite Vmin..................... 60ma
        Iwrite Vmax..................... 10ma
    
                     *** SPEEDS ***
        LATENCY......................... 274us,173us,172us,173us,172us,173us,173us,172us,
        SECTOR.......................... 357us,274us,274us,274us,273us,274us,273us,274us,
        BLOCKS.......................... 4,663kB/s @200MHz
    
                       *** MBR ***
        PARTITION....................... 0 00 INACTIVE
        FILE SYSTEM..................... FAT32 LBA
        CHS START....................... 0,130,3
        CHS END......................... 1023,254,63
        FIRST SECTOR.................... $0000_2000
        TOTAL SECTORS................... 62,325,760 = 31,910MB
    
    00170: 0000_0000 0000_0001 0002_0000 506F_7250     '............ProP'
    
                      *** FAT32 ***
        OEM.............................
        Byte/Sect....................... 512
        Sect/Clust...................... 64 = 32KB
        FATs............................ 2
        Media........................... F8
        Sect/Track...................... 63
        Heads........................... 255
        Hidden Sectors.................. 8,192 = 4MB
        Sect/Part....................... 62,325,760 = 31,910MB
        Sect/FAT........................ 7,607 = 3MB
        Flags........................... 0
        Ver............................. 00 00
        ROOT Cluster.................... $0000_0002 SECTOR: $0000_6000
        INFO Sector..................... $0001 = $0000_2001
        Backup Sector................... $0006 = $0000_2006
        res............................. 00 00 00 00 00 00 00 00 00 00 00 00
        Drive#.......................... 128
        Ext sig......................... $29 OK!
        Part Serial#.................... $3165_3038 #828715064
        Volume Name..................... NO NAME    FAT32    ok
    

    I notice that Iwrite Vmax is 10mA, like my other 32Gb device.

  • I now tried one of the "bad" 32GB cards with APropOs, which means the filesystem of FlexProp and it works. I can read and write files onto it. So it seems to be a problem of Taqoz.

  • That doesn't surprise me, suspected that Taqoz pushed the SD card interface hard to give the highest data rates. Good to hear the cards can be used on the P2.

  • Christof Eb.Christof Eb. Posts: 1,213
    edited 2023-04-06 09:47

    @bob_g4bby said:
    That doesn't surprise me, suspected that Taqoz pushed the SD card interface hard to give the highest data rates. Good to hear the cards can be used on the P2.

    Hi Bob,
    Yes, my direction of thought went also to speed. I have experimented:
    RCFAST
    Patching these:
    00644 006 00000000 clkdly long 0 ' SPI clock waitx delay => to 8
    00648 007 00000008 sddly long 8 ' sd clock delay => to 16
    0064c 008 00020004 sdhl long $2_0004 => $40008

    Additional capacitors 3v3 to GND at the connectors nearby.
    25 clkfreq!

    All these things did not help.

    Edit:
    !SD! .sd does give:

    TAQOZ# !SD! ---  ok
    TAQOZ# .sd ---  CARD: SANDISK   SD SD32G REV$85 #3030188542 DATE:2022/12
    
                       *** OCR ***
        VALUE........................... $C0FF_8000
        RANGE........................... 2.7V to 3.6V
    
                       *** CSD ***
        CARD TYPE....................... SDHC
        LATENCY......................... 1ms+1400 clocks
        SPEED........................... 50MHz
        CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
        BLKLEN.......................... 512
        SIZE............................ 31,178MB
        Iread Vmin...................... 35ma
        Iread Vmax...................... 45ma
        Iwrite Vmin..................... 60ma
        Iwrite Vmax..................... 200ma
    
                     *** SPEEDS ***
        LATENCY......................... 556us,267us,237us,236us,251us,251us,236us,235us,
        SECTOR.......................... 270us,330us,329us,328us,343us,343us,328us,328us,
        BLOCKS.......................... 3,016kB/s @200MHz ok
    TAQOZ# dir ---
    NAME...........ATR.1ST.SECTOR...MODIFIED.............FILE.SIZE.......MAX.SIZE.....HEADER   ERROR - INVALID PARTITION
    

    So !SD!, which does some sort of reset to the SD seems to help for a short while.
    !SD! mount, does not work

    At the moment I suspect, that perhaps the time between a SD command and data might be too short????

    Any other ideas?
    Thanks, Christof

  • bob_g4bbybob_g4bby Posts: 440
    edited 2023-04-06 14:11

    I don't have SD card expertise, so don't know what to suggest other than ...

    It's probably not worth delving deeper into timing etc because the 'problem space' is quite large. I still believe your Amazon 32 Gbyte cards are fakes, albeit functional ones - they probably weren't made by Sandisk. In the attached spreadsheet, I've listed the output from .DISK for three of my 32gb Sandisk cards that work with Taqoz. You can see the parameters are very close to one another in all three parts, purchased over a two year period - and this set is different from your readout. Your part is quite a bit slower I think.

    I would use your SD cards on your other devices (PCs, phones and tablets) and buy a genuine Sandisk card or two from somewhere trusted that you can return them too if they don't work out with Taqoz.

    Cheers, Bob

  • @bob_g4bby said:
    I don't have SD card expertise, so don't know what to suggest other than ...

    It's probably not worth delving deeper into timing etc because the 'problem space' is quite large. I still believe your Amazon 32 Gbyte cards are fakes, albeit functional ones - they probably weren't made by Sandisk. In the attached spreadsheet, I've listed the output from .DISK for three of my 32gb Sandisk cards that work with Taqoz. You can see the parameters are very close to one another in all three parts, purchased over a two year period - and this set is different from your readout. Your part is quite a bit slower I think.

    I would use your SD cards on your other devices (PCs, phones and tablets) and buy a genuine Sandisk card or two from somewhere trusted that you can return them too if they don't work out with Taqoz.

    Cheers, Bob

    Thank You Bob for the overview!
    Yes, I have ordered some new cards "SanDisk Extreme 32GB". I am relatively sure somehow, that these "bad" cards are no fakes. Think positive :-) . I could imagine, that SanDisk did some changes in late 2022, perhaps to reduce cost or because of parts availability, who knows. After all the cards work under other circumstances. There was and still is some "excitement" (I don't know, if this is the proper word for "Reiz" here.) for me to find and fix the problem in Taqoz.... Perhaps I will find a good description of the protocol and get some new ideas how to tackle it.
    Cheers, Christof

  • Puah, this drives me mad....
    New bought at and from Amazon: SanDisk Extreme 32GB A1 V30.
    Does only work shorttime after !SD!

    TAQOZ# .sd ---  CARD: SANDISK   SD SN32G REV$80 #617316858 DATE:2022/10
    
                       *** OCR ***
        VALUE........................... $C0FF_8000
        RANGE........................... 2.7V to 3.6V
    
                       *** CSD ***
        CARD TYPE....................... SDHC
        LATENCY......................... 1ms+1400 clocks
        SPEED........................... 50MHz
        CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
        BLKLEN.......................... 512
        SIZE............................ 31,154MB
        Iread Vmin...................... 35ma
        Iread Vmax...................... 45ma
        Iwrite Vmin..................... 35ma
        Iwrite Vmax..................... 35ma
    
                     *** SPEEDS ***
    þBOOTING....    ERROR - INVALID PARTITION29us,546756us,546683us,546610us
    
    -------------------------------------------------------------------------------
    TAQOZ# !SD! ---  ok
    TAQOZ# .sd ---  CARD: SANDISK   SD SN32G REV$80 #617316858 DATE:2022/10
    
                       *** OCR ***
        VALUE........................... $C0FF_8000
        RANGE........................... 2.7V to 3.6V
    
                       *** CSD ***
        CARD TYPE....................... SDHC
        LATENCY......................... 1ms+1400 clocks
        SPEED........................... 50MHz
        CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
        BLKLEN.......................... 512
        SIZE............................ 31,154MB
        Iread Vmin...................... 35ma
        Iread Vmax...................... 45ma
        Iwrite Vmin..................... 35ma
        Iwrite Vmax..................... 35ma
    
                     *** SPEEDS ***
        LATENCY......................... 252us,105us,105us,105us,105us,105us,105us,105us,
        SECTOR.......................... 337us,206us,206us,206us,206us,206us,206us,206us,
        BLOCKS.......................... 4,665kB/s @200MHz ok
    TAQOZ# Dir ---
    NAME...........ATR.1ST.SECTOR...MODIFIED.............FILE.SIZE.......MAX.SIZE.....HEADER   ERROR - INVALID PARTITION
    
    -------------------------------------------------------------------------------
    TAQOZ#
    
  • Suppose all of your cards are OK. Let's assume the same for your KISS board and your Taqoz image. Maybe there is something with the combination of your KISS board and your Taqoz image that none of your cards like ?

    What if I tried your Taqoz image with my KISS board and my 32 GB cards, both SanDisk nad non SanDisk ones ? That would either confirm or rule out the "combination effect", whatever that is. Do you think it to be a worthy experiment ?

  • Christof Eb.Christof Eb. Posts: 1,213
    edited 2023-04-08 18:58

    @Maciek said:
    Suppose all of your cards are OK. Let's assume the same for your KISS board and your Taqoz image. Maybe there is something with the combination of your KISS board and your Taqoz image that none of your cards like ?

    What if I tried your Taqoz image with my KISS board and my 32 GB cards, both SanDisk nad non SanDisk ones ? That would either confirm or rule out the "combination effect", whatever that is. Do you think it to be a worthy experiment ?

    Hi Maciek,
    thank you very much for the offer!
    I have now copied the image to a SanDisk Extreme 32GB from 2018
    TAQOZ# mount --- CARD: SANDISK SD SE32G REV$80 #3007066386 DATE:2018/3 ok
    And this works.
    So at the moment, such test seems only to be relevant, if you would have SanDisk cards from autumn 2022.
    This has already stolen so much time from me and from Bob, so at the moment I don't think, that someone else should invest time here.
    Christof

    Edit: I should mention, that the bootloader (which is not Taqoz, but P2 ROM) can load the image _BOOT_P2.BIX from these "bad" cards.

  • If both flexspin VFS and the bootloader can access the cards, it would indeed seem that there is a problem with TAQOZ and its SD driver...

    Not sure what whacky issue would allow it to correctly read the card ID registers but fail the actual sector reads. The TAQOZ code looks like line noise to me so idk what it's doing, but I'd hook up a logic analyzer and see what the patterns look like from TAQOZ vs flexspin.

  • "...code looks like line noise to me..."

    I like that. Consider yourself lucky if that holds true only for the TAQOZ for you.

    It's just the code, like any other if one knows how to go about it and it's very comapct and efficient.

  • Got some "new" result by chance. Something seems to be borderline. While the first 6 measurements of latency are "wrong", the last 2 measurements are reasonable.

    TAQOZ# !SD! .sd ---  CARD: SANDISK   SD SN32G REV$80 #617316858 DATE:2022/10
    
                       *** OCR ***
        VALUE........................... $C0FF_8000
        RANGE........................... 2.7V to 3.6V
    
                       *** CSD ***
        CARD TYPE....................... SDHC
        LATENCY......................... 1ms+1400 clocks
        SPEED........................... 50MHz
        CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
        BLKLEN.......................... 512
        SIZE............................ 31,154MB
        Iread Vmin...................... 35ma
        Iread Vmax...................... 45ma
        Iwrite Vmin..................... 35ma
        Iwrite Vmax..................... 35ma
    
                     *** SPEEDS ***
        LATENCY......................... 36082us,35837us,35952us,35573us,36128us,25705us,259us,258us,
        SECTOR.......................... 351us,355us,356us,355us,345us,356us,359us,359us,
        BLOCKS.......................... 4,619kB/s @200MHz ok
    TAQOZ# dir ---
    NAME...........ATR.1ST.SECTOR...MODIFIED.............FILE.SIZE.......MAX.SIZE.....HEADER   ERROR - INVALID PARTITION
    
    -------------------------------------------------------------------------------
    TAQOZ#
    

    @Wuerfel_21 said:
    If both flexspin VFS and the bootloader can access the cards, it would indeed seem that there is a problem with TAQOZ and its SD driver...

    Not sure what whacky issue would allow it to correctly read the card ID registers but fail the actual sector reads. The TAQOZ code looks like line noise to me so idk what it's doing, but I'd hook up a logic analyzer and see what the patterns look like from TAQOZ vs flexspin.

    As far as I think to have found out, the reading of the card registers is done by a completely independent lower speed code than high speed reading of a sector.

    Can you suggest a "SD-card interface and timing guide for the very beginner"? I do not own a logic analyzer, but I have a 100MHz 4 channel oszi.

    What do you think of this following code? For me, the clock generation is "obscure". It is done by the smartpin in parallel and independently from the shift-in.

    Thank you Christof

                       '********************** SPI READ/WRITE *********************
                       '
    
                       ' SPIRX ( dst cnt -- )
                       ' Read bytes in from SPI to memory
                       ' high speed SD SPI read at sysclk/4 = 50MHz read speed @200MHz clock
                       ' the clock timing is positioned just before SPIRX so runtime sw can find and adjust this
                       ' Timing:
                       ' TAQOZ# BUFFERS 512 LAP SPIRX LAP .LAP --- 19,800 cycles= 61,875ns @320MHz ok
                       '
                       'clkdly          long    0                       ' normally left at zero for no extra delay
                       'sddly           long    8                       ' 4 @80MHz, 6 @160MHz, 8 @240MHz, 10 at 320MHz
                       'sdhl            long    $2_0004                 ' pulses 2 cycles high, 2 low for fast 4 cycle bit-rate
    00c50 189          SPIRX ' ( b:dst a:cnt -- )
    00c50 189 fc880024                 wrfast   #0,b                    ' setup to write to dest
    00c54 18a fdb00030              call    #SPISET
    00c58 18b fc284002 .l0              wypin   #32,sck                 ' trigger 32 clocks
    00c5c 18c fd600e1f                 waitx   sddly                ' delay (set to 8 for 200MHz)
    00c60 18d fcd41e20                 rep     x,#32                    ' x=2 for fast or 3 for slower
    00c64 18e fd700840               testp  miso wc                 ' 4 cycle/bit read
    00c68 18f f0a42201               rcl    r1,#1                   ' shift in next bit
    00c6c 190 fd600c1f               waitx  clkdly                  ' optional extra wait instruction for modified SPIRX
    00c70 191 f9fc221b                 movbyts r1,#%00011011        ' rearrange bytes
    00c74 192 fd602217              wflong  r1                      ' save four bytes in one long
    00c78 193 fb6c47f7              djnz    a,#.l0                  ' for long count
    00c7c 194 fd600458 SPIXX           drvl    sck                      ' probably not necessary!!
    00c80 195 fc080002                 wrpin   #0,sck               ' disable smartpin
    00c84 196 fd800f20                 jmp     #\DROP2              ' discard dst and cnt
    
    00c88 197 f0444602 SPISET          shr     a,#2                 ' convert byte count to longs
    00c8c 198 f8f01e08              getbyte x,sdhl,#2               ' adjust rep loop for slower settings
    00c90 199 f20c1e02              cmp     x,#2 wz                 ' rep 2 or 3 instructions
    00c94 19a 56041e03  if_nz       mov     x,#3                    ' 3 for slower tranfers using extra waitx
    00c98 19b fd600450                  fltl    sck
    00c9c 19c fc089002              wrpin   #%01_001000,sck         ' pulse mode for sck
    00ca0 19d fd600458              drvl    sck
    00ca4 19e 0c101002  _ret_       wxpin   sdhl,sck                ' set sck hilo period
    
  • Oh wow, what a terrible little routine. From just a quick glance (currently filling up a bath...):

    1. Are you sure the sddly and sdhl values stay properly in sync?
    2. I think the clock/data phase doesn't properly stay constant. The output from P_PUSLE is always aligned to its internal cycles, even when the pulse count has run out. The code here seems written under the assumption that WYPIN would reset the smartpin's phase, but I know it does not.
    3. Why is it shifting in manually? The streamer is right there!

    To investigate 2., I'd suggest putting an FLTL and DRVL pair between the .l0 label and the WYPIN. Might need to play with clkdly values.


    Also, yes, a storage oscilloscope should be sufficient to investigate SPI signals.

    It's very verbose, but the ideal place to look up on the SD protocol is the official specification.
    Getting access to it involves some messing around with account registration and email verification if I remember.
    Fuc‌k that noise, here it is: (with the copy-paste protection removed, too): https://mega.nz/file/7TBVhCiQ#xxrwLOhsIQZZQhlGUP33O5ptsGH1fT9sIQUtO_tPNbc

    They inexplicably removed the timing sections in the public document, but SPI mode is really just SPI. We only care about SPI bus mode, disregard the rest of the document.

  • @Wuerfel_21 said:
    Oh wow, what a terrible little routine. From just a quick glance (currently filling up a bath...):

    1. Are you sure the sddly and sdhl values stay properly in sync?
    2. I think the clock/data phase doesn't properly stay constant. The output from P_PUSLE is always aligned to its internal cycles, even when the pulse count has run out. The code here seems written under the assumption that WYPIN would reset the smartpin's phase, but I know it does not.
    3. Why is it shifting in manually? The streamer is right there!

    To investigate 2., I'd suggest putting an FLTL and DRVL pair between the .l0 label and the WYPIN. Might need to play with clkdly values.


    Also, yes, a storage oscilloscope should be sufficient to investigate SPI signals.

    It's very verbose, but the ideal place to look up on the SD protocol is the official specification.
    Getting access to it involves some messing around with account registration and email verification if I remember.
    Fuc‌k that noise, here it is: (with the copy-paste protection removed, too): https://mega.nz/file/7TBVhCiQ#xxrwLOhsIQZZQhlGUP33O5ptsGH1fT9sIQUtO_tPNbc

    They inexplicably removed the timing sections in the public document, but SPI mode is really just SPI. We only care about SPI bus mode, disregard the rest of the document.

    Thanks for your feedback about the routine, I will try to write some less smart slower code and to patch it into that place. SPISET is only used by this routine, so there should be enough space, I hope. There is already code there to shift in 32 bits. It should have it's advantages to use code, that I can understand....

  • Ok, it was not that smart routine. But it has something to do with start up of the SD-card. Timing or reset or whatever. The "solution" is idiotic. Instead of trying it twice ( Peters way ), we try it 10 times with a pause and do not use !SD but only !SD! .
    On Peters P2D2 card there is a possibility to switch off and on the power supply to the SD card, which is used by !SD.

    !MOUNTA seems to work with both of these "bad" card types:

    {
    \ Original:
    
    pub !MOUNT
        SD? 0EXIT \ ( !SD DROP !SD DROP ) !SD 0EXIT
        !SD 0EXIT
        1 SECTORF DROP
        !SD 0EXIT
        fat32 fatsz ERASE
        RO --- disable sector sdwr
        0 SECTORF $1FE + W@ $AA55 <> " INVALID PARTITION" ?ERROR
        $1BE SDBUF+ parts 66 CMOVE
        GETFAT
        ROOT serial @ mntd !
        1 MB mksiz !
        ;
    }
    
    
    pub !MOUNTA \ New Version for !MOUNT
        SD? 0EXIT \ ( !SD DROP !SD DROP ) !SD 0EXIT
       RO --- disable sector sdwr
        10 for 1 ms !SD! 0 SECTORF $1FE + W@ $AA55 = ?next
        fat32 fatsz ERASE
       SDBUF 512 erase
        0 SECTORF $1FE + W@ $AA55 <> " INVALID PARTITION" ?ERROR
        $1BE SDBUF+ parts 66 CMOVE
        GETFAT
        ROOT serial @ mntd !
        1 MB mksiz !
    ;
    
    ' !MOUNTA 1+ ' !MOUNT W! \ patch it into !MOUNT
    \ BACKUP BIX
    
    
    .disk ---  CARD: SANDISK   SD SD32G REV$85 #3030188542 DATE:2022/12
    
                       *** OCR ***
        VALUE........................... $C0FF_8000
        RANGE........................... 2.7V to 3.6V
    
                       *** CSD ***
        CARD TYPE....................... SDHC
        LATENCY......................... 1ms+1400 clocks
        SPEED........................... 50MHz
        CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
        BLKLEN.......................... 512
        SIZE............................ 31,154MB
        Iread Vmin...................... 35ma
        Iread Vmax...................... 45ma
        Iwrite Vmin..................... 60ma
        Iwrite Vmax..................... 200ma
    
                     *** SPEEDS ***
        LATENCY......................... 589us,315us,276us,276us,291us,290us,275us,276us,
        SECTOR.......................... 302us,367us,366us,366us,382us,382us,366us,366us,
        BLOCKS.......................... 3,015kB/s @200MHz
    
                       *** MBR ***
        PARTITION....................... 0 00 INACTIVE
        FILE SYSTEM..................... FAT32 LBA
        CHS START....................... 1023,254,63
        CHS END......................... 0,0,0
        FIRST SECTOR.................... $0000_2000
        TOTAL SECTORS................... 62,301,184 = 31,898MB
    
    00170: 0000_0000 0000_0000 0000_0000 0000_0000     '................'
    
                      *** FAT32 ***
        OEM............................. TAQOZ P2
        Byte/Sect....................... 512
        Sect/Clust...................... 128 = 65KB
        FATs............................ 2
        Media........................... F8
        Sect/Track...................... 63
        Heads........................... 255
        Hidden Sectors.................. 8,192 = 4MB
        Sect/Part....................... 62,301,184 = 31,898MB
        Sect/FAT........................ 3,802 = 1MB
        Flags........................... 0
        Ver............................. 00 00
        ROOT Cluster.................... $0000_0002 SECTOR: $0000_3DD4
        INFO Sector..................... $0001 = $0000_2001
        Backup Sector................... $0006 = $0000_2006
        res............................. 00 00 00 00 00 00 00 00 00 00 00 00
        Drive#.......................... 128
        Ext sig......................... $29 OK!
        Part Serial#.................... $6269_0201 #1651048961
        Volume Name..................... P2 CARD    FAT32    ok
    
    
    TAQOZ# .disk ---  CARD: SANDISK   SD SN32G REV$80 #617316858 DATE:2022/10
    
                       *** OCR ***
        VALUE........................... $C0FF_8000
        RANGE........................... 2.7V to 3.6V
    
                       *** CSD ***
        CARD TYPE....................... SDHC
        LATENCY......................... 1ms+1400 clocks
        SPEED........................... 50MHz
        CLASSES......................... 0 1 0 1 1 0 1 1 0 1 0 1
        BLKLEN.......................... 512
        SIZE............................ 31,154MB
        Iread Vmin...................... 35ma
        Iread Vmax...................... 45ma
        Iwrite Vmin..................... 35ma
        Iwrite Vmax..................... 35ma
    
                     *** SPEEDS ***
        LATENCY......................... 269us,255us,255us,255us,244us,255us,260us,260us,
        SECTOR.......................... 354us,356us,357us,356us,345us,356us,360us,359us,
        BLOCKS.......................... 4,636kB/s @200MHz
    
                       *** MBR ***
        PARTITION....................... 0 00 INACTIVE
        FILE SYSTEM..................... FAT32 LBA
        CHS START....................... 0,130,3
        CHS END......................... 1023,254,63
        FIRST SECTOR.................... $0000_2000
        TOTAL SECTORS................... 31,108,096 = 15,927MB
    
    00170: 0000_0000 0000_0000 0000_0000 0000_0000     '................'
    
                      *** FAT32 ***
        OEM............................. MSDOS5.0
        Byte/Sect....................... 512
        Sect/Clust...................... 64 = 32KB
        FATs............................ 2
        Media........................... F8
        Sect/Track...................... 63
        Heads........................... 255
        Hidden Sectors.................. 8,192 = 4MB
        Sect/Part....................... 31,108,096 = 15,927MB
        Sect/FAT........................ 3,797 = 1MB
        Flags........................... 0
        Ver............................. 00 00
        ROOT Cluster.................... $0000_0002 SECTOR: $0000_4000
        INFO Sector..................... $0001 = $0000_2001
        Backup Sector................... $0006 = $0000_2006
        res............................. 00 00 00 00 00 00 00 00 00 00 00 00
        Drive#.......................... 128
        Ext sig......................... $29 OK!
        Part Serial#.................... $88B0_3114 #2293248276
        Volume Name..................... NO NAME    FAT32    ok
    

    Thanks for all the help! I did try to understand the startup procedure in "Physical_Layer_Simplified_Specification_Ver6.00", thank you, @Wuerfel_21 !
    Christof

  • Oh wow, what a simple fix. Maybe there's a loop missing somewhere where it's supposed to wait for the card to go ready? Idk, if it works it works. I've actually never dealt with SD init, all the proper custom SD drivers I wrote assume that something else already initialized it into SPI mode.

  • Christof Eb.Christof Eb. Posts: 1,213
    edited 2023-04-12 07:37

    @Wuerfel_21 said:
    Oh wow, what a simple fix. Maybe there's a loop missing somewhere where it's supposed to wait for the card to go ready? Idk, if it works it works. I've actually never dealt with SD init, all the proper custom SD drivers I wrote assume that something else already initialized it into SPI mode.

    Yes, I think, the status of initialization is not known well at this point, because Taqoz might be started by flash, or by the file in the SD bootsector or by the _BOOT_P2.BIX file. And the bus might be used by other devices so CS is probably off. Perhaps these cards fall into some sleep more quickly or their healthy sleep needs longer calling "Coffee is ready!" This !SD routine, called by the original !MOUNT, does switch off CS. Perhaps it is not so good to repeat that.

    Some other -perhaps helpful- links for similar problems:
    rjhcoding.com/avrc-sd-interface-1.php
    https://convict.lu/pdf/ProdManualSDCardv1.9.pdf says, that SanDisk cards will go to sleep after 5ms.

Sign In or Register to comment.