FatFS / STM32SD cannot compile examples

Post here first, or if you can't find a relevant section!
Post Reply
phil bowles
Posts: 13
Joined: Mon May 25, 2020 10:15 am

FatFS / STM32SD cannot compile examples

Post by phil bowles »

Getting started trying to use FatFS and/or STM32SD. I have to say I find the lack of documentation and working examples very difficult. I see in another thread that someone has the same compile errors and this was because his board did not have SDIO.

I have a NUCLEOF429ZI which I *know* has SDMMC - is this the same as SDIO? if not, how do I get around this? Are there any working examples? Is it too much to ask to provide a list of supported boards in the documentation? Or maybe at least *one* example in FatFS. I am happy and experienced enough to get most things working if I can find documenation for them - is there a guide anywhere?

Making it harder is this:
FatFs
The FatFs has several user defined options, which is specified from within the ffconf.h file.

This library provides a default user defined options file named ffconf_default.h
- but neither of those files exist in the version of FatFS I just downloaded.

I tried the Cardinfo example from STM32SD using boards/core 1.9.0 and:
Using library STM32SD-master at version 1.2.2 in folder: C:\Users\phil\Documents\Arduino\libraries\STM32SD-master
Using library FatFs-master at version 2.0.3 in folder: C:\Users\phil\Documents\Arduino\libraries\FatFs-master

I get the following errors:

Code: Select all

In file included from C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/Sd2Card.h:40,
                 from C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/STM32SD.h:22,
                 from C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\examples\CardInfo\CardInfo.ino:12:
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:58:40: error: variable or field 'BSP_SD_GetCardInfo' declared void
   58 | #define HAL_SD_CardInfoTypedef         HAL_SD_CardInfoTypeDef
      |                                        ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:115:28: note: in expansion of macro 'HAL_SD_CardInfoTypedef'
  115 | void    BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
      |                            ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:58:40: error: 'HAL_SD_CardInfoTypeDef' was not declared in this scope; did you mean 'HAL_SD_CardInfoTypedef'?
   58 | #define HAL_SD_CardInfoTypedef         HAL_SD_CardInfoTypeDef
      |                                        ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:115:28: note: in expansion of macro 'HAL_SD_CardInfoTypedef'
  115 | void    BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
      |                            ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:115:52: error: 'CardInfo' was not declared in this scope; did you mean 'SD_CardInfo'?
  115 | void    BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
      |                                                    ^~~~~~~~
      |                                                    SD_CardInfo
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:120:24: error: variable or field 'BSP_SD_MspInit' declared void
  120 | void    BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                        ^~~~~~~~~~~~~~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:120:24: error: 'SD_HandleTypeDef' was not declared in this scope; did you mean 'SPI_HandleTypeDef'?
  120 | void    BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                        ^~~~~~~~~~~~~~~~
      |                        SPI_HandleTypeDef
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:120:42: error: 'hsd' was not declared in this scope
  120 | void    BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                                          ^~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:120:47: error: expected primary-expression before 'void'
  120 | void    BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                                               ^~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:121:31: error: variable or field 'BSP_SD_Detect_MspInit' declared void
  121 | void    BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                               ^~~~~~~~~~~~~~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:121:31: error: 'SD_HandleTypeDef' was not declared in this scope; did you mean 'SPI_HandleTypeDef'?
  121 | void    BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                               ^~~~~~~~~~~~~~~~
      |                               SPI_HandleTypeDef
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:121:49: error: 'hsd' was not declared in this scope
  121 | void    BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                                                 ^~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:121:54: error: expected primary-expression before 'void'
  121 | void    BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
      |                                                      ^~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:122:26: error: variable or field 'BSP_SD_MspDeInit' declared void
  122 | void    BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
      |                          ^~~~~~~~~~~~~~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:122:26: error: 'SD_HandleTypeDef' was not declared in this scope; did you mean 'SPI_HandleTypeDef'?
  122 | void    BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
      |                          ^~~~~~~~~~~~~~~~
      |                          SPI_HandleTypeDef
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:122:44: error: 'hsd' was not declared in this scope
  122 | void    BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
      |                                            ^~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:122:49: error: expected primary-expression before 'void'
  122 | void    BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
      |                                                 ^~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:58:40: error: 'HAL_SD_CardInfoTypeDef' does not name a type; did you mean 'HAL_SD_CardInfoTypedef'?
   58 | #define HAL_SD_CardInfoTypedef         HAL_SD_CardInfoTypeDef
      |                                        ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/bsp_sd.h:64:21: note: in expansion of macro 'HAL_SD_CardInfoTypedef'
   64 | #define SD_CardInfo HAL_SD_CardInfoTypedef
      |                     ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\phil\Documents\Arduino\libraries\STM32SD-master\src/Sd2Card.h:62:5: note: in expansion of macro 'SD_CardInfo'
   62 |     SD_CardInfo _SdCardInfo;
      |     ^~~~~~~~~~~
User avatar
fpiSTM
Posts: 1745
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: FatFS / STM32SD cannot compile examples

Post by fpiSTM »

As the nucleo F429 doesn't have by default a card slot the HAL SD module is not enabled you will have to define it using hal_conf_extra.h.
https://github.com/stm32duino/wiki/wiki ... ion--150-1

And define this

Code: Select all

HAL_SD_MODULE_ENABLED
phil bowles
Posts: 13
Joined: Mon May 25, 2020 10:15 am

Re: FatFS / STM32SD cannot compile examples

Post by phil bowles »

Excellent - thank you.

But this is kind of my point - why isn't this in the documentation for STM32SD ?
phil bowles
Posts: 13
Joined: Mon May 25, 2020 10:15 am

Re: FatFS / STM32SD cannot compile examples

Post by phil bowles »

Now down to one error:
"C:\\Users\\phil\\AppData\\Local\\Temp\\arduino_build_551967\\core\\core.a" -lc -Wl,--end-group -lm -lgcc -lstdc++
c:/users/phil/appdata/local/arduino15/packages/stm32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\phil\AppData\Local\Temp\arduino_build_551967\libraries\STM32SD-master\bsp_sd.c.o: in function `BSP_SD_MspInit':
bsp_sd.c:(.text.BSP_SD_MspInit+0x34): undefined reference to `PinMap_SD'
collect2.exe: error: ld returned 1 exit status
Something this simple should not be so difficult and so undocumented!
Post Reply

Return to “General discussion”