Skip to content

Conversation

gschorcht
Copy link
Contributor

@gschorcht gschorcht commented Jul 9, 2025

Contribution description

This PR provides the support for the IEEE 802.15.4 interface for the ESP32-H2.

Testing procedure

Flash the test application examples/networking/gnrc/gnrc_networking

BOARD=esp32h2-devkit make -C examples/networking/gnrc/gnrc_networking flash term

which uses the IEEE 802.15.4 interface as netdev_default. It should be possible to ping other IEEE 802.15.4 nodes.

IEEE 802.15.4 for ESP32-H2 has been tested with an esp32h2-devkit board together with a waveshare-nrf52840-eval-kit board:

main(): This is RIOT! (Version: 2025.07-devel-513-g0af92-cpu/esp32/add_esp32h2_ieee802154)
RIOT network stack example application
All up, running the shell now
> ifconfig
Iface  8  HWaddr: 5B:72  Channel: 26  NID: 0x23  PHY: O-QPSK 
          Long HWaddr: EE:DD:84:74:AB:D8:DB:72 
           TX-Power: 0dBm  State: IDLE 
          ACK_REQ  L2-PDU:102  MTU:1280  HL:64  RTR  
          RTR_ADV  6LO  IPHC  
          Source address length: 8
          Link type: wireless
          inet6 addr: fe80::ecdd:8474:abd8:db72  scope: link  VAL
          inet6 group: ff02::2
          inet6 group: ff02::1
          inet6 group: ff02::1:ffd8:db72
          inet6 group: ff02::1a
          
          Statistics for Layer 2
            RX packets 0  bytes 0
            TX packets 3 (Multicast: 3)  bytes 0
            TX succeeded 0 errors 0
          Statistics for IPv6
            RX packets 0  bytes 0
            TX packets 3 (Multicast: 3)  bytes 178
            TX succeeded 3 errors 0

> 
> ping fe80::5c8f:194d:70fd:c9e6
12 bytes from fe80::5c8f:194d:70fd:c9e6%8: icmp_seq=0 ttl=64 rssi=1 dBm time=12.952 ms
12 bytes from fe80::5c8f:194d:70fd:c9e6%8: icmp_seq=1 ttl=64 rssi=1 dBm time=13.746 ms
12 bytes from fe80::5c8f:194d:70fd:c9e6%8: icmp_seq=2 ttl=64 rssi=1 dBm time=11.358 ms
You are running RIOT on a(n) waveshare-nrf52840-eval-kit board.
This board features a(n) nrf52 CPU.
main(): This is RIOT! (Version: 2025.07-devel-516-g4e85e-cpu/esp32/add_esp32h2_ieee802154)
RIOT network stack example application
All up, running the shell now
> ifconfig
Iface  6  HWaddr: 49:E6  Channel: 26  NID: 0x23  PHY: O-QPSK 
          Long HWaddr: 5E:8F:19:4D:70:FD:C9:E6 
           TX-Power: 0dBm  State: IDLE 
          ACK_REQ  L2-PDU:102  MTU:1280  HL:64  RTR  
          RTR_ADV  6LO  IPHC  
          Source address length: 8
          Link type: wireless
          inet6 addr: fe80::5c8f:194d:70fd:c9e6  scope: link  VAL
          inet6 group: ff02::2
          inet6 group: ff02::1
          inet6 group: ff02::1:fffd:c9e6
          inet6 group: ff02::1a
          
          Statistics for Layer 2
            RX packets 4  bytes 158
            TX packets 5 (Multicast: 5)  bytes 0
            TX succeeded 0 errors 0
          Statistics for IPv6
            RX packets 4  bytes 242
            TX packets 5 (Multicast: 5)  bytes 306
            TX succeeded 5 errors 0

> 
> ping fe80::ecdd:8474:abd8:db72
12 bytes from fe80::ecdd:8474:abd8:db72%6: icmp_seq=0 ttl=64 rssi=-44 dBm time=6.785 ms
12 bytes from fe80::ecdd:8474:abd8:db72%6: icmp_seq=1 ttl=64 rssi=-43 dBm time=8.704 ms
12 bytes from fe80::ecdd:8474:abd8:db72%6: icmp_seq=2 ttl=64 rssi=-43 dBm time=8.828 ms

Issues/PRs references

@github-actions github-actions bot added Area: network Area: Networking Area: tests Area: tests and testing framework Area: build system Area: Build system Area: pkg Area: External package ports Area: drivers Area: Device drivers Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: cpu Area: CPU/MCU ports Area: sys Area: System labels Jul 9, 2025
@crasbe crasbe added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jul 9, 2025
Copy link
Contributor

@crasbe crasbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly (as usual) some styling related comments. I haven't tested it, as I don't have the hardware for it.

I'm not familiar how this is integrated into the rest of RIOT's network code and how a user would use it, but I wonder if it wouldn't be good to add some more documentation about the inner workings of the code. Either in Doxygen format or in the long cpu/esp32/esp-ieee802154/esp_ieee802152_hal.c (yes, it's mostly wrapper functions, but only mostly).

Comment on lines 36 to 37
* @return 0 on success
* @return negative errno on error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return 0 on success
* @return negative errno on error
* @retval 0 on success
* @retval negative errno on error

It might be nice to write which errno it would return. However in the current implementation, it will always return 0, even on failure.

Is it planned to change that behavior? Perhaps it would make sense to adapt the documentation otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it planned to change that behavior?

I'm not sure. The function is called by auto_init_esp_ieee80215, which has no return value. So whatever esp_ieee802154_init returns is not used anyway.

We could embed each API function call in a series of if () else constructs and return a more meaningful return value, but does that make sense if no one evaluates it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Difficult indeed. Will esp_ieee802154_init only ever be called by auto_init_esp_ieee80215 or could it be expected that it'll be called by a custom program as well?

In the former case I'd say we could omit the return value, in the latter case it would be nice to handle the return.

In both cases, the documentation should reflect the actual behavior.

Copy link
Contributor Author

@gschorcht gschorcht Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Theoretically, if someone doesn't use auto_init it could be that esp_ieee802154_init is called by the application.

On the othe hand, it is implemented exactly in the same way as all other IEEE 802.15.4 drivers, e.g., mrjf24j40, kw2xrf_radio and nrf802154. All of them document

 * @return                  0 on success
 * @return                  <0 on error

but simply return 0.

@gschorcht gschorcht force-pushed the cpu/esp32/add_esp32h2_ieee802154 branch from 1e1b744 to 0af92ee Compare July 9, 2025 22:42
@gschorcht gschorcht added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet labels Jul 9, 2025
@gschorcht gschorcht requested a review from kaspar030 as a code owner July 10, 2025 05:58
@github-actions github-actions bot added the Area: CI Area: Continuous Integration of RIOT components label Jul 10, 2025
@riot-ci
Copy link

riot-ci commented Jul 10, 2025

Murdock results

✔️ PASSED

705a240 tests/net/ieee802154_submac: add ESP32x IEEE 802.15.4 suppport

Success Failures Total Runtime
10536 0 10538 26m:20s

Artifacts

@gschorcht gschorcht requested a review from benpicco July 10, 2025 14:47
@gschorcht gschorcht added this to the Release 2025.07 milestone Jul 14, 2025
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

Comment on lines +31 to +33
#define _USE_SET_RX 1
#define _USE_SET_IDLE 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case where those would not be set to 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I used them to be able to enable/disable the corresponding code quickly. I would prefer to leave them there for future testing.

return -EINVAL;
}

void esp_ieee802154_cca_done(bool channel_busy)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those appear unused - are they called from within the IDF?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, these are callbacks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better add a comment that the section is for IDF callbacks

@gschorcht
Copy link
Contributor Author

@benpicco Thanks for the approval, what about the change in commit 96492a2? It produces 14 bytes less code because iolist_size function isn't linked.

@benpicco
Copy link
Contributor

Fine with me!

@gschorcht gschorcht force-pushed the cpu/esp32/add_esp32h2_ieee802154 branch from 96492a2 to 705a240 Compare July 15, 2025 12:36
@github-actions github-actions bot removed the Area: CI Area: Continuous Integration of RIOT components label Jul 15, 2025
@benpicco benpicco enabled auto-merge July 15, 2025 12:37
@benpicco benpicco added this pull request to the merge queue Jul 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Jul 16, 2025
@gschorcht gschorcht added this pull request to the merge queue Jul 16, 2025
@gschorcht
Copy link
Contributor Author

Although the full build in Murdock was successful, the PR was removed from merge queue due to no response for status checks. The same with PR #21604.

Merged via the queue into RIOT-OS:master with commit fe448a4 Jul 16, 2025
25 checks passed
@gschorcht gschorcht deleted the cpu/esp32/add_esp32h2_ieee802154 branch July 16, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: network Area: Networking Area: pkg Area: External package ports Area: sys Area: System Area: tests Area: tests and testing framework 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 Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants