[libmaple] SDIO

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

Re: [libmaple] SDIO

Post by Pito » Wed Jul 05, 2017 9:32 am

If 2kB buffer works OK at 24MHz, why shouldn't 4kB buffer work as well?
Who does say that?
Also do not use SdFat-beta but the latest SdFat master https://github.com/greiman/SdFat
There is maybe a fix (see my post) already implemented as the SdFat got problem with file.write() with buffer sizes above 128kB.
Pukao Hats Cleaning Services Ltd.

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

Re: [libmaple] SDIO

Post by stevestrong » Wed Jul 05, 2017 9:52 am

Pito, as you can see in my first post, I refer to the SdFat lib.

You suggested to decrease the SDIO frequency for CL4 cards. And I do not see (yet) any reason for that, because from stephen's log obviously 2kB buffer works well @24MHz, it only generates 0x60 (SD_CARD_ERROR_DMA) error when using 4kB buffer. That's why I asked for more information from stephen, to understand and localize the issue.

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

Re: [libmaple] SDIO

Post by Pito » Wed Jul 05, 2017 9:57 am

Ah, ok, as I could not find any info on the 2k/4k buffer size issue in the posts above.. :?
So you do refer this, right?

Code: Select all

2048,344.94,1623.80
4096,file.write returned: 4294967295
error: write failed
SD errorCode: 0X60,0X0

Code: Select all

SD_CARD_ERROR_DMA = 0X60,
My strategy with the debug of this would be to start with most stable setup, therefore with clocks as slow as possible..
@stephen: you need at least two various cards to play with, best CL10, and always formatted with SdCard_Formatter https://www.sdcard.org/downloads/formatter_4/
The writing errors end up often with corruption, so formatting is a standard procedure with these exercises..
Also Serial1 is something you would need handy, definitely..

PS: and also set the SDIO gpio's output driver strength to MEDIUM!
Last edited by Pito on Wed Jul 05, 2017 11:21 am, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

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

Re: [libmaple] SDIO

Post by zmemw16 » Wed Jul 05, 2017 11:20 am

i think sleep intervened around 0400

steve - oh thank you for this and anyone else

what extra info do you want from me ?
changed the card from a whatever 4gb to 8gb, labelled ultra, 2 colour, red & silver, with a 1 inside a U
how high do you want to go, try 16G, 32G ? couple or three of those.
sdformat - if that's the official one, i don't think it's a linux port, dd +fdisk+mkfs.vfat is best i've got.
typical, win+mac
i'll go looking though.

Code: Select all

Type any character to start.

size,write,read
bytes,KB/sec,KB/sec
512,321.57,1078.55
1024,738.05,2124.35
2048,1250.39,3516.35
4096,2070.08,5286.28
8192,2439.10,5278.28
16384,2424.50,5270.61
32768,2356.58,5282.14

totalMicros  79140057
yieldMicros  46090617
yieldCalls   67753
yieldMaxUsec 193440
kHzSdClk     24000
Done
right, subtle hint, fsmc any chance of anything at all, waggle pins :) 8080 lcd 16bit :)
in fsmc.h i see 'See ../notes/fsmc.txt for more info'
is this a hang over from original sources or yours ?

stephen

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

Re: [libmaple] SDIO

Post by stevestrong » Wed Jul 05, 2017 11:47 am

@stephen,
I wanted to know whether successive test with the same card, which showed the error, will show similar/identical error on the following test as well.
zmemw16 wrote:
Wed Jul 05, 2017 11:20 am
in fsmc.h i see 'See ../notes/fsmc.txt for more info'
is this a hang over from original sources or yours ?
That is just part of original source.
Further supported features and development status can be found here: viewtopic.php?f=39&t=1976
(yes, FSMC for 16bit parallel LCDs works already ;) )

The official (Roger's) repo is also almost up to date with my one.

@Pito
Pito wrote:
Wed Jul 05, 2017 9:57 am
and also set the SDIO gpio's output driver strength to MEDIUM!
Nope, this libmaple SDIO lib works (at least for my CL10 card on generic black F407VET board) @24MHz only if the SDIO pins are set to output PP + PU at HIGH (50MHz) frequency.
I tried with MEDIUM strength and got errors at the very first card access after switching the SDIO clk from 400kHz to 24MHz...
Pito wrote:Also Serial1 is something you would need handy, definitely..
Not necessarily. So far I am well served with USB serial only.
As I am anyway using the USB port to power the board, why not using it as serial interface, too? This way I do not need any further USB -> serial adapter.
Uploading goes with STlink, until the DFU loader will be ready :mrgreen:
Last edited by stevestrong on Wed Jul 05, 2017 1:20 pm, edited 1 time in total.

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

Re: [libmaple] SDIO

Post by Pito » Wed Jul 05, 2017 1:15 pm

Nope, this libmaple SDIO lib works (at least for my CL10 card on generic black F407VET board) @24MHz only if the SDIO pins are set to output PP + PU at HIGH (50MHz) frequency.
Interestingly all my CL10 cards work @24-44MHz SDIO only with MEDIUM (Black 407ZET, STM32GENERIC) :D
So maybe there is a subtle difference in card's inits in the cores somewhere :)
Pukao Hats Cleaning Services Ltd.

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

Re: [libmaple] SDIO

Post by stevestrong » Wed Jul 05, 2017 1:23 pm

Pito wrote:
Wed Jul 05, 2017 1:15 pm
So maybe there is a subtle difference in card's inits in the cores somewhere :)
I would rather think on any difference in the F4 register settings, or any hardware issue, power supply decoupling.
Would a register dump make sense to find out the diff? Is there any reg-dumping sketch available?

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

Re: [libmaple] SDIO

Post by zmemw16 » Wed Jul 05, 2017 1:25 pm

i returned to the 4gb card, there is a press reset after each of the fails, surprisingly it seems to work after a warm up :o

Code: Select all

Type any character to start.
size,write,read
bytes,KB/sec,KB/sec
512,149.78,695.32
1024,227.49,840.88
2048,348.16,1633.62
4096,file.write returned: 4294967295

Type any character to start.
size,write,read
bytes,KB/sec,KB/sec
512,145.10,678.64
1024,224.82,847.31
2048,352.94,1664.60
4096,file.write returned: 4294967295

Type any character to start.
size,write,read
bytes,KB/sec,KB/sec
512,147.60,695.28
1024,231.63,872.22
2048,369.86,1719.74
4096,511.46,3556.26
8192,504.41,3560.83
16384,504.36,3562.77
32768,504.39,3569.58

totalMicros  218005614
yieldMicros  197107630
yieldCalls   60881
yieldMaxUsec 138343
kHzSdClk     24000
Done

Type any character to start.
size,write,read
bytes,KB/sec,KB/sec
512,147.33,695.80
1024,231.72,866.54
2048,369.51,1732.84
4096,511.83,3561.75
8192,504.74,3565.14
16384,504.56,3563.90
32768,504.45,3560.40

totalMicros  218100065
yieldMicros  200466135
yieldCalls   60934
yieldMaxUsec 146788
kHzSdClk     24000
Done

Type any character to start.
size,write,read
bytes,KB/sec,KB/sec
512,147.35,694.99
1024,231.79,867.61
2048,369.98,1727.27
4096,512.14,3564.36
8192,504.50,3568.53
16384,504.86,3557.19
32768,504.43,3563.17

totalMicros  218056619
yieldMicros  200422778
yieldCalls   60902
yieldMaxUsec 136086
kHzSdClk     24000
Done

Type any character to start.
size,write,read
bytes,KB/sec,KB/sec
512,147.39,695.88
1024,231.84,865.06
2048,369.89,1729.93
4096,512.36,3560.81
8192,504.73,3560.76
16384,504.18,3524.25
32768,504.84,3522.68

totalMicros  218097836
yieldMicros  200400149
yieldCalls   60909
yieldMaxUsec 145093
kHzSdClk     24000
Done
stephen

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

Re: [libmaple] SDIO

Post by Pito » Wed Jul 05, 2017 1:40 pm

stevestrong wrote:
Wed Jul 05, 2017 1:23 pm
Pito wrote:
Wed Jul 05, 2017 1:15 pm
So maybe there is a subtle difference in card's inits in the cores somewhere :)
I would rather think on any difference in the F4 register settings, or any hardware issue, power supply decoupling.
Would a register dump make sense to find out the diff? Is there any reg-dumping sketch available?
I think Black's 407VET and 407ZET boards are from the HW point almost identical, on my board I replaced the 100nF sdcard decoupling capacitor with 2x10u ceramic multilayer with no visible impact.
The F4 registers are set by sdcard's inits() so the diff has to be in sources somewhere.. Or, do you mean there is a difference in F4VET vs. F4ZET silicon ?

@stephen: except your temperature dependency it seems to me your write speed is suspiciously low - should be close to read speed.
Last edited by Pito on Wed Jul 05, 2017 1:54 pm, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

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

Re: [libmaple] SDIO

Post by stevestrong » Wed Jul 05, 2017 1:49 pm

zmemw16 wrote:
Wed Jul 05, 2017 1:25 pm
i returned to the 4gb card, there is a press reset after each of the fails, surprisingly it seems to work after a warm up :o
Is it maybe a power supply stability issue?
I power my board over USB, via a USB-hub, I sometimes use for the USB hub an extra power adapter.
Pito wrote:The F4 registers are set by sdcard's inits() so the diff has to be in sources somewhere..
I meant the difference of relevant F4 register values (set by the software in the source somewhere), and not the difference between available or not available registers between VE and ZE.
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?

Post Reply