PlatformIO can not install the tinyUSB depenency

Hello Community I bought an RSP32S2 devboard and would like to use it with PlatformIO. Since there is no Ardoino Support currently I decided to try the Espress IDF. Which worked for the first test programm too. Now I tryed to load the USB example but it can not comple due to a permission error (I guess phyton?) which prevents PlatformIO to install the TinyUSB dependency.
This is the code which I am using:

This is my error which I get while trying:
Executing task: platformio run --environment esp32-s2-saola-1 <

Processing esp32-s2-saola-1 (platform: espressif32; board: esp32-s2-saola-1; framework: espidf)
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (3.4.0) > Espressif ESP32-S2-Saola-1
HARDWARE: ESP32S2 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
 - framework-espidf 3.40301.0 (4.3.1) 
 - tool-cmake 3.16.4 
 - tool-esptoolpy 1.30100.210531 (3.1.0) 
 - tool-ninja 1.7.1 
 - toolchain-esp32s2ulp 1.22851.191205 (2.28.51) 
 - toolchain-riscv32-esp 8.4.0+2021r1 
 - toolchain-xtensa-esp32s2 8.4.0+2021r1
Installing ESP-IDF's Python dependencies
Collecting cryptography<35.0.0,>=2.1.4
  Using cached
Collecting future>=0.15.2
  Using cached
Collecting pyparsing<2.4.0,>=2.0.3
  Using cached
Collecting kconfiglib==13.7.1
  Using cached
Collecting cffi>=1.12
  Using cached
Collecting pycparser
  Using cached
Installing collected packages: pycparser, cffi, cryptography, future, pyparsing, kconfiglib
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Keine Berechtigung: '/usr/local/lib/python3.8/site-packages/pycparser-2.21.dist-info'
Consider using the `--user` option or check the permissions.

*** Error 1
Reading CMake configuration...
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/esp32-s2-saola-1/src/main.o
src/main.cpp:203: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  >

 #include "tinyusb.h"
compilation terminated.
Generating project linker script .pio/build/esp32-s2-saola-1/esp32s2.project.ld

How can I fix that problem?

PlatformIO should not attempt to install a Python package in the global Python packages site, but in its own isolated Python environment (e.g. ~/.platformio/penv/Lib/site-packages). Did you install PlatformIO globally via e.g. sudo -H pip3 install platformio or did you use the recommended installer script and appended your PATH as is recommended since it gives you the isolated envrionment?

What is the output of pio system info in a CLI?

I installed PlatformIO as Visual Studio Code extension. So I didn´t had to do anything else. Do I need to change something there?

This is my output of the pio system info command:

PlatformIO Core 5.2.3
Python 3.8.10-final.0
System Type linux_x86_64
Platform Linux-5.11.22-100.fc32.x86_64-x86_64-with-glibc2.2.5
File System Encoding utf-8
Locale Encoding UTF-8
PlatformIO Core Directory /home/djpx/.platformio
PlatformIO Core Executable /usr/local/bin/platformio
Python Executable /usr/bin/python3
Global Libraries 0
Development Platforms 3
Tools & Toolchains 24

It is clearly installed globally since that is not in ~/.platformio. When you do cd ~/.platformio and find . -name "pio", what does that return?

It only returns this:

This is the content:
# -- coding: utf-8 --
import re
import sys
from platformio.main import main
if name == ‘main’:
sys.argv[0] = re.sub(r’(-script.pyw|.exe)?$’, ‘’, sys.argv[0])

The PlatformIO installer does not create ~/usr/local/bin/platformio, it must come from another installation method. What does sudo dpkg list | grep plat and apt list --installed | grep plat and pip3 list | grep plat output?

Sorry that you had to wait i can not execute that command since I am on a fedora system. So I am not able to use the dpkg command

Then use either dnf list installed | grep plat or rpm -qa | grep plat.

It seems it only finds the KDE platform
First command: kde-platform-plugin.x86_64
Secound command: kde-platform-plugin-4.11.22-27.fc32.x86_64

Well, last try, what does rpm -qf /usr/local/bin/platformio output?

The pip3 command returend nothing?

Sorry I over looked the pip3 list | grep plat command the output is:
platformdirs 2.4.0
platformio 5.2.3

And rpm -qf /usr/local/bin/platformio returned:
The file /usr/local/bin/platformio does not belong to a package
( I translated that since it was in my mainlanguage

Aha so it was installed via the global pip3 program.

It’s highly not-recommended to do that – you should do the following

  1. Go to the VSCode PlatformIO extension settings and make sure the checkboxes “Use Builtin PIOCore” is on, “Use Builtin Python” is on
  2. Uninstall your global PlatformIO installion (/usr/local/bin/platformio) – try sudo -H pip3 uninstall platformio or pip3 uninstall platformio
  3. Restart VSCode and check if you can still compile basic projects (builtin core is working)
  4. Use the CLI to check that pio system info now returns a PlatformIO Core Executable within /home/djpx/.platformio.
  5. Execute a pio platform update espressif32 while you’re at it to update the Espressif 32 platform.
  6. Check if that makes the “Could not install packages” error disappear now that it’s using the builtin-Python and builtin-core
  7. If you want PlatformIO to be globally accessible from the CLI, see docs.

And regarding

Using the master branch is generally incorrect since PlatformIO may use a different version. Per releases, the latest platform-espressif32 uses ESP-IDF 4.3.1 – you must use the same, which is esp-idf/tusb_serial_device_main.c at v4.3.1 · espressif/esp-idf · GitHub
Further it is most critical that the sdkconfig is correct. The project commands

to be set. Make sure you either

  1. Copy the sdkconfig.defaults file inside the PlatformIO project, delete the old sdkconfig.<environment name> file and re-run compilation to regenerate the sdkconfig.<environment name> from the defaults file
  2. or, use menuconfig to search and enable the CONFIG_USB_ENABLED and CONFIG_USB_CDC_ENABLED oiptions – CONFIG_IDF_TARGET should be set up automatically.

This should take care of the compilation error “tinyusb.h not found”.

1 Like

Should I do a backup before I do that or does it not touch my project files?

Well if your project files are exactly just the ESP-IDF example (esp-idf/examples/peripherals/usb/tusb_serial_device at v4.3.1 · espressif/esp-idf · GitHub), the no need to backup – everything is online. If you have already added custom code, you can ofc do a backup.

There should be no need to backup anything (e.g. ~./platformio/) as it can be reinstalled from scratch at anytime, and no personal data is stored therein.

I got already alot projects with the ESP8266 and ESP32 which I don´t like to lose since I spend alot time on them. So I am currently doing an update on all of the just to be sure. :grinning:

If you did no custom changes to files within ~/.platformio, everything is recoverable. In fact, the extension is programmed to recover from a completely deleted ~/.platformio folder through automatic reinstallation as if it were nothing.

Thank you alot. It seems to compile now and i finally can do some testing when I assemble the USB-port on my ESP32S2.

Are you interessted in steams games or some Avast BreachGuard/Avast AntiTrack Premium I still have them here unused and would like give it to you if you are interested as thank you for your time.