Skip to content

STM32H747 + USB3320C #3054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
eng-software opened this issue Mar 28, 2025 · 2 comments
Open
1 task done

STM32H747 + USB3320C #3054

eng-software opened this issue Mar 28, 2025 · 2 comments
Labels

Comments

@eng-software
Copy link

eng-software commented Mar 28, 2025

Operating System

Others

Board

STM32H747I-DISCO

Firmware

examples/host/cdc_msc_hid

What happened ?

I am trying to use STM32H747I-DISCO as Host to plug USB HUB
In this hub I will conect a CDC, HID and MSC.
I solved many problems, but this last one I need help.

The USB3320 CPEN pin controls VBUS and I cant turn this pin on.

How to reproduce ?

Just run the STM32Cube project
https://github.com/eng-software/TestTinyUSB.git

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

TinyUSB Host CDC MSC HID Example
USBH init on controller 1, speed = High
sizeof(usbh_device_t) = 86
sizeof(hcd_event_t) = 12
sizeof(_ctrl_xfer) = 20
sizeof(tuh_xfer_t) = 24
sizeof(tu_fifo_t) = 12
sizeof(tu_edpt_stream_t) = 20
CDC init
sizeof(cdch_interface_t) = 196
MSC init
sizeof(msch_interface_t) = 52
sizeof(msch_epbuf_t) = 48
HID init
sizeof(hidh_interface_t) = 14
HUB init
guid, gsnpsid, ghwcfg1, ghwcfg2, ghwcfg3, ghwcfg4
0x00002300, 0x4F54330A, 0x00000000, 0x229FE190, 0x03B8D2E8, 0xE3F00030
Fullspeed PHY init
DMA = 0

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.
@eng-software
Copy link
Author

eng-software commented Mar 31, 2025

Now its working.

  • I fixed my hardware startup, clock, gpio
  • Added the configuration : #define BOARD_TUH_MAX_SPEED OPT_MODE_HIGH_SPEED

Sugestion:
USB disconnection is not working verywell, so I suggest the change above:

static void handle_hprt_irq(uint8_t rhport, bool in_isr) {
  dwc2_regs_t* dwc2 = DWC2_REG(rhport);
  uint32_t hprt = dwc2->hprt & ~HPRT_W1_MASK;
  const dwc2_hprt_t hprt_bm = dwc2->hprt_bm;

  if (dwc2->hprt & HPRT_CONN_DETECT) {
    // Port Connect Detect
    hprt |= HPRT_CONN_DETECT;

    if (hprt_bm.conn_status) {
      hcd_event_device_attach(rhport, in_isr);
    } else {
      hcd_event_device_remove(rhport, in_isr);
    }
  }

  if (dwc2->hprt & HPRT_ENABLE_CHANGE) {
    // Port enable change
    hprt |= HPRT_ENABLE_CHANGE;

    if (hprt_bm.enable) {
      // Port enable
      const tusb_speed_t speed = hprt_speed_get(dwc2);
      port0_enable(dwc2, speed);
    } else {
      // TU_ASSERT(false, );
    	hcd_event_device_remove(rhport, in_isr);
    }
  }

  dwc2->hprt = hprt; // clear interrupt
}

Added hcd_event_device_remove(rhport, in_isr); above // TU_ASSERT(false, );

The code on git is updated, except handle_hprt_irq

@HiFiPhile
Copy link
Collaborator

You can try bfa971a from #2960

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants