Skip to content
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

[v5.1][USB Host] usb_host_install returns ESP_ERR_NOT_FOUND (IDFGH-10194) #11462

Closed
chipweinberger opened this issue May 21, 2023 · 5 comments
Closed
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@chipweinberger
Copy link
Contributor

chipweinberger commented May 21, 2023

IDF version.

release/v5.1

Device

ESP32-S3

What is the expected behavior?

This used to work on v4.4.4 without error.

What is the actual behavior?

usb_host_install() returns ESP_ERR_NOT_FOUND. We are running out of interrupts.

Build or installation Logs.

            usb_host_config_t hostConfig = {
                .skip_phy_setup = false,
                // Interrupt flags for the underlying
                // ISR used by the USB Host stack
                .intr_flags = ESP_INTR_FLAG_LEVEL2, // LEVEL1 also fails
            };

            sTry(esp_err_t err =,usb_host_install,(&hostConfig));
I (12748) pd midi usb: init
I (12748) pd midi usb: xTaskCreate midi_usb_open_loop
I (12748) pd midi usb: midi_usb_open_loop task started
I (12748) pd usbh: oneTimeInit()
I (12748) pd usbh: [oneTimeInit] create xUsbhInitializeMutex
I (12748) pd usbh: [oneTimeInit] create xOpenedDeviceHandlesMutex
I (12748) pd usbh: [oneTimeInit] create queue xDeviceConnectedEvents
I (12748) pd main: Waiting 1.5 seconds for midi usb task to start
I (13748) pd usbh: [openSingleDevice] called
I (13748) pd usbh: [openSingleDevice] all devices closed. continuing...
I (13748) pd usbh: [openSingleDevice] initializing usbh
I (13748) pd usbh: [init] initialize
I (13748) pd usbh: [init] got mutex
I (13748) pd usbh: [init] xSemaphoreCreateRecursiveMutex() xClaimedInterfacesMutex
I (13748) pd usbh: [init] usb_host_install()
W (13748) pd usbh: [init] failed
I (13758) pd alerts: notify issue
W (13758) pd issues: RAISE - [Usb Device] Init Failure | None
E (13758) : e1 : [pd usbh] usb_host_install() failed. ESP_ERR_NOT_FOUND
e2 : [pd usbh] initialize failed
e3 : [pd midi usb] openSingleDevice() failed
@chipweinberger chipweinberger added the Type: Bug bugs in IDF label May 21, 2023
@github-actions github-actions bot changed the title [v5.1][USB Host] usb_host_install returns ESP_ERR_NOT_FOUND [v5.1][USB Host] usb_host_install returns ESP_ERR_NOT_FOUND (IDFGH-10194) May 21, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label May 21, 2023
@chipweinberger
Copy link
Contributor Author

chipweinberger commented May 21, 2023

The error happens here:

    esp_err_t intr_alloc_ret = esp_intr_alloc(ETS_USB_INTR_SOURCE,
                                              config->intr_flags | ESP_INTR_FLAG_INTRDISABLED,  //The interrupt must be disabled until the port is initialized
                                              intr_hdlr_main,
                                              (void *)p_hcd_obj_dmy->port_obj,
                                              &p_hcd_obj_dmy->isr_hdl);

I've tried using ESP_INTR_FLAG_LEVEL1 instead, but it still fails the same way.

@chipweinberger
Copy link
Contributor Author

chipweinberger commented May 21, 2023

These are the debug logs when using ESP_INTR_FLAG_LEVEL1. I can see I am already using interrupts for:

  • i2c
  • gpio_install_isr_service
  • sdcard detection (i think related to gpio_install_isr_service)
  • something related to "Usb Console: Install Driver"
  • uart
W (14810) intr_alloc: get_available_int: try to find existing. Cpu: 0, Source: 38
W (14810) intr_alloc: get_free_int: start looking. Current cpu: 0
W (14810) intr_alloc: Int 0 reserved 2 priority 1 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 1 reserved 2 priority 1 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 2 reserved 0 priority 1 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: already in (non-shared) use.
W (14810) intr_alloc: Int 3 reserved 0 priority 1 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: already in (non-shared) use.
W (14810) intr_alloc: Int 4 reserved 2 priority 1 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 5 reserved 2 priority 1 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 6 reserved 0 priority 1 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: special-purpose int
W (14810) intr_alloc: Int 7 reserved 0 priority 1 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: special-purpose int
W (14810) intr_alloc: Int 8 reserved 2 priority 1 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 9 reserved 0 priority 1 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: already in (non-shared) use.
W (14810) intr_alloc: Int 10 reserved 0 priority 1 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: incompatible trigger type
W (14810) intr_alloc: Int 11 reserved 0 priority 3 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: special-purpose int
W (14810) intr_alloc: Int 12 reserved 0 priority 1 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: already in (non-shared) use.
W (14810) intr_alloc: Int 13 reserved 0 priority 1 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: already in (non-shared) use.
W (14810) intr_alloc: Int 14 reserved 2 priority 7 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 15 reserved 0 priority 3 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: special-purpose int
W (14810) intr_alloc: Int 16 reserved 0 priority 5 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: special-purpose int
W (14810) intr_alloc: Int 17 reserved 0 priority 1 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: already in (non-shared) use.
W (14810) intr_alloc: Int 18 reserved 0 priority 1 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: already in (non-shared) use.
W (14810) intr_alloc: Int 19 reserved 0 priority 2 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: incompatible priority
W (14810) intr_alloc: Int 20 reserved 0 priority 2 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: incompatible priority
W (14810) intr_alloc: Int 21 reserved 0 priority 2 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: incompatible priority
W (14810) intr_alloc: Int 22 reserved 2 priority 3 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 23 reserved 0 priority 3 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: incompatible priority
W (14810) intr_alloc: Int 24 reserved 2 priority 4 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 25 reserved 2 priority 4 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 26 reserved 0 priority 5 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: incompatible priority
W (14810) intr_alloc: Int 27 reserved 2 priority 3 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 28 reserved 0 priority 4 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: incompatible priority
W (14810) intr_alloc: Int 29 reserved 0 priority 3 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: special-purpose int
W (14810) intr_alloc: Int 30 reserved 2 priority 4 EDGE hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: Int 31 reserved 2 priority 5 LEVEL hasIsr 0
W (14810) intr_alloc: ....Unusable: reserved
W (14810) intr_alloc: get_available_int: using int -1

@chipweinberger
Copy link
Contributor Author

chipweinberger commented May 21, 2023

What I dont understand: why does v5.1 use more interrupts? @igrr @Dazza0 ,

I've tried ESP_INTR_FLAG_LEVEL1 to ESP_INTR_FLAG_LEVEL6, and none are sufficient. I don't have enough interrupts anymore on v5.1.

This is a huge limitation. What am I going to do? Am I stuck on v4.4?

@igrr
Copy link
Member

igrr commented May 22, 2023

According to the log, you have 4 1 more interrupts available:

W (14810) intr_alloc: Int 19 reserved 0 priority 2 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: incompatible priority
W (14810) intr_alloc: Int 20 reserved 0 priority 2 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: incompatible priority
W (14810) intr_alloc: Int 21 reserved 0 priority 2 LEVEL hasIsr 1
W (14810) intr_alloc: ....Unusable: incompatible priority
...
W (14810) intr_alloc: Int 23 reserved 0 priority 3 LEVEL hasIsr 0   <<< available
W (14810) intr_alloc: ....Unusable: incompatible priority

You can use ESP_INTR_FLAG_LOWMED for one or more of the drivers, allowing them to use these level 2 and 3 interrupts.

If you are using ESP32-S3, you can initialize one or more of the drivers from the task running on the other CPU, this way you will also have more interrupt sources available.

Additionally, you can use ESP_INTR_FLAG_SHARED for two of the interrupts which aren't timing critical, for example for gpio_install_isr_service and for I2C. This will also make more interrupts available.

@chipweinberger
Copy link
Contributor Author

chipweinberger commented May 23, 2023

Thanks for all the suggestions Ivan. I gave them all a try.

  • using ESP_INTR_FLAG_LEVEL2 | ESP_INTR_FLAG_LEVEL3 for uart & i2c, and LEVEL1 for usb
  • using ESP_INTR_FLAG_SHARED for uart, and gpio_install_isr_service

None of those worked for whatever reason, usbh still could not find sufficient interrupts.

🎉🎉 However, what did work, was moving my usb init to CPU1 using xTaskCreatePinnedToCore, as you suggest. 🎉🎉

Thanks for the help and the suggestion! It's nice to be on v5.1!

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Opened Issue is new labels Jun 5, 2023
espressif-bot pushed a commit that referenced this issue Jul 21, 2023
ilutchenko pushed a commit to ilutchenko/esp-idf that referenced this issue Jul 24, 2023
ilutchenko pushed a commit to ilutchenko/esp-idf that referenced this issue Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants