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
158 stars 92 forks source link

Differences between STM32F1 and STM32H7 series MCUs using USBX #27

Closed arilink-tech closed 3 years ago

arilink-tech commented 3 years ago

I have successfully run the ThreadX+USBX program on the STM32H7 chip. The USB composite device (CDC ACM+HID) is used, so I tried to implement the same function on STM32F105RBT6, but I ran into trouble, running USB on F105 The composite device can run normally at the beginning, but after 40s, the USB will be disconnected and reconnected, and the USB will not be recognized. If I use HID or CDC alone, everything works fine . I learned that H7 has 9 endpoints and F1 has only 4 USB endpoints. Will it? Is USB working abnormally because of the number of endpoints?

xiaocq2001 commented 3 years ago

It's possible number of endpoints issue. I checked the example generated from STMCube for STM32H7, the following endpoints are used: 0x01, 0x82, 0x83 for CDC and 0x84 for HID, total 5 endpoints including EP0. If that's directly used in STM32F105 project, there is problem running endpoint 0x84 (as you mentioned only 4 USB endpoints are supported by F1).

arilink-tech commented 3 years ago

In this case, my guess is correct. CDC uses 2 IN endpoints, 1 OUT endpoint, HID uses 1 IN endpoint, plus EP0 for a total of three IN and 2 OUT endpoints. STM32F105 is enough, so I set USBD_CDCACM_EPINCMD_ADDR to 0x81U USBD_CDCACM_EPIN_ADDR to 0x82 USBD_CDCACM_EPOUT_ADDR is set to 0x01U USBD_HID_EPIN_ADDR is set to 0x83U At this time, the USB will not be disconnected and reconnected, but when I try to communicate via CDC, I find that the virtual serial port cannot be opened normally. What is the reason?

arilink-tech commented 3 years ago

It's really strange. CubeMX generates the USB driver of F103. hpcd_USB_OTG_FS.Init.dev_endpoints = 8 and F105, which is more advanced than F103, has only 4 endpoints. This is too outrageous.

flamingvines2 commented 3 years ago

Hi Arilink, Do you mind sharing your H7 codes? I am trying to port to H753 with STMCube but so far I can't make it work. Thanks so much

arilink-tech commented 3 years ago

@flamingvines2 HID+CDC?

flamingvines2 commented 3 years ago

Yes, please. Thanks a lot!

arilink-tech commented 3 years ago

leave me a email , the file size is very big ,github can‘t support to upload

@.***

From: flamingvines2 Date: 2021-09-01 15:38 To: azure-rtos/usbx CC: arilink; State change Subject: Re: [azure-rtos/usbx] Differences between STM32F1 and STM32H7 series MCUs using USBX (#27) Yes, please. Thanks a lot! — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

flamingvines2 commented 3 years ago

I think Github censored the email. I will a space in between. My email is

v i n e s 2 0 0 1 @ y a h o o . c o m

arilink-tech commented 3 years ago

Did you receive the file I sent?

@.***

From: flamingvines2 Date: 2021-09-01 15:58 To: azure-rtos/usbx CC: arilink; State change Subject: Re: [azure-rtos/usbx] Differences between STM32F1 and STM32H7 series MCUs using USBX (#27) @.*** — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

flamingvines2 commented 3 years ago

Yes I did. Thanks a lot. I am looking at it and comparing it with what I did. It seems that my code is almost identical to what you are doing except for some HAL IO writes example - HAL_GPIO_WritePin(GPIOI, GPIO_PIN_8, GPIO_PIN_SET). Probably you are just monitoring something.

As I am not using Arm Keil, do you mind telling me what exact chipset you are using? STM32H7?? Are you using a development board or custom board?

arilink-tech commented 3 years ago

I only operate IO to use LED lights to identify the running status of the system

I am using a board made by STM32H743XBH6

flamingvines2 commented 3 years ago

I solved the issue. It was a hardware issue not really on the firmware. Anyway, thanks.

arilink-tech commented 3 years ago

ok congratulate