stm32duino / STM32SD

Enables reading and writing on SD card using SD card slot of the STM32 Board.
157 stars 23 forks source link

Cannot compile, linker errors #37

Closed Bambofy closed 3 years ago

Bambofy commented 3 years ago

Hi i'm trying to use the STM32SD library on an STM32L452RE chip but i can't get it to compile.

Here's the linker messages:

Error linking for board Nucleo-64
ld.exe: STM32SD-1.2.2\bsp_sd.c.o: in function BSP_SD_MspInit
bsp_sd.c:435: undefined reference to PinMap_SD

I've used these defines in the hal_conf_extra.h which at the root of my project.

#define HAL_MODULE_ENABLED
#define HAL_SAI_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
#define USE_FULL_ASSERT
#define HAL_ADC_MODULE_ENABLED
#define HAL_MMC_MODULE_ENABLED
#define HAL_SD_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED

And these flags in build_opt.h

-DHAL_MODULE_ENABLED
-DHAL_SAI_MODULE_ENABLED
-DHAL_TIM_MODULE_ENABLED
-DHAL_ADC_MODULE_ENABLED
-DHAL_MMC_MODULE_ENABLED
-DHAL_SD_MODULE_ENABLED
-DHAL_GPIO_MODULE_ENABLED
-DHAL_EXTI_MODULE_ENABLED
-DHAL_I2C_MODULE_ENABLED
-DHAL_DMA_MODULE_ENABLED
-DHAL_RCC_MODULE_ENABLED
-DHAL_FLASH_MODULE_ENABLED
-DHAL_PWR_MODULE_ENABLED
-DHAL_CORTEX_MODULE_ENABLED

The card reader is connected to pins here:

uint32_t SD_CMD = PD2;
uint32_t SD_CLK = PC12;
uint32_t SD_D3 = PC11;
uint32_t SD_D2 = PC10;
uint32_t SD_D1 = PC9;
uint32_t SD_D0 = PC8;

And i'm trying to configure STM32Card to use these pins

fpistm commented 3 years ago

Hi @Bambofy which target you used ?

Bambofy commented 3 years ago

Hi @Bambofy which target you used ?

Nucleo L452RE

fpistm commented 3 years ago

Not the L452RE-P?

Bambofy commented 3 years ago

No

fpistm commented 3 years ago

Could you be more precise on your environment? Arduino IDE version? STM32 core version? STM32SD library version? ... Thanks in advance

fpistm commented 3 years ago

Using the latest Core release 19.0, the latest STM32SD 1.2.2, Arduino IDE 1.8.13 and enabling the HAL SD module thanks the hal_conf_extra.h. I'm able to build properly the CardInfo example for Nucleo L452:

Sketch uses 31252 bytes (5%) of program storage space. Maximum is 524288 bytes. Global variables use 2304 bytes (1%) of dynamic memory, leaving 161536 bytes for local variables. Maximum is 163840 bytes.

For the Nucleo L452RE, the PinMap_SD has been added since the 1.8.0 core version. So it seems you used an old version of the core, right?

Bambofy commented 3 years ago

Sorry for the delay,

Core version is 1.9.0 from the library manager, i am using visual micro to upload the code, when i try arduino IDE instead, it works. sSo it must be a bug with visual micro. Thanks for your help :)!

fpistm commented 3 years ago

I'm using also VSCode to debug but I do not have this issue. So probably a wrong configuration with Arduino plugin.