-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cpu/esp32: add ESP32-H2 support #21522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
terrific news!
Just quickly skimmed the PR:
unsigned len = 0; | ||
for (; psdu; psdu = psdu->iol_next) { | ||
if (psdu->iol_len) { | ||
memcpy(&_tx_frame[len + 1], psdu->iol_base, psdu->iol_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why len + 1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the IEEE802.15.4 driver of the ESP-IDF expects that byte 0 in the TX frame array is the length of the frame to be sent.
esp_ieee802154_set_rx_when_idle(true); | ||
esp_ieee802154_receive(); | ||
esp_ieee802154_set_cca_mode(ESP_IEEE802154_CCA_MODE_ED); | ||
esp_ieee802154_set_ack_timeout(3456); /* should be a multiple of 16 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not IEEE802154_ACK_TIMEOUT_SYMS * IEEE802154_SYMBOL_TIME_US
(864 µs)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar enough with IEEE 802.15.4 to know what the correct timeout value is. In ESP-IDF, esp_ieee802154_set_ack_timeout
is documented as follows:
* @param[in] timeout The time to wait for the ack frame, in us.
* It Should be a multiple of 16. The default value is 1728 us (108 * 16).
If I remember correctly, it didn't work with this default value, so I just tried it with the double which works.
cpu/esp32/include/periph_cpu.h
Outdated
#if defined(CPU_FAM_ESP32H2) && defined(CONFIG_IEEE802154_ENABLED) | ||
/* ESP32H2 has IEEE802.15.4 radio which has an EUI64 address. Function | ||
* esp_efuse_mac_get_default will return this 8 byte address if | ||
* CONFIG_IEEE802154_ENABLED */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it still have a separate CPU ID though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESPs don't have a CPU ID. Therefore, the MAC address burned in eFuse is usually used as CPU ID. For ESP32-H2, the function used to get the MAC address returns the 8 byte EUI64.
|
||
ifneq (esp32h2,$(CPU_FAM)) | ||
# All ESP* MCUs have a peripheral network interface | ||
FEATURES_PROVIDED += netif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the 802.15.4 radio?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It comes now as follow-up PR 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have the hardware (yet) to test it, but so far these are mostly styling related comments.
However in general I think it would've been good if this PR had been three PRs. One for the board, one for NimBLE and one for the 802.15.4 changes. This is quite a hefty chunk 😅
/** | ||
* @brief Indicates whether Setup NimBLE's controller has been initialized | ||
* | ||
* nimble_port_initialized` is false by default and is set to true as soon as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* nimble_port_initialized` is false by default and is set to true as soon as | |
* `nimble_port_initialized` is false by default and is set to true as soon as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not part of the PR any longer.
* @brief Indicates whether Setup NimBLE's controller has been initialized | ||
* | ||
* nimble_port_initialized` is false by default and is set to true as soon as | ||
* `nimble_port_init` has been called by nimble_riot_init, i.e. that the NimBLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `nimble_port_init` has been called by nimble_riot_init, i.e. that the NimBLE | |
* `nimble_port_init` has been called by nimble_riot_init(), i.e. that the NimBLE |
* of the low-level BLE controller driver starts sending events to the host | ||
* before the NimBLE stack has been initialized by the lower-prioritized | ||
* host thread. */ | ||
extern bool nimble_port_initialized; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change might fix the crashes I saw in #21206.
#ifndef ESP_IEEE802154_MAC_STACKSIZE | ||
#define ESP_IEEE802154_MAC_STACKSIZE (IEEE802154_STACKSIZE_DEFAULT) | ||
#endif | ||
|
||
#ifndef ESP_IEEE802154_MAC_PRIO | ||
#define ESP_IEEE802154_MAC_PRIO (GNRC_NETIF_PRIO) | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifndef ESP_IEEE802154_MAC_STACKSIZE | |
#define ESP_IEEE802154_MAC_STACKSIZE (IEEE802154_STACKSIZE_DEFAULT) | |
#endif | |
#ifndef ESP_IEEE802154_MAC_PRIO | |
#define ESP_IEEE802154_MAC_PRIO (GNRC_NETIF_PRIO) | |
#endif | |
#ifndef ESP_IEEE802154_MAC_STACKSIZE | |
# define ESP_IEEE802154_MAC_STACKSIZE (IEEE802154_STACKSIZE_DEFAULT) | |
#endif | |
#ifndef ESP_IEEE802154_MAC_PRIO | |
# define ESP_IEEE802154_MAC_PRIO (GNRC_NETIF_PRIO) | |
#endif |
@benpicco @crasbe Many thanks for your first look to this PR. I will take fix it next days. Yes, the PR is pretty big 😎 But do you really think it makes sense to split it into three PRs. Without having IEEE802.15.4 radio or BLE, the ESP32-H2 has no network interface. Unlike the other ESP32x variants, the ESP32-H2 has no WiFi interface. For me it would not be a problem to split it as you suggested, as I have sorted the commits exactly in the order you suggested anyway, because I implemented them in that order. |
Not sure if it makes sense to split it now, but it would've been better if it had been split to begin with. There are already many things to test without network interfaces on a new board and with the other two changes, the PR should be tested with other hardware too (not that I would have the required hardware though...). |
After removing the |
@crasbe @benpicco Do you see a real chance to get the PR merged before release 2025-07? I'm not sure whether the soft freeze or the hard freeze would be the deadline for this PR because I'm not sure whether its impact is high enough for the soft freeze. The Zephyr project already supports the EPS32-C6, but not the ESP32-H2. Both are the first ESP32 SoCs to support IEEE 802.15.4. I have RIOT-OS already working ESP32-C6 but it is implemented on top of this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is good for merging. I wanted to get an H2 board for testing it myself, but so far I haven't issued the Reichelt order yet :/
However I do trust your testing, so this should not postpone this.
@crasbe Thanks for reviewing and approving. So, may I squash? |
Yes, please squash. I was waiting if @benpicco has something else to note, but if not, you can hit merge at your own discretion. |
4e9d5c3
to
986cda8
Compare
Contribution description
This PR adds the support for the ESP32-H2 variant, a RISC-V based ESP32x SoC with IEEE802.15.4 and Bluetooth 5 (LE). It includes a board definition for the Espressif development board ESP32-H2-DevKitM-1.
Testing procedure
Basic tests for peripherals and ESP-specific modules have to work. Following peripherals and modules have been tested successfully:
[-] not supported by ESP32-H2
Issues/PRs references