Skip to content

Commit 3c6d9a8

Browse files
authored
Merge branch 'master' into fix/rainmaker-example
2 parents 9992275 + b1b6228 commit 3c6d9a8

22 files changed

+251
-57
lines changed

.github/scripts/tests_run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ function run_test() {
6969
if [[ -f "$sketchdir/scenario.yaml" ]]; then
7070
extra_args+=" --wokwi-scenario $sketchdir/scenario.yaml"
7171
fi
72+
if [[ -f "$sketchdir/diagram.$target.json" ]]; then
73+
extra_args+=" --wokwi-diagram $sketchdir/diagram.$target.json"
74+
fi
75+
7276
elif [ $platform == "qemu" ]; then
7377
PATH=$HOME/qemu/bin:$PATH
7478
extra_args="--embedded-services qemu --qemu-image-path $build_dir/$sketchname.ino.merged.bin"

README.md

Lines changed: 1 addition & 1 deletion
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/blob/gh-pages/LIBRARIES_TEST.md) [![Hardware Tests](https://github.com/espressif/arduino-esp32/blob/gh-pages/runtime-tests-results/badge.svg)](https://github.com/espressif/arduino-esp32/actions/workflows/tests_results.yml)
3+
[![Build Status](https://github.com/espressif/arduino-esp32/actions/workflows/push.yml/badge.svg?branch=master&event=push)](https://github.com/espressif/arduino-esp32/actions/workflows/push.yml) [![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/blob/gh-pages/runtime-tests-results/badge.svg)](https://github.com/espressif/arduino-esp32/actions/workflows/tests_results.yml)
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

cores/esp32/HardwareSerial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void serialEventRun(void) {
9696
#endif
9797

9898
HardwareSerial::HardwareSerial(uint8_t uart_nr)
99-
: _uart_nr(uart_nr), _uart(NULL), _rxBufferSize(256), _txBufferSize(0), _onReceiveCB(NULL), _onReceiveErrorCB(NULL), _onReceiveTimeout(false), _rxTimeout(2),
99+
: _uart_nr(uart_nr), _uart(NULL), _rxBufferSize(256), _txBufferSize(0), _onReceiveCB(NULL), _onReceiveErrorCB(NULL), _onReceiveTimeout(false), _rxTimeout(1),
100100
_rxFIFOFull(0), _eventTask(NULL)
101101
#if !CONFIG_DISABLE_HAL_LOCKS
102102
,

cores/esp32/chip-debug-report.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static void printChipInfo(void) {
9898
rtc_clk_cpu_freq_get_config(&conf);
9999
chip_report_printf(" CPU Frequency : %lu MHz\n", conf.freq_mhz);
100100
chip_report_printf(" XTAL Frequency : %d MHz\n", rtc_clk_xtal_freq_get());
101+
chip_report_printf(" Features Bitfield : %#010x\n", info.features);
101102
chip_report_printf(" Embedded Flash : %s\n", (info.features & CHIP_FEATURE_EMB_FLASH) ? "Yes" : "No");
102103
chip_report_printf(" Embedded PSRAM : %s\n", (info.features & CHIP_FEATURE_EMB_PSRAM) ? "Yes" : "No");
103104
chip_report_printf(" 2.4GHz WiFi : %s\n", (info.features & CHIP_FEATURE_WIFI_BGN) ? "Yes" : "No");

cores/esp32/esp32-hal-ledc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ static bool ledcDetachBus(void *bus) {
5252
bool channel_found = false;
5353
// Check if more pins are attached to the same ledc channel
5454
for (uint8_t i = 0; i < SOC_GPIO_PIN_COUNT; i++) {
55-
if (!perimanPinIsValid(i)) {
56-
continue; //invalid pin, skip
55+
if (!perimanPinIsValid(i) || i == handle->pin) {
56+
continue; //invalid pin or same pin
5757
}
5858
peripheral_bus_type_t type = perimanGetPinBusType(i);
5959
if (type == ESP32_BUS_TYPE_LEDC) {

cores/esp32/esp32-hal-uart.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,20 @@ uart_t *uartBegin(
503503
uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;
504504
uart_config.rx_flow_ctrl_thresh = rxfifo_full_thrhd;
505505
uart_config.baud_rate = baudrate;
506-
// CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6
507-
uart_config.source_clk = UART_SCLK_DEFAULT;
506+
// there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored
507+
// therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue.
508+
#if SOC_UART_SUPPORT_XTAL_CLK
509+
uart_config.source_clk = UART_SCLK_XTAL; // valid for C2, S3, C3, C6, H2 and P4
510+
#elif SOC_UART_SUPPORT_REF_TICK
511+
if (baudrate <= 1000000) {
512+
uart_config.source_clk = UART_SCLK_REF_TICK; // valid for ESP32, S2 - MAX supported baud rate is 1MHz
513+
} else {
514+
uart_config.source_clk = UART_SCLK_APB; // baudrate may change with the APB Frequency!
515+
}
516+
#else
517+
// Default CLK Source: CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6
518+
uart_config.source_clk = UART_SCLK_DEFAULT; // baudrate may change with the APB Frequency!
519+
#endif
508520

509521
UART_MUTEX_LOCK();
510522
bool retCode = ESP_OK == uart_driver_install(uart_nr, rx_buffer_size, tx_buffer_size, 20, &(uart->uart_event_queue), 0);
@@ -778,25 +790,25 @@ void uartSetBaudRate(uart_t *uart, uint32_t baud_rate) {
778790
return;
779791
}
780792
UART_MUTEX_LOCK();
781-
uint32_t sclk_freq;
782-
if (uart_get_sclk_freq(UART_SCLK_DEFAULT, &sclk_freq) == ESP_OK) {
783-
uart_ll_set_baudrate(UART_LL_GET_HW(uart->num), baud_rate, sclk_freq);
793+
if (uart_set_baudrate(uart->num, baud_rate) == ESP_OK) {
794+
uart->_baudrate = baud_rate;
795+
} else {
796+
log_e("Setting UART%d baud rate to %d has failed.", uart->num, baud_rate);
784797
}
785-
uart->_baudrate = baud_rate;
786798
UART_MUTEX_UNLOCK();
787799
}
788800

789801
uint32_t uartGetBaudRate(uart_t *uart) {
790802
uint32_t baud_rate = 0;
791-
uint32_t sclk_freq;
792803

793804
if (uart == NULL) {
794805
return 0;
795806
}
796807

797808
UART_MUTEX_LOCK();
798-
if (uart_get_sclk_freq(UART_SCLK_DEFAULT, &sclk_freq) == ESP_OK) {
799-
baud_rate = uart_ll_get_baudrate(UART_LL_GET_HW(uart->num), sclk_freq);
809+
if (uart_get_baudrate(uart->num, &baud_rate) != ESP_OK) {
810+
log_e("Getting UART%d baud rate has failed.", uart->num);
811+
baud_rate = (uint32_t)-1; // return value when failed
800812
}
801813
UART_MUTEX_UNLOCK();
802814
return baud_rate;

libraries/Network/src/NetworkUdp.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,14 @@ int NetworkUDP::parsePacket() {
296296
}
297297
struct sockaddr_storage si_other_storage; // enough storage for v4 and v6
298298
socklen_t slen = sizeof(sockaddr_storage);
299-
int len;
299+
int len = 0;
300+
if (ioctl(udp_server, FIONREAD, &len) == -1) {
301+
log_e("could not check for data in buffer length: %d", errno);
302+
return 0;
303+
}
304+
if (!len) {
305+
return 0;
306+
}
300307
char *buf = (char *)malloc(1460);
301308
if (!buf) {
302309
return 0;

libraries/WiFi/examples/WiFiScan/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This example demonstrates how to use the WiFi library to scan available WiFi net
44

55
## Supported Targets
66

7-
Currently this example supports the following targets.
7+
Currently, this example supports the following targets.
88

99
| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | ESP32-C6 |
1010
| ----------------- | ----- | -------- | -------- | -------- | -------- |
@@ -45,7 +45,7 @@ Nr | SSID | RSSI | CH | Encryption
4545
* **Programming Fail:** If the programming/flash procedure fails, try to reduce the serial connection speed.
4646
* **COM port not detected:** Check the USB cable connection and the USB to Serial driver installation.
4747

48-
If the error persist, you can ask help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).
48+
If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).
4949

5050
## Contribute
5151

libraries/WiFi/examples/WiFiScanAsync/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This example demonstrates how to use the WiFi library to scan available WiFi net
44

55
## Supported Targets
66

7-
Currently this example supports the following targets.
7+
Currently, this example supports the following targets.
88

99
| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | ESP32-C6 |
1010
| ----------------- | ----- | -------- | -------- | -------- | -------- |
@@ -55,7 +55,7 @@ Nr | SSID | RSSI | CH | Encryption
5555
* **Programming Fail:** If the programming/flash procedure fails, try to reduce the serial connection speed.
5656
* **COM port not detected:** Check the USB cable connection and the USB to Serial driver installation.
5757

58-
If the error persist, you can ask help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).
58+
If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).
5959

6060
## Contribute
6161

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# WiFiScanTime Example
2+
3+
This example demonstrates how to use the WiFi library to scan available WiFi networks with custom scan timing and print the results.
4+
5+
## Supported Targets
6+
7+
Currently, this example supports the following targets.
8+
9+
| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | ESP32-C6 |
10+
| ----------------- | ----- | -------- | -------- | -------- | -------- |
11+
12+
## How to Use Example
13+
14+
* How to install the Arduino IDE: [Install Arduino IDE](https://github.com/espressif/arduino-esp32/tree/master/docs/arduino-ide).
15+
16+
#### Using Arduino IDE
17+
18+
* Before Compile/Verify, select the correct board: `Tools -> Board`.
19+
* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
20+
21+
#### Using Platform IO
22+
23+
* Select the COM port: `Devices` or setting the `upload_port` option on the `platformio.ini` file.
24+
25+
## Example/Log Output
26+
27+
```
28+
Setup done
29+
Scan start
30+
Scan done, elapsed time: 4960 ms
31+
17 networks found
32+
Nr | SSID | RSSI | CH | Encryption
33+
1 | IoTNetwork | -62 | 1 | WPA2
34+
2 | WiFiSSID | -62 | 1 | WPA2-EAP
35+
3 | B3A7992 | -63 | 6 | WPA+WPA2
36+
4 | WiFi | -63 | 6 | WPA3
37+
5 | IoTNetwork2 | -64 | 11 | WPA2+WPA3
38+
...
39+
```
40+
41+
## Troubleshooting
42+
43+
***Important: Be sure you're using a good quality USB cable and you have enough power source for your project.***
44+
45+
* **Programming Fail:** If the programming/flash procedure fails, try to reduce the serial connection speed.
46+
* **COM port not detected:** Check the USB cable connection and the USB to Serial driver installation.
47+
48+
If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).
49+
50+
## Contribute
51+
52+
To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst)
53+
54+
If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome!
55+
56+
Before creating a new issue, be sure to try the Troubleshooting and to check if the same issue was already created by someone else.
57+
58+
## Resources
59+
60+
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
61+
* ESP32 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf)
62+
* ESP32-S2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf)
63+
* ESP32-C3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf)
64+
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
65+
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)

0 commit comments

Comments
 (0)