Page 1 of 1

Using tinyusb from a component

Posted: Sat Apr 22, 2023 2:23 pm
by ghoti57
ESP-IDF 5.0.1
Windows 11


I can create a fairly trivial project using tinyusb that creates two cdc-acm serial ports and echoes output from each in the other (test.zip).

However if I try to move usb.c and usb.h into a component I can't get the system to build.

In the first instance i just moved usb.c and usb.h to components\usb
created components\usb\CmakeLists.txt

Code: Select all

idf_component_register(
    SRCS "usb.c"
    INCLUDE_DIRS "."
)
and updated main\CMakeLists.txt

Code: Select all

# See the build system documentation in IDF programming guide
# for more information about component CMakeLists.txt files.

idf_component_register([attachment=1]test.zip[/attachment]
    SRCS main.c
    REQUIRES usb
)
Attempting to build now produces the following errors

Code: Select all

<path>/eclipse-workspace/test1/components/usb/usb.c:6:10: fatal error: tinyusb.h: No such file or directory
    6 | #include "tinyusb.h"
      |          ^~~~~~~~~~~
compilation terminated.

<path>/eclipse-workspace/test1/managed_components/espressif__esp_tinyusb/tinyusb.c:12:10: fatal error: esp_private/usb_phy.h: No such file or directory
   12 | #include "esp_private/usb_phy.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
The first can be fixed by adding a REQUIRES line to components\usb\CMakeLists.txt

Code: Select all

idf_component_register(
    SRCS "usb.c"
    INCLUDE_DIRS "."
    REQUIRES tinyusb
)
However, I can find no way to eliminate the second error.
I've tried moving idf_components.yml to various other parts of the project to no avail.
test1.zip is my latest component version

Anybody know how to get rid of this error please

Re: Using tinyusb from a component

Posted: Mon Apr 24, 2023 7:25 am
by ghoti57
This really belongs under ESP-IDF so reposted there and closing this topic