Skip to content

arch/xtensa: properly set carrier on/off on espnow driver#18778

Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom
fdcavalcanti:bugfix/add-netdev-carrier-espnow
Apr 30, 2026
Merged

arch/xtensa: properly set carrier on/off on espnow driver#18778
xiaoxiang781216 merged 1 commit intoapache:masterfrom
fdcavalcanti:bugfix/add-netdev-carrier-espnow

Conversation

@fdcavalcanti
Copy link
Copy Markdown
Contributor

Summary

  • arch/xtensa: properly set carrier on/off on espnow driver

In esp_espnow_pktradio.c, after ESP-NOW is successfully initialized in espnow_ifup, call netdev_carrier_on(dev).
In espnow_ifdown, call netdev_carrier_off(dev).

NuttX only sets IFF_RUNNING (carrier) when the driver calls netdev_carrier_on(). The ESP-NOW 6LoWPAN interface came up with IFF_UP but without RUNNING, so the stack still treated wpan0 as “not running.” That broke UDP paths that require IFF_IS_RUNNING (e.g. DHCPC over the interface) and other behavior that keys off “RUNNING” in ifconfig. Other radio/6LoWPAN drivers (e.g. xbee) already use the same netdev_carrier_on / netdev_carrier_off pairing.

Impact

Impact on user: Yes. Fixes espnow functionality.

Impact on build: No.

Impact on hardware: Only affects ESP32.

Impact on documentation: No.

Impact on security: No.

Impact on compatibility: No.

Testing

espnow two-board serial tests passed after the change (previous failure showed wpan0 as UP but not RUNNING; UDP/DHCP then failed on “device is not running”).

Building

  • ./tools/configure.sh esp32-devkitc:espnow
  • Make and flash two boards

Running

Execute the example available on the documentation.

On the board running as server:

  • ifconfig wpan0 inet6 fe80::ff:fe00:a
  • udpserver &

On the client:

  • udpclient fe80::ff:fe00:a &

Results

  • Before changes:
    No data was received on server side and had errors related to network interface.

  • After changes:
    Data exchanged as expected.

nsh> #x1B[Kserver: 1. Received 96 bytes from fe80:0000:0000:0000:0000:00ff:fe00:feff port 5472
server: 2. Receiving up 1024 bytes
server: 2. Received 96 bytes from fe80:0000:0000:0000:0000:00ff:fe00:feff port 5472
server: 3. Receiving up 1024 bytes
[dut-1] 
[dut-1] nsh> #x1B[Kserver: 3. Received 96 bytes from fe80:0000:0000:0000:0000:00ff:fe00:feff port 5472
[dut-1] server: 4. Receiving up 1024 bytes
[dut-0] client: 3. Sending 96 bytes
[dut-0] client: 3. Sent 96 bytes
[dut-0] client: 4. Sending 96 bytes
[dut-0] client: 4. Sent 96 bytes
[dut-1] server: 4. Received 96 bytes from fe80:0000:0000:0000:0000:00ff:fe00:feff port 5472
[dut-1] server: 5. Receiving up 1024 bytes
[dut-0] client: 5. Sending 96 bytes
[dut-0] client: 5. Sent 96 bytes
[dut-1] server: 5. Received 96 bytes from fe80:0000:0000:0000:0000:00ff:fe00:feff port 5472
[dut-1] server: 6. Receiving up 1024 bytes

In esp_espnow_pktradio.c, after ESP-NOW is successfully initialized in espnow_ifup, call netdev_carrier_on(dev).
In espnow_ifdown, call netdev_carrier_off(dev).

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
@github-actions github-actions Bot added Arch: xtensa Issues related to the Xtensa architecture Size: XS The size of the change in this PR is very small labels Apr 22, 2026
@xiaoxiang781216 xiaoxiang781216 merged commit 3759cc7 into apache:master Apr 30, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: xtensa Issues related to the Xtensa architecture Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants