Skip to content

Commit 2fb4556

Browse files
authored
Tasmota change
* Fix Unicore WDT on HTTP OTA update
1 parent bb573bf commit 2fb4556

File tree

17 files changed

+69
-48
lines changed

17 files changed

+69
-48
lines changed

.github/scripts/install-arduino-core-esp32.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if [ ! -d "$ARDUINO_ESP32_PATH" ]; then
2020
ln -s $GITHUB_WORKSPACE esp32
2121
else
2222
echo "Cloning Core Repository..."
23-
git clone https://github.com/espressif/arduino-esp32.git esp32 > /dev/null 2>&1
23+
git clone https://github.com/tasmota/arduino-esp32.git esp32 > /dev/null 2>&1
2424
fi
2525

2626
#echo "Updating Submodules ..."

.github/workflows/publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Unit Test Results
33
on:
44
workflow_run:
55
workflows: [Run tests in hardware]
6+
branches-ignore: [master]
67

78
types:
89
- completed
@@ -11,6 +12,9 @@ jobs:
1112
unit-test-results:
1213
name: Unit Test Results
1314
runs-on: ubuntu-latest
15+
if: |
16+
github.event.workflow_run.event == 'pull_request' &&
17+
github.event.workflow_run.conclusion != 'skipped'
1418
steps:
1519
- name: Download and Extract Artifacts
1620
env:

CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ set(LIBRARY_SRCS
9090
libraries/I2S/src/I2S.cpp
9191
libraries/NetBIOS/src/NetBIOS.cpp
9292
libraries/Preferences/src/Preferences.cpp
93-
libraries/RainMaker/src/RMaker.cpp
94-
libraries/RainMaker/src/RMakerNode.cpp
95-
libraries/RainMaker/src/RMakerParam.cpp
96-
libraries/RainMaker/src/RMakerDevice.cpp
97-
libraries/RainMaker/src/RMakerType.cpp
9893
libraries/SD_MMC/src/SD_MMC.cpp
9994
libraries/SD/src/SD.cpp
10095
libraries/SD/src/sd_diskio.cpp
@@ -184,7 +179,6 @@ set(includedirs
184179
libraries/I2S/src
185180
libraries/NetBIOS/src
186181
libraries/Preferences/src
187-
libraries/RainMaker/src
188182
libraries/SD_MMC/src
189183
libraries/SD/src
190184
libraries/SimpleBLE/src
@@ -239,10 +233,6 @@ endfunction()
239233

240234
maybe_add_component(esp-dsp)
241235

242-
if(CONFIG_ESP_RMAKER_TASK_STACK)
243-
maybe_add_component(esp_rainmaker)
244-
maybe_add_component(qrcode)
245-
endif()
246236
if(IDF_TARGET MATCHES "esp32s2|esp32s3" AND CONFIG_TINYUSB_ENABLED)
247237
maybe_add_component(arduino_tinyusb)
248238
endif()

boards.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13017,4 +13017,4 @@ deneyapkart1A.menu.DebugLevel.debug.build.code_debug=4
1301713017
deneyapkart1A.menu.DebugLevel.verbose=Verbose
1301813018
deneyapkart1A.menu.DebugLevel.verbose.build.code_debug=5
1301913019

13020-
##############################################################
13020+
##############################################################

cores/esp32/Esp.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extern "C" {
4747
#elif CONFIG_IDF_TARGET_ESP32C3
4848
#include "esp32c3/rom/spi_flash.h"
4949
#define ESP_FLASH_IMAGE_BASE 0x0000 // Esp32c3 is located at 0x0000
50-
#else
50+
#else
5151
#error Target CONFIG_IDF_TARGET is not supported
5252
#endif
5353
#else // ESP32 Before IDF 4.0
@@ -192,7 +192,7 @@ static uint32_t sketchSize(sketchSize_t response) {
192192
return data.image_len;
193193
}
194194
}
195-
195+
196196
uint32_t EspClass::getSketchSize () {
197197
return sketchSize(SKETCH_SIZE_TOTAL);
198198
}
@@ -231,6 +231,10 @@ String EspClass::getSketchMD5()
231231
md5.add(buf.get(), readBytes);
232232
lengthLeft -= readBytes;
233233
offset += readBytes;
234+
235+
#if CONFIG_FREERTOS_UNICORE
236+
delay(1); // Fix solo WDT
237+
#endif
234238
}
235239
md5.calculate();
236240
result = md5.toString();
@@ -391,17 +395,17 @@ bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size)
391395
return spi_flash_read(offset, (uint32_t*) data, size) == ESP_OK;
392396
}
393397

394-
bool EspClass::partitionEraseRange(const esp_partition_t *partition, uint32_t offset, size_t size)
398+
bool EspClass::partitionEraseRange(const esp_partition_t *partition, uint32_t offset, size_t size)
395399
{
396400
return esp_partition_erase_range(partition, offset, size) == ESP_OK;
397401
}
398402

399-
bool EspClass::partitionWrite(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size)
403+
bool EspClass::partitionWrite(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size)
400404
{
401405
return esp_partition_write(partition, offset, data, size) == ESP_OK;
402406
}
403407

404-
bool EspClass::partitionRead(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size)
408+
bool EspClass::partitionRead(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size)
405409
{
406410
return esp_partition_read(partition, offset, data, size) == ESP_OK;
407411
}

cores/esp32/HardwareSerial.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void serialEvent(void) {}
3737
#ifndef RX1
3838
#if CONFIG_IDF_TARGET_ESP32
3939
#define RX1 9
40-
#elif CONFIG_IDF_TARGET_ESP32S2
40+
#elif CONFIG_IDF_TARGET_ESP32S2
4141
#define RX1 18
4242
#elif CONFIG_IDF_TARGET_ESP32C3
4343
#define RX1 18
@@ -86,6 +86,8 @@ void serialEvent2(void) {}
8686
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
8787
#if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC
8888
HardwareSerial Serial0(0);
89+
#elif ARDUINO_HW_CDC_ON_BOOT
90+
HardwareSerial Serial0(0);
8991
#else
9092
HardwareSerial Serial(0);
9193
#endif
@@ -100,6 +102,8 @@ void serialEventRun(void)
100102
{
101103
#if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC
102104
if(Serial0.available()) serialEvent();
105+
#elif ARDUINO_HW_CDC_ON_BOOT
106+
if(Serial0.available()) serialEvent();
103107
#else
104108
if(Serial.available()) serialEvent();
105109
#endif

cores/esp32/HardwareSerial.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ extern void serialEventRun(void) __attribute__((weak));
156156
#define ARDUINO_USB_CDC_ON_BOOT 0
157157
#endif
158158
#if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC
159-
#if !ARDUINO_USB_MODE
160159
#include "USB.h"
161160
#include "USBCDC.h"
162-
#endif
161+
extern HardwareSerial Serial0;
162+
#elif ARDUINO_HW_CDC_ON_BOOT
163163
extern HardwareSerial Serial0;
164164
#else
165165
extern HardwareSerial Serial;

cores/esp32/USBCDC.cpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ void USBCDC::onEvent(arduino_usb_cdc_event_t event, esp_event_handler_t callback
114114
}
115115

116116
size_t USBCDC::setRxBufferSize(size_t rx_queue_len){
117-
if(rx_queue){
118-
if(!rx_queue_len){
117+
size_t currentQueueSize = rx_queue ?
118+
uxQueueSpacesAvailable(rx_queue) + uxQueueMessagesWaiting(rx_queue) : 0;
119+
120+
if (rx_queue && (!rx_queue_len || rx_queue_len != currentQueueSize)) {
119121
vQueueDelete(rx_queue);
120122
rx_queue = NULL;
121-
}
123+
}
124+
if(!rx_queue_len || rx_queue_len == currentQueueSize){
122125
return 0;
123126
}
124127
rx_queue = xQueueCreate(rx_queue_len, sizeof(uint8_t));
@@ -133,7 +136,8 @@ void USBCDC::begin(unsigned long baud)
133136
if(tx_lock == NULL) {
134137
tx_lock = xSemaphoreCreateMutex();
135138
}
136-
setRxBufferSize(256);//default if not preset
139+
// if rx_queue was set before begin(), keep it
140+
if (!rx_queue) setRxBufferSize(256); //default if not preset
137141
devices[itf] = this;
138142
}
139143

@@ -144,6 +148,7 @@ void USBCDC::end()
144148
setRxBufferSize(0);
145149
if(tx_lock != NULL) {
146150
vSemaphoreDelete(tx_lock);
151+
tx_lock = NULL;
147152
}
148153
}
149154

@@ -246,14 +251,27 @@ void USBCDC::_onLineCoding(uint32_t _bit_rate, uint8_t _stop_bits, uint8_t _pari
246251
void USBCDC::_onRX(){
247252
uint8_t buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE+1];
248253
uint32_t count = tud_cdc_n_read(itf, buf, CONFIG_TINYUSB_CDC_RX_BUFSIZE);
254+
255+
if(rx_queue == NULL) {
256+
return;
257+
}
258+
if (uxQueueSpacesAvailable(rx_queue) < count) {
259+
//this VTaskDelay gives, to Arduino's task, time to the CPU do its processing
260+
//without it, data may be lost when the number of bytes received is higher than CDC buffer size
261+
vTaskDelay(10);
262+
}
249263
for(uint32_t i=0; i<count; i++){
250-
if(rx_queue == NULL || !xQueueSend(rx_queue, buf+i, 0)){
251-
return;
264+
if(!xQueueSend(rx_queue, buf+i, 0)){
265+
// rx_queue overflow - data will be lost
266+
count = i;
267+
break;
252268
}
253269
}
254-
arduino_usb_cdc_event_data_t p;
255-
p.rx.len = count;
256-
arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_RX_EVENT, &p, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY);
270+
if (count) {
271+
arduino_usb_cdc_event_data_t p;
272+
p.rx.len = count;
273+
arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_RX_EVENT, &p, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY);
274+
}
257275
}
258276

259277
void USBCDC::_onTX(){

cores/esp32/esp32-hal-psram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bool psramInit(){
5656
#if CONFIG_IDF_TARGET_ESP32
5757
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
5858
uint32_t pkg_ver = chip_ver & 0x7;
59-
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 || pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
59+
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 || pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 || pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
6060
spiramFailed = true;
6161
log_w("PSRAM not supported!");
6262
return false;

libraries/AsyncUDP/src/AsyncUDP.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "IPAddress.h"
55
#include "IPv6Address.h"
66
#include "Print.h"
7+
#include "Stream.h"
78
#include <functional>
89
extern "C" {
910
#include "lwip/ip_addr.h"

0 commit comments

Comments
 (0)