Errors with Arduino as ESP-IDF Component or HybridCompile for my ESP32S2 USB Project

Hello,

so for the past days i have nonstop failed at getting this project working, i have reached full desperation. Here is whats going on:

  • I have a full working framework=arduino project with platform=pioarduino that uses OTA via USBMSC.
  • I want to add flash-encryption. From my research that means ESP-IDF needs to step in. Either as a framwork=arduino,espidf (arduino as esp-idf component) or a HybridCompile (which i guess is actived via custom_sdkconfig = … in platformio.ini, correct me if im wrong)

Either way i get a multitude of errors regarding tinyusb, ranging from tusb.h not found, USBSerial not found to ‘tinyusb_add_string_descriptor’ was not declared.

What ive done:

  1. Added Tinyusb as yml dependency (bc epsidf v5.5.4 doesn include it anymore (breaks because then there are two tinyusb in the project i believe)
  2. custom_component_remove = arduino_tinyusb (not working, its a critial component
  3. Probably all possible combinations of build_flags, build_unflags, #defines and skdconfig.defaults.
  4. adding arduino_espressive32 into the /components folder.
  5. rewriting my USBMSC OTA script to only use esp-idf syntax
  6. switches platform=pioarduino to espressif32

I dont know any further…

What i want to know is: Is this currently possible? Are there know working repos? Does someone has a underlying understanding of this an could assit in the project setup? Im all out of ideas.

Thanks for your time,
Peter

If you have a minimal failing compile with these USB components, report them to https://github.com/pioarduino/platform-espressif32/issues/ with the exact project files.

thanks max i will do that.
For now i have found this repo with a minimal working example GitHub - Jason2866/Arduino_IDF_TinyUSB · GitHub

It works on my device. Now when i try to modify the partition table for two OTAs i get invalid headers on boot. So somewhere there is something off. here is my table:

Name,   Type, SubType, Offset,  Size,     Flags

nvs,      data, nvs,     0x11000, 0x5000,
otadata,  data, ota,     0x16000, 0x2000,
app0,     app,  ota_0,   0x20000, 0x1D0000,
app1,     app,  ota_1,   0x1F0000,0x1D0000,
spiffs,   data, spiffs,  0x3C0000,0x30000,  encrypted
coredump, data, coredump,0x3F0000,0x10000,

and here is the table of the original repo:

Name,   Type, SubType, Offset,  Size, Flags

nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x1E0000,
app1,     app,  ota_1,   0x1F0000,0x1E0000,
eeprom,   data, 0x99,    0x3F0000,0x1000,
spiffs,   data, spiffs,  0x3F1000,0xF000,

this my flash command:

python C:\Users\peter\.platformio\packages\tool-esptoolpy\esptool.py --chip esp32s2 --port COM12 --baud 57600 write_flash 0x1000 .pio/build/esp32s2/bootloader.bin 0x10000 .pio/build/esp32s2/partitions.bin 0x20000 .pio/build/esp32s2/firmware.bin

and i have the partition table offset = 0x10000 in sdkconfig.

I am looking into this, now it seems like a problem with my flash setup and tables.

Make sure you do a clean build when changing those parameters, e.g., by removing the .pio directory.