Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/craigpeacock/zephyr_wifi
Example Zephyr WiFi code
https://github.com/craigpeacock/zephyr_wifi
esp32 esp32c3 nrf7002 wifi zephyr zephyr-rtos
Last synced: 4 months ago
JSON representation
Example Zephyr WiFi code
- Host: GitHub
- URL: https://github.com/craigpeacock/zephyr_wifi
- Owner: craigpeacock
- License: apache-2.0
- Created: 2023-01-07T04:42:26.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-17T04:42:11.000Z (6 months ago)
- Last Synced: 2024-10-10T14:01:19.711Z (4 months ago)
- Topics: esp32, esp32c3, nrf7002, wifi, zephyr, zephyr-rtos
- Language: C
- Homepage:
- Size: 47.9 KB
- Stars: 31
- Watchers: 1
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Zephyr WiFi Code
Simple example Zephyr WiFi code is targeted for the [ESP32](https://docs.zephyrproject.org/latest/boards/xtensa/esp32/doc/index.html) and [ESP32C3](https://docs.zephyrproject.org/3.1.0/boards/riscv/esp32c3_devkitm/doc/index.html), although it should be platform-agnostic.
Connects to a WiFi network, obtains an IPv4 address via DHCP and disconnects after 30 seconds.
```
*** Booting Zephyr OS build zephyr-v3.2.0-2019-g7ac69dc4ca95 ***
Connecting to SSID: Welcome_IN
Connected
IPv4 address: 192.168.0.67
Subnet: 255.255.255.0
Router: 192.168.0.254
Disconnected
```# Building for ESP32 (xtensa)
Follow the [Getting Started Guide](https://docs.zephyrproject.org/latest/develop/getting_started/index.html) to install Zephyr and the build tools.
```
git clone https://github.com/craigpeacock/Zephyr_ESP32_WiFi.git
cd Zephyr_ESP32_WiFi
west blobs fetch hal_espressif
west build -b esp32
west flash
west espressif monitor
```# Building for ESP32C3 (RISC-V)
Follow the [Getting Started Guide](https://docs.zephyrproject.org/latest/develop/getting_started/index.html) to install Zephyr and the build tools.
```
git clone https://github.com/craigpeacock/Zephyr_ESP32_WiFi.git
cd Zephyr_ESP32_WiFi
west blobs fetch hal_espressif
west build -b esp32c3_devkitm
west flash
west espressif monitor
```# Troubleshooting
*West blobs fetch hal_espressif* downloads WiFi and Bluetooth binary blobs required for the ESP32. If these are not installed, you are likely to get linker errors resulting from missing files such as
```
cannot find -lnet80211: No such file or directory
cannot find -lcore: No such file or directory
cannot find -lpp: No such file or directory
cannot find -lcoexist: No such file or directory
cannot find -lphy: No such file or directory
cannot find -lmesh: No such file or directory
```The RISC-V architecture (ESP32C3) requires the kconfig option CONFIG_HEAP_MEM_POOL_SIZE=32768 otherwise multiple errors result with undefined reference to `k_malloc'
If this value is too small, errors can result loading the WiFi driver at runtime:
```
[00:00:00.003,000] esp32_wifi_adapter: memory allocation failed
[00:00:00.005,000] esp32_wifi: Failed to start Wi-Fi driver
```# nrf7002dk_nrf5340_cpuapp (Nordic nRF7002)
This project currently builds and sucessfully connects when using nRFConnect SDK 2.2.0 and 2.3.0. Support for the nRF7002 is very new and change should be expected as the code matures over time. Below is a list of common issues encounted when porting your Zephyr WiFi code to the nRF7002 target:
## Troubleshooting
It may be observed when using SDK 2.3.0 that the following error (Unable to get wpa_s handle for wlan0) is reported at runtime:
```
WiFi Example
Board: nrf7002dk_nrf5340_cpuapp
Connecting to SSID: test_ap
[00:00:00.600,189] wpa_supp: z_wpas_start: 385 Starting wpa_supplicant thread with debug level: 3
[00:00:00.600,402] wpa_supp: Successfully initialized wpa_supplicant
[00:00:00.600,830] wpa_supp: z_wpas_get_handle_by_ifname: Unable to get wpa_s handle for wlan0
```Examing nRF7002 code from Nordic, it appears they have put a 1 second day in after registering the callbacks, and before calling wifi_connect(). This was not required in SDK 2.2.0
To prevent the following build error
```
\wifi\nrf700x\zephyr\src\shim.c:14:10: fatal error: sys/time.h: No such file or directory
```
add the following to your prj.conf:
```
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_NANO=n
```To prevent build error
```
undefined reference to `z_impl_sys_rand32_get'
```
and the following to your prj.conf:
```
CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y
```