Skip to content

Conversation

@benpicco
Copy link
Contributor

@benpicco benpicco commented Dec 2, 2025

Backport of #21926

Contribution description

This PR fixex issue #21919.

The reason for the issue was that the ESP-IDF WiFi interface wrapper library always calls xSemaphoreTakeRecursive and xSemaphoreGiveRecursive for mutexes, regardless of whether they are recursive or not.

It would certainly have been better in ESP-IDF to use functions xSemaphoreTake and xSemaphoreGive for all type of mutexes instead, as these functions already check the type of the mutex and then call the functions xSemaphoreTakeRecursive and xSemaphoreGiveRecursive in the case of a recursive mutex.

The fix fix now checks the type of the mutex also in recursive mutex functions and then calls the functions for normal mutexes if the mutex is not recursive.

Testing procedure

Flash e.g. examples/networking/gnrc/networking on any board from the ESP32 family:

BOARD=esp32s3-devkit make -C examples/networking/gnrc/networking flash

You should get an esp-now interface:

> ifconfig
Iface  10  HWaddr: 7C:DF:A1:E2:88:C5  Channel: 6 
          L2-PDU:249  MTU:1280  HL:64  RTR  
          RTR_ADV  6LO  Source address length: 6
          ...

Now try to change the channel with ifconfig 10 set chan 1. Without the PR, you will get an assertion.

> ifconfig 10 set chan 1
cpu/esp_common/freertos/semphr.c:177 => FAILED ASSERTION.

With the PR changing the channel should succeed:

> ifconfig 10 set chan 1
success: set channel on interface 10 to 1
> 
> ifconfig
Iface  10  HWaddr: 7C:DF:A1:E2:88:C5  Channel: 1 
          L2-PDU:249  MTU:1280  HL:64  RTR  
          RTR_ADV  6LO  Source address length: 6

Issues/PRs references

Fix of issue #21919

The ESP-IDF WiFi interface wrapper always calls `xSemaphoreTakeRecursive` and `xSemaphoreGiveRecursive` for mutexes, regardless of whether they are recursive or not. Instead of an `assert`, the fix now also checks the type of the mutex in the functions for recursive mutexes and then calls the functions for normal mutexes if the mutex is not recursive.

(cherry picked from commit 323d263)
@benpicco benpicco requested a review from gschorcht as a code owner December 2, 2025 21:14
@benpicco benpicco added Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms Process: release backport Integration Process: The PR is a release backport of a change previously provided to master Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) labels Dec 2, 2025
@benpicco benpicco requested a review from maribu December 2, 2025 21:14
@riot-ci
Copy link

riot-ci commented Dec 2, 2025

Murdock results

✔️ PASSED

e32942d cpu/esp_common: fix FreeRTOS rmutex handling

Success Failures Total Runtime
10561 0 10561 13m:45s

Artifacts

@maribu maribu added this pull request to the merge queue Dec 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 3, 2025
@maribu maribu added this pull request to the merge queue Dec 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 3, 2025
@maribu maribu added this pull request to the merge queue Dec 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 3, 2025
@maribu maribu added this pull request to the merge queue Dec 3, 2025
Merged via the queue into RIOT-OS:2025.10-branch with commit adfdbba Dec 3, 2025
31 checks passed
@benpicco benpicco deleted the backport/2025.10/cpu/esp_common/fix_freertos_mutex branch December 3, 2025 17:07
@benpicco benpicco added this to the Release 2025.10 milestone Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms Process: release backport Integration Process: The PR is a release backport of a change previously provided to master Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants