Skip to main content
PHlin.1
Associate III
April 21, 2020
Question

[Bug] Errors in template for sd_diskio.c in STM32CubeMX 5.6.0/1

  • April 21, 2020
  • 12 replies
  • 2895 views

Hi,

I was hoping that this will be fixed in 5.6.1, but it's still there.

In function "DRESULT SD_read" is this part of code:

#if defined(ENABLE_SCRATCH_BUFFER)
 }
 else
 {
 /* Slow path, fetch each sector a part and memcpy to destination buffer */
 int i;
 
 for (i = 0; i < count; i++)
 {
 ret = BSP_SD_ReadBlocks_DMA((uint32_t*)scratch, (uint32_t)sector++, 1);
 if (ret == MSD_OK )
 {

The problem is that variable "ret" is not defined and I have to define it manually after each code generation.

My settings are FreeRTOS, DMA and defined ENABLE_SCRATCH_BUFFER and ENABLE_SD_DMA_CACHE_MAINTENANCE

Also in addition to this, on line 78 is this code with missing USER CODE END comment.

/* USER CODE BEGIN enableSDDmaCacheMaintenance */
#define ENABLE_SD_DMA_CACHE_MAINTENANCE 1 
/* USER CODE BEGIN enableSDDmaCacheMaintenance */

The last thing is that I have defined symbol in project tool settings / Preprocessor "MBEDTLS_CONFIG_FILE="mbedtls_config.h" and this symbol disappear from the project settings every time the CubeMX code is generated, does anyone have any idea why is that happening?

Thanks,

Petr

This topic has been closed for replies.

12 replies

Khouloud ZEMMELI
ST Employee
April 21, 2020

​Hello @PHlin.1​ 

could you please share your ioc file ?

Thanks,

Khouloud

PHlin.1
PHlin.1Author
Associate III
April 21, 2020

Here is the ioc file

Khouloud ZEMMELI
ST Employee
April 21, 2020

​Hi @PHlin.1​ ,

For the ret declaration , it's ok on my side : uint8_t ret = BSP_SD_ReadBlocks_DMA((uint32_t*)buff, (uint32_t)(sector), count); (using the 5.6.1 MX version)

For the USER CODE END , issue will be fixed.

Best Regards,

Khouloud

Khouloud ZEMMELI
ST Employee
April 21, 2020

@PHlin.1​ 

​Please forget about the latest comment, it's related to an other issue.

Regards,

Khouloud

Khouloud ZEMMELI
ST Employee
April 21, 2020

Sorry , For the  USER CODE END , I have this result using your ioc file:

 /* USER CODE BEGIN enableScratchBuffer */

/* USER CODE END enableScratchBuffer */

/* USER CODE END enableScratchBuffer */​

PHlin.1
PHlin.1Author
Associate III
April 21, 2020

@Khouloud ZEMMELI​ 

I was referring to enableSDDmaCacheMaintenance, not enableScratchBuffer

/* USER CODE BEGIN enableSDDmaCacheMaintenance */
/* #define ENABLE_SD_DMA_CACHE_MAINTENANCE 1 */
/* USER CODE BEGIN enableSDDmaCacheMaintenance */

Khouloud ZEMMELI
ST Employee
April 22, 2020

​@PHlin.1​  Yes you're right, issue will be fixed; Thanks for your feedback

Best regards,

Khouloud

Khouloud ZEMMELI
ST Employee
April 21, 2020

/* USER CODE BEGIN enableScratchBuffer */

/* #define ENABLE_SCRATCH_BUFFER */

/* USER CODE END enableScratchBuffer */

franck23
Associate III
February 14, 2021

Hi,

The user code end has been fixed, but the ret issue reported by PHlin.1 is still present on CubeMx 6.1.1.

When ENABLE_SCRATCH_BUFFER is enabled, we get the following compile error for on line 332:

../FATFS/Target/sd_diskio.c:332:9: error: 'ret' undeclared (first use in this function)

uint8_t ret must be redeclared manually on line 329 every time CubeMX regenerates the code.