Skip to content

Commit 787b08b

Browse files
authored
Merge branch 'espressif:master' into master
2 parents b4f5688 + 2a3de9c commit 787b08b

35 files changed

+563
-110
lines changed

.github/scripts/sketch_utils.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
244244
build_dir="$ARDUINO_BUILD_DIR"
245245
elif [ "$len" -eq 1 ]; then
246246
# build_dir="$sketchdir/build"
247-
build_dir="$HOME/.arduino/tests/$sketchname/build.tmp"
247+
build_dir="$HOME/.arduino/tests/$target/$sketchname/build.tmp"
248248
fi
249249

250250
output_file="$HOME/.arduino/cli_compile_output.txt"
@@ -254,7 +254,7 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
254254
for i in $(seq 0 $((len - 1))); do
255255
if [ "$len" -ne 1 ]; then
256256
# build_dir="$sketchdir/build$i"
257-
build_dir="$HOME/.arduino/tests/$sketchname/build$i.tmp"
257+
build_dir="$HOME/.arduino/tests/$target/$sketchname/build$i.tmp"
258258
fi
259259
rm -rf "$build_dir"
260260
mkdir -p "$build_dir"

.github/scripts/tests_run.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ function run_test {
2727
fi
2828

2929
if [ "$len" -eq 1 ]; then
30-
sdkconfig_path="$HOME/.arduino/tests/$sketchname/build.tmp/sdkconfig"
30+
sdkconfig_path="$HOME/.arduino/tests/$target/$sketchname/build.tmp/sdkconfig"
3131
else
32-
sdkconfig_path="$HOME/.arduino/tests/$sketchname/build0.tmp/sdkconfig"
32+
sdkconfig_path="$HOME/.arduino/tests/$target/$sketchname/build0.tmp/sdkconfig"
3333
fi
3434

3535
if [ -f "$sketchdir"/ci.json ]; then
@@ -45,7 +45,7 @@ function run_test {
4545
fi
4646

4747
if [ ! -f "$sdkconfig_path" ]; then
48-
printf "\033[93mSketch %s not built\nMight be due to missing target requirements or build failure\033[0m\n" "$sketchname"
48+
printf "\033[93mSketch %s build not found in %s\nMight be due to missing target requirements or build failure\033[0m\n" "$(dirname "$sdkconfig_path")" "$sketchname"
4949
printf "\n\n\n"
5050
return 0
5151
fi
@@ -60,7 +60,7 @@ function run_test {
6060

6161
if [ "$len" -eq 1 ]; then
6262
# build_dir="$sketchdir/build"
63-
build_dir="$HOME/.arduino/tests/$sketchname/build.tmp"
63+
build_dir="$HOME/.arduino/tests/$target/$sketchname/build.tmp"
6464
report_file="$sketchdir/$target/$sketchname.xml"
6565
fi
6666

@@ -83,7 +83,7 @@ function run_test {
8383

8484
if [ "$len" -ne 1 ]; then
8585
# build_dir="$sketchdir/build$i"
86-
build_dir="$HOME/.arduino/tests/$sketchname/build$i.tmp"
86+
build_dir="$HOME/.arduino/tests/$target/$sketchname/build$i.tmp"
8787
report_file="$sketchdir/$target/$sketchname$i.xml"
8888
fi
8989

.github/workflows/tests_build.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
with:
2727
key: tests-${{ env.id }}-bin
2828
path: |
29-
~/.arduino/tests/**/build*.tmp/*.bin
30-
~/.arduino/tests/**/build*.tmp/*.elf
31-
~/.arduino/tests/**/build*.tmp/*.json
32-
~/.arduino/tests/**/build*.tmp/sdkconfig
29+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.bin
30+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.elf
31+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.json
32+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/sdkconfig
3333
3434
- name: Evaluate if tests should be built
3535
id: check-build
@@ -73,18 +73,18 @@ jobs:
7373
with:
7474
key: tests-${{ env.id }}-bin
7575
path: |
76-
~/.arduino/tests/**/build*.tmp/*.bin
77-
~/.arduino/tests/**/build*.tmp/*.elf
78-
~/.arduino/tests/**/build*.tmp/*.json
79-
~/.arduino/tests/**/build*.tmp/sdkconfig
76+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.bin
77+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.elf
78+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.json
79+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/sdkconfig
8080
8181
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} binaries as artifacts
8282
uses: actions/upload-artifact@v4
8383
with:
8484
name: tests-bin-${{ inputs.chip }}-${{ inputs.type }}
8585
overwrite: true
8686
path: |
87-
~/.arduino/tests/**/build*.tmp/*.bin
88-
~/.arduino/tests/**/build*.tmp/*.elf
89-
~/.arduino/tests/**/build*.tmp/*.json
90-
~/.arduino/tests/**/build*.tmp/sdkconfig
87+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.bin
88+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.elf
89+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.json
90+
~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/sdkconfig

.github/workflows/tests_hw.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ defaults:
2222
jobs:
2323
hardware-test:
2424
name: Hardware ${{ inputs.chip }} ${{ inputs.type }} tests
25-
runs-on: [arduino, "${{ inputs.chip }}"]
25+
runs-on: ["arduino", "${{ inputs.chip }}"]
2626
env:
2727
id: ${{ github.event.pull_request.number || github.ref }}-${{ github.event.pull_request.head.sha || github.sha }}-${{ inputs.chip }}-${{ inputs.type }}
2828
container:
2929
image: python:3.10.1-bullseye
30-
options: --privileged
30+
options: --privileged --device-cgroup-rule="c 188:* rmw" --device-cgroup-rule="c 166:* rmw"
3131
steps:
32+
- name: Clean workspace
33+
run: |
34+
rm -rf ./*
35+
rm -rf ~/.arduino/tests
36+
3237
- name: Check if already passed
3338
id: cache-results
3439
if: github.event.pull_request.number != null
@@ -81,7 +86,12 @@ jobs:
8186
with:
8287
name: tests-bin-${{ inputs.chip }}-${{ inputs.type }}
8388
path: |
84-
~/.arduino/tests
89+
~/.arduino/tests/${{ inputs.chip }}
90+
91+
- name: List binaries
92+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
93+
run: |
94+
ls -laR ~/.arduino/tests
8595
8696
- name: Run Tests
8797
if: ${{ steps.check-tests.outputs.enabled == 'true' }}

.github/workflows/tests_qemu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
with:
118118
name: tests-bin-${{ inputs.chip }}-${{ inputs.type }}
119119
path: |
120-
~/.arduino/tests
120+
~/.arduino/tests/${{ inputs.chip }}
121121
122122
- name: Run Tests
123123
if: ${{ steps.check-tests.outputs.enabled == 'true' }}

.github/workflows/tests_wokwi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ jobs:
276276
run-id: ${{ github.event.workflow_run.id }}
277277
name: tests-bin-${{ matrix.chip }}-${{ matrix.type }}
278278
path: |
279-
~/.arduino/tests
279+
~/.arduino/tests/${{ matrix.chip }}
280280
281281
- name: Run Tests
282282
if: ${{ steps.check-tests.outputs.enabled == 'true' }}

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ set(ARDUINO_LIBRARY_Zigbee_SRCS
298298
libraries/Zigbee/src/ep/ZigbeeAnalog.cpp
299299
libraries/Zigbee/src/ep/ZigbeeRangeExtender.cpp
300300
libraries/Zigbee/src/ep/ZigbeeGateway.cpp
301+
libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.cpp
301302
)
302303

303304
set(ARDUINO_LIBRARY_BLE_SRCS

cores/esp32/esp32-hal-gpio.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val) {
173173
if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL) {
174174
gpio_set_level((gpio_num_t)pin, val);
175175
} else {
176-
log_e("IO %i is not set as GPIO.", pin);
176+
log_e("IO %i is not set as GPIO. Execute digitalMode(%i, OUTPUT) first.", pin, pin);
177177
}
178178
}
179179

@@ -182,14 +182,12 @@ extern int ARDUINO_ISR_ATTR __digitalRead(uint8_t pin) {
182182
if (pin == RGB_BUILTIN) {
183183
return RGB_BUILTIN_storage;
184184
}
185-
#endif
186-
187-
if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL) {
188-
return gpio_get_level((gpio_num_t)pin);
189-
} else {
190-
log_e("IO %i is not set as GPIO.", pin);
191-
return 0;
185+
#endif // RGB_BUILTIN
186+
// This work when the pin is set as GPIO and in INPUT mode. For all other pin functions, it may return inconsistent response
187+
if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) == NULL) {
188+
log_w("IO %i is not set as GPIO. digitalRead() may return an inconsistent value.");
192189
}
190+
return gpio_get_level((gpio_num_t)pin);
193191
}
194192

195193
static void ARDUINO_ISR_ATTR __onPinInterrupt(void *arg) {

docs/en/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ ESP32-C3 target, you would run:
318318
319319
./.github/scripts/tests_build.sh -s uart -t esp32c3
320320
321-
You should see the output of the build process and the test binary should be generated in the ``~/.arduino/tests/<test_name>/build.tmp`` folder.
321+
You should see the output of the build process and the test binary should be generated in the ``~/.arduino/tests/<target_chip>/<test_name>/build.tmp`` folder.
322322

323323
Now that the test is built, you can run it in the target board. Connect the target board to your computer and run:
324324

@@ -339,7 +339,7 @@ The test will run on the target board and you should see the output of the test
339339
lucassvaz@Lucas--MacBook-Pro esp32 % ./.github/scripts/tests_run.sh -s uart -t esp32c3
340340
Sketch uart test type: validation
341341
Running test: uart -- Config: Default
342-
pytest tests --build-dir /Users/lucassvaz/.arduino/tests/uart/build.tmp -k test_uart --junit-xml=/Users/lucassvaz/Espressif/Arduino/hardware/espressif/esp32/tests/validation/uart/esp32c3/uart.xml --embedded-services esp,arduino
342+
pytest tests --build-dir /Users/lucassvaz/.arduino/tests/esp32c3/uart/build.tmp -k test_uart --junit-xml=/Users/lucassvaz/Espressif/Arduino/hardware/espressif/esp32/tests/validation/uart/esp32c3/uart.xml --embedded-services esp,arduino
343343
=============================================================================================== test session starts ================================================================================================
344344
platform darwin -- Python 3.12.3, pytest-8.2.2, pluggy-1.5.0
345345
rootdir: /Users/lucassvaz/Espressif/Arduino/hardware/espressif/esp32/tests

libraries/Ethernet/src/ETH.cpp

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
271271
eth_mac_config.sw_reset_timeout_ms = 1000;
272272
eth_mac_config.rx_task_stack_size = _task_stack_size;
273273

274-
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config, &eth_mac_config);
275-
if (mac == NULL) {
274+
_mac = esp_eth_mac_new_esp32(&mac_config, &eth_mac_config);
275+
if (_mac == NULL) {
276276
log_e("esp_eth_mac_new_esp32 failed");
277277
return false;
278278
}
@@ -281,26 +281,25 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
281281
phy_config.phy_addr = phy_addr;
282282
phy_config.reset_gpio_num = _pin_power;
283283

284-
esp_eth_phy_t *phy = NULL;
285284
switch (type) {
286285
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
287-
case ETH_PHY_GENERIC: phy = esp_eth_phy_new_generic(&phy_config); break;
286+
case ETH_PHY_GENERIC: _phy = esp_eth_phy_new_generic(&phy_config); break;
288287
#endif
289-
case ETH_PHY_LAN8720: phy = esp_eth_phy_new_lan87xx(&phy_config); break;
290-
case ETH_PHY_TLK110: phy = esp_eth_phy_new_ip101(&phy_config); break;
291-
case ETH_PHY_RTL8201: phy = esp_eth_phy_new_rtl8201(&phy_config); break;
292-
case ETH_PHY_DP83848: phy = esp_eth_phy_new_dp83848(&phy_config); break;
293-
case ETH_PHY_KSZ8041: phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
294-
case ETH_PHY_KSZ8081: phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
288+
case ETH_PHY_LAN8720: _phy = esp_eth_phy_new_lan87xx(&phy_config); break;
289+
case ETH_PHY_TLK110: _phy = esp_eth_phy_new_ip101(&phy_config); break;
290+
case ETH_PHY_RTL8201: _phy = esp_eth_phy_new_rtl8201(&phy_config); break;
291+
case ETH_PHY_DP83848: _phy = esp_eth_phy_new_dp83848(&phy_config); break;
292+
case ETH_PHY_KSZ8041: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
293+
case ETH_PHY_KSZ8081: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
295294
default: log_e("Unsupported PHY %d", type); break;
296295
}
297-
if (phy == NULL) {
296+
if (_phy == NULL) {
298297
log_e("esp_eth_phy_new failed");
299298
return false;
300299
}
301300

302301
_eth_handle = NULL;
303-
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
302+
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(_mac, _phy);
304303
ret = esp_eth_driver_install(&eth_config, &_eth_handle);
305304
if (ret != ESP_OK) {
306305
log_e("Ethernet driver install failed: %d", ret);
@@ -1010,6 +1009,18 @@ bool ETHClass::fullDuplex() const {
10101009
return (link_duplex == ETH_DUPLEX_FULL);
10111010
}
10121011

1012+
bool ETHClass::setFullDuplex(bool on) {
1013+
if (_eth_handle == NULL) {
1014+
return false;
1015+
}
1016+
eth_duplex_t link_duplex = on ? ETH_DUPLEX_FULL : ETH_DUPLEX_HALF;
1017+
esp_err_t err = esp_eth_ioctl(_eth_handle, ETH_CMD_S_DUPLEX_MODE, &link_duplex);
1018+
if (err != ESP_OK) {
1019+
log_e("Failed to set duplex mode: 0x%x: %s", err, esp_err_to_name(err));
1020+
}
1021+
return err == ESP_OK;
1022+
}
1023+
10131024
bool ETHClass::autoNegotiation() const {
10141025
if (_eth_handle == NULL) {
10151026
return false;
@@ -1019,6 +1030,17 @@ bool ETHClass::autoNegotiation() const {
10191030
return auto_nego;
10201031
}
10211032

1033+
bool ETHClass::setAutoNegotiation(bool on) {
1034+
if (_eth_handle == NULL) {
1035+
return false;
1036+
}
1037+
esp_err_t err = esp_eth_ioctl(_eth_handle, ETH_CMD_S_AUTONEGO, &on);
1038+
if (err != ESP_OK) {
1039+
log_e("Failed to set auto negotiation: 0x%x: %s", err, esp_err_to_name(err));
1040+
}
1041+
return err == ESP_OK;
1042+
}
1043+
10221044
uint32_t ETHClass::phyAddr() const {
10231045
if (_eth_handle == NULL) {
10241046
return 0;
@@ -1028,7 +1050,7 @@ uint32_t ETHClass::phyAddr() const {
10281050
return phy_addr;
10291051
}
10301052

1031-
uint8_t ETHClass::linkSpeed() const {
1053+
uint16_t ETHClass::linkSpeed() const {
10321054
if (_eth_handle == NULL) {
10331055
return 0;
10341056
}
@@ -1037,6 +1059,18 @@ uint8_t ETHClass::linkSpeed() const {
10371059
return (link_speed == ETH_SPEED_10M) ? 10 : 100;
10381060
}
10391061

1062+
bool ETHClass::setLinkSpeed(uint16_t speed) {
1063+
if (_eth_handle == NULL) {
1064+
return false;
1065+
}
1066+
eth_speed_t link_speed = (speed == 10) ? ETH_SPEED_10M : ETH_SPEED_100M;
1067+
esp_err_t err = esp_eth_ioctl(_eth_handle, ETH_CMD_S_SPEED, &link_speed);
1068+
if (err != ESP_OK) {
1069+
log_e("Failed to set link speed: 0x%x: %s", err, esp_err_to_name(err));
1070+
}
1071+
return err == ESP_OK;
1072+
}
1073+
10401074
// void ETHClass::getMac(uint8_t* mac)
10411075
// {
10421076
// if(_eth_handle != NULL && mac != NULL){

libraries/Ethernet/src/ETH.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,14 @@ class ETHClass : public NetworkInterface {
192192

193193
// ETH Handle APIs
194194
bool fullDuplex() const;
195-
uint8_t linkSpeed() const;
195+
bool setFullDuplex(bool on);
196+
197+
uint16_t linkSpeed() const;
198+
bool setLinkSpeed(uint16_t speed); //10 or 100
199+
196200
bool autoNegotiation() const;
201+
bool setAutoNegotiation(bool on);
202+
197203
uint32_t phyAddr() const;
198204

199205
esp_eth_handle_t handle() const;

libraries/Matter/examples/MatterColorLight/MatterColorLight.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV) {
6060
analogWrite(ledPin, colorHSV.v);
6161
#endif
6262
} else {
63+
#ifndef RGB_BUILTIN
64+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
65+
pinMode(ledPin, OUTPUT);
66+
#endif
6367
digitalWrite(ledPin, LOW);
6468
}
6569
// store last HSV Color and OnOff state for when the Light is restarted / power goes off

libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ bool setLightState(bool state, uint8_t brightness) {
5656
analogWrite(ledPin, brightness);
5757
#endif
5858
} else {
59+
#ifndef RGB_BUILTIN
60+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
61+
pinMode(ledPin, OUTPUT);
62+
#endif
5963
digitalWrite(ledPin, LOW);
6064
}
6165
// store last Brightness and OnOff state for when the Light is restarted / power goes off

libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint
6464
analogWrite(ledPin, colorHSV.v);
6565
#endif
6666
} else {
67+
#ifndef RGB_BUILTIN
68+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
69+
pinMode(ledPin, OUTPUT);
70+
#endif
6771
digitalWrite(ledPin, LOW);
6872
}
6973
// store last HSV Color and OnOff state for when the Light is restarted / power goes off

libraries/Matter/examples/MatterFan/MatterFan.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) {
4949
// drive the Fan DC motor
5050
if (fanState == false) {
5151
// turn off the Fan
52+
#ifndef RGB_BUILTIN
53+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
54+
pinMode(dcMotorPin, OUTPUT);
55+
#endif
5256
digitalWrite(dcMotorPin, LOW);
5357
} else {
5458
// set the Fan speed

libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ bool setLightState(bool state, uint8_t brightness, uint16_t temperature_Mireds)
6666
analogWrite(ledPin, brightness);
6767
#endif
6868
} else {
69+
#ifndef RGB_BUILTIN
70+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
71+
pinMode(ledPin, OUTPUT);
72+
#endif
6973
digitalWrite(ledPin, LOW);
7074
}
7175
// store last Brightness and OnOff state for when the Light is restarted / power goes off

0 commit comments

Comments
 (0)