Skip to content

ESP32-C6 Support & FastLED Update to 3.9.14 #4626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# ------------------------------------------------------------------------------

# CI/release binaries
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32dev_V4, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover, usermods
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32dev_V4, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32-c6-devkitc-1, esp32_wrover, usermods

src_dir = ./wled00
data_dir = ./wled00/data
Expand Down Expand Up @@ -137,7 +137,7 @@ upload_speed = 115200
# ------------------------------------------------------------------------------
lib_compat_mode = strict
lib_deps =
fastled/FastLED @ 3.6.0
fastled/FastLED @ 3.9.14
IRremoteESP8266 @ 2.8.2
makuna/NeoPixelBus @ 2.8.3
#https://github.com/makuna/NeoPixelBus.git#CoreShaderBeta
Expand Down Expand Up @@ -329,6 +329,34 @@ lib_deps =
board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs
board_build.flash_mode = qio

[env:esp32-c6-devkitc-1]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2025.03.30/platform-espressif32.zip
platform_packages =
framework = arduino
board = esp32-c6-devkitc-1

build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} -g -D WLED_RELEASE_NAME=\"ESP32-C6_8MB\"
-DARDUINO_ARCH_ESP32
-DARDUINO_ARCH_ESP32C6
-DCONFIG_IDF_TARGET_ESP32C6=1
-D CONFIG_ASYNC_TCP_USE_WDT=0
-DCO
-DARDUINO_USB_MODE=1
-D WLED_WATCHDOG_TIMEOUT=0
-DARDUINO_USB_CDC_ON_BOOT=0
-D WLED_DISABLE_INFRARED

upload_speed = 921600
lib_deps = ${env.lib_deps}
lib_ignore =
IRremoteESP8266

board_build.partitions = ${esp32.large_partitions}
board_build.f_flash = 80000000L
board_build.flash_mode = dio
monitor_filters = esp32_exception_decoder

[esp32s3]
;; generic definitions for all ESP32-S3 boards
platform = ${esp32_idf_V4.platform}
Expand Down
1 change: 1 addition & 0 deletions wled00/NodeStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define NODE_TYPE_ID_ESP32S2 33 // etc
#define NODE_TYPE_ID_ESP32S3 34
#define NODE_TYPE_ID_ESP32C3 35
#define NODE_TYPE_ID_ESP32C6 36

/*********************************************************************************************\
* NodeStruct
Expand Down
6 changes: 3 additions & 3 deletions wled00/bus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifdef ARDUINO_ARCH_ESP32
#include "driver/ledc.h"
#include "soc/ledc_struct.h"
#if !(defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3))
#if !(defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6))
#define LEDC_MUTEX_LOCK() do {} while (xSemaphoreTake(_ledc_sys_lock, portMAX_DELAY) != pdPASS)
#define LEDC_MUTEX_UNLOCK() xSemaphoreGive(_ledc_sys_lock)
extern xSemaphoreHandle _ledc_sys_lock;
Expand Down Expand Up @@ -478,7 +478,7 @@ BusPwm::BusPwm(const BusConfig &bc)
_pins[i] = bc.pins[i]; // store only after allocateMultiplePins() succeeded
#ifdef ESP8266
pinMode(_pins[i], OUTPUT);
#else
#elif !defined(CONFIG_IDF_TARGET_ESP32C6)
unsigned channel = _ledcStart + i;
ledcSetup(channel, _frequency, _depth - (dithering*4)); // with dithering _frequency doesn't really matter as resolution is 8 bit
ledcAttachPin(_pins[i], channel);
Expand Down Expand Up @@ -646,7 +646,7 @@ void BusPwm::deallocatePins() {
if (!PinManager::isPinOk(_pins[i])) continue;
#ifdef ESP8266
digitalWrite(_pins[i], LOW); //turn off PWM interrupt
#else
#elif !defined(CONFIG_IDF_TARGET_ESP32C6)
if (_ledcStart < WLED_MAX_ANALOG_CHANNELS) ledcDetachPin(_pins[i]);
#endif
}
Expand Down
132 changes: 123 additions & 9 deletions wled00/bus_wrapper.h

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions wled00/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ bool isButtonPressed(uint8_t b)
#ifdef SOC_TOUCH_VERSION_2 //ESP32 S2 and S3 provide a function to check touch state (state is updated in interrupt)
if (touchInterruptGetLastStatus(pin)) return true;
#else
#if !defined(CONFIG_IDF_TARGET_ESP32C6)
if (digitalPinToTouchChannel(btnPin[b]) >= 0 && touchRead(pin) <= touchThreshold) return true;
#endif
#endif
#endif
break;
}
Expand Down
2 changes: 1 addition & 1 deletion wled00/improv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define DIMPROV_PRINTF(x...)
#endif

#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6)
#undef WLED_DISABLE_IMPROV_WIFISCAN
#define WLED_DISABLE_IMPROV_WIFISCAN
#endif
Expand Down
4 changes: 4 additions & 0 deletions wled00/pin_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ bool PinManager::isPinOk(byte gpio, bool output)
#if ARDUINO_USB_CDC_ON_BOOT == 1 || ARDUINO_USB_DFU_ON_BOOT == 1
if (gpio > 17 && gpio < 20) return false; // 18-19 USB-JTAG
#endif
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
// strapping pins: 4, 5, 8, 9
if (gpio > 11 && gpio < 14) return false; // 12-13 USB-JTAG
if (gpio > 23 && gpio < 31) return false; // 24-30 SPI FLASH
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
// 00 to 18 are for general use. Be careful about straping pins GPIO0 and GPIO3 - these may be pulled-up or pulled-down on your board.
#if ARDUINO_USB_CDC_ON_BOOT == 1 || ARDUINO_USB_DFU_ON_BOOT == 1
Expand Down
2 changes: 1 addition & 1 deletion wled00/presets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void handlePresets()

DEBUG_PRINTF_P(PSTR("Applying preset: %u\n"), (unsigned)tmpPreset);

#if defined(ARDUINO_ARCH_ESP32S3) || defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32C3)
#if defined(ARDUINO_ARCH_ESP32S3) || defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6)
unsigned long start = millis();
while (strip.isUpdating() && millis() - start < FRAMETIME_FIXED) yield(); // wait for strip to finish updating, accessing FS during sendout causes glitches
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "AsyncMqttClient/Packets/PubRecPacket.hpp"
#include "AsyncMqttClient/Packets/PubCompPacket.hpp"

#if ESP32
#if ESP32 || defined(CONFIG_IDF_TARGET_ESP32C6)
#define SEMAPHORE_TAKE(X) if (xSemaphoreTake(_xSemaphore, 1000 / portTICK_PERIOD_MS) != pdTRUE) { return X; } // Waits max 1000ms
#define SEMAPHORE_GIVE() xSemaphoreGive(_xSemaphore);
#elif defined(ESP8266)
Expand Down
2 changes: 1 addition & 1 deletion wled00/src/dependencies/dmx/SparkFunDMX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Distributed as-is; no warranty is given.
#if defined(ARDUINO_ARCH_ESP32)

#include <Arduino.h>
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S2)
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C6)

#include "SparkFunDMX.h"
#include <HardwareSerial.h>
Expand Down
4 changes: 4 additions & 0 deletions wled00/src/dependencies/e131/ESPAsyncE131.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "../network/Network.h"
#include <string.h>

#if defined(CONFIG_IDF_TARGET_ESP32C6)
#define Network Network_C6
#endif

// E1.17 ACN Packet Identifier
const byte ESPAsyncE131::ACN_ID[12] = { 0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 };

Expand Down
6 changes: 5 additions & 1 deletion wled00/src/dependencies/network/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ bool NetworkClass::isEthernet()
return false;
}

NetworkClass Network;
#if defined(CONFIG_IDF_TARGET_ESP32C6)
NetworkClass Network_C6;
#else
NetworkClass Network;
#endif
5 changes: 4 additions & 1 deletion wled00/src/dependencies/network/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class NetworkClass
bool isEthernet();
};

#if defined(CONFIG_IDF_TARGET_ESP32C6)
extern NetworkClass Network_C6;
#else
extern NetworkClass Network;

#endif
#endif
2 changes: 2 additions & 0 deletions wled00/udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ void sendSysInfoUDP()
data[38] = NODE_TYPE_ID_ESP32S3;
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
data[38] = NODE_TYPE_ID_ESP32S2;
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
data[38] = NODE_TYPE_ID_ESP32C6;
#elif defined(ARDUINO_ARCH_ESP32)
data[38] = NODE_TYPE_ID_ESP32;
#else
Expand Down
16 changes: 9 additions & 7 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void WLED::setup()
Serial.setTimeout(50); // this causes troubles on new MCUs that have a "virtual" USB Serial (HWCDC)
#else
#endif
#if defined(WLED_DEBUG) && defined(ARDUINO_ARCH_ESP32) && (defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || ARDUINO_USB_CDC_ON_BOOT)
#if defined(WLED_DEBUG) && defined(ARDUINO_ARCH_ESP32) && (defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || ARDUINO_USB_CDC_ON_BOOT || defined(CONFIG_IDF_TARGET_ESP32C6))
delay(2500); // allow CDC USB serial to initialise
#endif
#if !defined(WLED_DEBUG) && defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DEBUG_HOST) && ARDUINO_USB_CDC_ON_BOOT
Expand Down Expand Up @@ -370,7 +370,7 @@ void WLED::setup()

#if defined(ARDUINO_ARCH_ESP32)
// BOARD_HAS_PSRAM also means that a compiler flag "-mfix-esp32-psram-cache-issue" was used and so PSRAM is safe to use on rev.1 ESP32
#if !defined(BOARD_HAS_PSRAM) && !(defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3))
#if !defined(BOARD_HAS_PSRAM) && !(defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6))
if (psramFound() && ESP.getChipRevision() < 3) psramSafe = false;
if (!psramSafe) DEBUG_PRINTLN(F("Not using PSRAM."));
#endif
Expand Down Expand Up @@ -624,11 +624,13 @@ void WLED::initConnection()
WiFi.setPhyMode(force802_3g ? WIFI_PHY_MODE_11G : WIFI_PHY_MODE_11N);
#endif

if (multiWiFi[selectedWiFi].staticIP != 0U && multiWiFi[selectedWiFi].staticGW != 0U) {
WiFi.config(multiWiFi[selectedWiFi].staticIP, multiWiFi[selectedWiFi].staticGW, multiWiFi[selectedWiFi].staticSN, dnsAddress);
} else {
WiFi.config(IPAddress((uint32_t)0), IPAddress((uint32_t)0), IPAddress((uint32_t)0));
}
// Check if static IP and gateway are set by comparing against default-constructed IPAddress()
// This is safer and more portable than using 0U, which may not work reliably across all platforms (e.g., ESP32-C6)
if (multiWiFi[selectedWiFi].staticIP != IPAddress() && multiWiFi[selectedWiFi].staticGW != IPAddress()) {
WiFi.config(multiWiFi[selectedWiFi].staticIP, multiWiFi[selectedWiFi].staticGW, multiWiFi[selectedWiFi].staticSN, dnsAddress);
} else {
WiFi.config(IPAddress(), IPAddress(), IPAddress());
}

lastReconnectAttempt = millis();

Expand Down
5 changes: 4 additions & 1 deletion wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
#include <SPI.h>

#include "src/dependencies/network/Network.h"
#if defined(CONFIG_IDF_TARGET_ESP32C6)
#define Network Network_C6
#endif

#ifdef WLED_USE_MY_CONFIG
#include "my_config.h"
Expand Down Expand Up @@ -318,7 +321,7 @@ WLED_GLOBAL bool rlyOpenDrain _INIT(RLYODRAIN);
#define IRTYPE 0
#endif

#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || (defined(RX) && defined(TX))
#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C6) || (defined(RX) && defined(TX))
// use RX/TX as set by the framework - these boards do _not_ have RX=3 and TX=1
constexpr uint8_t hardwareRX = RX;
constexpr uint8_t hardwareTX = TX;
Expand Down