SD Drivers for REVa - FSRW (working) and physical SPI

1235»

Comments

  • I'm wondering how much faster this is with the assembly driver versus just plain Spin (or FastSpin)…

    I think the regular SPI interface for SD is limited to 25 MHz, right?

    Also, can a smartpin be used to make it better in Spin?
  • Peter JakackiPeter Jakacki Posts: 8,980
    edited 2020-02-10 - 14:37:01
    I am hitting around 35MHz with a sustained read of over 3MBs and the SPI limit for SDHC is 50MHz but you would have to be careful with board layout.

    This is the CSD report from a common Sandisk:
    TAQOZ# .CARD --- SANDISK   SD SC64G REV$80 #35190404 DATE:2018 /10 ok
    TAQOZ# .CSD --- 
    
                       *** 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............................ 62,367MB
        Iread Vmin...................... 10ma
        Iread Vmax...................... 25ma
        Iwrite Vmin..................... 60ma
        Iwrite Vmax..................... 35ma ok
    TAQOZ# 
    
  • Rayman wrote: »
    I'm wondering how much faster this is with the assembly driver versus just plain Spin (or FastSpin)…

    I think the regular SPI interface for SD is limited to 25 MHz, right?

    Also, can a smartpin be used to make it better in Spin?

    That's a really good question! To be honest, I'm not really sure. I think a pure spin2/fastspin version would probably be pretty close in speed to the current code. There's still a lot of optimizations I'm missing along the way. I wanted to get something working and incrementally improve along the way, although now that it's working I haven't had a lot of time to revisit.

    One of the things I've been thinking about a lot is pushing data directly to LUT. I also need to add the ability to load a binary.
  • roglohrogloh Posts: 2,012
    edited 2020-02-11 - 03:31:45
    @Peter Jakacki Is the maximum clock speed reported by the SDCARD the same for SPI and SD modes? For some weird reason I thought I read somewhere that legacy SPI mode was limited to 25MHz and if you wanted to operate at higher frequencies than that you'd need to move into SD mode. Perhaps this is something that is card dependent or only for older card types. I realize from a board signal integrity viewpoint both modes should be limited to about the same so it might come down to whether the SD card's internal processor / logic path is designed to clock data via SPI at this rate.
  • cheezuscheezus Posts: 291
    edited 2020-02-11 - 05:23:09
    rogloh wrote: »
    @Peter Jakacki Is the maximum clock speed reported by the SDCARD the same for SPI and SD modes? For some weird reason I thought I read somewhere that legacy SPI mode was limited to 25MHz and if you wanted to operate at higher frequencies than that you'd need to move into SD mode. Perhaps this is something that is card dependent or only for older card types. I realize from a board signal integrity viewpoint both modes should be limited to about the same so it might come down to whether the SD card's internal processor / logic path is designed to clock data via SPI at this rate.

    I was just wondering the same and found this. -see pg 88
    http://users.ece.utexas.edu/~valvano/EE345M/SD_Physical_Layer_Spec.pdf
    • TRAN_SPEED The following table defines the maximum data transfer rate per one data line - 
    TRAN_SPEED:   TRAN_SPEED bit code 
    2:0 transfer rate unit 0=100kbit/s, 1=1Mbit/s, 2=10Mbit/s, 3=100Mbit/s, 
    4... 7=reserved 
    6:3 time value 0=reserved, 1=1.0, 2=1.2, 3=1.3, 4=1.5, 5=2.0, 6=2.5, 7=3.0, 8=3.5, 9=4.0, 
    A=4.5, B=5.0, C=5.5, D=6.0, E=7.0, F=8.0 7 reserved   
    Table 5-6: Maximum Data Transfer Rate Definition 
     
    Note that for current SD Memory Cards, this field shall be always 0_0110_010b (032h) which is equal to 25 MHz - 
    the mandatory maximum operating frequency of SD Memory Card. 
    In High-Speed mode, this field shall be always 0_1011_010b (05Ah) which is equal to 50 MHz, 
    and when the timing mode returns to the default by CMD6 or CMD0 command, its value will be 032h. 
    

    So another improvement I need to make is to read this register and adjust SPI clk accordingly. Right now I have the constant spi_clk_max =25 that I should probably keep as a hard limiting factor.

    *edited table- poor formatting
  • The old SD SPI spec and cards were limited to 25MHz but this was upped a long time ago to, 50MHz. The various SD modes themselves may specify clock rates over 200MHz.
    Obviously I have gone well and truly over 25MHz without any problems.
  • cheezus wrote: »
    Note that for current SD Memory Cards, this field shall be always 0_0110_010b (032h) which is equal to 25 MHz - the mandatory maximum operating frequency of SD Memory Card. In High-Speed mode,

    This is true for plain old-fashioned "SD" cards, but nobody sells or uses SD cards anymore, they are all SDHC or better, and I have never seen this field anything other than 50MHz in SDHC.

  • cheezus wrote: »
    Note that for current SD Memory Cards, this field shall be always 0_0110_010b (032h) which is equal to 25 MHz - the mandatory maximum operating frequency of SD Memory Card. In High-Speed mode,

    This is true for plain old-fashioned "SD" cards, but nobody sells or uses SD cards anymore, they are all SDHC or better, and I have never seen this field anything other than 50MHz in SDHC.

    That was poorly formatted, sorry. That table looks a bit better now. All HC cards are High Speed... The part I need to wrap my head around next is when the timing mode returns to the default by CMD6 or CMD0 command

    I keep thinking it might be handy to have a test, to determine IF the hardware is able to run up to the speed specified by the card. Still not sure how to do this...
  • Changing to a 340MHz clock for P2 I measure the SD clock at around 42MHz. This is the result of the encounter.
    TAQOZ# 340 P2MHZ --- ok
    TAQOZ# 0 0 CMD . --- 1  ok
    TAQOZ#  ---  ok
    TAQOZ# MOUNT ---  CARD: SANDISK   SD SC64G REV$80 #35190404 DATE:2018 /10 ok
    TAQOZ# .CSD --- 
    
                       *** 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............................ 62,367MB
        Iread Vmin...................... 10ma
        Iread Vmax...................... 25ma
        Iwrite Vmin..................... 60ma
        Iwrite Vmax..................... 35ma ok
    
Sign In or Register to comment.