STM32F103C8T6 with SD Card

Post Reply
Sacha
Posts: 4
Joined: Sun Sep 27, 2020 1:40 pm

STM32F103C8T6 with SD Card

Post by Sacha »

Hello,

I'm not able to use an SD card with an STM32F103C8T6 on Arduino.
I have test with HAL on stm32cube and all worked fine. My stm32 and my SD card work correctly.

I'am using the library Adafruit Fork SD.
I had some compilation error and after many correction. I have an error that I'm not able to resolve :

In Adafruit Fork\src\SpiDriver\SdSpiSTM32.cpp:
error: 'class SPIClass' has no member named 'dmaTransfer'

I try to replace dmaTransfer by transfer but I have a new compilation error :

In Adafruit Fork\src\SpiDriver\SdSpiSTM32.cpp:
error: void value not ignored as it ought to be

Thank in advance for all replies.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: STM32F103C8T6 with SD Card

Post by stevestrong »

Whic example do you try to compile?
Which line of SdSpiSTM32.cpp gives the error?
Please post the complete Arduino error message.
Sacha
Posts: 4
Joined: Sun Sep 27, 2020 1:40 pm

Re: STM32F103C8T6 with SD Card

Post by Sacha »

Hello,

Here is the full error message:

.pio\libdeps\genericSTM32F103CB\SdFat - Adafruit Fork\src\SpiDriver\SdSpiSTM32.cpp: In member function 'uint8_t SdSpiAltDriver::receive(uint8_t*, size_t)':
.pio\libdeps\genericSTM32F103CB\SdFat - Adafruit Fork\src\SpiDriver\SdSpiSTM32.cpp:78:10: error: 'class SPIClass' has no member named 'dmaTransfer'; did you mean 'transfer'?
78 | m_spi->dmaTransfer(nullptr, buf, n);
| ^~~~~~~~~~~
| transfer
.pio\libdeps\genericSTM32F103CB\SdFat - Adafruit Fork\src\SpiDriver\SdSpiSTM32.cpp: In member function 'void SdSpiAltDriver::send(const uint8_t*, size_t)':
.pio\libdeps\genericSTM32F103CB\SdFat - Adafruit Fork\src\SpiDriver\SdSpiSTM32.cpp:101:10: error: 'class SPIClass' has no member named 'dmaTransfer'; did you mean 'transfer'?
101 | m_spi->dmaTransfer(const_cast<uint8_t*>(buf), nullptr, n);
| ^~~~~~~~~~~
| transfer
*** [.pio\build\genericSTM32F103CB\lib7e2\SdFat - Adafruit Fork\SpiDriver\SdSpiSTM32.cpp.o] Error 1

I use PlatformIO.

My Code :

#include <SPI.h>
#include "SdFat.h"

SPIClass SPI_2(PB15, PB14, PB13);
SdFat sd(&SPI_2);
const uint8_t SD_CS = PB12; // chip select for sd2

void setup() {
delay(1000);
Serial.begin(9600);
Serial.println("OK");

if (!sd.begin(SD_CS, SD_SCK_MHZ(2))) {
Serial.print("Error....");
}
else{
Serial.print("OK....");
}
}
void loop() {}
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: STM32F103C8T6 with SD Card

Post by mrburnette »

Sacha wrote: Sun Sep 27, 2020 1:48 pm ...
I'm not able to use an SD card with an STM32F103C8T6 on Arduino.
I have test with HAL on stm32cube and all worked fine. My stm32 and my SD card work correctly.
...
Then use the Official core. (Long-term proper thing to do.)
-- OR --
Do not use Adafruit's SD and use the default Arduino SD which has worked previously with Roger's core (not Officially supported.)

https://stm32duinoforum.com/forum/viewt ... _4149.html

Libraries cannot be swapped around willy-nilly.
Sacha
Posts: 4
Joined: Sun Sep 27, 2020 1:40 pm

Re: STM32F103C8T6 with SD Card

Post by Sacha »

I have try with the official core and the STM32duino core
And I have test both Arduino SD and Adafruit SD but both give the same error
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32F103C8T6 with SD Card

Post by fpiSTM »

Official Arduino SD library can't have this error as it does not have DMA.
Try the default examples.
Sacha
Posts: 4
Joined: Sun Sep 27, 2020 1:40 pm

Re: STM32F103C8T6 with SD Card

Post by Sacha »

Effectively, I made a mistake with the SD library from Adruino
But SD card and STM32 seems to doesn't work propely.
I'm on spi2 and I have change pin mapping in SD.beging and Sd2PinMap.h.
But that still doesn't work

Edit:
Thank I have success to make the SPI2 work properly with :

SPI.setMOSI(PB15);
SPI.setMISO(PB14);
SPI.setSCLK(PB13);

I want to use this SD card with a screen and I don't know if SD from Arduino is fast. But if someone know a better SD library

Thanks for all replies
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: STM32F103C8T6 with SD Card

Post by mrburnette »

Sacha wrote: Sun Sep 27, 2020 5:52 pm ...
I want to use this SD card with a screen and I don't know if SD from Arduino is fast. But if someone know a better SD library
...
Everything was tested for Roger's core (Orig LeafLib core) back long, long ago. Some performance numbers were published but I know of nothing recently done, but the old "crashed" forum is difficult to search.

Fast like "fast" or fast like "fast, fast." Generally the software programmer (you) will identify the metric that is considered required and then perform your own tests with a prototype to validate the library chosen. Fast means nothing.

Arduino SD Card is authored by Bill Greiman and I have never heard it called "fast" but you can roll your own tests.
https://github.com/greiman/SdFat
STM32-centric: https://forum.arduino.cc/index.php?topic=414514.0

A discussion about SD speed from the past: https://stm32duinoforum.com/forum/viewt ... rt_90.html

I can assure it once worked acceptably.
https://www.hackster.io/rayburne/maple- ... ate-74468b
FerroFerido
Posts: 12
Joined: Tue Nov 17, 2020 11:10 pm

Re: STM32F103C8T6 with SD Card

Post by FerroFerido »

Sacha wrote: Sun Sep 27, 2020 5:52 pm Effectively, I made a mistake with the SD library from Adruino
But SD card and STM32 seems to doesn't work propely.
I'm on spi2 and I have change pin mapping in SD.beging and Sd2PinMap.h.
But that still doesn't work

Edit:
Thank I have success to make the SPI2 work properly with :

SPI.setMOSI(PB15);
SPI.setMISO(PB14);
SPI.setSCLK(PB13);

I want to use this SD card with a screen and I don't know if SD from Arduino is fast. But if someone know a better SD library

Thanks for all replies
Guy, can you send me your complete code? I have the same problem but i don't know what do.
Post Reply

Return to “STM32F1 based boards”