Skip to content

Commit 373889a

Browse files
authored
Merge branch 'master' into wifi_init_status_idle
2 parents 0140871 + e382b6a commit 373889a

7 files changed

+105
-67
lines changed

Diff for: README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ Latest Development Release [![Release Version](https://img.shields.io/github/re
2525

2626
Our Development is fully tracked on this public **[Roadmap 🎉](https://github.com/orgs/espressif/projects/3)**
2727

28-
For even more information you can take a look at [Sprint Meeting notes](https://github.com/espressif/arduino-esp32/discussions/categories/sprints-meeting-notes) or join [Monthly Community Meetings 🔔](https://github.com/espressif/arduino-esp32/discussions/categories/monthly-community-meetings)
28+
For even more information you can join our **[Monthly Community Meetings 🔔](https://github.com/espressif/arduino-esp32/discussions/categories/monthly-community-meetings).**
2929

3030
### Documentation
3131

3232
You can use the [Arduino-ESP32 Online Documentation](https://docs.espressif.com/projects/arduino-esp32/en/latest/) to get all information about this project.
3333

34+
---
35+
36+
**Migration guide from version 2.x to 3.x is available [here](https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html).**
37+
38+
---
39+
3440
* [Getting Started](https://docs.espressif.com/projects/arduino-esp32/en/latest/getting_started.html)
3541
* [Installing (Windows, Linux and macOS)](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html)
3642
* [Libraries](https://docs.espressif.com/projects/arduino-esp32/en/latest/libraries.html)
@@ -40,7 +46,18 @@ You can use the [Arduino-ESP32 Online Documentation](https://docs.espressif.com/
4046

4147
### Supported Chips
4248

43-
Visit the [supported chips](https://docs.espressif.com/projects/arduino-esp32/en/latest/getting_started.html#supported-soc-s) documentation to see the list of current supported ESP32 SoCs.
49+
Here are the ESP32 series supported by the Arduino-ESP32 project:
50+
51+
| **SoC** | **Stable** | **Development** | **Datasheet** |
52+
|----------|:----------:|:---------------:|:-------------------------------------------------------------------------------------------------:|
53+
| ESP32 | Yes | Yes | [ESP32](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf) |
54+
| ESP32-S2 | Yes | Yes | [ESP32-S2](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf) |
55+
| ESP32-C3 | Yes | Yes | [ESP32-C3](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf) |
56+
| ESP32-S3 | Yes | Yes | [ESP32-S3](https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf) |
57+
| ESP32-C6 | No | Yes | [ESP32-C6](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf) |
58+
| ESP32-H2 | No | Yes | [ESP32-H2](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf) |
59+
60+
For more details visit the [supported chips](https://docs.espressif.com/projects/arduino-esp32/en/latest/getting_started.html#supported-soc-s) documentation page.
4461

4562
### Decoding exceptions
4663

Diff for: cores/esp32/HardwareSerial.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ _eventTask(NULL)
107107
}
108108
}
109109
#endif
110-
// sets UART0 (default console) RX/TX pins as already configured in boot
111-
if (uart_nr == 0) {
112-
setPins(SOC_RX0, SOC_TX0);
113-
}
114110
// set deinit function in the Peripheral Manager
115111
uart_init_PeriMan();
116112
}

Diff for: cores/esp32/chip-debug-report.cpp

+1-49
Original file line numberDiff line numberDiff line change
@@ -251,55 +251,7 @@ static void printPerimanInfo(void){
251251
continue;//unused pin
252252
}
253253
chip_report_printf(" %17u : ", i);
254-
switch(type){
255-
case ESP32_BUS_TYPE_GPIO: chip_report_printf("GPIO\n"); break;
256-
case ESP32_BUS_TYPE_UART_RX: chip_report_printf("UART_RX\n"); break;
257-
case ESP32_BUS_TYPE_UART_TX: chip_report_printf("UART_TX\n"); break;
258-
case ESP32_BUS_TYPE_UART_CTS: chip_report_printf("UART_CTS\n"); break;
259-
case ESP32_BUS_TYPE_UART_RTS: chip_report_printf("UART_RTS\n"); break;
260-
#if SOC_SDM_SUPPORTED
261-
case ESP32_BUS_TYPE_SIGMADELTA: chip_report_printf("SIGMADELTA\n"); break;
262-
#endif
263-
#if SOC_ADC_SUPPORTED
264-
case ESP32_BUS_TYPE_ADC_ONESHOT: chip_report_printf("ADC_ONESHOT\n"); break;
265-
case ESP32_BUS_TYPE_ADC_CONT: chip_report_printf("ADC_CONT\n"); break;
266-
#endif
267-
#if SOC_DAC_SUPPORTED
268-
case ESP32_BUS_TYPE_DAC_ONESHOT: chip_report_printf("DAC_ONESHOT\n"); break;
269-
case ESP32_BUS_TYPE_DAC_CONT: chip_report_printf("DAC_CONT\n"); break;
270-
case ESP32_BUS_TYPE_DAC_COSINE: chip_report_printf("DAC_COSINE\n"); break;
271-
#endif
272-
#if SOC_LEDC_SUPPORTED
273-
case ESP32_BUS_TYPE_LEDC: chip_report_printf("LEDC\n"); break;
274-
#endif
275-
#if SOC_RMT_SUPPORTED
276-
case ESP32_BUS_TYPE_RMT_TX: chip_report_printf("RMT_TX\n"); break;
277-
case ESP32_BUS_TYPE_RMT_RX: chip_report_printf("RMT_RX\n"); break;
278-
#endif
279-
#if SOC_I2S_SUPPORTED
280-
case ESP32_BUS_TYPE_I2S_STD: chip_report_printf("I2S_STD\n"); break;
281-
case ESP32_BUS_TYPE_I2S_TDM: chip_report_printf("I2S_TDM\n"); break;
282-
case ESP32_BUS_TYPE_I2S_PDM_TX: chip_report_printf("I2S_PDM_TX\n"); break;
283-
case ESP32_BUS_TYPE_I2S_PDM_RX: chip_report_printf("I2S_PDM_RX\n"); break;
284-
#endif
285-
#if SOC_I2C_SUPPORTED
286-
case ESP32_BUS_TYPE_I2C_MASTER: chip_report_printf("I2C_MASTER\n"); break;
287-
case ESP32_BUS_TYPE_I2C_SLAVE: chip_report_printf("I2C_SLAVE\n"); break;
288-
#endif
289-
#if SOC_GPSPI_SUPPORTED
290-
case ESP32_BUS_TYPE_SPI_MASTER: chip_report_printf("SPI_MASTER\n"); break;
291-
#endif
292-
#if SOC_SDMMC_HOST_SUPPORTED
293-
case ESP32_BUS_TYPE_SDMMC: chip_report_printf("SDMMC\n"); break;
294-
#endif
295-
#if SOC_TOUCH_SENSOR_SUPPORTED
296-
case ESP32_BUS_TYPE_TOUCH: chip_report_printf("TOUCH\n"); break;
297-
#endif
298-
#if SOC_USB_SERIAL_JTAG_SUPPORTED || SOC_USB_OTG_SUPPORTED
299-
case ESP32_BUS_TYPE_USB: chip_report_printf("USB\n"); break;
300-
#endif
301-
default: chip_report_printf("%d\n", type); break;
302-
}
254+
chip_report_printf("%s\n", perimanGetTypeName(type));
303255
}
304256
}
305257

Diff for: cores/esp32/esp32-hal-periman.c

+65-10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,59 @@ static peripheral_pin_item_t pins[SOC_GPIO_PIN_COUNT];
1818

1919
#define GPIO_NOT_VALID(p) ((p >= SOC_GPIO_PIN_COUNT) || ((SOC_GPIO_VALID_GPIO_MASK & (1ULL << p)) == 0))
2020

21+
const char* perimanGetTypeName(peripheral_bus_type_t type) {
22+
switch(type) {
23+
case ESP32_BUS_TYPE_INIT: return "INIT";
24+
case ESP32_BUS_TYPE_GPIO: return "GPIO";
25+
case ESP32_BUS_TYPE_UART_RX: return "UART_RX";
26+
case ESP32_BUS_TYPE_UART_TX: return "UART_TX";
27+
case ESP32_BUS_TYPE_UART_CTS: return "UART_CTS";
28+
case ESP32_BUS_TYPE_UART_RTS: return "UART_RTS";
29+
#if SOC_SDM_SUPPORTED
30+
case ESP32_BUS_TYPE_SIGMADELTA: return "SIGMADELTA";
31+
#endif
32+
#if SOC_ADC_SUPPORTED
33+
case ESP32_BUS_TYPE_ADC_ONESHOT: return "ADC_ONESHOT";
34+
case ESP32_BUS_TYPE_ADC_CONT: return "ADC_CONT";
35+
#endif
36+
#if SOC_DAC_SUPPORTED
37+
case ESP32_BUS_TYPE_DAC_ONESHOT: return "DAC_ONESHOT";
38+
case ESP32_BUS_TYPE_DAC_CONT: return "DAC_CONT";
39+
case ESP32_BUS_TYPE_DAC_COSINE: return "DAC_COSINE";
40+
#endif
41+
#if SOC_LEDC_SUPPORTED
42+
case ESP32_BUS_TYPE_LEDC: return "LEDC";
43+
#endif
44+
#if SOC_RMT_SUPPORTED
45+
case ESP32_BUS_TYPE_RMT_TX: return "RMT_TX";
46+
case ESP32_BUS_TYPE_RMT_RX: return "RMT_RX";
47+
#endif
48+
#if SOC_I2S_SUPPORTED
49+
case ESP32_BUS_TYPE_I2S_STD: return "I2S_STD";
50+
case ESP32_BUS_TYPE_I2S_TDM: return "I2S_TDM";
51+
case ESP32_BUS_TYPE_I2S_PDM_TX: return "I2S_PDM_TX";
52+
case ESP32_BUS_TYPE_I2S_PDM_RX: return "I2S_PDM_RX";
53+
#endif
54+
#if SOC_I2C_SUPPORTED
55+
case ESP32_BUS_TYPE_I2C_MASTER: return "I2C_MASTER";
56+
case ESP32_BUS_TYPE_I2C_SLAVE: return "I2C_SLAVE";
57+
#endif
58+
#if SOC_GPSPI_SUPPORTED
59+
case ESP32_BUS_TYPE_SPI_MASTER: return "SPI_MASTER";
60+
#endif
61+
#if SOC_SDMMC_HOST_SUPPORTED
62+
case ESP32_BUS_TYPE_SDMMC: return "SDMMC";
63+
#endif
64+
#if SOC_TOUCH_SENSOR_SUPPORTED
65+
case ESP32_BUS_TYPE_TOUCH: return "TOUCH";
66+
#endif
67+
#if SOC_USB_SERIAL_JTAG_SUPPORTED || SOC_USB_OTG_SUPPORTED
68+
case ESP32_BUS_TYPE_USB: return "USB";
69+
#endif
70+
default: return "UNKNOWN";
71+
}
72+
}
73+
2174
bool perimanSetPinBus(uint8_t pin, peripheral_bus_type_t type, void * bus){
2275
peripheral_bus_type_t otype = ESP32_BUS_TYPE_INIT;
2376
void * obus = NULL;
@@ -26,37 +79,38 @@ bool perimanSetPinBus(uint8_t pin, peripheral_bus_type_t type, void * bus){
2679
return false;
2780
}
2881
if(type >= ESP32_BUS_TYPE_MAX){
29-
log_e("Invalid type: %u", (unsigned int)type);
82+
log_e("Invalid type: %s (%u) when setting pin %u", perimanGetTypeName(type), (unsigned int)type, pin);
3083
return false;
3184
}
3285
if(type > ESP32_BUS_TYPE_GPIO && bus == NULL){
33-
log_e("Bus is NULL");
86+
log_e("Bus is NULL for pin %u with type %s (%u)", pin, perimanGetTypeName(type), (unsigned int)type);
3487
return false;
3588
}
3689
if (type == ESP32_BUS_TYPE_INIT && bus != NULL){
37-
log_e("Can't set a Bus to INIT Type");
90+
log_e("Can't set a Bus to INIT Type (pin %u)", pin);
3891
return false;
39-
}
92+
}
4093
otype = pins[pin].type;
4194
obus = pins[pin].bus;
4295
if(type == otype && bus == obus){
4396
if (type != ESP32_BUS_TYPE_INIT) {
44-
log_i("Bus already set");
97+
log_i("Pin %u already has type %s (%u) with bus %p", pin, perimanGetTypeName(type), (unsigned int)type, bus);
4598
}
4699
return true;
47100
}
48101
if(obus != NULL){
49102
if(deinit_functions[otype] == NULL){
50-
log_e("Bus does not have deinit function set");
103+
log_e("No deinit function for type %s (%u) (pin %u)", perimanGetTypeName(otype), (unsigned int)otype, pin);
51104
return false;
52105
}
53106
if(!deinit_functions[otype](obus)){
54-
log_e("Previous bus failed to deinit");
107+
log_e("Deinit function for previous bus type %s (%u) failed (pin %u)", perimanGetTypeName(otype), (unsigned int)otype, pin);
55108
return false;
56109
}
57110
}
58111
pins[pin].type = type;
59112
pins[pin].bus = bus;
113+
log_v("Pin %u successfully set to type %s (%u) with bus %p", pin, perimanGetTypeName(type), (unsigned int)type, bus);
60114
return true;
61115
}
62116

@@ -66,7 +120,7 @@ void * perimanGetPinBus(uint8_t pin, peripheral_bus_type_t type){
66120
return NULL;
67121
}
68122
if(type >= ESP32_BUS_TYPE_MAX || type == ESP32_BUS_TYPE_INIT){
69-
log_e("Invalid type: %u", (unsigned int)type);
123+
log_e("Invalid type %s (%u) for pin %u", perimanGetTypeName(type), (unsigned int)type, pin);
70124
return NULL;
71125
}
72126
if(pins[pin].type == type){
@@ -85,14 +139,15 @@ peripheral_bus_type_t perimanGetPinBusType(uint8_t pin){
85139

86140
bool perimanSetBusDeinit(peripheral_bus_type_t type, peripheral_bus_deinit_cb_t cb){
87141
if(type >= ESP32_BUS_TYPE_MAX || type == ESP32_BUS_TYPE_INIT){
88-
log_e("Invalid type: %u", (unsigned int)type);
142+
log_e("Invalid type: %s (%u)", perimanGetTypeName(type), (unsigned int)type);
89143
return false;
90144
}
91145
if(cb == NULL){
92-
log_e("Callback is NULL");
146+
log_e("Callback is NULL when setting deinit function for type %s (%u)", perimanGetTypeName(type), (unsigned int)type);
93147
return false;
94148
}
95149
deinit_functions[type] = cb;
150+
log_v("Deinit function for type %s (%u) successfully set to %p", perimanGetTypeName(type), (unsigned int)type, cb);
96151
return true;
97152
}
98153

Diff for: cores/esp32/esp32-hal-periman.h

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ typedef enum {
7070

7171
typedef bool (*peripheral_bus_deinit_cb_t)(void * bus);
7272

73+
const char* perimanGetTypeName(peripheral_bus_type_t type);
74+
7375
// Sets the bus type and bus handle for given pin.
7476
bool perimanSetPinBus(uint8_t pin, peripheral_bus_type_t type, void * bus);
7577

Diff for: cores/esp32/esp32-hal-uart.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
184184

185185
bool retCode = true;
186186
if (rxPin >= 0) {
187+
// forces a clean detaching from a previous peripheral
188+
if (perimanGetPinBusType(rxPin) != ESP32_BUS_TYPE_INIT) perimanSetPinBus(rxPin, ESP32_BUS_TYPE_INIT, NULL);
187189
// connect RX Pad
188190
bool ret = ESP_OK == uart_set_pin(uart->num, UART_PIN_NO_CHANGE, rxPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
189191
if (ret) {
@@ -196,6 +198,8 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
196198
retCode &= ret;
197199
}
198200
if (txPin >= 0) {
201+
// forces a clean detaching from a previous peripheral
202+
if (perimanGetPinBusType(txPin) != ESP32_BUS_TYPE_INIT) perimanSetPinBus(txPin, ESP32_BUS_TYPE_INIT, NULL);
199203
// connect TX Pad
200204
bool ret = ESP_OK == uart_set_pin(uart->num, txPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
201205
if (ret) {
@@ -208,6 +212,8 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
208212
retCode &= ret;
209213
}
210214
if (ctsPin >= 0) {
215+
// forces a clean detaching from a previous peripheral
216+
if (perimanGetPinBusType(ctsPin) != ESP32_BUS_TYPE_INIT) perimanSetPinBus(ctsPin, ESP32_BUS_TYPE_INIT, NULL);
211217
// connect CTS Pad
212218
bool ret = ESP_OK == uart_set_pin(uart->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, ctsPin);
213219
if (ret) {
@@ -220,6 +226,8 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
220226
retCode &= ret;
221227
}
222228
if (rtsPin >= 0) {
229+
// forces a clean detaching from a previous peripheral
230+
if (perimanGetPinBusType(rtsPin) != ESP32_BUS_TYPE_INIT) perimanSetPinBus(rtsPin, ESP32_BUS_TYPE_INIT, NULL);
223231
// connect RTS Pad
224232
bool ret = ESP_OK == uart_set_pin(uart->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, rtsPin, UART_PIN_NO_CHANGE);
225233
if (ret) {
@@ -759,12 +767,14 @@ int log_printfv(const char *format, va_list arg)
759767
return 0;
760768
}
761769
}
770+
/*
771+
// This causes dead locks with logging in specific cases and also with C++ constructors that may send logs
762772
#if !CONFIG_DISABLE_HAL_LOCKS
763773
if(s_uart_debug_nr != -1 && _uart_bus_array[s_uart_debug_nr].lock){
764774
xSemaphoreTake(_uart_bus_array[s_uart_debug_nr].lock, portMAX_DELAY);
765775
}
766776
#endif
767-
777+
*/
768778
#if CONFIG_IDF_TARGET_ESP32C3
769779
vsnprintf(temp, len+1, format, arg);
770780
ets_printf("%s", temp);
@@ -774,15 +784,19 @@ int log_printfv(const char *format, va_list arg)
774784
ets_write_char_uart(temp[i]);
775785
}
776786
#endif
777-
787+
/*
788+
// This causes dead locks with logging and also with constructors that may send logs
778789
#if !CONFIG_DISABLE_HAL_LOCKS
779790
if(s_uart_debug_nr != -1 && _uart_bus_array[s_uart_debug_nr].lock){
780791
xSemaphoreGive(_uart_bus_array[s_uart_debug_nr].lock);
781792
}
782793
#endif
794+
*/
783795
if(len >= sizeof(loc_buf)){
784796
free(temp);
785797
}
798+
// flushes TX - make sure that the log message is completely sent.
799+
if(s_uart_debug_nr != -1) while(!uart_ll_is_tx_idle(UART_LL_GET_HW(s_uart_debug_nr)));
786800
return len;
787801
}
788802

Diff for: cores/esp32/main.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ __attribute__((weak)) bool shouldPrintChipDebugReport(void) {
4545

4646
void loopTask(void *pvParameters)
4747
{
48+
// sets UART0 (default console) RX/TX pins as already configured in boot or as defined in variants/pins_arduino.h
49+
Serial0.setPins(SOC_RX0, SOC_TX0);
4850
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
4951
printBeforeSetupInfo();
5052
#else

0 commit comments

Comments
 (0)