Arduino support for ESP32C6

User avatar
Basalt
Posts: 28
Joined: Wed Aug 16, 2023 7:59 pm

Arduino support for ESP32C6

Postby Basalt » Sat Jun 08, 2024 9:16 am

I used to work with the ESP32C3, but now I have these tiny "Seeed Studio XIAO ESP32C6" boards and want to program in them as well with Platfomio using the Arduino framework.

There is no board config availabe, so I copied "esp32-c6-devkitc-1.json", modified some fields, and saved it as "seeed_xiao_esp32c6.json" in my Platformio "boards" folder.

Code: Select all

{
  "build": {
    "core": "esp32",
    "f_cpu": "160000000L",
    "f_flash": "80000000L",
    "flash_mode": "qio",
    "mcu": "esp32c6",
    "variant": "esp32c6"
  },
  "connectivity": [
    "wifi"
  ],
  "debug": {
    "openocd_target": "esp32c6.cfg"
  },
  "frameworks": [
    "espidf"
  ],
  "name": "Seeed Studio XIAO ESP32C6",
  "upload": {
    "flash_size": "4MB",
    "maximum_ram_size": 524288,
    "maximum_size": 4194304,
    "require_upload_port": true,
    "speed": 460800
  },
  "url": "https://www.google.com/",
  "vendor": "Espressif"
}
I did not test it yet, but the file does not contain any Arduino info like I have for my currently working ESP32C3 config. for example:

Code: Select all

{
  "build": {
    "arduino": {
      "ldscript": "esp32c3_out.ld"
    },
    "core": "esp32",
    "extra_flags": [
      "-DARDUINO_XIAO_ESP32C3",
      "-DARDUINO_USB_MODE=1",
      "-DARDUINO_USB_CDC_ON_BOOT=1"
    ],

  ...and...
  
  "frameworks": [
    "arduino",
    "espidf"
  ],
Should I simply add such Arduino info to my JSON for the ESP32C6 to make it build on the Arduino framework?
Or is Arduino actually not supported by Platformio on the C6?

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Arduino support for ESP32C6

Postby lbernstone » Sat Jun 08, 2024 5:46 pm

The tasmota team has CI building framework packages for platformio. You can specify one of their packages like:

Code: Select all

platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.06.10/platform-espressif32.zip
which should have all the assets you need. You will still need to include the extra flags to set the USB mode properly since that is specific to your implementation.

User avatar
Basalt
Posts: 28
Joined: Wed Aug 16, 2023 7:59 pm

Re: Arduino support for ESP32C6

Postby Basalt » Sat Jun 08, 2024 8:45 pm

To be honest I don't know much about this whole CI setup in Platformio, and also have no clue what to do with that Tasmota stuff I downloaded. I gave it a brave try, but no success si far. Some more directions would be appreciated very much.

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Arduino support for ESP32C6

Postby lbernstone » Sun Jun 09, 2024 6:34 pm

Keep it simple. platformio.ini:

Code: Select all

[env:esp32-c6-devkitc-1]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.06.10/platform-espressif32.zip
board = esp32-c6-devkitc-1
framework = arduino
monitor_speed = 115200
build_flags =
    -DARDUINO_USB_MODE=1
    -DARDUINO_USB_CDC_ON_BOOT=1

User avatar
Basalt
Posts: 28
Joined: Wed Aug 16, 2023 7:59 pm

Re: Arduino support for ESP32C6

Postby Basalt » Sun Jun 09, 2024 9:43 pm

I adjusted platformio.ini as suggested. It takes some time until the Tasmota stuff was downloaded and installed. Then I gave the "Build" command in Platformio. The build fails however, see log below.

Code: Select all

 *  Executing task: C:\Users\Erik\.platformio\penv\Scripts\platformio.exe run --environment env_analogclock 

Processing env_analogclock (board: esp32-c6-devkitc-1; platform: https://github.com/tasmota/platform-espressif32/releases/download/2024.06.10/platform-espressif32.zip; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-c6-devkitc-1.html
PLATFORM: Espressif 32 (2024.6.10) > Espressif ESP32-C6-DevKitC-1
HARDWARE: ESP32C6 160MHz, 320KB RAM, 8MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-builtin, 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)
PACKAGES:
 - framework-arduinoespressif32 @ 3.0.1+sha.371d83e
 - tool-esptoolpy @ 4.7.3
 - tool-mklittlefs @ 3.2.0
 - tool-openocd-esp32 @ 2.1100.20220706 (11.0)
 - tool-riscv32-esp-elf-gdb @ 11.2.0+20220823
 - tool-xtensa-esp-elf-gdb @ 11.2.0+20230208
 - toolchain-riscv32-esp @ 12.2.0+20230208
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 32 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ArduinoJson @ 7.0.4
|-- AsyncTCP-esphome @ 2.1.3
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- WiFiManager @ 2.0.17+sha.d82d0a1 
|-- espMqttClient @ 1.7.0
|-- U8g2 @ 2.35.19
|-- Adafruit NeoPixel @ 1.12.2
|-- Ticker @ 2.0.0
|-- Wire @ 2.0.0
|-- ArduinoOTA @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- LittleFS @ 2.0.0
|-- WiFi @ 2.0.0
Building in release mode
Compiling .pio\build\env_analogclock\src\app_analogclock\clock.cpp.o
Compiling .pio\build\env_analogclock\src\app_analogclock\pulsegenerator.cpp.o
Compiling .pio\build\env_analogclock\src\app_analogclock\settings.cpp.o
Compiling .pio\build\env_analogclock\src\application.cpp.o
Compiling .pio\build\env_analogclock\src\drivers\console.cpp.o
Compiling .pio\build\env_analogclock\src\drivers\files.cpp.o
Compiling .pio\build\env_analogclock\src\drivers\hal.cpp.o
In file included from src/httpserver.h:3,
                 from src/application.cpp:6:
.pio/libdeps/env_analogclock/AsyncTCP-esphome/src/AsyncTCP.h:26:10: fatal error: IPv6Address.h: No such file or directory

*********************************************************************
* Looking for IPv6Address.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:IPv6Address.h"
* Web  > https://registry.platformio.org/search?q=header:IPv6Address.h
*
*********************************************************************

   26 | #include "IPv6Address.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\env_analogclock\src\application.cpp.o] Error 1
In file included from C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiSTA.h:29,
                 from C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFi.h:33,
                 from src/network.h:2,
                 from src/main.h:4,
                 from src/drivers/console.cpp:5:
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:46:25: error: 'network_event_handle_t' does not name a type; did you mean 'esp_event_handler_t'?
   46 | #define wifi_event_id_t network_event_handle_t
      |                         ^~~~~~~~~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:79:3: note: in expansion of macro 'wifi_event_id_t'
   79 |   wifi_event_id_t onEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |   ^~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:46:25: error: 'network_event_handle_t' does not name a type; did you mean 'esp_event_handler_t'?
   46 | #define wifi_event_id_t network_event_handle_t
      |                         ^~~~~~~~~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:80:3: note: in expansion of macro 'wifi_event_id_t'
   80 |   wifi_event_id_t onEvent(WiFiEventFuncCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |   ^~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:46:25: error: 'network_event_handle_t' does not name a type; did you mean 'esp_event_handler_t'?
   46 | #define wifi_event_id_t network_event_handle_t
      |                         ^~~~~~~~~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:81:3: note: in expansion of macro 'wifi_event_id_t'
   81 |   wifi_event_id_t onEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |   ^~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:43:25: error: 'NetworkEventCb' has not been declared
   43 | #define WiFiEventCb     NetworkEventCb
      |                         ^~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:82:20: note: in expansion of macro 'WiFiEventCb'
   82 |   void removeEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                    ^~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:82:41: error: 'arduino_event_id_t' has not been declared
   82 |   void removeEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                                         ^~~~~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:45:25: error: 'NetworkEventSysCb' has not been declared
   45 | #define WiFiEventSysCb  NetworkEventSysCb
      |                         ^~~~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:83:20: note: in expansion of macro 'WiFiEventSysCb'
   83 |   void removeEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                    ^~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:83:44: error: 'arduino_event_id_t' has not been declared
   83 |   void removeEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                                            ^~~~~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:83:8: error: 'void WiFiGenericClass::removeEvent(int, int)' cannot be overloaded 
with 'void WiFiGenericClass::removeEvent(int, int)'
   83 |   void removeEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |        ^~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:82:8: note: previous declaration 'void WiFiGenericClass::removeEvent(int, int)'  
   82 |   void removeEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |        ^~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:46:25: error: 'network_event_handle_t' has not been declared
   46 | #define wifi_event_id_t network_event_handle_t
      |                         ^~~~~~~~~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:84:20: note: in expansion of macro 'wifi_event_id_t'
   84 |   void removeEvent(wifi_event_id_t id);
      |                    ^~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:128:25: error: 'arduino_event_id_t' has not been declared
  128 |   const char *eventName(arduino_event_id_t id);
      |                         ^~~~~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:130:30: error: 'arduino_event_t' has not been declared
  130 |   static void _eventCallback(arduino_event_t *event);
      |                              ^~~~~~~~~~~~~~~
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:82:68: error: 'ARDUINO_EVENT_MAX' was not declared in this scope; did you mean 'WIFI_EVENT_MAX'?
   82 |   void removeEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                                                                    ^~~~~~~~~~~~~~~~~
      |                                                                    WIFI_EVENT_MAX
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.h:83:71: error: 'ARDUINO_EVENT_MAX' was not declared in this scope; did you mean 'WIFI_EVENT_MAX'?
   83 |   void removeEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                                                                       ^~~~~~~~~~~~~~~~~
      |                                                                       WIFI_EVENT_MAX
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiSTA.h:44:42: error: expected class-name before '{' token
   44 | class STAClass : public NetworkInterface {
      |                                          ^
In file included from C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFi.h:34:
C:/Users/Erik/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiAP.h:39:41: error: expected class-name before '{' token
   39 | class APClass : public NetworkInterface {
      |                                         ^
*** [.pio\build\env_analogclock\src\drivers\console.cpp.o] Error 1
========================================================================== [FAILED] Took 36.54 seconds ==========================================================================

Environment      Status    Duration
---------------  --------  ------------
env_analogclock  FAILED    00:00:36.537
===================================================================== 1 failed, 0 succeeded in 00:00:36.537 ===================================================================== 
I changed back my platformio.ini, but the errors remain ?!
So I removed my local ".platformio" folder and have rebuilt it all, now it's working again with ESP32C3.

I'm puzzled what is going wrong.
Could it be that Tasmota is not 100% compatible (or older/newer?) with plain vanilla Arduino?
See partial log below of the working config with ESP32C3 and plain vanilla Arduino.

Code: Select all

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/adafruit_qtpy_esp32c3.html
PLATFORM: Espressif 32 (6.7.0) > Adafruit QT Py ESP32-C3
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-builtin, 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)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20016.0 (2.0.16)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-openocd-esp32 @ 2.1100.20220706 (11.0)
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Arduino support for ESP32C6

Postby lbernstone » Sun Jun 09, 2024 11:05 pm

Does a hello world sketch compile and run with the platformio.ini I posted?
If you are upgrading from a v2.0.X compiled sketch to v3.0, you are going to need to fix version inconsistencies.

User avatar
Basalt
Posts: 28
Joined: Wed Aug 16, 2023 7:59 pm

Re: Arduino support for ESP32C6

Postby Basalt » Mon Jun 10, 2024 8:01 pm

Actually, I was not planning (or aware of) upgrading from 2.0.16 to 3.0.1 :shock:

Does that mean that Tasmota is ahead of plain vanilla Arduino, or is it me somehow being behind with my installed (2.0.16) version?
AFAIK everything is up-to-date, but I may have overlooked something. Before switching to Tasmota I would be happy to upgrade, if only I knew how...

BTW:
I didn't try a hello world program, looking at my logging that fails at networking related stuff, I'd guess this simple program would most probably work.

User avatar
Basalt
Posts: 28
Joined: Wed Aug 16, 2023 7:59 pm

Re: Arduino support for ESP32C6

Postby Basalt » Tue Jun 11, 2024 8:22 pm

I read this looong thread https://github.com/platformio/platform- ... ssues/1225 about the support of Arduino ESP32 v3.0 based on ESP-IDF v5.x and it seems quite doubtful to me if PlatformIO will be supported on the new framework. Indeed I could use Tasmota, but I feel that fore me this would be more a workaround than a long term structural solution.

Maybe better to skip Arduino and use the plain ESP-IDF instead?
Only reason I use Arduino is for the the easy libraries, any clue how much work would be involved in converting?

bblanchon/ArduinoJson@^7.0.4
esphome/AsyncTCP-esphome@^2.1.3
ottowinter/ESPAsyncWebServer-esphome@^3.2.0
https://github.com/tzapu/WiFiManager.git#v2.0.17
bertmelis/espMqttClient@^1.6.0
olikraus/U8g2@^2.35.19
SPI
majicdesigns/MD_MAX72XX@^3.5.1
majicdesigns/MD_Parola@^3.7.3
makuna/NeoPixelBus@^2.8.0

User avatar
Basalt
Posts: 28
Joined: Wed Aug 16, 2023 7:59 pm

Re: Arduino support for ESP32C6

Postby Basalt » Tue Jun 11, 2024 8:26 pm

...or can I also skip using PlatformIO, and run ESP-IDF v5.x with Arduino on native VSC ?
Is that possible indeed? What PlatformIO benefits I would loose?

noweare
Posts: 72
Joined: Tue Jul 02, 2019 11:35 am

Re: Arduino support for ESP32C6

Postby noweare » Wed Jun 12, 2024 12:49 am

Platformio supports esp-idf. To me the biggest problem it would be 3rd party libraries that you would lose.

Who is online

Users browsing this forum: No registered users and 32 guests