Tinyusb on the esp32 s3 devkitc

I am trying to add the platformio_tinyusb library into a “hello world” example on a .
→ The first thing I do is to install the platformio.
→ Then I run a hello world program.

I search for a tinyusb library for platformio.

platformio tinyusb

I clone it on the lib folder.
and I change the platformio.ini to observe this library dependency

The moment I add the library dependency this causes this error:

This causes an error.

lib_deps and framework = espidf do not mix together well at all. (issue). You should be using the components folder or the Espressif component registry together with a idf_component.yml (example). You’ll probably want to look at the components

You can see the same idf_component.yml way being used in the official examples, for example:

Equally, you should not be using build_flags to configure your ESP-IDF / components setting. Use the sdkconfig.defaults file to setup default options like the example

and remember to delete the .pio and sdkconfig.<environment name> file for a full clean rebuild under the new settings.

And of course, PlatformIO provides a premade example, too:

https://github.com/platformio/platform-espressif32/tree/develop/examples/espidf-peripherals-usb

1 Like

Thanks, I will try. I will use the usbtmc example of the espressif__tinyusb-v0.18.0_4.

The first thing that I will do is to delete/erase the .pio folder and delete the sdkconfig.esp32-s3-devkitc-1 file.

CONFIG_TINYUSB_ENABLED=y
CONFIG_TINYUSB_CDC_ENABLED=y
CONFIG_TINYUSB_DESC_CUSTOM=y

I add this flags into the sdkconfig.defaults and I remove the build flags and the lib_dep from the platformio.ini.

Is it ok if I use the 5.5 ESP-IDF’s idf.py to install the dependencies?
Thanks.

You don’t need to use idf.py at all. If CMake/PlatformIO detects your src/idf_component.yml, it will automatically install it upon the next build. (or, if the precloned esp_tinyusb component in the components/ exists, it of course needs to do nothing).

The examples/espidf-peripherals-usb from platform-espressif32 should work out of the box, zero modifications needed.


I assume it will be something like that.


→ I erased the .pio folder
→ I removed the lib_dep
→ I changed from the sdkconfig.esp32_s3-devkitc-1 to sdkconfig.defaults
→ I added the change in the idf_component.yml…

but in the main.c there are no tinyusb suggestion… why how can I solve it?

No? Just as per the linked example,

You have to press the “Build” button for the intellisense to update and give you suggestions. (Or Ctrl+Shift+P → Rebuild Intellise Index).

I want to use the tinyusb not the esp_tinyusb.
I assume that it will be something like that:

IDF Component Manager Manifest File

dependencies:
espressif/tinyusb: “^0.18.0~4”
idf: “^5.0”

esp_tinyusb has some pretty important integration code for TinyUSB, like starting up the USB PHY, creating the TinyUSB processing task (tusb_device_task()), registering the callback functions for the CDC, et cetera. Sure, you can do it with just tinyusb, but you’ll end up writing just another version of the esp_tinyusb integration code, I think.

See

Using tinyusb directly is explained in https://components.espressif.com/components/espressif/tinyusb, " Use component directly".

The reason because of my early choice is the fact that the tinyusb has an example with usbtmc. USBTMC stands for USB Test & Measurement Class.

Perhaps I should add both.

Interesting, because in the USBTMC example, the espessif family is explicitly in the “skip” list, indicating it’s not directly compilable for it.

You’ll have to adapt the example anyway because of stuff like app_main() being the entry point instead of main(), et cetera. Let me just have a look at compiling and running that example for an S3.

I will use both. In fact according to the component register esp_tinyusb is dependant of the tinyusb.
Thanks.

Good news:
I am able to add the tinyusb component: in fact a new folder is created once I clean and I build the project. The suggested managed code appear when I include a new library.

I am almost done.
→ I was able to install and use the components.
→ The suggested code is shown and I am able to use the components.
However, when I clean and build the project and error appears…

Seems like the logic in esp_tinyusb in regards to decsriptors_control.c is trying to overwrite the exact same function as the usbtmc_app.c tries to overwrite – both can’t be present at the same time. So you either need to rewrite it to use esp_tinyusb’s mechanism, or discard esp_tinyusb and use only tinyusb.

I got the TMC example to compile, though I had to rely on a hack to add the family.c file and board BSP folder ot the include path.

https://github.com/maxgerhardt/esp32s3-usbtmc-example

It does not use espressif_tinyusb, only pure tinyusb.

Only modifications from the code are really

  • int main()void app_main()
  • #define CFG_TUSB_OS OPT_OS_FREERTOS in the tusb_config.h
  • #define CFG_TUSB_MCU OPT_MCU_ESP32S3 in the tusb_config.h
1 Like