Skip to content

Commit 97fa64f

Browse files
authored
Merge pull request #5477 from TD-er/bugfix/ESP32S2_USB_console
[Serial Console] Fix outputting data to USBCDC port for ESP32S2
2 parents 4d2d04b + 59c3953 commit 97fa64f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+738
-448
lines changed

platformio_core_defs.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ extra_scripts = ${esp82xx_common.extra_scripts}
171171
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1311-2008-5.5_orig/framework-arduinoespressif32-release_v5.5_orig-276436da.tar.xz
172172

173173
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF55_gcc15
174-
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/0401-1225-5.5/framework-arduinoespressif32-release_v5.5-ad03770f.tar.xz
174+
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1002-1125-5.5_gcc151/framework-arduinoespressif32-release_v5.5_gcc151-7eede06a.tar.xz
175175

176176
custom_remove_include = true
177177

platformio_esp32c6_envs.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ build_unflags = ${esp32_base_idf5_5.build_unflags}
1010
-fexceptions
1111
board_build.filesystem = littlefs
1212
lib_ignore = ${esp32_base_idf5_5.lib_ignore}
13+
PPP
14+
HeatpumpIR
15+
IRremoteESP8266
1316
board = esp32c6cdc
1417

1518

@@ -78,6 +81,7 @@ build_flags = ${esp32c6_common_LittleFS.build_flags}
7881
-D ST7789_EXTRA_INIT=1
7982
-D P116_EXTRA_ST7789=1
8083
extra_scripts = ${esp32c6_common_LittleFS.extra_scripts}
84+
lib_ignore = ${esp32_base_idf5_5.lib_ignore}
8185

8286

8387
[env:max_ESP32c6_16M8M]
@@ -91,6 +95,7 @@ build_flags = ${esp32c6_common_LittleFS.build_flags}
9195
-D ST7789_EXTRA_INIT=1
9296
-D P116_EXTRA_ST7789=1
9397
extra_scripts = ${esp32c6_common_LittleFS.extra_scripts}
98+
lib_ignore = ${esp32_base_idf5_5.lib_ignore}
9499

95100

96101

src/ESPEasy/net/NWPluginStructs/NW004_data_struct_ETH_SPI.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,15 @@ void NW004_data_struct_ETH_SPI::webform_load(EventStruct *event)
229229
addFormNote(F("I²C-address of Ethernet PHY"));
230230
}
231231
{
232-
if ((getSPIBusCount() > 1) && (Settings.isSPI_valid(0u) || Settings.isSPI_valid(1u))) {
232+
if (Settings.getNrConfiguredSPI_buses()) {
233233
const int key = NW004_KEY_SPI_BUS;
234234
const uint8_t spiBus = _kvs->getValueAsInt(key);
235235
KVS_StorageType::Enum storageType;
236236
SPIInterfaceSelector(getLabelString(key, true, storageType),
237237
getLabelString(key, false, storageType),
238238
spiBus);
239+
} else {
240+
// TODO TD-er: Add error message as we need a SPI bus
239241
}
240242

241243
const int gpio_keys[] = {
@@ -446,15 +448,16 @@ bool NW004_data_struct_ETH_SPI::ETHConnectRelaxed() {
446448

447449
// FIXME TD-er: Fallback for ETH01-EVO board
448450
SPI_host = spi_host_device_t::SPI2_HOST;
449-
Settings.InitSPI = static_cast<int>(SPI_Options_e::UserDefined);
451+
Settings.InitSPI = static_cast<int>(SPI_Options_e::UserDefined_VSPI);
450452
Settings.SPI_SCLK_pin = 7;
451453
Settings.SPI_MISO_pin = 3;
452454
Settings.SPI_MOSI_pin = 10;
453455
# endif // ifdef ESP32C3
454456
}
455457

456458
// else
457-
{
459+
if (SPI_host != spi_host_device_t::SPI_HOST_MAX) {
460+
// TODO TD-er: Do we need to include the CLK, MISO, MOSI pins in the call or do we need to start the SPI bus first?
458461
# if ETH_SPI_SUPPORTS_CUSTOM
459462
success = iface->begin(
460463
to_ESP_phy_type(phyType),

src/src/Commands/InternalCommands.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ bool checkNrArguments(const char *cmd, const String& Line, int nrArguments) {
101101
log += F(" ExtraArg");
102102
}
103103
log += i;
104-
log += '=';
104+
log += ':';
105105
log += parameter;
106106
}
107107
++i;
108108
}
109109
}
110-
log += F(" lineLength=");
110+
log += F(" lineLength:");
111111
log += Line.length();
112112
addLogMove(LOG_LEVEL_ERROR, log);
113113
}

src/src/CustomBuild/define_plugin_sets.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ To create/register a plugin, you have to :
103103
#ifndef WEBSERVER_HARDWARE
104104
#define WEBSERVER_HARDWARE
105105
#endif
106+
#ifndef WEBSERVER_INTERFACES
107+
#define WEBSERVER_INTERFACES
108+
#endif
106109
#ifndef WEBSERVER_PINSTATES
107110
#define WEBSERVER_PINSTATES
108111
#endif
@@ -2179,6 +2182,10 @@ To create/register a plugin, you have to :
21792182
#define PLUGIN_DESCR "Climate A"
21802183
#endif
21812184

2185+
#ifndef BUILD_NO_DEBUG
2186+
#define BUILD_NO_DEBUG
2187+
#endif
2188+
21822189
// Features and plugins cherry picked from stable set
21832190
#ifndef FEATURE_SERVO
21842191
#define FEATURE_SERVO 1

src/src/DataStructs/SettingsStruct.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ class SettingsStruct_tmpl
371371
bool noCheck = false) const;
372372

373373
bool isSPI_enabled(uint8_t spi_bus) const;
374+
uint8_t getNrConfiguredSPI_buses() const;
374375
#ifdef ESP32
375376
spi_host_device_t getSPI_host(uint8_t spi_bus = 0) const;
376377
#endif
@@ -395,6 +396,8 @@ class SettingsStruct_tmpl
395396

396397
// Return true if I2C settings are correct
397398
bool isI2CEnabled(uint8_t i2cBus) const;
399+
uint8_t getNrConfiguredI2C_buses() const;
400+
398401

399402
uint8_t getI2CInterface(taskIndex_t TaskIndex) const;
400403
int8_t getI2CSdaPin(uint8_t i2cBus) const;

src/src/DataStructs_templ/SettingsStruct.cpp

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,17 @@ bool SettingsStruct_tmpl<N_TASKS>::isSPI_enabled(uint8_t spi_bus) const {
993993
return SPI_Options_e::None != SPI_selection;
994994
}
995995

996+
template<uint32_t N_TASKS>
997+
uint8_t SettingsStruct_tmpl<N_TASKS>::getNrConfiguredSPI_buses() const
998+
{
999+
uint8_t res{};
1000+
if (isSPI_valid(0u)) ++res;
1001+
#ifdef ESP32
1002+
if (getSPIBusCount() > 1 && isSPI_valid(1u)) ++res;
1003+
#endif
1004+
return res;
1005+
}
1006+
9961007
template<uint32_t N_TASKS>
9971008
bool SettingsStruct_tmpl<N_TASKS>::getSPI_pins(int8_t spi_gpios[3], uint8_t spi_bus, bool noCheck) const {
9981009
spi_gpios[0] = -1;
@@ -1020,7 +1031,10 @@ bool SettingsStruct_tmpl<N_TASKS>::getSPI_pins(int8_t spi_gpios[3], uint8_t spi_
10201031
break;
10211032
}
10221033
#endif
1023-
case SPI_Options_e::UserDefined:
1034+
case SPI_Options_e::UserDefined_VSPI:
1035+
#if SOC_SPI_PERIPH_NUM > 2
1036+
case SPI_Options_e::UserDefined_HSPI:
1037+
#endif
10241038
{
10251039
#ifdef ESP32
10261040
if (0 == spi_bus)
@@ -1059,6 +1073,7 @@ spi_host_device_t SettingsStruct_tmpl<N_TASKS>::getSPI_host(uint8_t spi_bus) con
10591073
const SPI_Options_e SPI_selection = static_cast<SPI_Options_e>(0 == spi_bus ? InitSPI : InitSPI1);
10601074
switch (SPI_selection) {
10611075
case SPI_Options_e::Vspi_Fspi:
1076+
case SPI_Options_e::UserDefined_VSPI:
10621077
{
10631078
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
10641079
return static_cast<spi_host_device_t>(FSPI_HOST);
@@ -1072,14 +1087,12 @@ spi_host_device_t SettingsStruct_tmpl<N_TASKS>::getSPI_host(uint8_t spi_bus) con
10721087
return static_cast<spi_host_device_t>(HSPI_HOST);
10731088
}
10741089
#endif
1075-
case SPI_Options_e::UserDefined:
1090+
#if SOC_SPI_PERIPH_NUM > 2
1091+
case SPI_Options_e::UserDefined_HSPI:
10761092
{
1077-
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
1078-
return static_cast<spi_host_device_t>(FSPI_HOST);
1079-
#else
1080-
return static_cast<spi_host_device_t>(VSPI_HOST);
1081-
#endif
1093+
return static_cast<spi_host_device_t>(HSPI_HOST);
10821094
}
1095+
#endif
10831096
case SPI_Options_e::None:
10841097
break;
10851098
}
@@ -1202,6 +1215,24 @@ bool SettingsStruct_tmpl<N_TASKS>::isI2CEnabled(uint8_t i2cBus) const {
12021215
(getI2CClockSpeedSlow(i2cBus) > 0);
12031216
}
12041217

1218+
template<uint32_t N_TASKS>
1219+
uint8_t SettingsStruct_tmpl<N_TASKS>::getNrConfiguredI2C_buses() const
1220+
{
1221+
#ifdef ESP32
1222+
uint8_t res{};
1223+
if (isI2CEnabled(0)) ++res;
1224+
if (getI2CBusCount() > 1) {
1225+
if (isI2CEnabled(1)) ++res;
1226+
#if FEATURE_I2C_INTERFACE_3
1227+
if (isI2CEnabled(2)) ++res;
1228+
#endif
1229+
}
1230+
return res;
1231+
#else
1232+
return isI2CEnabled(0) ? 1 : 0;
1233+
#endif
1234+
}
1235+
12051236
// stored in I2C_SPI_bus_Flags per Task
12061237
template<uint32_t N_TASKS>
12071238
uint8_t SettingsStruct_tmpl<N_TASKS>::getSPIBusForTask(taskIndex_t TaskIndex) const {

src/src/DataTypes/SPI_options.cpp

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#ifdef ESP32
55

6+
#include "../Helpers/Hardware_device_info.h"
7+
68
// ESP32 VSPI:
79
// SCK = 18
810
// MISO = 19
@@ -35,28 +37,31 @@
3537

3638

3739
# if CONFIG_IDF_TARGET_ESP32S3 // ESP32-S3
38-
#define VSPI_FSPI_SHORT_STRING "FSPI"
40+
#define VSPI_FSPI_SHORT_STRING "FSPI (" STRINGIFY(FSPI_HOST) ")"
3941
# elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2
40-
#define VSPI_FSPI_SHORT_STRING "FSPI"
41-
# elif CONFIG_IDF_TARGET_ESP32C2 // ESP32-C2
42-
#define VSPI_FSPI_SHORT_STRING "FSPI"
43-
# elif CONFIG_IDF_TARGET_ESP32C3 // ESP32-C3
44-
#define VSPI_FSPI_SHORT_STRING "SPI"
45-
# elif CONFIG_IDF_TARGET_ESP32C5 // ESP32-C5
46-
#define VSPI_FSPI_SHORT_STRING "FSPI"
47-
# elif CONFIG_IDF_TARGET_ESP32C6 // ESP32-C6
48-
#define VSPI_FSPI_SHORT_STRING "FSPI"
49-
# elif CONFIG_IDF_TARGET_ESP32C61 // ESP32-C61
50-
#define VSPI_FSPI_SHORT_STRING "FSPI"
51-
# elif CONFIG_IDF_TARGET_ESP32P4 // ESP32-P4
52-
#define VSPI_FSPI_SHORT_STRING "FSPI"
42+
#define VSPI_FSPI_SHORT_STRING "FSPI (" STRINGIFY(FSPI_HOST) ")"
43+
#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C5 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32C61 || CONFIG_IDF_TARGET_ESP32P4
44+
# if SOC_SPI_PERIPH_NUM > 2
45+
#define VSPI_FSPI_SHORT_STRING "FSPI (" STRINGIFY(VSPI_HOST) ")"
46+
# else
47+
#define VSPI_FSPI_SHORT_STRING "SPI" // STRINGIFY(VSPI_HOST)
48+
# endif
49+
5350
# elif CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
54-
#define VSPI_FSPI_SHORT_STRING "VSPI"
51+
#define VSPI_FSPI_SHORT_STRING "VSPI (" STRINGIFY(VSPI_HOST) ")"
5552

5653
# else // if CONFIG_IDF_TARGET_ESP32S2
5754
# error Target CONFIG_IDF_TARGET is not supported
5855
# endif // if CONFIG_IDF_TARGET_ESP32S2
5956

57+
#if SOC_SPI_PERIPH_NUM > 2
58+
#ifdef ESP32_CLASSIC
59+
#define HSPI_SHORT_STRING "HSPI (" STRINGIFY(HSPI_HOST) ")"
60+
#else
61+
#define HSPI_SHORT_STRING STRINGIFY(HSPI_HOST)
62+
#endif
63+
#endif
64+
6065

6166
const __FlashStringHelper* getSPI_optionToString(SPI_Options_e option) {
6267
switch (option) {
@@ -65,43 +70,73 @@ const __FlashStringHelper* getSPI_optionToString(SPI_Options_e option) {
6570
case SPI_Options_e::Vspi_Fspi:
6671
return F(
6772
VSPI_FSPI_SHORT_STRING
68-
": CLK=GPIO-" STRINGIFY(VSPI_FSPI_SCK)
69-
", MISO=GPIO-" STRINGIFY(VSPI_FSPI_MISO)
70-
", MOSI=GPIO-" STRINGIFY(VSPI_FSPI_MOSI) );
73+
": CLK=" STRINGIFY(VSPI_FSPI_SCK)
74+
", MISO=" STRINGIFY(VSPI_FSPI_MISO)
75+
", MOSI=" STRINGIFY(VSPI_FSPI_MOSI) );
7176
#ifdef ESP32_CLASSIC
7277
case SPI_Options_e::Hspi:
7378
return F(
74-
"HSPI"
75-
": CLK=GPIO-" STRINGIFY(HSPI_SCLK)
76-
", MISO=GPIO-" STRINGIFY(HSPI_MISO)
77-
", MOSI=GPIO-" STRINGIFY(HSPI_MOSI) );
79+
HSPI_SHORT_STRING
80+
": CLK=" STRINGIFY(HSPI_SCLK)
81+
", MISO=" STRINGIFY(HSPI_MISO)
82+
", MOSI=" STRINGIFY(HSPI_MOSI) );
7883

7984

8085
#endif
81-
case SPI_Options_e::UserDefined:
82-
return F("User-defined: CLK, MISO, MOSI GPIO-pins");
86+
case SPI_Options_e::UserDefined_VSPI:
87+
return F("User-defined " VSPI_FSPI_SHORT_STRING);
88+
#if SOC_SPI_PERIPH_NUM > 2
89+
case SPI_Options_e::UserDefined_HSPI:
90+
return F("User-defined " HSPI_SHORT_STRING);
91+
#endif
8392
}
8493
return F("Unknown");
8594
}
8695

96+
const __FlashStringHelper* get_vspi_fspi_str()
97+
{
98+
return F(VSPI_FSPI_SHORT_STRING);
99+
}
100+
87101
const String getSPI_optionToShortString(SPI_Options_e option, uint8_t spi_bus) {
102+
#ifdef ESP32
103+
String res;
88104
switch (option) {
89105
case SPI_Options_e::None:
90106
return F("Disabled");
91107
case SPI_Options_e::Vspi_Fspi:
92-
return F(VSPI_FSPI_SHORT_STRING);
108+
res = F(VSPI_FSPI_SHORT_STRING);
109+
break;
93110
#ifdef ESP32_CLASSIC
94111
case SPI_Options_e::Hspi:
95-
return F("HSPI");
112+
res = F("HSPI");
113+
break;
114+
#endif
115+
case SPI_Options_e::UserDefined_VSPI:
116+
res = F("User-defined " VSPI_FSPI_SHORT_STRING);
117+
break;
118+
#if SOC_SPI_PERIPH_NUM > 2
119+
case SPI_Options_e::UserDefined_HSPI:
120+
res = F("User-defined " HSPI_SHORT_STRING);
121+
break;
96122
#endif
97-
case SPI_Options_e::UserDefined:
98-
#ifdef ESP32
99-
return concat(F("User-defined SPI Bus "), spi_bus);
100-
#endif // ifdef ESP32
101-
#ifdef ESP8266
123+
}
124+
if (!res.isEmpty()) {
125+
if (getSPIBusCount() > 1) {
126+
return concat(res + F(" bus "), spi_bus);
127+
}
128+
return res;
129+
}
130+
#else
131+
switch (option) {
132+
case SPI_Options_e::None:
133+
return F("Disabled");
134+
case SPI_Options_e::Vspi_Fspi:
135+
return F(VSPI_FSPI_SHORT_STRING);
136+
case SPI_Options_e::UserDefined_VSPI:
102137
return F("User-defined SPI");
103-
#endif // ifdef ESP8266
104138
}
139+
#endif
105140
return F("Unknown");
106141
}
107142

src/src/DataTypes/SPI_options.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// ESP32-S2/S3 : FSPI
1515

1616
// ESP32 classic:
17-
// SPI_HOST = SPI1_HOST // Only usable on ESP32
17+
// SPI_HOST = SPI1_HOST // Only usable on ESP32, when all functions doing SPI operations are in IRAM
1818
// HSPI_HOST = SPI2_HOST
1919
// VSPI_HOST = SPI3_HOST
2020
//
@@ -73,12 +73,16 @@ enum class SPI_Options_e {
7373
// For ESP32 classic, this is called VSPI
7474
// For later versions it is called FSPI
7575
// N.B. the ESP32-C3 does not seem to name these as there is no SPI3_HOST.
76-
UserDefined = 9 // Leave some room for other, possible future, hardware-related options
76+
UserDefined_VSPI = 9 // Leave some room for other, possible future, hardware-related options
77+
#if SOC_SPI_PERIPH_NUM > 2
78+
,UserDefined_HSPI = 10
79+
#endif
7780

7881
};
7982

8083
#ifdef ESP32
8184
const __FlashStringHelper* getSPI_optionToString(SPI_Options_e option);
85+
const __FlashStringHelper* get_vspi_fspi_str();
8286
const String getSPI_optionToShortString(SPI_Options_e option, uint8_t spi_bus = 0);
8387
#endif // ifdef ESP32
8488

0 commit comments

Comments
 (0)