GithubHelp home page GithubHelp logo

dawei8823 / zephyr_wifi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from craigpeacock/zephyr_wifi

0.0 0.0 0.0 34 KB

Example Zephyr WiFi code

License: Apache License 2.0

C 97.50% CMake 2.50%

zephyr_wifi's Introduction

Zephyr WiFi Code

Simple example Zephyr WiFi code is targeted for the ESP32 and ESP32C3, 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 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 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] <err> esp32_wifi_adapter: memory allocation failed          
[00:00:00.005,000] <err> 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] <inf> wpa_supp: z_wpas_start: 385 Starting wpa_supplicant thread with debug level: 3
[00:00:00.600,402] <inf> wpa_supp: Successfully initialized wpa_supplicant
[00:00:00.600,830] <err> 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

zephyr_wifi's People

Contributors

craigpeacock avatar dawei8823 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.