Skip to content

drivers: wifi: Add WiFi drivers for ESP hosted firmware. #87685

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

Merged

Conversation

iabdalkader
Copy link
Contributor

@iabdalkader iabdalkader commented Mar 26, 2025

This is a host driver for ESP32 chips running the esp-hosted firmware, which turns ESP32s into a WLAN/BT co-processor. See https://github.com/espressif/esp-hosted

Note I'll update this PR to enable the driver for Arduino Portenta C33, once that board is upstream.

@github-actions github-actions bot added the area: Wi-Fi Wi-Fi label Mar 26, 2025
@jukkar jukkar assigned sylvioalves and unassigned jukkar Mar 26, 2025
@jukkar jukkar added the platform: ESP32 Espressif ESP32 label Mar 26, 2025
@jukkar jukkar requested a review from sylvioalves March 26, 2025 13:33
@iabdalkader iabdalkader force-pushed the upstream_c33_wifi_support branch from a7648d9 to 75c92a6 Compare March 26, 2025 13:38
@iabdalkader
Copy link
Contributor Author

iabdalkader commented Mar 26, 2025

This driver does Not run on ESP32, it runs on other host microcontrollers that control ESP32 as a co-processor. So, I don't think this PR is tagged correctly.

@iabdalkader iabdalkader force-pushed the upstream_c33_wifi_support branch from 75c92a6 to 25a8141 Compare March 26, 2025 13:47
@jukkar
Copy link
Member

jukkar commented Mar 26, 2025

It mentions ESP32 so I assigned to @sylvioalves. Sylvio, please re-assign if this is not related to your areas.

@iabdalkader iabdalkader force-pushed the upstream_c33_wifi_support branch from 25a8141 to e462660 Compare March 26, 2025 21:46
This is a host driver for ESP32 chips running the esp-hosted
firmware, which turns ESP32s into a WLAN/BT co-processor.

Signed-off-by: Ibrahim Abdalkader <[email protected]>
@iabdalkader iabdalkader force-pushed the upstream_c33_wifi_support branch 2 times, most recently from 2a185ed to 66939c5 Compare March 27, 2025 14:40
@sylvioalves
Copy link
Collaborator

I am planning to give it a try soon. LGTM.

@sylvioalves
Copy link
Collaborator

@iabdalkader Are there any blockers to get this merged?

@iabdalkader
Copy link
Contributor Author

@iabdalkader Are there any blockers to get this merged?

I was waiting on the Portenta-C33 board support to be merged first, so I can enable the driver and make sure everything is okay. I guess it could also be merged now. CC @pillo79 @facchinm

@facchinm
Copy link
Collaborator

Cross linking the PR fro Portenta C33 support #85337

@kartben kartben merged commit a4b9e71 into zephyrproject-rtos:main May 26, 2025
26 checks passed
@iabdalkader iabdalkader deleted the upstream_c33_wifi_support branch May 27, 2025 06:24
@m-cz
Copy link

m-cz commented Jun 16, 2025

Which version of the esp-hosted firmware is supported? I can see that this PR adds

typedef enum {
	ESP_HOSTED_STA_IF = 0,
	[...]
} esp_hosted_interface_t;

but in esp_hosted interfaces start with ESP_INVALID_IF and ESP_STA_IF is 1. Also the endpoind names are different, "ctrlResp" and "ctrlEvnt" in the PR vs "RPCRsp" and "RPCEvt" in esp_hosted.

@mantriyogesh
Copy link

@m-cz, Please note thaThis is not added directly by Espressif.

When it should happen, we would use https://github.com/espressif/esp-hosted-mcu as a base, as it is a dedicated repository to handle the MCU port.

@iabdalkader
Copy link
Contributor Author

Which version of the esp-hosted firmware is supported? I can see that this PR adds

This driver is for esp_hosted_fg, and it's mainly intended to support the firmware that ships with Arduino's Portenta-C33 boards (I believe it's release/fg-v0.0.5, have to double check to be sure). Note that ESP has changed the protocol for FG in a way that seems to break backward compatibility, so new builds will probably not work.

@mantriyogesh
Copy link

@iabdalkader Thanks for the contribution!

The driver is based on ESP-Hosted FG, and the current code remains compatible with the latest esp-hosted-fg master.

Please note, the MCU part has been deprecated in esp-hosted-fg and is now maintained separately at esp-hosted-mcu, which is aligned with newer ESP-IDF versions and ESP32-Cx (any ESP as host or slave) targets.

For ESP32-based hosts with Zephyr, we recommend using esp-hosted-mcu for the MCU side. The FG repo still actively supports the Linux host side.

@iabdalkader
Copy link
Contributor Author

The driver is based on ESP-Hosted FG, and the current code remains compatible with the latest esp-hosted-fg master.

I don't think so. I compared the proto files, and other than the new request/response pairs and events, which I assume we can safely ignore, the protocol has been changed in a breaking way. The main change is adding band_mode to some request and response messages (such as CtrlMsg_Req_ConnectAP) in espressif/esp-hosted@488a063. This would make the latest firmware incompatible with this driver as it will send/recv different packed messages. Couldn't this have been avoided by using new message to set the band mode?

For ESP32-based hosts with Zephyr, we recommend using esp-hosted-mcu for the MCU side

We don't have any plans to add support for that as our boards ship with FG firmware.

@mantriyogesh
Copy link

Yes, band_mode was added to support 5G-capable chipsets.

Protobuf itself is backward-compatible. i.e., older firmware can safely ignore unknown fields (although I would still treat this as a logical inconsistency, as discussed in the later part of the comment) as long as they're added using new field numbers. For instance, in esp-hosted@488a063 example, the field:

int32 band_mode = 6;

is added with a new tag number (6), so existing firmware without knowledge of band_mode will ignore it during decoding.

You would be correct; the older firmware would not support 5G-capable devices. But it is expected, as it is a new addition.

But this would pose a problem if you are using a newer host and an older slave. not at the protobuf level, but logical inconsistencies. For example,
the application starts a 5G capable scan. But old slaves would ignore this 5G argument and still treat it as if it were a 2G scan.

For this reason, we always recommend using the same code commit at the host and the slave in case of ESP-Hosted-FG.

@iabdalkader
Copy link
Contributor Author

iabdalkader commented Jun 18, 2025

Protobuf itself is backward-compatible. i.e., older firmware can safely ignore unknown fields

Other than unknown fields, the new events that were added, such as Event_StationConnectedToAP, must be handled by this driver, otherwise it will just queue them as responses to requests. It should be relatively easy to support those new events and also add band_mode, but the CtrlMsg itself also has been changed. The new one has uid and req_resp_type before the uinion/payload. Will those also be ignored? Or does the host driver have to set them? I still don't think it will work with newer firmware.

For this reason, we always recommend using the same code commit at the host and the slave in case of ESP-Hosted-FG.

It's easier to update the host than the firmware, we already shipped thousands of boards flashed with older firmware.

@mantriyogesh Thanks for taking the time to reply and explain this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Wi-Fi Wi-Fi platform: ESP32 Espressif ESP32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants