eclipse-threadx / usbx

Eclipse ThreadX - USBX is a high-performance USB host, device, and on-the-go (OTG) embedded stack, that is fully integrated with Eclipse ThreadX RTOS
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/usbx/index.md
MIT License
157 stars 91 forks source link

Is there a USBX HOST PIMA reference code ? #132

Open 111llll111 opened 8 months ago

111llll111 commented 8 months ago

Hi ,

I need to use STM32H573 as a USB host to read and write Android phone files.

I registered the pima class, connected to the mobile phone to set the MTP function, enumeration failed, but the PTP function can be successfully enumerated.

I have not used PIMA function. What function code should I use to read and write files on my phone?

Do you have the usbx host pima reference code?

Thanks!

xiaocq2001 commented 8 months ago

Define UX_PIMA_WITH_MTP_SUPPORT and compile again to enable MTP support. PIMA manages files as objects, you can use object functions to access your files. Usually you should open a session, get object information, open it, read/write it then close it.

111llll111 commented 8 months ago

Hi 20240111142234

MTP mode still fails enumeration, PTP enumerates successfully.

I opened the macro definition UX_PIMA_WITH_MTP_SUPPORT ,But this macro definition only seems to work on the USB DEVICE side?

111llll111 commented 8 months ago

Hi CQ,

I would like to confirm whether these are the only file formats supported by MTP?

/* Define PIMA Object Format Codes.  */

#define UX_HOST_CLASS_PIMA_OFC_UNDEFINED                        0x3000
#define UX_HOST_CLASS_PIMA_OFC_ASSOCIATION                      0x3001
#define UX_HOST_CLASS_PIMA_OFC_SCRIPT                           0x3002
#define UX_HOST_CLASS_PIMA_OFC_EXECUTABLE                       0x3003
#define UX_HOST_CLASS_PIMA_OFC_TEXT                             0x3004
#define UX_HOST_CLASS_PIMA_OFC_HTML                             0x3005
#define UX_HOST_CLASS_PIMA_OFC_DPOF                             0x3006
#define UX_HOST_CLASS_PIMA_OFC_AIFF                             0x3007
#define UX_HOST_CLASS_PIMA_OFC_WAV                              0x3008
#define UX_HOST_CLASS_PIMA_OFC_MP3                              0x3009
#define UX_HOST_CLASS_PIMA_OFC_AVI                              0x300A
#define UX_HOST_CLASS_PIMA_OFC_MPEG                             0x300B
#define UX_HOST_CLASS_PIMA_OFC_ASF                              0x300C
#define UX_HOST_CLASS_PIMA_OFC_QT                               0x300D
#define UX_HOST_CLASS_PIMA_OFC_EXIF_JPEG                        0x3801
#define UX_HOST_CLASS_PIMA_OFC_TIFF_EP                          0x3802
#define UX_HOST_CLASS_PIMA_OFC_FLASHPIX                         0x3803
#define UX_HOST_CLASS_PIMA_OFC_BMP                              0x3804
#define UX_HOST_CLASS_PIMA_OFC_CIFF                             0x3805
#define UX_HOST_CLASS_PIMA_OFC_GIF                              0x3807
#define UX_HOST_CLASS_PIMA_OFC_JFIF                             0x3808
#define UX_HOST_CLASS_PIMA_OFC_PCD                              0x3809
#define UX_HOST_CLASS_PIMA_OFC_PICT                             0x380A
#define UX_HOST_CLASS_PIMA_OFC_PNG                              0x380B
#define UX_HOST_CLASS_PIMA_OFC_TIFF                             0x380D
#define UX_HOST_CLASS_PIMA_OFC_TIFF_IT                          0x380E
#define UX_HOST_CLASS_PIMA_OFC_JP2                              0x380F
#define UX_HOST_CLASS_PIMA_OFC_JPX                              0x3810

If I want to transfer zip files or bin files, is it not supported?

Thanks!

xiaocq2001 commented 8 months ago

The upper code is actually defined by PIMA 15740:2000. I'm not sure if how your device reports zip or bin files, if they can be referenced in undefined code or some other codes you can use them.

111llll111 commented 8 months ago

Hi CQ,

Can you help us see why the MTP enumeration fails, but the PTP enumeration succeeds?

xiaocq2001 commented 8 months ago

Do you have traces for the enumerations to analyze?