2024-10-03 05:57 AM
Current working device
For a client we developed a device using stm32F469 that writes sensor data to an sd-card periodically. Later the data are read out from sd-card by connecting it via USB to a computer, using USBD_MSC_CLASS. The system uses FreeRTOS, FatFS, ST USB driver. This works well (using blocking write and read commands to SDIO). The two paths to access the sd-card (from the MCU software using FatFS and the access from Windows using USB driver from ST) is separated by the MCU software, using init and de-init functions of the modules.
New approach
Now I wanted to transfer it to Azure RTOS using ThreadX, FileX, UsbX. The access to SDIO shall be done with DMA (fx_stm32_sd_write_blocks() calls BSP_SD_WriteBlocks_DMA()). The interrupt callbacks from SDIO (transfer completed) are rerouted with callback functions, depending on who (FileX or UsbX) accesses the sd-card.
However this does not work with the following issues:
sd_write_data(..){
[..]
status = fx_stm32_sd_write_blocks(FX_STM32_SD_INSTANCE, (UINT *)media_ptr->fx_media_driver_buffer, (UINT)start_sector, num_sectors);
if (status == error){..}
FX_STM32_SD_WRITE_CPLT_NOTIFY(); /* --> This calls tx_semaphore_put(&transfer_semaphore); */
tx_thread_sleep(10); /* --> delay added as workaround */
[..]
}
fx_stm32_sd_write_blocks(..){
[..]
if (BSP_SD_WriteBlocks((uint32_t *)buffer, start_block, total_blocks, 2000) != MSD_OK) { ret = 1; }
FX_SD_WriteCpltCallback(); /* --> this function is (should be) called by ISR when using DMA.
It executes: tx_semaphore_put(&transfer_semaphore);
return ret;
}
==> So looks like having issues with synchronization and threads...
Questions that possibly help:
Thanks for any support!
2024-10-08 03:05 AM
Hello @Led,
Could you please share your project files so we can analyze and assist you more effectively?
2024-10-08 08:52 AM
Unfortunately it is a client project and I cant share it. What I can provide is parts of the code, without the sensitive parts. Still I dont want to publish it. I'll send you a post with the access data.