[Solved] Compile error with STM32SD library

Working libraries, libraries being ported and related hardware
Phono
Posts: 68
Joined: Thu Mar 19, 2020 9:32 am

[Solved] Compile error with STM32SD library

Post 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?
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: Compile error with STM32SD library

Post by stas2z »

Are you sure your f103rb have sdio?
As far i can remember only high density f103 chips (starting from f103xC) support it.
Last edited by stas2z on Mon May 04, 2020 5:02 pm, edited 1 time in total.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Compile error with STM32SD library

Post by fpiSTM »

STM32F103RB has no SDIO
Phono
Posts: 68
Joined: Thu Mar 19, 2020 9:32 am

Re: Compile error with STM32SD library

Post 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?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Compile error with STM32SD library

Post by fpiSTM »

Yes simply use standard Arduino API SD (through SPI)
Phono
Posts: 68
Joined: Thu Mar 19, 2020 9:32 am

Re: Compile error with STM32SD library

Post 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.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Compile error with STM32SD library

Post by fpiSTM »

Strange as I use it.
I guess we do not talk the same or there is an other mistake
Phono
Posts: 68
Joined: Thu Mar 19, 2020 9:32 am

Re: Compile error with STM32SD library

Post 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.
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: Compile error with STM32SD library

Post by stas2z »

you can change pins of your default SPI instance by calling SPI.setMOSI/.setMISO/.setSCLK/.setSSEL before SD.begin
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Compile error with STM32SD library

Post by fpiSTM »

Post Reply

Return to “Libraries & Hardware”