Custom Layer Creation (WiFi Driver rtl8188eus)
I will compile the following RTL8188EUS driver source code. The work will be done inside a container.
$ docker start raspi2
$ docker exec -ti raspi2 bash
To be sure, check whether the Linux kernel included in Yocto supports rtl8188eu. To check the Yocto kernel configuration, execute the following command:
# bitbake -c menuconfig virtual/kernel
Driver Source : GitHub aircrack-ng/rtl8188eus
Prepare the meta directory to create the custom layer rtl8188eus.bb.
# pwd
~/poky
bitbake-layers create-layer meta-custom
# cd meta-custom
# mkdir -p recipes-drivers/rtl8188eus
# cd recipes-drivers/rtl8188eus
# nano rtl8188eus.bb
rtl8188eus.bb will be the following;
meta-custom/recipes-drivers/rtl8188eus/rtl8188eus.bb
# rtl8188eus.bb
SUMMARY = "RTL8188EUS Wi-Fi driver"
LICENSE = "GPL-2.0-or-later"
SRC_URI = "git://github.com/aircrack-ng/rtl8188eus.git;branch=v5.3.9;protocol=https"
SRCREV = "f969c544ab6100da3d80a5709e077f920f2df698"
LIC_FILES_CHKSUM = "file://include/linux/wireless.h;beginline=1;endline=12;md5=2e8246ed3abbbb95c781b51b5c89857e"
S = "${WORKDIR}/git"
inherit module
DEPENDS = "virtual/kernel"
EXTRA_OEMAKE = "KSRC=${STAGING_KERNEL_DIR}"
do_compile() {
oe_runmake
}
do_install() {
install -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless
install -m 0644 8188eu.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/
}
SRCREV is the commit ID (SHA-1 hash value) from GitHub.
SRCREV = “f969c544ab6100da3d80a5709e077f920f2df698”
LIC_FILES_CHKSUM is the MD5 hash value of the license content (comments) at the beginning of any specified file. The extracted lines are saved in a text file (text.txt), and the hash is calculated using md5. This process is executed on the host machine.
$ md5sum text.txt
LIC_FILES_CHKSUM = “file://include/linux/wireless.h;beginline=1;endline=12;md5=2e8246ed3abbbb95c781b51b5c89857e”
Add the custom layer into ~/poky/build/conf/bblayers.conf
# bitbake-layers add-layer ~/poky/meta-custom
When multiple layers provide the same recipe or file, the priority is controlled by setting BBFILE_PRIORITY in the layer.conf file.
meta-custom/conf/layer.conf
BBFILE_PRIORITY_meta-custom = "7"
Confirm All Layer:
# bitbake-layers show-layers
In the project’s build/conf/local.conf, add rtl8188eus to IMAGE_INSTALL:append.
IMAGE_INSTALL:append = " alsa-plugins alsa-utils alsa-lib boost gettext glew libopus libsrtp libvpx v4l-utils raspi-gpio linphone-sdk openssl mpc mpd ntp rtl8188eus"
Build:
# bitbake core-image sato
Write the image to the SD card and set it up in the Raspberry Pi.
Post-Image Boot Operations
SSH into the Raspberry Pi with a wired LAN connection and check if the RTL8188EU driver module is loaded.
# lsmod
.....
.....
8188eu 1142784 0
cfg80211 872448 1 8188eu
.....
.....
To avoid conflicts with other Realtek drivers, disable the default driver module rtl8xxxu by adding it to the blacklist and then reboot.
# echo "blacklist rtl8xxxu" >> /etc/modprobe.d/blacklist.conf
# reboot
Enable WiFi:
# rfkill list all
0: phy0: wlan
Soft blocked: yes
Hard blocked: no
# rfkill unblock all
# rfkill list all
0: phy0: wlan
Soft blocked: no
Hard blocked: no
Check the network interfaces and enable the WiFi interface:
# ip link show
# ip link set wlan0 up
# ip addr
Scan for available networks and connect (confirm the connection).
# iw wlan0 scan
# iw wlan0 scan | grep SSID
# wpa_passphrase "<ssid>" "password" > /etc/wpa_supplicant.conf
# wpa_supplicant -B -i wlan0 -D nl80211 -c /etc/wpa_supplicant.conf
# iw dev wlan0 link
Connected to 50:41:b9:67:ba:5c (on wlan0)
SSID: <ssid>
freq: 2427.0
signal: -26 dBm
tx bitrate: 150.0 MBit/s
# wpa_cli status
Selected interface 'wlan0'
.....
ssid=<ssid>
id=1
mode=station
wifi_generation=4
pairwise_cipher=CCMP
group_cipher=TKIP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
ip_address=192.168.xx.xx
.....
Configure DNS settings and start the DHCP client to obtain an IPv4 address.
# echo "nameserver 8.8.8.8" > /etc/resolv.conf
# udhcpc -i wlan0
To ensure it remains enabled after reboot…
/var/lib/connman/settings
[WiFi]
Enable=true
Tethering=false
Tethering.Freq=2412
/etc/network/interfaces
# Wireless interfaces
iface wlan0 inet dhcp
wireless_mode managed
wireless_essid any
wpa-driver nl80211
wpa-conf /etc/wpa_supplicant.conf
pre-up /sbin/udhcpc -R -b -p /var/run/udhcpc.wlan0.pid -i wlan0
post-up ip link set wlan0 mtu 1500
Note : udhcpc startup error: Add pre-up , post-up options.
- To obtain an inet (IPv4 address) on wlan0, start udhcpc (the default DHCP client of BusyBox) in the background beforehand.
- The default MTU is 2312, so it is set to 1500. If this is not done, UDP packet fragmentation will occur, making communication impossible.
https://unix.stackexchange.com/questions/261872/how-is-udhcpc-executed-and-how-to-change-it