startKIT and sc_sdcard library

All technical discussions and projects around startKIT
mhanuel
Member++
Posts: 16
Joined: Mon Apr 07, 2014 3:15 am

startKIT and sc_sdcard library

Postby mhanuel » Fri Apr 11, 2014 4:17 am

Dear all,

I am trying to compile sc_sdcard for startKIT.
I am using the interface 0 defined in the library for SPI signals, that is

Code: Select all

static SDHostInterface SDif[] = {XS1_CLKBLK_1, XS1_CLKBLK_2, XS1_PORT_1O, XS1_PORT_1M, XS1_PORT_1N, XS1_PORT_1P, 0, 0}; // resources used for interface #0
I already change the processor definition in makefile.

When I run the application, It just hangs, I have place printf functions to get into the failure, what I found is kind of disconcerting, it happens that the function disk_initialize; produce some problem at execution time, inside the function there is a call to rcvr_mmc, which generates the initial clock for initialization, the function code is

Code: Select all

void rcvr_mmc (BYTE drv,
  BYTE buff[],  /* Pointer to read buffer */
  UINT bc    /* Number of bytes to receive */
)
{
  BYTE d;

  partout(SDif[drv].mosi, 8, 0xFF);                 // mosi high
  clearbuf(SDif[drv].miso);
  for(int i = 0; i < bc; i++)
  {
    partout(SDif[drv].sclk, 16, CLK_PATTERN);       // load 8 clock
    d = partin(SDif[drv].miso, 8);
    buff[i] = bitrev(d) >> 24;
  }
}

The execution hangs forever when it enter this function, I think the problem resides in this function, if I place a printf at the beginning, I see that it re enter by far more than 10 times, but the call is a finite for loop, as defined in disk_initialize; as

Code: Select all

  for (n = 10; n; n--) rcvr_mmc(drv, buf, 1);  /* 80 dummy clocks */
Also the code hangs somewhere else in the code after exiting the function disk_initialize; on line 2057 of ff.c, I know it because I have comment the code afterwards.

I am pretty new to XMOS, I know the sc_sdcard was not code for startKIT analog IC, but I guess it should be easily ported.

I will appreciate your comments,

Best,
shanthini
New User
Posts: 2
Joined: Tue Jan 28, 2014 5:52 am

Postby shanthini » Wed Apr 16, 2014 7:17 am

The SD card driver for SPI interface has changed.
Please try the software from this link.
https://github.com/shanthinick/sc_sdcard

You will need SPI xSOFTip to build this.
User avatar
LyleHaze
Experienced Member
Posts: 71
Joined: Wed Apr 11, 2012 6:21 am

Postby LyleHaze » Tue Jul 15, 2014 8:10 pm

Interesting..
I am also bringing up the SD interface and FAT file system.. or at least working towards that.

I have been out of the loop for a while now, last time I was here they called them threads instead of cores..

I was building the project for an XS1-L02 chip, but I have changed my mind and decided to build it for an XS1-L16A chip instead. :)

It's not any of the standard developers kits though, so there's always more adjustments to be made. I'm wired for 4 bit access, and hoping to use this to catch debug logs from the host computer.

I was slogging through the various qualifiers for pointers.. wish me luck with that.
Hopefully this new download will be "new style" and hopefully I'll be able to learn from it.

Thanks for the update!
LyleHaze
User avatar
tuck1s
Active Member
Posts: 32
Joined: Thu Sep 25, 2014 1:19 am

Postby tuck1s » Mon Sep 07, 2015 4:12 pm

Thought I'd share my experiences so far with getting the github version of sc_sdcard up and running.
Firstly using SPI (1 bit mode). I followed advice to put 10k pullup resistors into the MISO (pin 7) and CMD (pin 2) lines. I also included 100R series resistors to reduce possible reflections in line with all data lines. Here's a short blog showing my prototype. I'm using a standard StartKit to drive the SD card, actually with the default port allocations used in the GitHub library.

http://tuck1s.blogspot.co.uk/2015/08/xm ... to-sd.html

The adaptor worked first time, and gives OK read/write speeds on a Class 10 16Gbyte card, but not as high as others have got.

I would appreciate some tips on what to look for, in particular to try and increase write speeds.

Code: Select all

15026112 KB total drive space.
15748096 KB available.

Deleting file Data.bin if existing...done.

Creating a new file Data.bin...done.

Writing data to the file...20480 bytes written. Write rate: 215KBytes/Sec

Closing the file...done.

Opening an existing file: Data.bin...done.

Reading file content...20480 bytes read. Read rate: 275KBytes/Sec

Closing the file...done.

Open root directory.

Directory listing...
   <dir>  DCIM
   <dir>  MISC
   <dir>  PRIVATE
    4096  ~1.TRA
   20480  DATA.BIN
   <dir>  TRASHE~1
   <dir>  SYSTEM~1

Test completed.
On a brand new, 32GB Sandisk Ultra card, I got slightly higher speeds, particularly on a second run:

Code: Select all

First time run:

31164768 KB total drive space.
31165440 KB available.

Deleting file Data.bin if existing...done.

Creating a new file Data.bin...done.

Writing data to the file...20480 bytes written. Write rate: 759KBytes/Sec

Closing the file...done.

Opening an existing file: Data.bin...done.

Reading file content...20480 bytes read. Read rate: 291KBytes/Sec

Closing the file...done.

Open root directory.

Directory listing...
   <dir>  DCIM
   <dir>  MISC
   <dir>  PRIVATE
    4096  ~1.TRA
   20480  DATA.BIN
   <dir>  TRASHE~1
   <dir>  FSEVEN~1

Test completed.

----
Second time run:

31164736 KB total drive space.
31165440 KB available.

Deleting file Data.bin if existing...deleted.

Creating a new file Data.bin...done.

Writing data to the file...20480 bytes written. Write rate: 882KBytes/Sec

Closing the file...done.

Opening an existing file: Data.bin...done.

Reading file content...20480 bytes read. Read rate: 995KBytes/Sec

Closing the file...done.

Open root directory.

Directory listing...
   <dir>  DCIM
   <dir>  MISC
   <dir>  PRIVATE
    4096  ~1.TRA
   20480  DATA.BIN
   <dir>  TRASHE~1
   <dir>  FSEVEN~1

Test completed.
I then remapped the SD card to use the default port assignments for 4-bit mode (leaving both 10k pullups and the series R's in place). I found that:
- the 16GB card would not work at all
- the 32GB card works, and gives high-ish read speeds, but slower write speeds:

Code: Select all

Starting with BUS_MODE_4BIT
31164736 KB total drive space.
31165440 KB available.

Deleting file Data.bin if existing...deleted.

Creating a new file Data.bin...done.

Writing data to the file...20480 bytes written. Write rate: 690KBytes/Sec

Closing the file...done.

Opening an existing file: Data.bin...done.

Reading file content...20480 bytes read. Read rate: 1908KBytes/Sec

Closing the file...done.

Open root directory.

Directory listing...
   <dir>  DCIM
   <dir>  MISC
   <dir>  PRIVATE
    4096  ~1.TRA
   20480  DATA.BIN
   <dir>  TRASHE~1
   <dir>  FSEVEN~1

Test completed.
----
Starting with BUS_MODE_4BIT
31164736 KB total drive space.
31165440 KB available.

Deleting file Data.bin if existing...deleted.

Creating a new file Data.bin...done.

Writing data to the file...20480 bytes written. Write rate: 784KBytes/Sec

Closing the file...done.

Opening an existing file: Data.bin...done.

Reading file content...20480 bytes read. Read rate: 1907KBytes/Sec

Closing the file...done.

Open root directory.

Directory listing...
   <dir>  DCIM
   <dir>  MISC
   <dir>  PRIVATE
    4096  ~1.TRA
   20480  DATA.BIN
   <dir>  TRASHE~1
   <dir>  FSEVEN~1

Test completed.
----
Starting with BUS_MODE_4BIT
31164736 KB total drive space.
31165440 KB available.

Deleting file Data.bin if existing...deleted.

Creating a new file Data.bin...done.

Writing data to the file...20480 bytes written. Write rate: 888KBytes/Sec

Closing the file...done.

Opening an existing file: Data.bin...done.

Reading file content...20480 bytes read. Read rate: 1909KBytes/Sec

Closing the file...done.

Open root directory.

Directory listing...
   <dir>  DCIM
   <dir>  MISC
   <dir>  PRIVATE
    4096  ~1.TRA
   20480  DATA.BIN
   <dir>  TRASHE~1
   <dir>  FSEVEN~1

Test completed.

User avatar
tuck1s
Active Member
Posts: 32
Joined: Thu Sep 25, 2014 1:19 am

Postby tuck1s » Mon Sep 07, 2015 11:20 pm

Screenshot 2015-09-07 23.24.55.png
Some further results with sustained writing & reading. I can get over 1000 Kbytes/sec writing, by setting the test size to (512 * 32) i.e. 16Kbyte block size rather than the test program default of (512*40).

By capturing 100 consecutive runs, then printing out the results, I see

Code: Select all

Starting with BUS_MODE_4BIT
31163968 KB total drive space.
31165440 KB available.

Deleting file Data.bin if existing...deleted.

Creating a new file Data.bin...done.

Writing data to the file
Run    0: 16384 bytes written. Write rate: 811 KBytes/Sec
Run    1: 16384 bytes written. Write rate: 1143 KBytes/Sec
Run    2: 16384 bytes written. Write rate: 1022 KBytes/Sec
Run    3: 16384 bytes written. Write rate: 1006 KBytes/Sec
Run    4: 16384 bytes written. Write rate: 1136 KBytes/Sec
Run    5: 16384 bytes written. Write rate: 1143 KBytes/Sec
Run    6: 16384 bytes written. Write rate: 1024 KBytes/Sec
Run    7: 16384 bytes written. Write rate: 1048 KBytes/Sec
Run    8: 16384 bytes written. Write rate: 1135 KBytes/Sec
Run    9: 16384 bytes written. Write rate: 1148 KBytes/Sec
Run   10: 16384 bytes written. Write rate: 1025 KBytes/Sec
Run   11: 16384 bytes written. Write rate: 1049 KBytes/Sec
Run   12: 16384 bytes written. Write rate: 1141 KBytes/Sec
Run   13: 16384 bytes written. Write rate: 1148 KBytes/Sec
Run   14: 16384 bytes written. Write rate: 1031 KBytes/Sec
Run   15: 16384 bytes written. Write rate: 1050 KBytes/Sec
Run   16: 16384 bytes written. Write rate: 1129 KBytes/Sec
Run   17: 16384 bytes written. Write rate: 1143 KBytes/Sec
Run   18: 16384 bytes written. Write rate: 1033 KBytes/Sec
Run   19: 16384 bytes written. Write rate: 1055 KBytes/Sec
Run   20: 16384 bytes written. Write rate: 1135 KBytes/Sec
Run   21: 16384 bytes written. Write rate: 1143 KBytes/Sec
Run   22: 16384 bytes written. Write rate: 1025 KBytes/Sec
Run   23: 16384 bytes written. Write rate: 1048 KBytes/Sec
Run   24: 16384 bytes written. Write rate: 1134 KBytes/Sec
Run   25: 16384 bytes written. Write rate: 1143 KBytes/Sec
Run   26: 16384 bytes written. Write rate: 1027 KBytes/Sec
Run   27: 16384 bytes written. Write rate: 1005 KBytes/Sec
Run   28: 16384 bytes written. Write rate: 1138 KBytes/Sec
Run   29: 16384 bytes written. Write rate: 1128 KBytes/Sec
Run   30: 16384 bytes written. Write rate: 1027 KBytes/Sec
Run   31: 16384 bytes written. Write rate: 1048 KBytes/Sec
Run   32: 16384 bytes written. Write rate: 1132 KBytes/Sec
Run   33: 16384 bytes written. Write rate: 1145 KBytes/Sec
Run   34: 16384 bytes written. Write rate: 1019 KBytes/Sec
Run   35: 16384 bytes written. Write rate: 1138 KBytes/Sec
Run   36: 16384 bytes written. Write rate: 1144 KBytes/Sec
Run   37: 16384 bytes written. Write rate: 589 KBytes/Sec
Run   38: 16384 bytes written. Write rate: 1134 KBytes/Sec
Run   39: 16384 bytes written. Write rate: 1128 KBytes/Sec
Run   40: 16384 bytes written. Write rate: 1123 KBytes/Sec
Run   41: 16384 bytes written. Write rate: 1138 KBytes/Sec
Run   42: 16384 bytes written. Write rate: 1119 KBytes/Sec
Run   43: 16384 bytes written. Write rate: 1139 KBytes/Sec
Run   44: 16384 bytes written. Write rate: 1017 KBytes/Sec
Run   45: 16384 bytes written. Write rate: 1133 KBytes/Sec
Run   46: 16384 bytes written. Write rate: 1136 KBytes/Sec
Run   47: 16384 bytes written. Write rate: 1042 KBytes/Sec
Run   48: 16384 bytes written. Write rate: 1124 KBytes/Sec
Run   49: 16384 bytes written. Write rate: 1136 KBytes/Sec
Run   50: 16384 bytes written. Write rate: 1013 KBytes/Sec
Run   51: 16384 bytes written. Write rate: 1040 KBytes/Sec
Run   52: 16384 bytes written. Write rate: 1124 KBytes/Sec
Run   53: 16384 bytes written. Write rate: 1137 KBytes/Sec
Run   54: 16384 bytes written. Write rate: 1010 KBytes/Sec
Run   55: 16384 bytes written. Write rate: 1004 KBytes/Sec
Run   56: 16384 bytes written. Write rate: 1135 KBytes/Sec
Run   57: 16384 bytes written. Write rate: 1148 KBytes/Sec
Run   58: 16384 bytes written. Write rate: 1016 KBytes/Sec
Run   59: 16384 bytes written. Write rate: 1005 KBytes/Sec
Run   60: 16384 bytes written. Write rate: 1135 KBytes/Sec
Run   61: 16384 bytes written. Write rate: 1143 KBytes/Sec
Run   62: 16384 bytes written. Write rate: 1026 KBytes/Sec
Run   63: 16384 bytes written. Write rate: 1050 KBytes/Sec
Run   64: 16384 bytes written. Write rate: 1128 KBytes/Sec
Run   65: 16384 bytes written. Write rate: 1141 KBytes/Sec
Run   66: 16384 bytes written. Write rate: 1026 KBytes/Sec
Run   67: 16384 bytes written. Write rate: 1046 KBytes/Sec
Run   68: 16384 bytes written. Write rate: 1129 KBytes/Sec
Run   69: 16384 bytes written. Write rate: 1136 KBytes/Sec
Run   70: 16384 bytes written. Write rate: 1021 KBytes/Sec
Run   71: 16384 bytes written. Write rate: 1050 KBytes/Sec
Run   72: 16384 bytes written. Write rate: 1129 KBytes/Sec
Run   73: 16384 bytes written. Write rate: 1136 KBytes/Sec
Run   74: 16384 bytes written. Write rate: 1023 KBytes/Sec
Run   75: 16384 bytes written. Write rate: 1049 KBytes/Sec
Run   76: 16384 bytes written. Write rate: 1124 KBytes/Sec
Run   77: 16384 bytes written. Write rate: 1142 KBytes/Sec
Run   78: 16384 bytes written. Write rate: 1020 KBytes/Sec
Run   79: 16384 bytes written. Write rate: 1052 KBytes/Sec
Run   80: 16384 bytes written. Write rate: 1129 KBytes/Sec
Run   81: 16384 bytes written. Write rate: 1142 KBytes/Sec
Run   82: 16384 bytes written. Write rate: 1026 KBytes/Sec
Run   83: 16384 bytes written. Write rate: 1052 KBytes/Sec
Run   84: 16384 bytes written. Write rate: 1130 KBytes/Sec
Run   85: 16384 bytes written. Write rate: 1142 KBytes/Sec
Run   86: 16384 bytes written. Write rate: 1023 KBytes/Sec
Run   87: 16384 bytes written. Write rate: 1015 KBytes/Sec
Run   88: 16384 bytes written. Write rate: 1130 KBytes/Sec
Run   89: 16384 bytes written. Write rate: 1142 KBytes/Sec
Run   90: 16384 bytes written. Write rate: 1025 KBytes/Sec
Run   91: 16384 bytes written. Write rate: 1016 KBytes/Sec
Run   92: 16384 bytes written. Write rate: 1129 KBytes/Sec
Run   93: 16384 bytes written. Write rate: 1142 KBytes/Sec
Run   94: 16384 bytes written. Write rate: 1025 KBytes/Sec
Run   95: 16384 bytes written. Write rate: 1057 KBytes/Sec
Run   96: 16384 bytes written. Write rate: 1129 KBytes/Sec
Run   97: 16384 bytes written. Write rate: 1142 KBytes/Sec
Run   98: 16384 bytes written. Write rate: 1019 KBytes/Sec
Run   99: 16384 bytes written. Write rate: 1052 KBytes/Sec

Closing the file...done.

Opening an existing file: Data.bin...done.

Reading file content...Run    0: 16384 bytes read. Read rate: 1601 KBytes/Sec
Run    1: 16384 bytes read. Read rate: 1874 KBytes/Sec
Run    2: 16384 bytes read. Read rate: 1698 KBytes/Sec
Run    3: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run    4: 16384 bytes read. Read rate: 1893 KBytes/Sec
Run    5: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run    6: 16384 bytes read. Read rate: 1891 KBytes/Sec
Run    7: 16384 bytes read. Read rate: 1877 KBytes/Sec
Run    8: 16384 bytes read. Read rate: 1892 KBytes/Sec
Run    9: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   10: 16384 bytes read. Read rate: 1890 KBytes/Sec
Run   11: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   12: 16384 bytes read. Read rate: 1894 KBytes/Sec
Run   13: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run   14: 16384 bytes read. Read rate: 1890 KBytes/Sec
Run   15: 16384 bytes read. Read rate: 1875 KBytes/Sec
Run   16: 16384 bytes read. Read rate: 1894 KBytes/Sec
Run   17: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run   18: 16384 bytes read. Read rate: 1888 KBytes/Sec
Run   19: 16384 bytes read. Read rate: 1873 KBytes/Sec
Run   20: 16384 bytes read. Read rate: 1892 KBytes/Sec
Run   21: 16384 bytes read. Read rate: 1877 KBytes/Sec
Run   22: 16384 bytes read. Read rate: 1891 KBytes/Sec
Run   23: 16384 bytes read. Read rate: 1875 KBytes/Sec
Run   24: 16384 bytes read. Read rate: 1894 KBytes/Sec
Run   25: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run   26: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   27: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run   28: 16384 bytes read. Read rate: 1892 KBytes/Sec
Run   29: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run   30: 16384 bytes read. Read rate: 1891 KBytes/Sec
Run   31: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run   32: 16384 bytes read. Read rate: 1893 KBytes/Sec
Run   33: 16384 bytes read. Read rate: 1881 KBytes/Sec
Run   34: 16384 bytes read. Read rate: 1895 KBytes/Sec
Run   35: 16384 bytes read. Read rate: 1877 KBytes/Sec
Run   36: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   37: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   38: 16384 bytes read. Read rate: 1890 KBytes/Sec
Run   39: 16384 bytes read. Read rate: 1879 KBytes/Sec
Run   40: 16384 bytes read. Read rate: 1893 KBytes/Sec
Run   41: 16384 bytes read. Read rate: 1881 KBytes/Sec
Run   42: 16384 bytes read. Read rate: 1893 KBytes/Sec
Run   43: 16384 bytes read. Read rate: 1881 KBytes/Sec
Run   44: 16384 bytes read. Read rate: 1892 KBytes/Sec
Run   45: 16384 bytes read. Read rate: 1873 KBytes/Sec
Run   46: 16384 bytes read. Read rate: 1887 KBytes/Sec
Run   47: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   48: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   49: 16384 bytes read. Read rate: 1877 KBytes/Sec
Run   50: 16384 bytes read. Read rate: 1888 KBytes/Sec
Run   51: 16384 bytes read. Read rate: 1877 KBytes/Sec
Run   52: 16384 bytes read. Read rate: 1893 KBytes/Sec
Run   53: 16384 bytes read. Read rate: 1874 KBytes/Sec
Run   54: 16384 bytes read. Read rate: 1891 KBytes/Sec
Run   55: 16384 bytes read. Read rate: 1875 KBytes/Sec
Run   56: 16384 bytes read. Read rate: 1891 KBytes/Sec
Run   57: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run   58: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   59: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   60: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   61: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   62: 16384 bytes read. Read rate: 1888 KBytes/Sec
Run   63: 16384 bytes read. Read rate: 1875 KBytes/Sec
Run   64: 16384 bytes read. Read rate: 1892 KBytes/Sec
Run   65: 16384 bytes read. Read rate: 1875 KBytes/Sec
Run   66: 16384 bytes read. Read rate: 1888 KBytes/Sec
Run   67: 16384 bytes read. Read rate: 1875 KBytes/Sec
Run   68: 16384 bytes read. Read rate: 1893 KBytes/Sec
Run   69: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   70: 16384 bytes read. Read rate: 1887 KBytes/Sec
Run   71: 16384 bytes read. Read rate: 1877 KBytes/Sec
Run   72: 16384 bytes read. Read rate: 1892 KBytes/Sec
Run   73: 16384 bytes read. Read rate: 1873 KBytes/Sec
Run   74: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   75: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run   76: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   77: 16384 bytes read. Read rate: 1875 KBytes/Sec
Run   78: 16384 bytes read. Read rate: 1887 KBytes/Sec
Run   79: 16384 bytes read. Read rate: 1873 KBytes/Sec
Run   80: 16384 bytes read. Read rate: 1892 KBytes/Sec
Run   81: 16384 bytes read. Read rate: 1872 KBytes/Sec
Run   82: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   83: 16384 bytes read. Read rate: 1874 KBytes/Sec
Run   84: 16384 bytes read. Read rate: 1892 KBytes/Sec
Run   85: 16384 bytes read. Read rate: 1873 KBytes/Sec
Run   86: 16384 bytes read. Read rate: 1886 KBytes/Sec
Run   87: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   88: 16384 bytes read. Read rate: 1891 KBytes/Sec
Run   89: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   90: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   91: 16384 bytes read. Read rate: 1876 KBytes/Sec
Run   92: 16384 bytes read. Read rate: 1892 KBytes/Sec
Run   93: 16384 bytes read. Read rate: 1878 KBytes/Sec
Run   94: 16384 bytes read. Read rate: 1889 KBytes/Sec
Run   95: 16384 bytes read. Read rate: 1873 KBytes/Sec
Run   96: 16384 bytes read. Read rate: 1891 KBytes/Sec
Run   97: 16384 bytes read. Read rate: 1874 KBytes/Sec
Run   98: 16384 bytes read. Read rate: 1885 KBytes/Sec
Run   99: 16384 bytes read. Read rate: 1875 KBytes/Sec

Closing the file...done.

Open root directory.

Directory listing...
   <dir>  DCIM
   <dir>  MISC
   <dir>  PRIVATE
    4096  ~1.TRA
 1638400  DATA.BIN
   <dir>  TRASHE~1
   <dir>  FSEVEN~1

Test completed.
I wonder if this is the max speed for this card, or whether the StartKit core is the limiting factor? The card is one of these: http://cpc.farnell.com/sandisk/sdsdun-0 ... st=MD00550

Here are two separate runs of 100 writes, with the speed in Kbytes/sec graphed.
Screenshot 2015-09-07 23.24.55.png
Interestingly there are dips part way through both runs - I wonder if the card is going off for a while to do housekeeping.
You do not have the required permissions to view the files attached to this post.
User avatar
tuck1s
Active Member
Posts: 32
Joined: Thu Sep 25, 2014 1:19 am

Postby tuck1s » Tue Sep 08, 2015 12:16 am

Another test result: Recompiled the project in "release" node rather than "debug". The first system call returns with an error RC=13 which means FR_NO_FILESYSTEM. I wonder if release mode is somehow running faster, and is violating card timings?
Or maybe my 100R series resistors are causing trouble?

Adding some debug into file ff.c:

Code: Select all

  if (fmt == 3) return FR_DISK_ERR;
  if (fmt) {
      printf("Bombing with fmt = %d\n", fmt);
      return FR_NO_FILESYSTEM;    /* No FAT volume is found */
It returns with:

Code: Select all

Getting free cluster info ...
Got to here in chk_mounted
Bombing with fmt = 2

Failed with rc=13.
User avatar
tuck1s
Active Member
Posts: 32
Joined: Thu Sep 25, 2014 1:19 am

Postby tuck1s » Wed Sep 09, 2015 5:36 pm

I found the problem with 'release' mode compilation in my implementation.

The library uses programmed I/O to pulse the clock lines, which in (with optimisation level -O3 on the compiler) was just too fast for my electrical setup.

If I add some asm("nop")s into the critical sections - i.e. everywhere the file SDCardHost4Bit.xc manipulates SDif[IfNum].Clk - then it works fine and I get around 4.5Mbytes/s read, and 2.0Mbytes/s write performance.

However I noticed that it appeared possible to achieve even higher write speeds, without errors reported, but the file on the card was not being changed (it was apparently not deleted on re-run).
Perhaps this is because the code isn't checking CRCs on readback:

Code: Select all

      case DAT_RECEIVING_CRC: // ignoring crc. todo?
        //SDif.Dat :> Dat;
        if(--j) break; // discard 17 nibbles ( 8 bytes CRC + 1 nibble end data )
        if(DatByteCount < DatBytesLen)
Does it check that the SD card is happy with the incoming CRC on write, or does that just fail silently?
User avatar
tuck1s
Active Member
Posts: 32
Joined: Thu Sep 25, 2014 1:19 am

Postby tuck1s » Wed Sep 09, 2015 11:31 pm

I have modified test files that now work reliably on two different Class10 cards (meaning that the file contents are as expected afterward when checked on a PC).

On the SD card adapter, I found the following description useful (although I'm using discrete resistors, not this part).
http://www.nxp.com/documents/applicatio ... N10911.pdf

I lowered my series resistors to 22R and have pullups of 15K on all active lines except for CLK.

The timing changes are made in file SDCardHost4Bit.xc.
The main program sdcard_test.xc has been enhanced to provide multiple iterations over the data for timing and checking purposes, with 16k blocks.
SDCardHost4Bit.xc
sdcard_test.c
I wonder whether the busy-waits in this design could be replaced with a more event-driven approach (and the CRC checks added).
You do not have the required permissions to view the files attached to this post.
User avatar
tuck1s
Active Member
Posts: 32
Joined: Thu Sep 25, 2014 1:19 am

Postby tuck1s » Fri Sep 18, 2015 12:58 am

The 4-bit SD card code currently on GitHub treats the clock line as Idle=1.

Information from http://wiki.seabright.co.nz/wiki/SdCardProtocol.html:

Data is clocked into the host or card on the rising edge of CLK and changes on the falling edge.
This is equivalent to the SPI (0, 0) mode.


I've got an experimental version running, and this seems to be more stable, happier to run with fewer NOPs than the previous version, and is giving around 2.9 MB/s write and 4.2MB/s read. I've also enhanced the test code to check the actual file contents read back from the card.

It now seems to give good performance even with smaller block sizes:
File created in 512 blocks of size 16384 bytes: Write rate min: 944, max: 3218, avg: 2928 Kbytes/sec
File created in 512 blocks of size 8192 bytes: Write rate min: 629, max: 2825, avg: 2437 Kbytes/sec
File created in 512 blocks of size 4096 bytes: Write rate min: 373, max: 2261, avg: 1771 Kbytes/sec
File created in 512 blocks of size 2048 bytes: Write rate min: 209, max: 1624, avg: 1252 Kbytes/sec
File created in 512 blocks of size 1024 bytes: Write rate min: 96, max: 1031, avg: 794 Kbytes/sec
meenadora
New User
Posts: 3
Joined: Mon Jul 18, 2016 4:23 am

Postby meenadora » Mon Jul 18, 2016 4:46 am

Hi All,

Does anyone have any latest update on SD card benchmarking with XMOS interface?
I am running the example project and getting up to 3.8MB write performance with 512 blocks of 16384 bytes on ScanDisk Chlass 10 16GB SD card. But I also observe the dip in performance mid way through the sequential writes as another user indicated. Does anyone have an idea on why the sd write speed dips in between and then resumes to average speed?

Thanks,
M Dora

Who is online

Users browsing this forum: No registered users and 1 guest