add board ESP32-C6 4mb and 8mb

This commit is contained in:
Mit4el
2024-11-22 22:45:10 +03:00
parent 6820460915
commit d392858cb1
13 changed files with 284 additions and 21 deletions

View File

@@ -52,8 +52,16 @@
#define FIRMWARE_NAME "esp32s3_16mb"
#endif
#ifdef LIBRETINY
#define FIRMWARE_NAME "libretiny"
#ifdef bk7231n
#define FIRMWARE_NAME "bk7231n"
#endif
#ifdef esp32c6_4mb
#define FIRMWARE_NAME "esp32c6_4mb"
#endif
#ifdef esp32c6_8mb
#define FIRMWARE_NAME "esp32c6_8mb"
#endif
// Размер буфера json

View File

@@ -6,9 +6,10 @@
// xtensa-esp32-elf-addr2line.exe -pfiaC -e Путь_к_файлу/firmware.elf Стэк_адресов_из_сообщения
// %%USERPROFILE%/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin xtensa-esp32-elf-addr2line.exe -pfiaC -e .pio/build/esp32_4mb3f/firmware.elf Стэк_адресов
#include "Global.h"
#if defined(ESP32) && !defined(esp32c3m_4mb) && !defined(esp32c6_4mb) && !defined(esp32c6_8mb)
#define RESTART_DEBUG_INFO
#if defined(RESTART_DEBUG_INFO) && defined(ESP32) && !defined(esp32c3m_4mb)
#endif
#if defined(RESTART_DEBUG_INFO)
#define CONFIG_RESTART_DEBUG_STACK_DEPTH 15
typedef struct {
size_t heap_total;

View File

@@ -21,12 +21,12 @@
"pinSDA": 0,
"i2cFreq": 100000,
"wg": "group1",
"debugTrace": 1
"debugTrace": 1
},
"projectProp": {
"platformio": {
"default_envs": "esp32_4mb3f",
"comments_default_envs": "choose from: esp8266_4mb, esp32_4mb, esp32_4mb3f, esp8266_16mb, esp32_16mb, esp32cam_4mb, esp32s2_4mb, esp32s3_16mb, esp32c3m_4mb, esp8266_1mb, esp8266_1mb_ota, esp8266_2mb, esp8266_2mb_ota, esp8285_1mb, esp8285_1mb_ota",
"comments_default_envs": "choose from: esp8266_4mb, esp32_4mb, esp32_4mb3f, esp8266_16mb, esp32_16mb, esp32cam_4mb, esp32s2_4mb, esp32s3_16mb, esp32c3m_4mb, esp8266_1mb, esp8266_1mb_ota, esp8266_2mb, esp8266_2mb_ota, esp8285_1mb, esp8285_1mb_ota, esp32c6_4mb, esp32c6_8mb, bk7231n",
"envs": [
{
"name": "esp8266_4mb",
@@ -123,6 +123,22 @@
"firmware": "0x10000",
"partitions": "0x8000",
"littlefs": "0x910000"
},
{
"name": "esp32c6_4mb",
"boot_app0": "0xe000",
"bootloader_qio_80m": "0x1000",
"firmware": "0x10000",
"partitions": "0x8000",
"littlefs": "0x310000"
},
{
"name": "esp32c6_8mb",
"boot_app0": "0xe000",
"bootloader_qio_80m": "0x1000",
"firmware": "0x10000",
"partitions": "0x8000",
"littlefs": "0x670000"
}
]
}

View File

@@ -381,6 +381,65 @@ build_src_filter =
+<modules/*.cpp>
${env:esp32_16mb_fromitems.build_src_filter}
[env:esp32c6_4mb]
extra_scripts = pre:tools/patch32c6.py
lib_deps =
${common_env_data.lib_deps_external}
${env:esp32c6_4mb_fromitems.lib_deps}
lib_ignore = LT_WebSockets
build_flags =
-Desp32c6_4mb="esp32c6_4mb"
-DARDUINO_USB_CDC_ON_BOOT=0
-DARDUINO_USB_MODE=0
-Wl,--wrap=esp_panic_handler
framework = arduino
board = esp32-c6-devkitm-1
platform = espressif32 @6.9.0
platform_packages =
platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git
platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
monitor_filters = esp32_exception_decoder
upload_speed = 921600
monitor_speed = 115200
debug_tool = esp-prog
board_build.partitions = tools/partitions_custom.csv
board_build.filesystem = littlefs
build_src_filter =
+<*.cpp>
+<classes/*.cpp>
+<utils/*.cpp>
+<modules/*.cpp>
${env:esp32c6_4mb_fromitems.build_src_filter}
[env:esp32c6_8mb]
extra_scripts = pre:tools/patch32c6.py
lib_deps =
${common_env_data.lib_deps_external}
${env:esp32c6_8mb_fromitems.lib_deps}
lib_ignore = LT_WebSockets
build_flags =
-Desp32c6_4mb="esp32c6_4mb"
-DARDUINO_USB_CDC_ON_BOOT=0
-DARDUINO_USB_MODE=0
-Wl,--wrap=esp_panic_handler
framework = arduino
board = esp32-c6-devkitc-1
platform = espressif32 @6.9.0
platform_packages =
platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git
platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
monitor_filters = esp32_exception_decoder
upload_speed = 921600
monitor_speed = 115200
debug_tool = esp-prog
board_build.filesystem = littlefs
build_src_filter =
+<*.cpp>
+<classes/*.cpp>
+<utils/*.cpp>
+<modules/*.cpp>
${env:esp32c6_8mb_fromitems.build_src_filter}
[env:bk7231n]
extra_scripts = pre:tools/lt_fsbuildscript.py
lib_compat_mode = off
@@ -882,6 +941,126 @@ build_src_filter =
+<modules/virtual/VariableColor>
+<modules/virtual/VButton>
[env:esp32c6_4mb_fromitems]
lib_deps =
https://github.com/enjoyneering/AHTxx.git
adafruit/Adafruit BME280 Library
adafruit/Adafruit BMP280 Library
beegee-tokyo/DHT sensor library for ESPx
https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg
robtillaart/SHT2x@^0.1.1
WEMOS SHT3x@1.0.0
plerup/EspSoftwareSerial
gyverlibs/EncButton @ ^2.0
https://github.com/RoboticsBrno/ServoESP32#v1.0.3
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
adafruit/Adafruit BusIO @ ^1.13.2
adafruit/Adafruit BusIO @ ^1.13.2
https://github.com/robotclass/RobotClass_LiquidCrystal_I2C
marcoschwartz/LiquidCrystal_I2C@^1.1.4
https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED
https://github.com/adafruit/Adafruit-GFX-Library
build_src_filter =
+<modules/virtual/Cron>
+<modules/virtual/Loging>
+<modules/virtual/LogingDaily>
+<modules/virtual/Math>
+<modules/virtual/owmWeather>
+<modules/virtual/Ping>
+<modules/virtual/Timer>
+<modules/virtual/Variable>
+<modules/virtual/VButton>
+<modules/sensors/A02Distance>
+<modules/sensors/Acs712>
+<modules/sensors/AhtXX>
+<modules/sensors/AnalogAdc>
+<modules/sensors/BL0937>
+<modules/sensors/Bme280>
+<modules/sensors/Bmp280>
+<modules/sensors/Dht1122>
+<modules/sensors/Ds18b20>
+<modules/sensors/Impulse>
+<modules/sensors/RTC>
+<modules/sensors/S8>
+<modules/sensors/Sht20>
+<modules/sensors/Sht30>
+<modules/sensors/Sonar>
+<modules/sensors/UART>
+<modules/exec/AnalogBtn>
+<modules/exec/ButtonIn>
+<modules/exec/ButtonOut>
+<modules/exec/Buzzer>
+<modules/exec/Enconder>
+<modules/exec/IoTServo>
+<modules/exec/Mcp23017>
+<modules/exec/Multitouch>
+<modules/exec/Pcf8574>
+<modules/exec/Pwm32>
+<modules/exec/TelegramLT>
+<modules/display/Lcd2004>
+<modules/display/Oled64>
+<modules/display/Smi2_m>
[env:esp32c6_8mb_fromitems]
lib_deps =
https://github.com/enjoyneering/AHTxx.git
adafruit/Adafruit BME280 Library
adafruit/Adafruit BMP280 Library
beegee-tokyo/DHT sensor library for ESPx
https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg
robtillaart/SHT2x@^0.1.1
WEMOS SHT3x@1.0.0
plerup/EspSoftwareSerial
gyverlibs/EncButton @ ^2.0
https://github.com/RoboticsBrno/ServoESP32#v1.0.3
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
adafruit/Adafruit BusIO @ ^1.13.2
adafruit/Adafruit BusIO @ ^1.13.2
https://github.com/robotclass/RobotClass_LiquidCrystal_I2C
marcoschwartz/LiquidCrystal_I2C@^1.1.4
https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED
https://github.com/adafruit/Adafruit-GFX-Library
build_src_filter =
+<modules/virtual/Cron>
+<modules/virtual/Loging>
+<modules/virtual/LogingDaily>
+<modules/virtual/Math>
+<modules/virtual/owmWeather>
+<modules/virtual/Ping>
+<modules/virtual/Timer>
+<modules/virtual/Variable>
+<modules/virtual/VButton>
+<modules/sensors/A02Distance>
+<modules/sensors/Acs712>
+<modules/sensors/AhtXX>
+<modules/sensors/AnalogAdc>
+<modules/sensors/BL0937>
+<modules/sensors/Bme280>
+<modules/sensors/Bmp280>
+<modules/sensors/Dht1122>
+<modules/sensors/Ds18b20>
+<modules/sensors/Impulse>
+<modules/sensors/RTC>
+<modules/sensors/S8>
+<modules/sensors/Sht20>
+<modules/sensors/Sht30>
+<modules/sensors/Sonar>
+<modules/sensors/UART>
+<modules/exec/AnalogBtn>
+<modules/exec/ButtonIn>
+<modules/exec/ButtonOut>
+<modules/exec/Buzzer>
+<modules/exec/Enconder>
+<modules/exec/IoTServo>
+<modules/exec/Mcp23017>
+<modules/exec/Multitouch>
+<modules/exec/Pcf8574>
+<modules/exec/Pwm32>
+<modules/exec/TelegramLT>
+<modules/display/Lcd2004>
+<modules/display/Oled64>
+<modules/display/Smi2_m>
[env:bk7231n_fromitems]
lib_deps =
build_src_filter =

View File

@@ -1,5 +1,5 @@
#include "DebugTrace.h"
#if defined(RESTART_DEBUG_INFO) && defined(ESP32) && !defined(esp32c3m_4mb)
#if defined(RESTART_DEBUG_INFO)
// #ifdef RESTART_DEBUG_INFO
__NOINIT_ATTR static re_restart_debug_t _debug_info;
@@ -282,12 +282,14 @@ void sendDebugTraceAndFreeMemory(bool postMsg)
void printDebugTrace() {}
void sendDebugTraceAndFreeMemory(bool) {}
//void IRAM_ATTR debugUpdate() {}
#if !defined(esp32c6_4mb) && !defined(esp32c6_8mb)
extern "C" void __wrap_esp_panic_handler(void *info)
{
// Call the original panic handler function to finish processing this error (creating a core dump for example...)
__real_esp_panic_handler(info);
}
#endif // RESTART_DEBUG_INFO
#endif //esp32c6
#endif // !RESTART_DEBUG_INFO
#if defined(ESP32)
@@ -299,8 +301,10 @@ extern "C" void __wrap_esp_panic_handler(void *info)
void startWatchDog()
{
#if !defined(esp32c6_4mb) && !defined(esp32c6_8mb) //TODO esp32-c6 переписать esp_task_wdt_init
esp_task_wdt_init(WDT_TIMEOUT, true); // enable panic so ESP32 restarts
esp_task_wdt_add(NULL); // add current thread to WDT watch
#endif
}
extern "C" bool verifyRollbackLater()

View File

@@ -1,5 +1,8 @@
#include "EspFileSystem.h"
#include "Global.h"
#if defined(esp32c6_4mb) || defined(esp32c6_8mb)
#include "esp_mac.h"
#endif
bool fileSystemInit()
{
@@ -149,7 +152,7 @@ const String getMacAddress()
char buf[13] = { 0 };
#if defined(ESP8266)
WiFi.macAddress(mac);
sprintf(buf, MACSTR, MAC2STR(mac));
sprintf(buf, MACSTR, MAC2STR(mac));
#elif defined(ESP32)
esp_read_mac(mac, ESP_MAC_WIFI_STA);
sprintf(buf, MACSTR, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

View File

@@ -104,7 +104,7 @@ void setup() {
Serial.begin(115200);
Serial.flush();
//----------- Отладка EXCEPTION (функции с заглушками для отключения) ---------
#if defined(RESTART_DEBUG_INFO) && defined(ESP32) && !defined(esp32c3m_4mb)
#if defined(RESTART_DEBUG_INFO)
//Привязка коллбэк функции для вызова при перезагрузке
esp_register_shutdown_handler(debugUpdate);
#endif // RESTART_DEBUG_INFO
@@ -156,7 +156,7 @@ void setup() {
#endif
SerialPrint("i", "i2c", F("i2c pins overriding done"));
}
#if defined(RESTART_DEBUG_INFO) && defined(ESP32) && !defined(esp32c3m_4mb)
#if defined(RESTART_DEBUG_INFO)
esp_reset_reason_t esp_reason = esp_reset_reason();
if (esp_reason == ESP_RST_UNKNOWN || esp_reason == ESP_RST_POWERON)
bootloop_panic_count = 0;
@@ -291,7 +291,7 @@ void setup() {
Serial.println("--------test end---------");
stopErrorMarker(SETUPLAST_ERRORMARKER);
#if defined(RESTART_DEBUG_INFO) && defined(ESP32) && !defined(esp32c3m_4mb)
#if defined(RESTART_DEBUG_INFO)
bootloop_panic_count = 0;
#endif // RESTART_DEBUG_INFO
}

View File

@@ -64,7 +64,7 @@ String ESP_getResetReason(void) {
return ESP.getResetReason();
}
#endif
#if defined(esp32s2_4mb) || defined(esp32s3_16mb) || defined(esp32c3m_4mb)
#if defined(esp32s2_4mb) || defined(esp32s3_16mb) || defined(esp32c3m_4mb) || defined(esp32c6_4mb) || defined(esp32c6_8mb)
String ESP_getResetReason(void) {
// return ESP32GetResetReason(0); // CPU 0
esp_reset_reason_t esp_reason = esp_reset_reason();
@@ -102,8 +102,8 @@ String ESP32GetResetReason(uint32_t cpu_no) {
return F("Timer Group1 Watchdog reset digital core"); // 8
case RTCWDT_SYS_RESET:
return F("RTC Watchdog Reset digital core"); // 9
case INTRUSION_RESET:
return F("Instrusion tested to reset CPU"); // 10
// case INTRUSION_RESET:
// return F("Instrusion tested to reset CPU"); // 10
case TG0WDT_CPU_RESET:
return F("Time Group reset CPU"); // 11
case RTC_SW_CPU_RESET:

View File

@@ -92,6 +92,12 @@
"esp32*": [
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
],
"esp32c6_4mb": [
"exclude"
],
"esp32c6_8mb": [
"exclude"
],
"esp82*": [
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
]

View File

@@ -8,15 +8,15 @@
extern IoTGpio IoTgpio;
class Pwm32 : public IoTItem {
private:
private:
int _pin;
int _freq;
int _freq;
int _apin, _oldValue;
bool _freezVal = true;
int _ledChannel;
int _ledChannel;
int _resolution;
public:
public:
Pwm32(String parameters): IoTItem(parameters) {
_interval = _interval / 1000; // корректируем величину интервала int, теперь он в миллисекундах
@@ -24,10 +24,14 @@ class Pwm32 : public IoTItem {
jsonRead(parameters, "freq", _freq);
jsonRead(parameters, "ledChannel", _ledChannel);
jsonRead(parameters, "PWM_resolution", _resolution);
pinMode(_pin, OUTPUT);
#if defined(esp32c6_4mb) || defined(esp32c6_8mb)
ledcAttachChannel(_pin, _freq, _resolution, _ledChannel);
#else
ledcSetup(_ledChannel, _freq, _resolution);
ledcAttachPin(_pin, _ledChannel);
#endif
ledcWrite(_ledChannel, value.valD);
_resolution = pow(2, _resolution); // переводим биты в значение
@@ -53,7 +57,7 @@ class Pwm32 : public IoTItem {
}
}
}
void setValue(const IoTValue& Value, bool genEvent = true) {
value = Value;
ledcWrite(_ledChannel, value.valD);

View File

@@ -42,6 +42,12 @@
"esp32*": [
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
],
"esp32c6_4mb": [
"https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg"
],
"esp32c6_8mb": [
"https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg"
],
"esp82*": [
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
]

View File

@@ -17,7 +17,11 @@ IPAddress stringToIp(String strIp)
void routerConnect()
{
#if !defined LIBRETINY
#if defined(esp32c6_4mb) || defined(esp32c6_8mb)
WiFi.setAutoReconnect(false);
#else
WiFi.setAutoConnect(false);
#endif
WiFi.persistent(false);
#endif
/* String s_staip = "192.168.2.62";

32
tools/patch32c6.py Normal file
View File

@@ -0,0 +1,32 @@
import json
import os
import shutil
from sys import platform
if platform == "linux" or platform == "linux2":
# linux
devkitm = '/home/rise/.platformio/platforms/espressif32/boards/esp32-c6-devkitm-1.json'
devkitc = '/home/rise/.platformio/platforms/espressif32/boards/esp32-c6-devkitc-1.json'
else:
# windows
devkitm = os.environ['USERPROFILE'] + '\\.platformio\\platforms\\espressif32\\boards\\esp32-c6-devkitm-1.json'
devkitc = os.environ['USERPROFILE'] + '\\.platformio\\platforms\\espressif32\\boards\\esp32-c6-devkitc-1.json'
def add_arduino_to_frameworks(file_name):
with open(file_name, 'r+') as f:
data = json.load(f)
frameworks = data['frameworks']
if 'arduino' not in frameworks:
frameworks.insert(frameworks.index('espidf') + 1, 'arduino')
data['frameworks'] = frameworks
f.seek(0)
json.dump(data, f, indent=4)
f.truncate()
else:
print(f"Arduino already exists in {file_name}")
if os.path.exists(devkitm) and os.path.exists(devkitc):
add_arduino_to_frameworks(devkitm)
add_arduino_to_frameworks(devkitc)
else:
print("One or both files do not exist.")