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

Diff for: .github/scripts/install-arduino-core-esp32.sh

+1-1
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 ..."

Diff for: .github/workflows/publish.yml

+4
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:

Diff for: CMakeLists.txt

-10
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()

Diff for: boards.txt

+1-1
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+
##############################################################

Diff for: cores/esp32/Esp.cpp

+9-5
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
}

Diff for: cores/esp32/HardwareSerial.cpp

+5-1
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

Diff for: cores/esp32/HardwareSerial.h

+2-2
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;

Diff for: cores/esp32/USBCDC.cpp

+27-9
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(){

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

+1-1
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;

Diff for: libraries/AsyncUDP/src/AsyncUDP.h

+1
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"

Diff for: libraries/ESP32/examples/RMT/RMTCallback/RMTCallback.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ void loop()
6464
{
6565
Serial.printf("GPIO 4: %08x 5: %08x 10: %08x\n", mp1.val(), mp2.val(), mp3.val());
6666
delay(500);
67-
}
67+
}

Diff for: libraries/README.md

-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
6767
### Preferences
6868
Flash keystore using ESP32 NVS
6969

70-
### ESP RainMaker
71-
End-to-end platform by Espressif that enables Makers to realize their IoT ideas faster
72-
7370
### SD
7471
Secure Digital card filesystem using SPI access
7572

Diff for: libraries/Update/src/Updater.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ size_t UpdateClass::writeStream(Stream &data) {
352352
bytesToRead = remaining();
353353
}
354354

355-
/*
355+
/*
356356
Init read&timeout counters and try to read, if read failed, increase counter,
357357
wait 100ms and try to read again. If counter > 300 (30 sec), give up/abort
358358
*/
@@ -377,6 +377,8 @@ size_t UpdateClass::writeStream(Stream &data) {
377377
if((_bufferLen == remaining() || _bufferLen == SPI_FLASH_SEC_SIZE) && !_writeBuffer())
378378
return written;
379379
written += toRead;
380+
381+
delay(1); // Fix solo WDT
380382
}
381383
return written;
382384
}

Diff for: tools/sdk/esp32c3/ld/esp32c3.rom.ld

+2-1
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ r_lld_con_tx_prog = 0x40001140;
10671067
r_lld_conn_dynamic_pti_process = 0x40001144;
10681068
r_lld_continue_scan_rx_isr_end_process = 0x40001148;
10691069
r_lld_ext_scan_dynamic_pti_process = 0x4000114c;
1070+
r_lld_ext_adv_dynamic_aux_pti_process = 0x40001b44;
10701071
r_lld_hw_cca_end_isr = 0x40001150;
10711072
r_lld_hw_cca_evt_handler = 0x40001154;
10721073
r_lld_hw_cca_isr = 0x40001158;
@@ -1896,7 +1897,7 @@ rom_read_sar2_code = 0x40001aa4;
18961897
rom_get_sar2_vol = 0x40001aa8;
18971898
rom_get_pll_vol = 0x40001aac;
18981899
rom_get_phy_target_power = 0x40001ab0;
1899-
/* rom_temp_to_power = 0x40001ab4; */
1900+
rom_temp_to_power = 0x40001ab4;
19001901
rom_phy_track_pll_cap = 0x40001ab8;
19011902
rom_phy_pwdet_always_en = 0x40001abc;
19021903
rom_phy_pwdet_onetime_en = 0x40001ac0;

Diff for: variants/adafruit_feather_esp32_v2/pins_arduino.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,19 @@ static const uint8_t A9 = 33;
4242
static const uint8_t A10 = 27;
4343
static const uint8_t A11 = 12;
4444
static const uint8_t A12 = 13;
45+
static const uint8_t A13 = 35;
4546

4647
// vbat measure
47-
static const uint8_t BATT_MONITOR = 35;
48-
static const uint8_t A13 = 35;
48+
#define BATT_MONITOR 35
4949

5050
// internal switch
51-
static const uint8_t BUTTON = 38;
51+
#define BUTTON = 38;
5252

5353
// Neopixel
54-
static const uint8_t NEOPIXEL_PIN = 0;
55-
static const uint8_t PIN_NEOPIXEL = 0;
54+
#define PIN_NEOPIXEL 0
5655

5756
// Neopixel & I2C power
58-
static const uint8_t NEOPIXEL_I2C_POWER = 2;
57+
#define NEOPIXEL_I2C_POWER 2
5958

6059
static const uint8_t T0 = 4;
6160
static const uint8_t T1 = 0;

Diff for: variants/adafruit_feather_esp32s2/variant.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ void initVariant(void)
3636
pinMode(NEOPIXEL_POWER, OUTPUT);
3737
digitalWrite(NEOPIXEL_POWER, HIGH);
3838

39-
// This board has a power control pin, and we must set it to output and low
40-
// in order to enable the I2C port.
39+
// turn on the I2C power by setting pin to opposite of 'rest state'
40+
pinMode(PIN_I2C_POWER, INPUT);
41+
delay(1);
42+
bool polarity = digitalRead(PIN_I2C_POWER);
4143
pinMode(PIN_I2C_POWER, OUTPUT);
42-
digitalWrite(PIN_I2C_POWER, LOW);
44+
digitalWrite(PIN_I2C_POWER, !polarity);
4345
}
44-
4546
}

Diff for: variants/adafruit_qtpy_esp32c3/pins_arduino.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#define digitalPinToInterrupt(p) (((p)<NUM_DIGITAL_PINS)?(p):-1)
1212
#define digitalPinHasPWM(p) (p < EXTERNAL_NUM_INTERRUPTS)
1313

14-
static const uint8_t SWITCH = 9;
15-
static const uint8_t NEOPIXEL_PIN = 2;
14+
#define BUTTON 9
15+
#define PIN_NEOPIXEL 2
1616

1717
static const uint8_t TX = 21;
1818
static const uint8_t RX = 20;

0 commit comments

Comments
 (0)