cancel
Showing results for 
Search instead for 
Did you mean: 

Example for Azure RTOS USBX device video (UVC)

Johannes
Senior

Hello everyone

Does anyone have example code for Azure RTOS USBX device class video (UVC)?

I was able to add Video to my USBX demo application on Nucleo H7A3

There was sample code for CDC_ACM and MSC (mass storage), this worked fine. But for device class video, I was not able to find any example code.

CubeIDE 1.12.1 generated two files

ux_device_video.c

ux_device_video.h

But both files only contain prototypes of callback functions which need to be filled

Like this:

/**
  * @brief  USBD_VIDEO_StreamRequest
  *         This function is invoked to manage the UVC class requests.
  * @param  video_stream: Pointer to video class stream instance.
  * @param  transfer: Pointer to the transfer request.
  * @retval status
  */
UINT USBD_VIDEO_StreamRequest(UX_DEVICE_CLASS_VIDEO_STREAM *video_stream,
                              UX_SLAVE_TRANSFER *transfer)
{
   UINT status  = UX_SUCCESS;
 
  /* USER CODE BEGIN USBD_VIDEO_StreamRequest */
  UX_PARAMETER_NOT_USED(video_stream);
  UX_PARAMETER_NOT_USED(transfer);
  /* USER CODE END USBD_VIDEO_StreamRequest */
 
  return status;
}

How to fill it, that it works?

Thanks

Johannes

1 ACCEPTED SOLUTION

Accepted Solutions
mohamed.ayed
ST Employee

Hi Johannes,

It's mentioned in readme file

https://github.com/STMicroelectronics/x-cube-azrtos-h7/blob/main/Projects/NUCLEO-H723ZG/Applications/USBX/Ux_Device_Video/README.md

if you you open ioc of application (download https://www.st.com/en/embedded-software/x-cube-azrtos-h7.html) change VIDEO_STREAMING_FORMAT to MJPEG and change video width and height finally generate code and include stream2.h in project instead of stream1.h

- stream2 FORMAT : UNCOMPRESSED and Width = 176, Height = 144 and the descriptor shall be updated.

View solution in original post

23 REPLIES 23
Johannes
Senior

This is my project so far. It generates a composite device with 3 endpoints

  • CDC_ACM (serial port)
  • MSC (mass storage) with a ramdisk and FileX
  • Video (does not work)

Generated with CubeIDE 1.12.1

on an Nucleo H7A3ZI-Q

mohamed.ayed
ST Employee

Hi @Johannes​ ,

Please refer to this example application with STM32H723-Nucleo:

https://github.com/STMicroelectronics/x-cube-azrtos-h7/tree/main/Projects/NUCLEO-H723ZG/Applications/USBX/Ux_Device_Video

Johannes
Senior

Hello Mohamed

Thanky you very much (I could have found this myself, silly me)

 

Unfortunately I have additional problems

Windows is still complaining, that the camera cannot be started.

0693W00000bjwQyQAI_image.png

It complains about a wrong parameter being transmitted

Code 0x0A Status 0xC000000D

 


_legacyfs_online_stmicro_images_0693W00000bjwRhQAI.png 

Do you have an idea, what the problem might be?

 

I must admit, that I haven't run the exact example,

  • I use Nucleo H7A3
  • I have setup a compound device with 3 endpoints (MSC, CDC_ACM, Video)
  • I use Cube IDE1.12.1 and have cubeIDE generate all the code

I checked the file usb descriptors and they look the same. (i am using endpoin 0x84 for video)

 

Thank you .

Johannes

mohamed.ayed
ST Employee

Hi @Johannes​  can you please share with an usb trace of your device enumeration, or you can port Ux_Device_Video with  STM32H7A3-Nucleo to ensure that it work and then intergrate it in your application.

Johannes
Senior

Hello Mohamed

Good news: I was able to make the USB Device Video example run.

But I needed to strip my demo code down to a single endpoint USB device.

Strangely: If the device endpoint address is less than 0x83 for video, the camera app on windows does not show the video, just a black screen.

If the endpoint is 0x83 or higher, The camera app shows the demo video.

As soon as I make the device a compound device by adding MSC storage, windows is complaining about the wrong parameter for the USB camera.

I have a wireshark USB trace. There are multiple strange packets:


_legacyfs_online_stmicro_images_0693W00000bjxw7QAA.pngAnd a malformed packet


_legacyfs_online_stmicro_images_0693W00000bjxwCQAQ.pngThe rest of the packets are related to MSC storage, i think

Johannes
Senior

This is a trace of a working camera (singular endpoint device)


_legacyfs_online_stmicro_images_0693W00000bjy3mQAA.pngThe "unknown frames" are still there, but there is no "malformed package".

mohamed.ayed
ST Employee

@Johannes​ if you modifie device descriptor you need to modifie PID (Product ID)

Johannes
Senior

@mohamed.ayed​ Change the PID to what?

If I change the PID from e.g. 0x5710 to 0x5711, windows re-installes the drivers. But the malformed package is still there.

Johannes
Senior

If a package is "ok", this seems to be the position is the lengh information of the payload


_legacyfs_online_stmicro_images_0693W00000bjyGDQAY.pngbLengh = 4, 1 byte "bDescriptor type" and 2 bytes payload = 4 bytes.

In the malformed package

bLength = 4, but only the bDescriptor is following and 2 bytes are missing


_legacyfs_online_stmicro_images_0693W00000bjyLCQAY.png