Wifi Configuration - cu-ecen-aeld/buildroot-assignments-base GitHub Wiki

Overview

This page describes how to setup Wifi on Buildroot. A working example for Raspberry Pi can be found HERE

Introduction

Wi-Fi is most preferred wireless form of communication for mobile devices with an Wi-Fi chip embedded into it. Many a time we require to connect to the internet in order to download packages and transmit messages implementing lightweight protocol such as MQTT. This page helps to install the necessary firmware and packages which are necessary for connecting to a wireless network.

Steps to setup Wi-Fi on Buildroot:

  1. Build a default configuration of Build root for raspberry pi (3/4) with glibc toolchain.
-> make menuconfig(inside buildroot) > toolchain > C library > glibc 

Note: If you already Built the image with c library configuration(uClibc-ng) you should first clean the build and then build it again after changing. Clean build is specified HERE.

  1. Change the /dev management to Dynamic using devtmpfs + mdev
-> System Configuration > /dev management > Dynamic using devtmpfs + mdev
  1. Set the path to rootfs_overlay in System configuration and create a folder in base external
-> System Configuration > Root filesystem overlay directories > ../base_external/rootfs_overlay 
  1. Select the Wi-Fi firmware to include it in Build root. in older versions of buildroot this package is in firmware, but in newer versions its under firmware > brcmfmac-sdio-firmware-rpi.
-> Target packages > hardware handling > Firmware > rpi-wifi-firmware or brcmfmac-sdio-firmware-rpi-wifi(under brcmfmac-sdio-firmware-rpi) 
  1. Select the wpa_supplicant and others under it.
-> Target packages -> Networking applications -> wpa_supplicant 
and select nl80211 support, autoscan, wpa_passphrase binary.
  1. Add dhcpcd package
-> Target packages -> Networking applications -> dhcpcd 
  1. For SSH support add dropbear package
-> Target packages -> Networking applications -> dropbear 
  1. Make sure ifupdown scripts is selected in Networking applications.

  2. Set up the necessary files in rootfs_overlay directory as below to setup the wlan0 interface on raspberry pi. It has interfaces file to setup the wlan0 interface while S40network connects to the configured WiFi network through wpa_supplicant.conf file.

image

-> Check this for reference

-> Change the Wifi details in the wpa_supplicant.conf file with corresponding SSID, passsword and passkey management.

-> You can modify the wpa_supplicant.conf depending on your Wifi Network as below:

network={

ssid="YouR WiFi Network Name"

psk="PASSWORD"

proto=RSN

key_mgmt=WPA-PSK

pairwise=CCMP

auth_alg=OPEN

}

  1. Build the Image using the make or ./build.sh

  2. Burn the sdcard.img to the raspberry pi.

  3. Once the raspberry pi boots up, WiFi is connected automatically. You can check if the Wi-Fi is connected using "ifconfig" or "ping" commands.

  4. Congrats your Raspberry Pi is connected to a WiFi Network!

OUTPUT

The final ifconfig results should be as below and you should be able to ping www.google.com as below:

ifconfig

Ping

Common Issues and debug steps:

  1. After startup see if the brcmfmac package is loaded. by using command: lsmod

brcmfmac

  1. if brcmfmac is not laoded you can load it by modprobe brcmfmac. and then do command: [PATH TO S40network] restart (exmaple: /etc/init.d/S40network restart) to restart your network. Note: if the pi is connected on an SSH the connection shuts down and starts again.

  2. ifup wlan0 and ifdown wlan0 can be used to turn on WiFi on or off.

  3. If the Raspberry pi connects to Wifi, IP_Address can be found by command: ifconfig by using a display.

  4. Without display You can use an Advanced IP address Scanner to check the IP address of the devices that are connected to your WiFi. Then connect through SSH.

ipaddress1

  1. To connect to SSH from Laptop you can use: ssh <RPi_username>@<IP_ADDRESS>

  2. After completing above setup, you might have some trouble logging into target(pi) via SSH. You may be asked to provide password during ssh as shown below:

image

To resolve above issue, we must edit /etc/ssh/sshd_config as follows:

  1. uncomment and change PermitRootLogin parameter to yes
  2. uncomment and change PermitEmptyPasswords to yes

Now, execute "passwd" command in raspberry Pi and enter password as "root" and retype password again as "root".

Now, try logging into target (pi) via SSH as root, enter password also as root. You will successfully access the target.

REFERENCE LINKS

Please refer to the below mentioned links as referenced while building this page :

https://blog.crysys.hu

https://www.raspberrypi.org

⚠️ **GitHub.com Fallback** ⚠️