cancel
Showing results for 
Search instead for 
Did you mean: 

USBX Device MSC problem with file system recognition

RB4020
Associate II

Hi everyone!
I'm working on USB MSC implementation on STM32U0 series MCU with W25Q32JV (NOR Flash) by using USBX + ThreadX.

W25Q32 Memory organization:
- It has 64 blocks and each block is of size 64KB
- Each block has 16 sectors and each sector is of size 4KB (Total 1024 sectors)
- Each sector has 16 pages and each page is of size 256B (Total 16384 pages)
- Total size of flash memory = 4MB

I've already created and mounted a file system in W25Q32 using FatFS library. Also created one folder with one text file in it. Then, using USBX I tried to implement the MSC and till now I'm able to achieve these things:
1) My laptop (USB Host) is able to detect the device i.e MCU as "USB Mass Storage Device" (in the Device Manager -> USB controllers) and "AzureRTO USBX storage dev USB Device" (in the Device Manager -> Disk drives)
2) Coming to the capacity information of this disk, it is showing correctly as 4MB but the volume of the Drive (D:) as 2MB. And when I open the Properties of this Drive (D:), File system is "Unknown"
3) And in My PC -> USB Drive (D:) is appearing but empty and when I try to open it, this pop-up is coming "Format it before accessing" also, when the device is connected to PC via USB, after some time this pop-up is appearing "D:/ The directory name is invalid"

My analysis:
- There are few parameters named MediaBlockLength and LastLba. According to my understanding, I need to put
MediaBlockLength = 4096 and LastLba = (1024-1) = 1023.
- But I'm getting restricted (in terms of size of block) by other 2 parameters named UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH and UX_SLAVE_REQUEST_DATA_MAX_LENGTH. 
- Maximum value of MediaBlockLength is getting restricted by the value of UX_SLAVE_REQUEST_DATA_MAX_LENGTH. But the thing is, I'm not able to put the value of UX_SLAVE_REQUEST_DATA_MAX_LENGTH > 2048 i.e the device is not getting detected at all. 
- And because the MediaBlockLength = 2KB, In the device manager, I'm getting the capacity of (D:) as 2MB. Like, if I put it as 1KB, it is showing 1MB.
- Also, maximum value of UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH = 1024. 

My doubts:

a) Is there anything related to UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH that is causing the issue?
b) What should be the correct value of MediaBlockLength and UX_SLAVE_REQUEST_DATA_MAX_LENGTH?
c) Finally, how to fix this issue of not recognizing the file system? By the way, I've done all the file system related things in different project. So, do I need to mount the file system again in this USB project as well? (Anyways, I've mounted in this project also and it is successful)

I've attached the code files: ux_user.h, ux_port.h and ux_device_msc.h. Also the configuration part.

RB4020_0-1725348458969.pngRB4020_1-1725348491663.pngRB4020_2-1725348520821.pngRB4020_3-1725348544403.png

RB4020_4-1725348585064.png

 

0 REPLIES 0