STMicroelectronics / x-cube-azrtos-h7

X-CUBE-AZRTOS-H7 (Azure RTOS Software Expansion for STM32Cube) provides a full integration of Microsoft Azure RTOS in the STM32Cube environment for the STM32H7 series of microcontrollers.
https://www.st.com/en/embedded-software/x-cube-azrtos-h7.html
Other
149 stars 56 forks source link

About FileX using Dcache and DMA #8

Open zi-niu opened 3 years ago

zi-niu commented 3 years ago

Hello, I have successfully ported ThreadX and FileX on my own board STM32H735G DK and successfully run the Fx_uSD_File_Edit example. But when I enable the FX_ENABLE_EXFAT macro and use the exfat format SD card, the program makes an error when opening the SD device and returns FX_IO_ERROR. When I disable DCache, the program runs normally. So I checked the code and found that there seems to be some problems in the processing of DCache, in x-cube-azrtos-h7/Middlewares/ST/filex/common/drivers/fx_stm32_sd_driver.c line 122, unaligned_buffer = (UINT)(media_ptr-> fx_media_driver_buffer) & 0x3; This is used to determine whether the four bytes are aligned, and if so, use DMA transmission directly. In line 300 and line 336, SCB_InvalidateDCache_by_Addr() is used to maintain data consistency, but SCB_InvalidateDCache_by_Addr() requires 32-byte data alignment. I changed the code to unaligned_buffer = (UINT)(media_ptr->fx_media_driver_buffer) & 0x1f; The program seems to be able to use exfat and Dcache at the same time. I want to know if I am doing this right? And why there is no problem when using the FAT32 file system.

Thank you .

ALABSTM commented 3 years ago

Hi @zi-niu,

Thank you very much for this clear and detailed report. It has been already forwarded to our development teams. We will get back to you as soon as we have their answer.

With regards,

arilink-tech commented 3 years ago

@zi-niu Did you configure and generate the project through CubeMX and then port ThreadX and FileX? I also want to perform a similar operation, but I am not sure about the SD card DMA configuration. The official example is not easy to see the configuration process. Can you refer to your project?

zi-niu commented 3 years ago

@arilink https://github.com/zi-niu/STM32H735-FileX-demo

arilink-tech commented 3 years ago

Are you using the same chip and engineering directly? I’m using H750 and can’t directly use H735’s project. Porting H735’s code keeps prompting that the mount fails.

arilink-tech commented 3 years ago

Hi zi-niu Are you Chinese? I feel that you have a deep research on ThreadX and its supporting components. I want to learn more from you.

@.***

From: zi-niu Date: 2021-08-27 18:00 To: STMicroelectronics/x-cube-azrtos-h7 CC: arilink; Mention Subject: Re: [STMicroelectronics/x-cube-azrtos-h7] About FileX using Dcache and DMA (#8) @arilink https://github.com/zi-niu/STM32H735-FileX-demo — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

zi-niu commented 3 years ago

@arilink Yes, I am Chinese. You can friend me on WeChat: Calf_K