Page 1 of 2

[Solved] Compile error with STM32SD library

Posted: Mon May 04, 2020 4:34 pm
by Phono
Hi,
I am testing the example file STM32SD/examples/ReadWrite/ReadWrite.ino. I have installed the library FatFs, and I selected the following compile options: Generic STM32F1 board, Board part number F103RBT6, UART enabled, CDC generic enabled.

I get the following compile error:

Code: Select all

In file included from D:\STM32DuinoPortable\SketchesSTM32Duino\libraries\STM32SD\src/Sd2Card.h:40,
                 from D:\STM32DuinoPortable\SketchesSTM32Duino\libraries\STM32SD\src/STM32SD.h:22,
                 from D:\STM32DuinoPortable\SketchesSTM32Duino\Maison\exempleSD\exempleSD.ino:9:
D:\STM32DuinoPortable\SketchesSTM32Duino\libraries\STM32SD\src/bsp_sd.h:58:40: error: variable or field 'BSP_SD_GetCardInfo' declared void
   58 | #define HAL_SD_CardInfoTypedef         HAL_SD_CardInfoTypeDef
      |                                        ^~~~~~~~~~~~~~~~~~~~~~
D:\STM32DuinoPortable\SketchesSTM32Duino\libraries\STM32SD\src/bsp_sd.h:115:28: note: in expansion of macro 'HAL_SD_CardInfoTypedef'
  115 | void    BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
I renamed the file to exempleSD.ino.
Did I forget something?

Re: Compile error with STM32SD library

Posted: Mon May 04, 2020 5:00 pm
by stas2z
Are you sure your f103rb have sdio?
As far i can remember only high density f103 chips (starting from f103xC) support it.

Re: Compile error with STM32SD library

Posted: Mon May 04, 2020 5:02 pm
by fpiSTM
STM32F103RB has no SDIO

Re: Compile error with STM32SD library

Posted: Mon May 04, 2020 5:36 pm
by Phono
Ok I overlooked this requirement. I am porting a sketch that worked with Roger's core, the SD card being supported by the SDFat library. So this library did not use the SDIO feature of the STM32F103. Actually, it just used a SPI.
Now, is there another library that will allow me to interface my SD card?

Re: Compile error with STM32SD library

Posted: Mon May 04, 2020 5:44 pm
by fpiSTM
Yes simply use standard Arduino API SD (through SPI)

Re: Compile error with STM32SD library

Posted: Mon May 04, 2020 7:17 pm
by Phono
I checked the Arduino SD library. It compiles. However, the pin allocation is wrong, since the STM32 is not defined in the file SD2Pinmap.h. Curiously, no compile error is produced. I suppose that __arm__ is defined somewhere, which makes the library think the board is an Arduino Due. This library must at least be provided with more definitions to take the STM32 into account. Currently, this library is deceptive, since it compiles and you will end up with a sketch that does not work, without any warning.

Re: Compile error with STM32SD library

Posted: Mon May 04, 2020 8:10 pm
by fpiSTM
Strange as I use it.
I guess we do not talk the same or there is an other mistake

Re: Compile error with STM32SD library

Posted: Mon May 04, 2020 8:18 pm
by Phono
Sorry, I omitted an important information. I am not using a SD card shield, but a Olimexino STM32 board (Maple-like) that has a built-in SD card fixture. This one does not use the Arduino pins 10 through 13, but instead what they call D25, D32, D33 and D34, which correspond to the SPI2 (pins PD2, PB13, PB14 and PB15 respectively). The SD.begin() function has no provision for selecting SPI2, only the CS pin and the clock rate.

Re: Compile error with STM32SD library

Posted: Mon May 04, 2020 8:24 pm
by stas2z
you can change pins of your default SPI instance by calling SPI.setMOSI/.setMISO/.setSCLK/.setSSEL before SD.begin

Re: Compile error with STM32SD library

Posted: Mon May 04, 2020 8:57 pm
by fpiSTM