[libmaple] SDIO

Limited support for STM32F4 Discovery, Nucleo and custom F4 boards
User avatar
Pito
Posts: 1531
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [libmaple] SDIO

Post by Pito » Wed Jul 05, 2017 2:01 pm

But it can also be a difference between the boards, since your board is not the "generic black F4VET" one. Is the difference only in the chip or are there other differences?
The only difference is the chip and maybe +/- 1-3cm in SDIO's signal wires length.
The same vendor, similar layout..
My board: http://www.stm32duino.com/viewtopic.php ... =30#p22456

PS: why the write speed in above benchmark is 1/7 of the read speed?

Code: Select all

4096,512.36,3560.81
8192,504.73,3560.76
16384,504.18,3524.25
32768,504.84,3522.68
Pukao Hats Cleaning Services Ltd.

stevestrong
Posts: 1612
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [libmaple] SDIO

Post by stevestrong » Wed Jul 05, 2017 2:21 pm

Pito wrote:
Wed Jul 05, 2017 2:01 pm
PS: why the write speed in above benchmark is 1/7 of the read speed?

Code: Select all

4096,512.36,3560.81
8192,504.73,3560.76
16384,504.18,3524.25
32768,504.84,3522.68
Good question. Is this a CL4 card? I assume this has to do with the card physical properties.
stephen's results also show saturated values for 4kB (and more) large buffer: viewtopic.php?f=39&t=2215&start=40#p30985

I'll check my results again later today.

I'll post a binary file and a sketch to test in the first post.

zmemw16
Posts: 1422
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: [libmaple] SDIO

Post by zmemw16 » Wed Jul 05, 2017 3:33 pm

on my hub i've replaced the wimpy supplied walwart with a 5V 4A capable one
although just about everything hangs off the hub, ols,2x usb serial, stlink and the board.

stephen

stevestrong
Posts: 1612
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [libmaple] SDIO

Post by stevestrong » Wed Jul 05, 2017 3:48 pm

I updated the first post with two attachments, one INO example and the corresponding BIN file.
The results today are similar to what I have measured that time (SanDisk Ultra 16GB CL10 card)

Code: Select all

Type any character to start.

size,write,read
bytes,KB/sec,KB/sec
512,352.13,1855.96
1024,615.75,2573.66
2048,1273.42,3993.01
4096,3232.87,6568.02
8192,5171.66,8589.67
16384,6754.45,9880.24
32768,8231.03,10657.71

totalMicros  64281101
yieldMicros  44535132
yieldCalls   53279
yieldMaxUsec 134928
kHzSdClk     24000
Done

Type any character to start.

size,write,read
bytes,KB/sec,KB/sec
512,430.66,2197.68
1024,684.68,2444.70
2048,1424.19,4174.99
4096,3339.52,6118.28
8192,5012.46,8629.27
16384,6870.03,9874.56
32768,8144.14,10624.18

totalMicros  57296702
yieldMicros  38051319
yieldCalls   51383
yieldMaxUsec 116471
kHzSdClk     24000
Done
...
and this for CL4 card:

Code: Select all

size,write,read
bytes,KB/sec,KB/sec
512,185.31,863.50
1024,358.01,1054.87
2048,645.52,2104.41
4096,file.write returned: 4294967295
error: write failed
SD errorCode: 0X60,0X0
no warm-up effect for me, so that I can reliably reproduce the issue.

UPDATE 1
It looks like the writing of the very first 8 blocks group will be timed out by DMA.
Increasing timeout to 1 sec.

UPDATE 2
It seems that more timeout helped:

Code: Select all

size,write,read
bytes,KB/sec,KB/sec
512,185.99,860.55
1024,357.34,1056.89
2048,646.17,2090.50
4096,1094.19,4065.31
8192,1094.58,4057.11
16384,1096.93,4040.55
32768,1092.60,4063.81

totalMicros  142184940
yieldMicros  106522579
yieldCalls   115617
yieldMaxUsec 148572
kHzSdClk     24000
Done
I will change the timeout in repo.
Last edited by stevestrong on Wed Jul 05, 2017 6:07 pm, edited 2 times in total.

User avatar
Pito
Posts: 1531
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [libmaple] SDIO

Post by Pito » Wed Jul 05, 2017 5:36 pm

I've decided to risk :) and I've tried with your binary on Black F407ZET6 board (cards not formatted before the test):
Samsung EVO CL10 8GB

Code: Select all

SdFatSdio uses a traditional DMA SDIO implementation.

Type any character to start.

size,write,read
bytes,KB/sec,KB/sec
512,268.75,1186.61
1024,578.31,2013.27
2048,902.17,3499.82
4096,2799.68,5325.05
8192,4729.74,7705.77
16384,7165.14,9325.13
32768,8636.38,10346.14

totalMicros  79935842
yieldMicros  56356622
yieldCalls   114859
yieldMaxUsec 199834
kHzSdClk     24000
Done

Type any character to start.
Samsung EVO CL10 16GB

Code: Select all

size,write,read
bytes,KB/sec,KB/sec
512,315.42,1295.00
1024,486.53,2033.53
2048,1517.90,3509.05
4096,2738.69,5332.19
8192,4632.94,7709.81
16384,7191.61,9327.00
32768,8425.72,10344.20

totalMicros  73763594
yieldMicros  50792680
yieldCalls   114860
yieldMaxUsec 198584
kHzSdClk     24000
Done
Sandisk Ultra CL10 16GB, card 1.

Code: Select all

size,write,read
bytes,KB/sec,KB/sec
512,439.61,1914.48
1024,538.54,2518.62
2048,1441.54,4153.86
4096,3370.35,6156.08
8192,6380.76,8115.88
16384,7596.10,9546.00
32768,9727.74,10468.51

totalMicros  60056059
yieldMicros  40286200
yieldCalls   52631
yieldMaxUsec 74410
kHzSdClk     24000
Done
Sandisk Ultra CL10 16GB, card 2.

Code: Select all

size,write,read
bytes,KB/sec,KB/sec
512,362.94,1666.05
1024,602.00,2421.28
2048,1303.10,4093.86
4096,3167.93,6554.75
8192,5363.25,8609.24
16384,6699.70,9865.31
32768,7869.86,10634.55

totalMicros  64457002
yieldMicros  43704083
yieldCalls   51403
yieldMaxUsec 124242
kHzSdClk     24000
Done
Sandisk CL4, 4GB

Code: Select all

size,write,read
bytes,KB/sec,KB/sec
512,342.61,1162.36
1024,646.56,1869.17
2048,1118.13,3018.84
4096,file.write returned: 4294967295
error: write failed
SD errorCode: 0X60,0X0
Kingston CL4 4GB, after several minutes (and after formatting too):

Code: Select all

size,write,read
bytes,KB/sec,KB/sec
512,
I would add a message "Please wait - the 512 test may last for 15 seconds.." otherwise I start to panic.. :roll:
Pukao Hats Cleaning Services Ltd.

stevestrong
Posts: 1612
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [libmaple] SDIO

Post by stevestrong » Wed Jul 05, 2017 10:39 pm

I updated the first post with new BIN and INO files, a fix was necessary for CL4 cards to work with buffers greater or equal than 4kB.
Additionally I added to monitor log info about the SD card.
And, as requested, the user gets warned about the time to wait.
Last edited by stevestrong on Wed Jul 05, 2017 10:53 pm, edited 2 times in total.

User avatar
Pito
Posts: 1531
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [libmaple] SDIO

Post by Pito » Wed Jul 05, 2017 10:50 pm

Kingston CL4 4GB (formatted)

Code: Select all

######################################################
This sketch demonstrates STM32F4 SDIO (DMA) implementation.
######################################################

init time: 7 ms

Card type: SDHC

Manufacturer ID: 2
OEM ID: TM
Product: SA04G
Version: 0.6
Serial number: 289b4188
Manufacturing date: 3/2011

cardSize: 3951.03 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: c0ff8000

Volume is FAT32
blocksPerCluster: 64
clusterCount: 120320
freeClusters: 120193
freeSpace: 3938.48 MB (MB = 1,000,000 bytes)
fatStartBlock: 14502
fatCount: 2
blocksPerFat: 941
rootDirStart: 2
dataStartBlock: 16384

FreeStack: 84095
######################################################

Type any character to start

Test started - please wait, it may take up to 3 minutes

size, write, read
bytes, KB/sec, KB/sec
512,
Sandisk CL4 4GB (formatted)

Code: Select all

######################################################
This sketch demonstrates STM32F4 SDIO (DMA) implementation.
######################################################

init time: 12 ms

Card type: SDHC

Manufacturer ID: 3
OEM ID: SD
Product: SU04G
Version: 8.0
Serial number: cb65e554
Manufacturing date: 10/2011

cardSize: 3965.19 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: c0ff8000

Volume is FAT32
blocksPerCluster: 64
clusterCount: 120752
freeClusters: 120751
freeSpace: 3956.77 MB (MB = 1,000,000 bytes)
fatStartBlock: 14496
fatCount: 2
blocksPerFat: 944
rootDirStart: 2
dataStartBlock: 16384

FreeStack: 84095
######################################################

Type any character to start

Test started - please wait, it may take up to 3 minutes

size, write, read
bytes, KB/sec, KB/sec
512, 350.17, 1140.61
1024, 657.74, 1869.21
2048, 1142.84, 2936.87
4096, 2382.75, 5641.95
8192, 2199.07, 7567.05
16384, 4125.74, 9295.20
32768, 6569.25, 10285.50

totalMicros  73707421
yieldMicros  48709966
yieldCalls   52923
yieldMaxUsec 209866
kHzSdClk     24000
Done

Type any character to start
Last edited by Pito on Wed Jul 05, 2017 10:58 pm, edited 3 times in total.
Pukao Hats Cleaning Services Ltd.

stevestrong
Posts: 1612
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [libmaple] SDIO

Post by stevestrong » Wed Jul 05, 2017 10:55 pm

@Pito, did you wait 3 minutes?

User avatar
Pito
Posts: 1531
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [libmaple] SDIO

Post by Pito » Wed Jul 05, 2017 10:59 pm

Nope, I started to panic.. I'll try again..

Kingston CL4 4GB

Code: Select all

Test started - please wait, it may take up to 3 minutes  :)

size, write, read
bytes, KB/sec, KB/sec
512, 45.45, 482.42                  in T=00:03:15
1024, 24.92, 693.02                  in T=00:06:05
2048, 25.21, 1286.25                       in T=00:15:00
4096, 1337.13, 2271.51
8192, 1702.51, 3916.33
16384, 3012.27, 5492.42
32768, 3638.46, 7413.43                  in T=00:15:20

totalMicros  914714129             => 15.5minutes
yieldMicros  867872714
yieldCalls   84774
yieldMaxUsec 150782
kHzSdClk     24000
Done

Type any character to start
Last edited by Pito on Wed Jul 05, 2017 11:45 pm, edited 3 times in total.
Pukao Hats Cleaning Services Ltd.

stevestrong
Posts: 1612
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [libmaple] SDIO

Post by stevestrong » Wed Jul 05, 2017 11:01 pm

I might have not attached the very latest BIN previously, so I updated the first post again.

Code: Select all

######################################################
  Demo sketch of STM32F4 SDIO (DMA) implementation.
######################################################

init time: 8 ms

Card type: SD2

Manufacturer ID: 27
OEM ID: PH
Product: SD02G
Version: 3.0
Serial number: 97bdbf7c
Manufacturing date: 8/2011

cardSize: 1969.23 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: 80ff8000

Volume is FAT16
blocksPerCluster: 64
clusterCount: 60086
freeClusters: 59578
freeSpace: 1952.25 MB (MB = 1,000,000 bytes)
fatStartBlock: 138
fatCount: 2
blocksPerFat: 235
rootDirStart: 608
dataStartBlock: 640

FreeStack: 84095
######################################################

Type any character to start
Test started - please wait, it may take up to 3 minutes

size, write, read
bytes, KB/sec, KB/sec
512, 191.49, 872.32
1024, 359.56, 1059.29
2048, 661.10, 2100.89
4096, 1133.47, 4102.19
8192, 1612.33, 5705.51
16384, 1965.11, 7776.31
32768, 2231.90, 9110.85

totalMicros  127501398
yieldMicros  94566913
yieldCalls   87120
yieldMaxUsec 151458
kHzSdClk     24000
Done

Type any character to start

Post Reply