STM32U385 Filex Standalone SDMMC
Hi, i want to use STM32U385RG (NUCLEO-U385RG-Q) to read and write files on SD using SDMMC (1 bit mode) interface, with FileX in standalone mode. I've successfully tested Fx_File_Edit_Standalone (SRAM) example and SD_ReadWrite_DMA (1 bit mode) example.
Following my MX_FileX_Process function:
VOID MX_FileX_Process(VOID)
{
UINT status;
ULONG bytes_read;
CHAR read_buffer[32];
CHAR data[] = "This is FileX working on STM32";
/* Start application */
printf("FileX Edit Standalone Application Start.\n");
/* Open the sram_disk driver. */
status = fx_media_open(&sram_disk, "STM32_SDIO_DISK", fx_stm32_sd_driver, (VOID *)FX_NULL, (VOID *) fx_sd_media_memory, sizeof(fx_sd_media_memory));
/* Check the media open status. */
if (status != FX_SUCCESS)
{
Error_Handler();
}
printf("SD card opened.\n");
/* Create a file called STM32.TXT in the root directory. */
status = fx_file_create(&sram_disk, "STM32.TXT");
/* Check the create status. */
if (status != FX_SUCCESS)
{
/* Check for an already created status. This is expected on the
second pass of this loop! */
if (status != FX_ALREADY_CREATED)
{
/* Create error, call error handler. */
Error_Handler();
}
}
/* Open the test file. */
status = fx_file_open(&sram_disk, &fx_file, "STM32.TXT", FX_OPEN_FOR_WRITE);
/* Check the file open status. */
if (status != FX_SUCCESS)
{
/* Error opening file, call error handler. */
Error_Handler();
}
/* Seek to the beginning of the test file. */
status = fx_file_seek(&fx_file, 0);
/* Check the file seek status. */
if (status != FX_SUCCESS)
{
/* Error performing file seek, call error handler. */
Error_Handler();
}
printf("Writing data into the file. \n");
/* Write a string to the test file. */
status = fx_file_write(&fx_file, data, sizeof(data));
/* Check the file write status. */
if (status != FX_SUCCESS)
{
/* Error writing to a file, call error handler. */
Error_Handler();
}
/* Close the test file. */
status = fx_file_close(&fx_file);
/* Check the file close status. */
if (status != FX_SUCCESS)
{
/* Error closing the file, call error handler. */
Error_Handler();
}
status = fx_media_flush(&sram_disk);
/* Check the media flush status. */
if (status != FX_SUCCESS)
{
/* Error closing the file, call error handler. */
Error_Handler();
}
/* Open the test file. */
status = fx_file_open(&sram_disk, &fx_file, "STM32.TXT", FX_OPEN_FOR_READ);
/* Check the file open status. */
if (status != FX_SUCCESS)
{
/* Error opening file, call error handler. */
Error_Handler();
}
/* Seek to the beginning of the test file. */
status = fx_file_seek(&fx_file, 0);
/* Check the file seek status. */
if (status != FX_SUCCESS)
{
/* Error performing file seek, call error handler. */
Error_Handler();
}
/* Read the first 28 bytes of the test file. */
status = fx_file_read(&fx_file, read_buffer, sizeof(data), &bytes_read);
/* Check the file read status. */
if ((status != FX_SUCCESS) || (bytes_read != sizeof(data)))
{
/* Error reading file, call error handler. */
Error_Handler();
}
/* Close the test file. */
status = fx_file_close(&fx_file);
/* Check the file close status. */
if (status != FX_SUCCESS)
{
/* Error closing the file, call error handler. */
Error_Handler();
}
/* Close the media. */
status = fx_media_close(&sram_disk);
/* Check the media close status. */
if (status != FX_SUCCESS)
{
/* Error closing the media, call error handler. */
Error_Handler();
}
printf("Data successfully written.\n");
/* Infinite loop */
while (1)
{
/* Toggle GREEN LED to indicate status */
HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
HAL_Delay(500);
}
}
The code fail on fx_media_open returning Error_Handler after 10 seconds timeout.
What is the problem?
Thank you
