Skip to content

Commit 9716d5d

Browse files
authored
Merge branch 'master' into feature/network_refactoring
2 parents 6691cdb + c17a688 commit 9716d5d

File tree

36 files changed

+3277
-923
lines changed

36 files changed

+3277
-923
lines changed

.github/workflows/docs_build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
PATH=/home/runner/.local/bin:$PATH pip3 install -r requirements.txt --prefer-binary
3939
PATH=/home/runner/.local/bin:$PATH SPHINXOPTS="-W" build-docs -l en
4040
- name: Archive Docs
41-
uses: actions/upload-artifact@v2
41+
uses: actions/upload-artifact@v4
4242
with:
4343
name: docs
4444
path: docs

.github/workflows/hil.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
run: |
5757
bash .github/scripts/tests_build.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}}
5858
- name: Upload ${{matrix.chip}}-${{matrix.chunks}} artifacts
59-
uses: actions/upload-artifact@v3
59+
uses: actions/upload-artifact@v4
6060
with:
6161
name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts
6262
path: |
@@ -81,7 +81,7 @@ jobs:
8181
uses: actions/checkout@v4
8282

8383
- name: Download ${{matrix.chip}}-${{matrix.chunks}} artifacts
84-
uses: actions/download-artifact@v3
84+
uses: actions/download-artifact@v4
8585
with:
8686
name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts
8787
path: ~/.arduino/tests/
@@ -97,7 +97,7 @@ jobs:
9797
bash .github/scripts/tests_run.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} -e
9898
9999
- name: Upload test result artifacts
100-
uses: actions/upload-artifact@v3
100+
uses: actions/upload-artifact@v4
101101
if: always()
102102
with:
103103
name: test_results-${{matrix.chip}}-${{matrix.chunks}}
@@ -112,7 +112,7 @@ jobs:
112112
runs-on: ubuntu-latest
113113
steps:
114114
- name: Upload
115-
uses: actions/upload-artifact@v3
115+
uses: actions/upload-artifact@v4
116116
with:
117117
name: Event File
118118
path: ${{github.event_path}}

.github/workflows/lib.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ jobs:
7575
- --warnings="all"
7676
7777
- name: Upload artifact
78-
uses: actions/upload-artifact@v3
78+
uses: actions/upload-artifact@v4
7979
with:
80-
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
80+
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}-${{ matrix.target }}
8181
path: ${{ env.SKETCHES_REPORTS_PATH }}
8282

8383
report-to-file:
@@ -98,9 +98,10 @@ jobs:
9898

9999
# This step is needed to get the size data produced by the compile jobs
100100
- name: Download sketches reports artifact
101-
uses: actions/download-artifact@v3
101+
uses: actions/download-artifact@v4
102102
with:
103-
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
103+
pattern: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}-*
104+
merge-multiple: true
104105
path: ${{ env.SKETCHES_REPORTS_PATH }}
105106

106107
- name: Report results
@@ -129,7 +130,7 @@ jobs:
129130
runs-on: ubuntu-latest
130131
steps:
131132
- name: Upload
132-
uses: actions/upload-artifact@v2
133+
uses: actions/upload-artifact@v4
133134
with:
134135
name: Event File
135-
path: ${{github.event_path}}
136+
path: ${{github.event_path}}

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ set(CORE_SRCS
5454
cores/esp32/IPAddress.cpp
5555
cores/esp32/libb64/cdecode.c
5656
cores/esp32/libb64/cencode.c
57+
cores/esp32/MacAddress.cpp
5758
cores/esp32/main.cpp
5859
cores/esp32/MD5Builder.cpp
5960
cores/esp32/Print.cpp

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Arduino core for the ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6 and ESP32-H2
22

3-
![Build Status](https://github.com/espressif/arduino-esp32/workflows/ESP32%20Arduino%20CI/badge.svg) [![External Libraries Test](https://github.com/espressif/arduino-esp32/actions/workflows/lib.yml/badge.svg?branch=master&event=schedule)](https://github.com/espressif/arduino-esp32/actions/workflows/lib.yml?link=http://https://github.com/espressif/arduino-esp32/blob/master/LIBRARIES_TEST.md)
3+
![Build Status](https://github.com/espressif/arduino-esp32/workflows/ESP32%20Arduino%20CI/badge.svg) [![External Libraries Test](https://github.com/espressif/arduino-esp32/actions/workflows/lib.yml/badge.svg?branch=master&event=schedule)](https://github.com/espressif/arduino-esp32/blob/gh-pages/LIBRARIES_TEST.md) [![Hardware Tests](https://github.com/espressif/arduino-esp32/actions/workflows/hil.yml/badge.svg?branch=master&event=schedule)](https://github.com/espressif/arduino-esp32/actions/workflows/hil.yml?query=event%3Aschedule)
44

55
### Need help or have a question? Join the chat at [Gitter](https://gitter.im/espressif/arduino-esp32) or [open a new Discussion](https://github.com/espressif/arduino-esp32/discussions)
66

boards.txt

+1,512-327
Large diffs are not rendered by default.

cores/esp32/HWCDC.cpp

+35-11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "esp_intr_alloc.h"
2525
#include "soc/periph_defs.h"
2626
#include "soc/io_mux_reg.h"
27+
#include "soc/usb_serial_jtag_struct.h"
2728
#pragma GCC diagnostic ignored "-Wvolatile"
2829
#include "hal/usb_serial_jtag_ll.h"
2930
#pragma GCC diagnostic warning "-Wvolatile"
@@ -86,7 +87,7 @@ static void hw_cdc_isr_handler(void *arg) {
8687
} else {
8788
connected = true;
8889
}
89-
if (usb_serial_jtag_ll_txfifo_writable() == 1) {
90+
if (tx_ring_buf != NULL && usb_serial_jtag_ll_txfifo_writable() == 1) {
9091
// We disable the interrupt here so that the interrupt won't be triggered if there is no data to send.
9192
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
9293
size_t queued_size;
@@ -164,6 +165,9 @@ bool HWCDC::isCDC_Connected()
164165
}
165166

166167
static void ARDUINO_ISR_ATTR cdc0_write_char(char c) {
168+
if(tx_ring_buf == NULL) {
169+
return;
170+
}
167171
uint32_t tx_timeout_ms = 0;
168172
if(HWCDC::isConnected()) {
169173
tx_timeout_ms = requested_tx_timeout_ms;
@@ -177,7 +181,8 @@ static void ARDUINO_ISR_ATTR cdc0_write_char(char c) {
177181
}
178182

179183
HWCDC::HWCDC() {
180-
184+
perimanSetBusDeinit(ESP32_BUS_TYPE_USB_DM, HWCDC::deinit);
185+
perimanSetBusDeinit(ESP32_BUS_TYPE_USB_DP, HWCDC::deinit);
181186
}
182187

183188
HWCDC::~HWCDC(){
@@ -237,27 +242,45 @@ void HWCDC::begin(unsigned long baud)
237242
log_e("HW CDC TX Buffer error");
238243
}
239244
}
245+
246+
// the HW Serial pins needs to be first deinited in order to allow `if(Serial)` to work :-(
247+
deinit(NULL);
248+
delay(10); // USB Host has to enumerate it again
249+
250+
// Peripheral Manager setting for USB D+ D- pins
251+
uint8_t pin = USB_DM_GPIO_NUM;
252+
if(!perimanSetPinBus(pin, ESP32_BUS_TYPE_USB_DM, (void *) this, -1, -1)) goto err;
253+
pin = USB_DP_GPIO_NUM;
254+
if(!perimanSetPinBus(pin, ESP32_BUS_TYPE_USB_DP, (void *) this, -1, -1)) goto err;
255+
256+
// Configure PHY
257+
// USB_Serial_JTAG use internal PHY
258+
USB_SERIAL_JTAG.conf0.phy_sel = 0;
259+
// Disable software control USB D+ D- pullup pulldown (Device FS: dp_pullup = 1)
260+
USB_SERIAL_JTAG.conf0.pad_pull_override = 0;
261+
// Enable USB D+ pullup
262+
USB_SERIAL_JTAG.conf0.dp_pullup = 1;
263+
// Enable USB pad function
264+
USB_SERIAL_JTAG.conf0.usb_pad_enable = 1;
240265
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
241-
usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
242266
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);
243267
if(!intr_handle && esp_intr_alloc(ETS_USB_SERIAL_JTAG_INTR_SOURCE, 0, hw_cdc_isr_handler, NULL, &intr_handle) != ESP_OK){
244268
isr_log_e("HW USB CDC failed to init interrupts");
245269
end();
246270
return;
247271
}
248-
if (perimanSetBusDeinit(ESP32_BUS_TYPE_USB_DM, HWCDC::deinit) && perimanSetBusDeinit(ESP32_BUS_TYPE_USB_DP, HWCDC::deinit)) {
249-
// Setting USB D+ D- pins
250-
perimanSetPinBus(USB_DM_GPIO_NUM, ESP32_BUS_TYPE_USB_DM, (void *) this, -1, -1);
251-
perimanSetPinBus(USB_DP_GPIO_NUM, ESP32_BUS_TYPE_USB_DP, (void *) this, -1, -1);
252-
} else {
253-
log_e("Serial JTAG Pins can't be set into Peripheral Manager.");
254-
}
272+
return;
273+
274+
err:
275+
log_e("Serial JTAG Pin %u can't be set into Peripheral Manager.", pin);
276+
end();
255277
}
256278

257279
void HWCDC::end()
258280
{
259-
//Disable tx/rx interrupt.
281+
//Disable/clear/free tx/rx interrupt.
260282
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
283+
usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
261284
esp_intr_free(intr_handle);
262285
intr_handle = NULL;
263286
if(tx_lock != NULL) {
@@ -271,6 +294,7 @@ void HWCDC::end()
271294
arduino_hw_cdc_event_loop_handle = NULL;
272295
}
273296
HWCDC::deinit(this);
297+
setDebugOutput(false);
274298
connected = false;
275299
}
276300

cores/esp32/HardwareSerial.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -537,35 +537,37 @@ bool HardwareSerial::setMode(SerialMode mode)
537537
return uartSetMode(_uart, mode);
538538
}
539539

540+
// minimum total RX Buffer size is the UART FIFO space (128 bytes for most SoC) + 1. IDF imposition.
540541
size_t HardwareSerial::setRxBufferSize(size_t new_size) {
541542

542543
if (_uart) {
543-
log_e("RX Buffer can't be resized when Serial is already running.\n");
544+
log_e("RX Buffer can't be resized when Serial is already running. Set it before calling begin().");
544545
return 0;
545546
}
546547

547548
if (new_size <= SOC_UART_FIFO_LEN) {
548-
log_e("RX Buffer must be higher than %d.\n", SOC_UART_FIFO_LEN); // ESP32, S2, S3 and C3 means higher than 128
549-
return 0;
549+
log_w("RX Buffer set to minimum value: %d.", SOC_UART_FIFO_LEN + 1); // ESP32, S2, S3 and C3 means higher than 128
550+
new_size = SOC_UART_FIFO_LEN + 1;
550551
}
551552

552553
_rxBufferSize = new_size;
553554
return _rxBufferSize;
554555
}
555556

557+
// minimum total TX Buffer size is the UART FIFO space (128 bytes for most SoC).
556558
size_t HardwareSerial::setTxBufferSize(size_t new_size) {
557559

558560
if (_uart) {
559-
log_e("TX Buffer can't be resized when Serial is already running.\n");
561+
log_e("TX Buffer can't be resized when Serial is already running. Set it before calling begin().");
560562
return 0;
561563
}
562564

563565
if (new_size <= SOC_UART_FIFO_LEN) {
564-
log_e("TX Buffer must be higher than %d.\n", SOC_UART_FIFO_LEN); // ESP32, S2, S3 and C3 means higher than 128
565-
return 0;
566+
log_w("TX Buffer set to minimum value: %d.", SOC_UART_FIFO_LEN); // ESP32, S2, S3 and C3 means higher than 128
567+
_txBufferSize = 0; // it will use just UART FIFO with SOC_UART_FIFO_LEN bytes (128 for most SoC)
568+
return SOC_UART_FIFO_LEN;
566569
}
567-
570+
// if new_size is higher than SOC_UART_FIFO_LEN, TX Ringbuffer will be active and it will be used to report back "availableToWrite()"
568571
_txBufferSize = new_size;
569-
return _txBufferSize;
572+
return new_size;
570573
}
571-

0 commit comments

Comments
 (0)