Page 1 of 1

Many errors in the "STM32duino_STM32SD" library

Posted: Thu Jun 20, 2024 9:39 am
by ChPr
Hello everybody,

I want to use the "STM32duino_STM32SD" library (last version 1.3.2) to connect a SD Card to my Blue Pill STM32F103C8 with 128 k.

In the Arduino IDE, to get this card, I selected :
  • STM32 MCU based boards --> Generic STM32F1 series --> BluePill F103CB(or C8 with 128 k)
  • Uploadmethod : "STM32CubeProgrammer (SWD)"
NOTE : This configuration works well to animate a blinking LED.

Now, I try an example of the library : "CardInfo.ino". This sketch includes <STM32SD.h>.

When I click to compile, I get the following errors, all belonging to this library :

Code: Select all

In file included from e:\Arduino\libraries\STM32duino_STM32SD\src/Sd2Card.h:40,
                 from e:\Arduino\libraries\STM32duino_STM32SD\src/STM32SD.h:22,
                 from E:\Arduino\libraries\STM32duino_STM32SD\examples\CardInfo\CardInfo.ino:12:
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:179:9: error: variable or field 'BSP_SD_GetCardInfo' declared void
  179 | void    BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo);
      |         ^~~~~~~~~~~~~~~~~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:179:28: error: 'HAL_SD_CardInfoTypeDef' was not declared in this scope
  179 | void    BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo);
      |                            ^~~~~~~~~~~~~~~~~~~~~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:179:52: error: 'CardInfo' was not declared in this scope; did you mean 'SD_CardInfo'?
  179 | void    BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo);
      |                                                    ^~~~~~~~
      |                                                    SD_CardInfo
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:184:9: error: variable or field 'BSP_SD_MspInit' declared void
  184 | void    BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |         ^~~~~~~~~~~~~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:184:24: error: 'SD_HandleTypeDef' was not declared in this scope; did you mean 'SPI_HandleTypeDef'?
  184 | void    BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                        ^~~~~~~~~~~~~~~~
      |                        SPI_HandleTypeDef
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:184:42: error: 'hsd' was not declared in this scope
  184 | void    BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                                          ^~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:184:47: error: expected primary-expression before 'void'
  184 | void    BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                                               ^~~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:185:9: error: variable or field 'BSP_SD_Detect_MspInit' declared void
  185 | void    BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |         ^~~~~~~~~~~~~~~~~~~~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:185:31: error: 'SD_HandleTypeDef' was not declared in this scope; did you mean 'SPI_HandleTypeDef'?
  185 | void    BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                               ^~~~~~~~~~~~~~~~
      |                               SPI_HandleTypeDef
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:185:49: error: 'hsd' was not declared in this scope
  185 | void    BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                                                 ^~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:185:54: error: expected primary-expression before 'void'
  185 | void    BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                                                      ^~~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:186:9: error: variable or field 'BSP_SD_MspDeInit' declared void
  186 | void    BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
      |         ^~~~~~~~~~~~~~~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:186:26: error: 'SD_HandleTypeDef' was not declared in this scope; did you mean 'SPI_HandleTypeDef'?
  186 | void    BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
      |                          ^~~~~~~~~~~~~~~~
      |                          SPI_HandleTypeDef
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:186:44: error: 'hsd' was not declared in this scope
  186 | void    BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
      |                                            ^~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:186:49: error: expected primary-expression before 'void'
  186 | void    BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
      |                                                 ^~~~
e:\Arduino\libraries\STM32duino_STM32SD\src/bsp_sd.h:62:25: error: 'HAL_SD_CardInfoTypeDef' does not name a type
   62 | #define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
      |                         ^~~~~~~~~~~~~~~~~~~~~~
e:\Arduino\libraries\STM32duino_STM32SD\src/Sd2Card.h:135:5: note: in expansion of macro 'BSP_SD_CardInfo'
  135 |     BSP_SD_CardInfo _SdCardInfo;
      |     ^~~~~~~~~~~~~~~

exit status 1

Compilation error: exit status 1
it's not normal for such a library to have such errors. i've tried earlier versions: same problem.

How can I solve this problem?

Best regards.

Pierre.

Re: Many errors in the "STM32duino_STM32SD" library

Posted: Thu Jun 20, 2024 10:18 am
by fpiSTM
Read the Readme.md on github . This library is for SD over SDIO or SDMMC interface. STM32F1 does not support this. I guess you have a SD over SPI in that case use SD library from Arduino.

Re: Many errors in the "STM32duino_STM32SD" library

Posted: Thu Jun 20, 2024 12:24 pm
by ChPr
Thank you for this reply.

I tried the STM32 library because I had previously tried an Arduino library ... which gave no results.

Perhaps you have an Arduino library to recommend.

Sincerely your.

Pierre.

Re: Many errors in the "STM32duino_STM32SD" library

Posted: Thu Jun 20, 2024 12:51 pm
by fpiSTM
Use the one provided in Arduino IDE: SD.

Re: Many errors in the "STM32duino_STM32SD" library

Posted: Thu Jun 20, 2024 2:26 pm
by ChPr
I can't get a sketch using the SD library to work.

On the STM32F103C8 board, there are two groups of pins on the connector for the SPI1 bus.

How do you choose SPI1 over SPI2 ? Is it automatic ?

If SPI1 is chosen, which plug group is selected ? Is one or the other, automatic, and if so, which group is selected ?

If nothing is automatic, are there any special instructions?

Thank you for this information.

Best regards.

Pierre.

Re: Many errors in the "STM32duino_STM32SD" library

Posted: Thu Jun 20, 2024 2:38 pm
by fpiSTM
Library use default SPI instance. Sketch is already configured to use it.
Sketch:
https://github.com/arduino-libraries/SD ... rdInfo.ino

Library documentation:
https://www.arduino.cc/reference/en/libraries/sd/

As BluePill does not have a Arduino connect you can find in the variant which pin is used by default for SPI:
https://github.com/stm32duino/Arduino_C ... #L106-L114

Think to update the CS pin you used.

Re: Many errors in the "STM32duino_STM32SD" library

Posted: Fri Jun 21, 2024 4:00 pm
by ChPr
Thank you very much "fpiSTM" for this information.

I had already tried this code without being able to make it work. I think it was due to the fact that I was using PB3, PB4, PB5 and PA15 pins. Since I've been using PA4, PA5, PA6 and PA7, it works without a problem.
Thanks again.
Best regards.
Pierre.

Re: Many errors in the "STM32duino_STM32SD" library

Posted: Fri Jun 21, 2024 4:43 pm
by fpiSTM
Welcome. See the wiki to know how change the default pins.