2024-09-09 02:13 PM
Hello,
I'm trying to do a proof of concept using the STM32429I-EVAL1, which basically sends a PTP command to a camera. All the USB host library documentation only covers MTP, but there is nothing about PTP. I understand that this board offers out of the box support for MTP, but in the "MTP_Standalone" project example, the files "usbh_mtp_ptp.h" and "usbh_mtp_ptp.c" are part of the projects and the function USBH_PTP_SendRequest, seems to be what I need to send a specific PTP command, but there is no documentation about those functions. I'd appreciate a bit of guidance on this.
Thank you!
2024-09-09 02:26 PM
MTP is extension of PTP, so you can start from MTP host examples.
2024-09-09 02:34 PM
Hi Pavel,
The reason why I'm asking for guidance here is because I already went through that documentation and there is nothing there about the APIs I referenced in my previous message.
2024-09-09 02:38 PM - edited 2024-09-09 02:41 PM
Let me google copilot this for you.
Q: where is documentation on picture transfer protocol (PTP)?
A:
You can find detailed documentation on the Picture Transfer Protocol (PTP) from several sources:
Q: Isn't PTP described in some USB.org standard?
A:Yes, the Picture Transfer Protocol (PTP) is described in the USB Still Image Capture Device Definition, which is part of the USB.org standards. Specifically, it is detailed in the USB Still Image Capture Device Definition, Revision 1.0, which outlines how PTP is used for transferring images over USB connections.
2024-09-09 02:44 PM
I'm glad you know how Google and Copilot works, but that is not what I'm asking. I'm reaching out to the STMicro forum with the hope that the people that work for STMicro can shed some light on how their HW/FW works. Can you please pretend to care and read my first message and at least try to help me?
2024-09-09 02:49 PM - edited 2024-09-09 02:52 PM
Yes I've read your first message. Can you build the host MTP host example and connect a PTP device to it? It is expected at least to start enumeration, parse descriptors and so on.
Azure/Eclipse USBX supports PTP and PictBridge, it's worth to check there too.
2024-09-09 03:18 PM
I've built the MTP Standalone example and connected the dev kit to the camera. The camera is recognized by the DK and everything works as is intended in the example.
I've also modified the example code, because I need to send a PTP command. The MTP APIs that appear in the document UM1720 page 34, don't work for what I'm trying to do, because they are specific to the transfer of media. The only function that seems to be useful for that purpose is USBH_PTP_SendRequest, which I found going through the "usbh_mtp_ptp.h" and "usbh_mtp_ptp.c" files in the example folder. There is no documentation about those PAIs as I mentioned before. Unfortunately, the modified example does not work and I'm not sure if it's because I'm incorrectly using the argument of type PTP_ContainerTypedef or because I need to use the function USBH_PTP_GetResponseas well.
2024-09-09 04:47 PM
Hmm indeed UM1720 does not document USBH_PTP_SendRequest, USBH_PTP_GetResponse. Not great (( But as you've already found, usbh_mtp_ptp.c gives clues about sending and receiving requests. See for example flow of USBH_PTP_GetStorageInfo().
2024-10-28 11:00 AM
Hi Pavel,
Thanks for the tip. I implemented a function that starts a capture based on your advice and still it isn't working. I've been doing some digging to understand why, but unfortunately I haven't been able to figure it out. The function code is below. Can you please let me know if you spot something I'm overlooking? Thanks!
USBH_StatusTypeDef USBH_PTP_InitOpenCapture(USBH_HandleTypeDef *phost)
{
USBH_StatusTypeDef status = USBH_BUSY;
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
PTP_ContainerTypedef ptp_container;
switch (MTP_Handle->ptp.req_state)
{
case PTP_REQ_SEND:
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_NODATA;
/* Fill operation request params */
ptp_container.Code = PTP_OC_InitiateOpenCapture;
ptp_container.SessionID = MTP_Handle->ptp.session_id;
ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id++;
ptp_container.Nparam = 0U;
/* convert request packet inti USB raw packet*/
(void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
#if (osCMSIS < 0x20000U)
(void)osMessagePut(phost->os_event, phost->os_msg, 0U);
#else
(void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, 0U);
#endif
#endif
break;
case PTP_REQ_WAIT:
status = USBH_PTP_Process(phost);
break;
default:
break;
}
return status;
}
2024-10-29 03:13 PM
Sorry I don't have a suitable board anymore.