Skip to content

Incorrect StorageID DataType in USBX PIMA MTP Example Causes Hierarchical Storage Detection Failure #2

@polescudero

Description

@polescudero

In the example STM32H735G-DK/Applications/USBX/Ux_Device_PIMA_MTP, there is a bug in the implementation of the StorageID object property description.

Inside the USBD_MTP_GetObjectPropDesc() function, in the case:

case UX_DEVICE_CLASS_PIMA_OBJECT_PROP_STORAGEID:

the following code is used:

/* Fill MTP object property struct */
MTP_ObjectPropDesc.ObjectPropertyCode = UX_DEVICE_CLASS_PIMA_OBJECT_PROP_STORAGEID;
MTP_ObjectPropDesc.DataType = UX_DEVICE_CLASS_PIMA_TYPES_UINT16;
MTP_ObjectPropDesc.GetSet = UX_DEVICE_CLASS_PIMA_OBJECT_PROPERTY_DATASET_VALUE_GET;
MTP_ObjectPropDesc.DefValue = (uint8_t *)&storageid;
MTP_ObjectPropDesc.GroupCode = 0U;
MTP_ObjectPropDesc.FormFlag = 0U;

However, the StorageID property must be defined as a UINT32, not UINT16.

The following line:

MTP_ObjectPropDesc.DataType = UX_DEVICE_CLASS_PIMA_TYPES_UINT16;

should be changed to:

MTP_ObjectPropDesc.DataType = UX_DEVICE_CLASS_PIMA_TYPES_UINT32;

This issue caused the host PC to incorrectly recognize the storage information. In my case, Windows could not properly detect the hierarchical folder structure of the storage exposed through MTP.

The correct definition of this property is specified in the Media Transfer Protocol Specification Revision 1.1 (April 6, 2011), Appendix B, section B.2.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions