cancel
Showing results for 
Search instead for 
Did you mean: 

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

PHlin.1
Associate III

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

12 REPLIES 12

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

Best regards,

Khouloud

Hi @Khouloud ZEMMELI​ ,

The problem is that that declaration from line 278 is valid only up to line 325 where the block with declared "ret" variable ends. After that "ret" is undeclared. And yes, I'm getting compilation error, that's the only reason why I created this thread.

franck23
Senior

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.