Skip to content

Commit 0aae015

Browse files
authored
Merge branch 'release/v2.x' into uart_begin
2 parents 76b10f4 + 995d3e9 commit 0aae015

File tree

1,303 files changed

+17779
-14848
lines changed

Some content is hidden

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

1,303 files changed

+17779
-14848
lines changed

.github/scripts/on-release.sh

+8-10
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,14 @@ find "$PKG_DIR" -name '*.git*' -type f -delete
217217
echo "Generating platform.txt..."
218218
cat "$GITHUB_WORKSPACE/platform.txt" | \
219219
sed "s/version=.*/version=$RELEASE_TAG/g" | \
220-
sed 's/tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32-elf/tools.xtensa-esp32-elf-gcc.path=\{runtime.tools.xtensa-esp32-elf-gcc.path\}/g' | \
221-
sed 's/tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s2-elf/tools.xtensa-esp32s2-elf-gcc.path=\{runtime.tools.xtensa-esp32s2-elf-gcc.path\}/g' | \
222-
sed 's/tools.xtensa-esp32s3-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s3-elf/tools.xtensa-esp32s3-elf-gcc.path=\{runtime.tools.xtensa-esp32s3-elf-gcc.path\}/g' | \
223-
sed 's/tools.xtensa-esp-elf-gdb.path={runtime.platform.path}\/tools\/xtensa-esp-elf-gdb/tools.xtensa-esp-elf-gdb.path=\{runtime.tools.xtensa-esp-elf-gdb.path\}/g' | \
224-
sed 's/tools.riscv32-esp-elf-gcc.path={runtime.platform.path}\/tools\/riscv32-esp-elf/tools.riscv32-esp-elf-gcc.path=\{runtime.tools.riscv32-esp-elf-gcc.path\}/g' | \
225-
sed 's/tools.riscv32-esp-elf-gdb.path={runtime.platform.path}\/tools\/riscv32-esp-elf-gdb/tools.riscv32-esp-elf-gdb.path=\{runtime.tools.riscv32-esp-elf-gdb.path\}/g' | \
226-
sed 's/tools.esptool_py.path={runtime.platform.path}\/tools\/esptool/tools.esptool_py.path=\{runtime.tools.esptool_py.path\}/g' | \
227-
sed 's/debug.server.openocd.path={runtime.platform.path}\/tools\/openocd-esp32\/bin\/openocd/debug.server.openocd.path=\{runtime.tools.openocd-esp32.path\}\/bin\/openocd/g' | \
228-
sed 's/debug.server.openocd.scripts_dir={runtime.platform.path}\/tools\/openocd-esp32\/share\/openocd\/scripts\//debug.server.openocd.scripts_dir=\{runtime.tools.openocd-esp32.path\}\/share\/openocd\/scripts\//g' | \
229-
sed 's/debug.server.openocd.scripts_dir.windows={runtime.platform.path}\\tools\\openocd-esp32\\share\\openocd\\scripts\\/debug.server.openocd.scripts_dir.windows=\{runtime.tools.openocd-esp32.path\}\\share\\openocd\\scripts\\/g' \
220+
sed 's/{runtime\.platform\.path}.tools.xtensa-esp-elf-gdb/\{runtime.tools.xtensa-esp-elf-gdb.path\}/g' | \
221+
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32-elf/\{runtime.tools.xtensa-esp32-elf-gcc.path\}/g' | \
222+
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32s2-elf/\{runtime.tools.xtensa-esp32s2-elf-gcc.path\}/g' | \
223+
sed 's/{runtime\.platform\.path}.tools.xtensa-esp32s3-elf/\{runtime.tools.xtensa-esp32s3-elf-gcc.path\}/g' | \
224+
sed 's/{runtime\.platform\.path}.tools.riscv32-esp-elf-gdb/\{runtime.tools.riscv32-esp-elf-gdb.path\}/g' | \
225+
sed "s/{runtime\.platform\.path}.tools.riscv32-esp-elf/\\{runtime.tools.riscv32-esp-elf-gcc.path\\}/g" | \
226+
sed 's/{runtime\.platform\.path}.tools.esptool/\{runtime.tools.esptool_py.path\}/g' | \
227+
sed 's/{runtime\.platform\.path}.tools.openocd-esp32/\{runtime.tools.openocd-esp32.path\}/g' \
230228
> "$PKG_DIR/platform.txt"
231229

232230
if ! [ -z ${VENDOR} ]; then

.github/scripts/sketch_utils.sh

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
148148
--fqbn "$currfqbn" \
149149
--board-options "$curroptions" \
150150
--warnings "all" \
151+
--build-property "compiler.warning_flags.all=-Wall -Werror=all -Wextra" \
151152
--build-cache-path "$ARDUINO_CACHE_DIR" \
152153
--build-path "$build_dir" \
153154
$xtra_opts "${sketchdir}"

boards.txt

+580-3
Large diffs are not rendered by default.

cores/esp32/Esp.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ String EspClass::getSketchMD5()
240240
md5.add(buf.get(), readBytes);
241241
lengthLeft -= readBytes;
242242
offset += readBytes;
243+
244+
#if CONFIG_FREERTOS_UNICORE
245+
delay(1); // Fix solo WDT
246+
#endif
243247
}
244248
md5.calculate();
245249
result = md5.toString();

cores/esp32/HWCDC.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ void HWCDC::begin(unsigned long baud)
186186
}
187187
}
188188
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
189-
usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
190189
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_BUS_RESET);
191190
if(!intr_handle && esp_intr_alloc(ETS_USB_SERIAL_JTAG_INTR_SOURCE, 0, hw_cdc_isr_handler, NULL, &intr_handle) != ESP_OK){
192191
isr_log_e("HW USB CDC failed to init interrupts");

cores/esp32/HardwareSerial.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,10 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
346346
if(detectedBaudRate) {
347347
delay(100); // Give some time...
348348
_uart = uartBegin(_uart_nr, detectedBaudRate, config, rxPin, txPin, _rxBufferSize, _txBufferSize, invert, rxfifo_full_thrhd);
349-
if (_uart == NULL) {
350-
log_e("UART driver failed to start. Please check the logs.");
351-
HSERIAL_MUTEX_UNLOCK();
352-
return;
353-
}
349+
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
350+
// S3 and C3 have a limitation and both can't detect a baud rate lower than 9600
351+
if (detectedBaudRate == 9600) log_w("The baud detected, as 9600, may be wrong. ESP32-C3 and ESP32-S3 can't detect a baud rate under 9600.");
352+
#endif
354353
} else {
355354
log_e("Could not detect baudrate. Serial data at the port must be present within the timeout for detection to be possible");
356355
_uart = NULL;

cores/esp32/esp32-hal-uart.c

+32-65
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,11 @@ void uartSetBaudRate(uart_t* uart, uint32_t baud_rate)
711711
return;
712712
}
713713
UART_MUTEX_LOCK();
714+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
714715
uart_ll_set_baudrate(UART_LL_GET_HW(uart->num), _get_effective_baudrate(baud_rate));
715-
uart->_baudrate = baud_rate;
716+
#else
717+
uart_ll_set_baudrate(UART_LL_GET_HW(uart->num), baud_rate);
718+
#endif
716719
UART_MUTEX_UNLOCK();
717720
}
718721

@@ -725,7 +728,13 @@ uint32_t uartGetBaudRate(uart_t* uart)
725728
}
726729

727730
UART_MUTEX_LOCK();
728-
baud_rate = uart_ll_get_baudrate(UART_LL_GET_HW(uart->num));
731+
uint32_t baud_rate = uart_ll_get_baudrate(UART_LL_GET_HW(uart->num));
732+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
733+
uint32_t Freq = getApbFrequency()/1000000;
734+
if (Freq < 80) {
735+
baud_rate = baud_rate / (80 / Freq);
736+
}
737+
#endif
729738
UART_MUTEX_UNLOCK();
730739
return baud_rate;
731740
}
@@ -895,32 +904,31 @@ void log_print_buf(const uint8_t *b, size_t len){
895904

896905
/*
897906
* if enough pulses are detected return the minimum high pulse duration + minimum low pulse duration divided by two.
907+
* In the case of S3 and C3 using XTAL as UART CLK SOURCE, one bit period = Negative Pulse Count + 1
898908
* This equals one bit period. If flag is true the function return inmediately, otherwise it waits for enough pulses.
899909
*/
900910
unsigned long uartBaudrateDetect(uart_t *uart, bool flg)
901911
{
902-
// Baud rate detection only works for ESP32 and ESP32S2
903-
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
904912
if(uart == NULL) {
905913
return 0;
906914
}
907915

908916
uart_dev_t *hw = UART_LL_GET_HW(uart->num);
909917

910-
while(hw->rxd_cnt.edge_cnt < 30) { // UART_PULSE_NUM(uart_num)
918+
while(uart_ll_get_rxd_edge_cnt(hw) < 30) { // UART_PULSE_NUM(uart_num)
911919
if(flg) return 0;
912920
ets_delay_us(1000);
913921
}
914922

915923
UART_MUTEX_LOCK();
916-
//log_i("lowpulse_min_cnt = %d hightpulse_min_cnt = %d", hw->lowpulse.min_cnt, hw->highpulse.min_cnt);
917-
unsigned long ret = ((hw->lowpulse.min_cnt + hw->highpulse.min_cnt) >> 1);
924+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
925+
unsigned long ret = ((uart_ll_get_low_pulse_cnt(hw) + uart_ll_get_high_pulse_cnt(hw)) >> 1);
926+
#else
927+
unsigned long ret = uart_ll_get_neg_pulse_cnt(hw) + 1;
928+
#endif
918929
UART_MUTEX_UNLOCK();
919930

920931
return ret;
921-
#else
922-
return 0;
923-
#endif
924932
}
925933

926934

@@ -929,47 +937,15 @@ unsigned long uartBaudrateDetect(uart_t *uart, bool flg)
929937
* detected calling uartBadrateDetect(). The raw baudrate is computed using the UART_CLK_FREQ. The raw baudrate is
930938
* rounded to the closed real baudrate.
931939
*
932-
* ESP32-C3 reports wrong baud rate detection as shown below:
933-
*
934-
* This will help in a future recall for the C3.
935-
* Baud Sent: Baud Read:
936-
* 300 --> 19536
937-
* 2400 --> 19536
938-
* 4800 --> 19536
939-
* 9600 --> 28818
940-
* 19200 --> 57678
941-
* 38400 --> 115440
942-
* 57600 --> 173535
943-
* 115200 --> 347826
944-
* 230400 --> 701754
945-
*
946-
*
947940
*/
948941
void uartStartDetectBaudrate(uart_t *uart) {
949942
if(uart == NULL) {
950943
return;
951944
}
952945

953-
// Baud rate detection only works for ESP32 and ESP32S2
954-
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
955946
uart_dev_t *hw = UART_LL_GET_HW(uart->num);
956-
hw->auto_baud.glitch_filt = 0x08;
957-
hw->auto_baud.en = 0;
958-
hw->auto_baud.en = 1;
959-
#else
960-
961-
// ESP32-C3 requires further testing
962-
// Baud rate detection returns wrong values
963-
964-
log_e("baud rate detection for this SoC is not supported.");
965-
return;
966-
967-
// Code bellow for C3 kept for future recall
968-
//hw->rx_filt.glitch_filt = 0x08;
969-
//hw->rx_filt.glitch_filt_en = 1;
970-
//hw->conf0.autobaud_en = 0;
971-
//hw->conf0.autobaud_en = 1;
972-
#endif
947+
uart_ll_set_autobaud_en(hw, false);
948+
uart_ll_set_autobaud_en(hw, true);
973949
}
974950

975951
unsigned long uartDetectBaudrate(uart_t *uart)
@@ -978,9 +954,6 @@ unsigned long uartDetectBaudrate(uart_t *uart)
978954
return 0;
979955
}
980956

981-
// Baud rate detection only works for ESP32 and ESP32S2
982-
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
983-
984957
static bool uartStateDetectingBaudrate = false;
985958

986959
if(!uartStateDetectingBaudrate) {
@@ -994,33 +967,27 @@ unsigned long uartDetectBaudrate(uart_t *uart)
994967
}
995968

996969
uart_dev_t *hw = UART_LL_GET_HW(uart->num);
997-
hw->auto_baud.en = 0;
970+
uart_ll_set_autobaud_en(hw, false);
998971

999972
uartStateDetectingBaudrate = false; // Initialize for the next round
1000-
1001-
unsigned long baudrate = getApbFrequency() / divisor;
1002973

1003-
//log_i("APB_FREQ = %d\nraw baudrate detected = %d", getApbFrequency(), baudrate);
1004-
1005-
static const unsigned long default_rates[] = {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400, 256000, 460800, 921600, 1843200, 3686400};
1006-
974+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
975+
unsigned long baudrate = getApbFrequency() / divisor; // ESP32 and S2 APB Freq
976+
#else
977+
unsigned long baudrate = (getXtalFrequencyMhz() * 1000000) / divisor; // S3 and C3 XTAL Frequency
978+
#endif
979+
980+
static const unsigned long default_rates[] = {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400, 250000,
981+
256000, 460800, 500000, 921600, 1000000, 1843200, 2000000, 3686400};
1007982
size_t i;
1008-
for (i = 1; i < sizeof(default_rates) / sizeof(default_rates[0]) - 1; i++) // find the nearest real baudrate
1009-
{
1010-
if (baudrate <= default_rates[i])
1011-
{
1012-
if (baudrate - default_rates[i - 1] < default_rates[i] - baudrate) {
1013-
i--;
1014-
}
983+
for (i = 1; i < sizeof(default_rates) / sizeof(default_rates[0]) - 1; i++) { // find the nearest real baudrate
984+
if (baudrate <= default_rates[i]) {
985+
if (baudrate - default_rates[i - 1] < default_rates[i] - baudrate) i--;
1015986
break;
1016987
}
1017988
}
1018989

1019990
return default_rates[i];
1020-
#else
1021-
log_e("baud rate detection this SoC is not supported.");
1022-
return 0;
1023-
#endif
1024991
}
1025992

1026993
/*

cores/esp32/esp_arduino_version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern "C" {
2323
/** Minor version number (x.X.x) */
2424
#define ESP_ARDUINO_VERSION_MINOR 0
2525
/** Patch version number (x.x.X) */
26-
#define ESP_ARDUINO_VERSION_PATCH 14
26+
#define ESP_ARDUINO_VERSION_PATCH 15
2727

2828
/**
2929
* Macro to convert ARDUINO version number into an integer

libraries/ArduinoOTA/src/ArduinoOTA.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ void ArduinoOTAClass::_runUpdate() {
315315
size_t r = client.read(buf, available);
316316
if(r != available){
317317
log_w("didn't read enough! %u != %u", r, available);
318+
if((int32_t) r<0) {
319+
delay(1);
320+
continue; //let's not try to write 4 gigabytes when client.read returns -1
321+
}
318322
}
319323

320324
written = Update.write(buf, r);

libraries/Update/src/Updater.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ size_t UpdateClass::writeStream(Stream &data) {
386386
if((_bufferLen == remaining() || _bufferLen == SPI_FLASH_SEC_SIZE) && !_writeBuffer())
387387
return written;
388388
written += toRead;
389+
390+
#if CONFIG_FREERTOS_UNICORE
391+
delay(1); // Fix solo WDT
392+
#endif
389393
}
390394
return written;
391395
}

0 commit comments

Comments
 (0)