Adding an ESP32 IDF component does some very weird things

Here’s what I’ve done:

  • Created a components directory
  • Downloaded this: directory an placed it into componenets. Now its components/esp_tinyusb
  • ran pio run -t clean
  • ran pio run

What happened:

PIO created a new subdirectory named managed_components that contains espressif__tinyusb. It then ignores the version in components and issues this error:

Reading CMake configuration...
-- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git'
-- Building ESP-IDF components for target esp32s3
Processing 2 dependencies:
[1/2] espressif/tinyusb (0.15.0~5)
[2/2] idf (5.1.2)
-- Configuring incomplete, errors occurred!
See also "/home/epoulsen/workspaces/dragonfly-supervisor/firmware/.pio/build/esp32dev/CMakeFiles/CMakeOutput.log".

fatal: not a git repository (or any of the parent directories): .git
CMake Error at /home/epoulsen/.platformio/packages/framework-espidf/tools/cmake/component.cmake:250 (message):
  ERROR: 2 problems were found in the manifest file

  Invalid manifest format

  Unknown targets: esp32p4


  SUGGESTION: This component may be using a newer version of the component

  You can try to update the component manager by running:

      /home/epoulsen/.platformio/penv/.espidf-5.1.2/bin/python -m pip install --upgrade idf-component-manager


Call Stack (most recent call first):
  /home/epoulsen/.platformio/packages/framework-espidf/tools/cmake/build.cmake:574 (__component_get_requirements)
  /home/epoulsen/.platformio/packages/framework-espidf/tools/cmake/project.cmake:547 (idf_build_process)
  CMakeLists.txt:4 (project)

============================== [FAILED] Took 1.29 seconds ==============================

I can edit the idf_component.yml file to remove the reference to esp32p4, but then PIO complains that I changed a managed component, and that I move it to components

So, I remove my original components/esp_tinyusb and move the modified espressif__tinyusb there, only for my code to fail to compile because espressif__tinyusb does not contain the same code that I originally downloaded – it’s a different, incompatible version.

I’ve been through all the forum posts, and the IDF documentation.

Adding an IDF component seems to be an exercise in futility at this point. Is there anyone who has successfully added tinyusb (with the tinyusb_msc_storage_init_sdmmc function) to an IDF PIO project?

I don’t know if this is your case, but I was also having difficulty porting an ESP-IDF project to Arduino. And I ended up discovering that just disabling the IDF extension would stop what was happening, which was changing the icons in the bottom toolbar.

Thanks for this. I’m not using the IDE at all … so no extensions to enable or disable.

@valeros could it be the problem?

Unknown targets: esp32p4

Apparently, the latest version of the tinyusb library added support for new ESP32 targets that are not yet supported in PlatformIO. As a workaround I’d recommend locking the tinyusb version in components/esp_tinyusb/idf_component.yml to ==0.15.0~3.

So … to be clear here. The version of esp_tinyusb that I’m putting into components does not specify esp32p4. Here is the idf_components.yml from that:

## IDF Component Manager Manifest File
description: Espressif's additions to TinyUSB
documentation: ""
version: "1.4.3"
  idf: '>=5.0' # IDF 4.x contains TinyUSB as submodule
    version: '>=0.14.2'
    public: true

When this is present, however, Platformio core is creating managed_components and placing a different version of the code in a directory named espressif__tinyusb that does specify esp32p4.

The issue isn’t that esp32p4 exists there. The issue is that PIO is seeing an unmanaged component, and it’s triggering PIO to download/create a managed component that is causing this error.

Having said that, even if I do force the version in components/esp_tinyusb/idf_components.yml to be 0.15.0~3, PIO will still download an incompatible version into managed_components which then fails to link because that version does not contain tinyusb_msc_storage_init_sdmmc.

On second thought, maybe the issue is not the library version, but the version of the idf-component-manager package that’s not aware of the new targets. This should be fixed in the development branch, so it would be great if you could test it out with your project. Just revert changes to your initial state described in the first message and pull your platform directly from the repository, for example:

platform =
framework = espidf
board = esp32-s3-devkitc-1

This does fix the Unknown targets: esp32p4 issue.

However the issue of ignoring the code in the components directory and installing an incompatible version of the USB code in managed_components still persists.

For an ESP32S3, I have recently encountered this too and found these compiling versions


Hi Max,

No idea how to make this work. Where do I put the idf_component.yml where it will be picked up by PIO or IDF?

I added idf_component.yml to my src directory (the same as yours), and I get zero logging showing it was detected, and then this:

src/sdmmc/SDMMC.cpp:8:10: fatal error: tinyusb.h: No such file or directory

* Looking for tinyusb.h dependency? Check our library registry!
* CLI  > platformio lib search "header:tinyusb.h"
* Web  >

    8 | #include "tinyusb.h"

additionally the documentation here: IDF Component Manager - ESP32 - — ESP-IDF Programming Guide v5.2.1 documentation looks like a re-hash of the IDF documentation. The stuff it says (e.g. create-manifest) flat out doesn’t work when using PIO since isn’t even in the path.

There is no tinyusb.h header file. There is tusb.h. Check out

Your code that you linked to has #include "tinyusb.h" in it’s main.c

And, tusb.h also doesn’t work, same error.

Ah. That’s in the Espressif additions indeed.


The PIO documentation WRT IDF components needs to spell out how to do this. As it is, no amount of searching PIO docs, forums, IDF docs, has yielded anything that actually works.

1 Like

What is your current platformio.ini? The ESP32S3 example with TinyUSB in my repo definitely works, it is checked by Github Actions CI to compile properly.


monitor_speed = 115200
;platform = espressif32
platform =
board = esp32-s3-devkitc-1
framework = espidf
board_build.partitions = partitions.csv


Aha! I had id_component.yml instead of idf_component.yml

It compiles now!

I take that back – still have the linking error. Damnit.

The example will compile just fine, and it uses tinyusb_msc_storage_init_sdmmc().