-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
kartben
merged 1 commit into
zephyrproject-rtos:main
from
iabdalkader:upstream_c33_wifi_support
May 26, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (c) 2025 Arduino SA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
if (CONFIG_WIFI_ESP_HOSTED) | ||
|
||
zephyr_library_named(esp_hosted) | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${ZEPHYR_BASE}/modules/nanopb) | ||
include(nanopb) | ||
|
||
zephyr_library_sources( | ||
esp_hosted_hal.c | ||
esp_hosted_wifi.c | ||
) | ||
|
||
zephyr_nanopb_sources(esp_hosted | ||
esp_hosted_proto.pb | ||
) | ||
|
||
zephyr_include_directories( | ||
./ | ||
) | ||
|
||
zephyr_compile_definitions( | ||
PB_ENABLE_MALLOC=1 | ||
) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# ESP Hosted WiFi driver options | ||
|
||
# Copyright (c) 2025 Arduino SA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
menuconfig WIFI_ESP_HOSTED | ||
bool "ESP_HOSTED driver support" | ||
depends on DT_HAS_ESPRESSIF_ESP_HOSTED_ENABLED | ||
default y | ||
select GPIO | ||
select SPI | ||
select WIFI_OFFLOAD | ||
select WIFI_NM | ||
select NANOPB | ||
select NET_L2_ETHERNET | ||
select NET_L2_WIFI_MGMT | ||
select WIFI_USE_NATIVE_NETWORKING | ||
|
||
if WIFI_ESP_HOSTED | ||
|
||
config WIFI_ESP_HOSTED_DEBUG | ||
bool "Extra debugging messages" | ||
|
||
config WIFI_ESP_HOSTED_EVENT_TASK_PRIORITY | ||
int "Event task priority" | ||
default 4 | ||
|
||
config WIFI_ESP_HOSTED_EVENT_TASK_STACK_SIZE | ||
int "Event task stack size" | ||
default 16384 | ||
|
||
config WIFI_ESP_HOSTED_EVENT_TASK_POLL_MS | ||
int "Event task poll rate in ms" | ||
default 20 | ||
|
||
config WIFI_ESP_HOSTED_AP_CLIENTS_MAX | ||
int "Max number of AP clients" | ||
default 5 | ||
|
||
config WIFI_ESP_HOSTED_AP_CHANNEL_DEF | ||
int "Default AP channel" | ||
default 9 | ||
|
||
endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (c) 2025 Arduino SA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
#include <zephyr/kernel.h> | ||
#include "esp_hosted_wifi.h" | ||
|
||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_REGISTER(esp_hosted_hal, CONFIG_WIFI_LOG_LEVEL); | ||
|
||
int esp_hosted_hal_init(const struct device *dev) | ||
{ | ||
const esp_hosted_config_t *config = dev->config; | ||
|
||
if (!spi_is_ready_dt(&config->spi_bus)) { | ||
LOG_ERR("SPI device is not ready"); | ||
return -ENODEV; | ||
} | ||
|
||
/* Configure pins. */ | ||
gpio_pin_configure_dt(&config->dataready_gpio, GPIO_OUTPUT); | ||
gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT); | ||
|
||
/* Perform a hard-reset */ | ||
gpio_pin_set_dt(&config->dataready_gpio, 1); | ||
gpio_pin_set_dt(&config->reset_gpio, 0); | ||
k_msleep(100); | ||
gpio_pin_set_dt(&config->reset_gpio, 1); | ||
k_msleep(500); | ||
|
||
/* Configure handshake/dataready pins. */ | ||
gpio_pin_configure_dt(&config->dataready_gpio, GPIO_INPUT); | ||
gpio_pin_configure_dt(&config->handshake_gpio, GPIO_INPUT); | ||
|
||
return 0; | ||
} | ||
|
||
bool esp_hosted_hal_data_ready(const struct device *dev) | ||
{ | ||
const esp_hosted_config_t *config = dev->config; | ||
|
||
return gpio_pin_get_dt(&config->dataready_gpio); | ||
} | ||
|
||
int esp_hosted_hal_spi_transfer(const struct device *dev, void *tx, void *rx, uint32_t size) | ||
{ | ||
int ret = 0; | ||
esp_hosted_data_t *data = dev->data; | ||
const esp_hosted_config_t *config = dev->config; | ||
|
||
const struct spi_buf tx_buf = {.buf = tx ? tx : rx, .len = size}; | ||
const struct spi_buf_set tx_set = {.buffers = &tx_buf, .count = 1}; | ||
|
||
const struct spi_buf rx_buf = {.buf = rx ? rx : tx, .len = size}; | ||
const struct spi_buf_set rx_set = {.buffers = &rx_buf, .count = 1}; | ||
|
||
/* Wait for handshake pin to go high. */ | ||
for (uint64_t start = k_uptime_get();; k_msleep(1)) { | ||
if (gpio_pin_get_dt(&config->handshake_gpio) && | ||
(rx == NULL || gpio_pin_get_dt(&config->dataready_gpio))) { | ||
break; | ||
} | ||
if ((k_uptime_get() - start) >= 100) { | ||
return -ETIMEDOUT; | ||
} | ||
} | ||
|
||
if (k_sem_take(&data->bus_sem, K_FOREVER) != 0) { | ||
return -1; | ||
} | ||
|
||
/* Transfer SPI buffers. */ | ||
if (spi_transceive_dt(&config->spi_bus, &tx_set, &rx_set)) { | ||
LOG_ERR("spi_transceive failed"); | ||
ret = -EIO; | ||
} | ||
|
||
k_sem_give(&data->bus_sem); | ||
return ret; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright (c) 2025 Arduino SA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDED_DRIVERS_ESP_HOSTED_HAL_H | ||
#define ZEPHYR_INCLUDED_DRIVERS_ESP_HOSTED_HAL_H | ||
int esp_hosted_hal_init(const struct device *dev); | ||
bool esp_hosted_hal_data_ready(const struct device *dev); | ||
int esp_hosted_hal_spi_transfer(const struct device *dev, void *tx, void *rx, uint32_t size); | ||
#endif /* ZEPHYR_INCLUDED_DRIVERS_ESP_HOSTED_HAL_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.ssid max_size:32 max_length:31 | ||
*.bssid max_size:17 | ||
*.mac max_size:17 | ||
*.pwd max_size:64 max_length:63 | ||
*.entries type:FT_POINTER | ||
*.stations type:FT_POINTER | ||
*.init_data max_size:0 | ||
esp_hosted_proto.pb max_size:256 max_count:64 anonymous_oneof:true type:FT_STATIC |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.