GithubHelp home page GithubHelp logo

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

zephyr_wifi's Issues

Failed to resolve address

Hello,

I found this project useful to demonstrate connecting to a wifi ap... Unfortunately that is about all the code does at this time.

For me the part which tries to resolve the hostname to ipv4 address constantly fails. Here is the log:

--- idf_monitor on /dev/ttyUSB0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6604
ho 0 tail 12 room 4
load:0x40078000,len:15224
ho 0 tail 12 room 4
load:0x40080400,len:3992
entry 0x40080634
I (30) boot: ESP-IDF 8d8d537fa 2nd stage bootloader
I (30) boot: compile time 09:43:37
I (30) boot: chip revision: 1
I (33) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (41) boot.esp32: SPI Speed      : 40MHz
I (45) boot.esp32: SPI Mode       : DIO
I (50) boot.esp32: SPI Flash Size : 4MB
I (54) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (85) boot:  2 factory          factory app      00 00 00010000 00100000
I (93) boot: End of partition table
I (97) boot_comm: chip revision: 1, min. application chip revision: 0
I (104) esp_image: segment 0: paddr=00010020 vaddr=00000020 size=0001ch (    28) 
I (113) esp_image: segment 1: paddr=00010044 vaddr=3ffb0000 size=0168ch (  5772) load
I (123) esp_image: segment 2: paddr=000116d8 vaddr=3ffb168c size=00550h (  1360) load
I (130) esp_image: segment 3: paddr=00011c30 vaddr=40080000 size=07f60h ( 32608) load
I (152) esp_image: segment 4: paddr=00019b98 vaddr=00000000 size=064a0h ( 25760) 
I (161) esp_image: segment 5: paddr=00020040 vaddr=3f400040 size=09040h ( 36928) map
I (175) esp_image: segment 6: paddr=00029088 vaddr=00000000 size=06f90h ( 28560) 
I (186) esp_image: segment 7: paddr=00030020 vaddr=400d0020 size=4d9c0h (317888) map
I (306) boot: Loaded app from partition at offset 0x10000
I (306) boot: Disabling RNG early entropy source...
*** Booting Zephyr OS build v3.4.0-rc1 ***
WiFi Example
Board: esp32
Connecting to SSID: softwaremagic
Connected
SSID: softwaremagic                   
Band: 2.4GHz
Channel: 11
Security: WPA2-PSK
RSSI: -52
IPv4 address: 192.168.0.116
Subnet: 255.255.255.0
Router: 192.168.0.1
Ready...
Looking up IP addresses:
getaddrinfo() failed, err 12


Backtrace:0x400d63d5:0x3ffe9470 0x400d669d:0x3ffe94d0 0x40083ecf:0x3ffe9500 0x400d685b:0x3ffe9520 
0x400d63d5: print_addrinfo_results at /home/michael_uman/gitroot/Zephyr_WiFi/build/../src/http_get.c:41

0x400d669d: main at /home/michael_uman/gitroot/Zephyr_WiFi/build/../src/wifi.c:192

0x40083ecf: bg_thread_main at /home/michael_uman/zephyrproject/zephyr/kernel/init.c:344

0x400d685b: z_thread_entry at /home/michael_uman/zephyrproject/zephyr/lib/os/thread_entry.c:36



getaddrinfo() fails with code 12 (not sure what it means). Has anyone else resolved this problem?

I believe I am using Zephyr tag v3.4.0-rc1 at the moment...

Thank you,
Michael Uman

Cannot get wifi status

Hey there,
I am using an ESP32-Devkit.
I tried using your firmware and I am getting wifi status request failed.

Here are the logs :

WiFi Example
Board: esp32
Connecting to SSID: ******
Connected
WiFi Status Request Failed

Timeout while waiting network interface - nrf7002DK

Hi,

I am new to using Zephyr and Wi-Fi and am currently attempting to implement this code on the nRF7002 DK. I have run into an error that I cannot seem to resolve on my own. I would appreciate any guidance you can provide. I am particularly concerned about whether I need to make adjustments to the devicetree bindings when switching from QSPI to SPI.
May be something like "const struct device *dev = DEVICE_DT_GET();

Thank you very much for your help.

image

No working on zephyr v3.3

Unfortunately the code doesn't work on zephyr v3.3 this is the output:
`�*** Booting Zephyr OS build zephyr-v3.3.0-1125-gb9dabf04f0e0 ***
WiFi Example
Board: esp32
Connecting to SSID: Naser
Connected
WiFi Status Request Failed
Disconnected

`
It says it's connected but when I see the connected devices on my phone, actually esp32 is not connected.
I tested the code using zephyr v3.2. Although it can't get the status, it connects with no problem.

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.