• sales

    +86-0755-88291180

LuckFox Pico SDK1.4 configure RTL8723BS WIFI User Guide

【Basic information】

[] Only the following models are supported:Luckfox Pico Mini B /Luckfox Pico Plus /Luckfox Pico Pro /Luckfox Pico Max

[] Not supported:Luckfox PicoOther models in the series

[] Module model: LF-WIFI (A) module developed by Banli Electronics based on RTL8723BS

[] SDK used: Luckfox SDK V1.4

[] Source code address:https://github.com/LuckfoxTECH/luckfox-pico.git


】Hardware Introduction

[] RTL8723BS is a module that integrates Bluetooth and WIFI.

[]LF-WIFI (A) module: It is a module based on RTL8723BS for secondary development. It has a TF card slot shape and is driven by the SDIO interface. Due to the interface limitations of SDIO, this module only uses the RTL8723BS WIFI function and does not use the Bluetooth function.


】TF card interface hardware schematic diagram




】LF-WIFI (A) schematic diagram


Pin 12 (WL_DSI/WL_REG) is pulled high.

Pin 13 (WL_HOST_WAKE) is pulled high.


【Pre-configured images】

Luckfox Pico Mini B

Luckfox Pico Plus

Luckfox Pico Pro

Luckfox Pico Max


【Install the driver yourself (based on SDK1.4)】

Note: This tutorial uses the Luckfox Pico Max as an example!


Step 1 Modify the kernel


Content that needs to be modified

Type :Kernel WiFi Driver Support

File Path:<SDK Directory>/sysdrv/source/kernel/arch/arm/configs/luckfox_rv1106_linux_defconfig

Configuring WIFI requires modifying the kernel. Rockchip can directly modify the kernel to support WIFI function. You can directly open the kernel configuration interface through the command ./build.sh kernelconfig in the SDK root directory.

[] Notice

"M" Indicates that it is loaded into the system kernel as a module

" * " Indicates direct compilation into the kernel

(kernelconfig Tutorial:https://wiki.luckfox.com/zh/Luckfox-Pico/Luckfox-Pico-SDK/)

[] kernelconfig Instructions to configure the kernel

cd <sdk>/path 

sudo ./build.sh kernelconfig

[] Kernel configuration turns on cfg80211

Select:Networking support > Wireless >{M} cfg80211 - wireless configuration API 


[] Kernel configuration enabled build wifi ko modules

Select:Device Drivers > Network device support > Wireless LAN > Rockchip Wireless LAN support > [*] build wifi ko modules


[] Kernel configuration to enable RTL8723BS SDIO driver

Select:Device Drivers > Staging drivers >  <M>Realtek RTL8723BS SDIO Wireless LAN NIC driver



Step 2 Add buildroot package


To modify buildroot, you can use the command ./build.sh buildrootconfig, which is newly added to the 1.3 version of the SDK. Its goal is to simplify the build process of embedded Linux systems. By configuring Buildroot, you can customize the software packages and libraries included in the embedded system to meet specific needs.

(buildrootconfig TutorialSDK environment deployment (X86_64 platform) | LUCKFOX WIKI)

Add iw (optional) software package

Select:Target packages > Networking applications > [*] iw


[] Add wpa_supplicant package

Select: Target packages > Networking applications > wpa_supplicant > check all options under wpa_supplicant


The compiled wpa_supplicant source program mainly includes two executable tools: wpa_supplicant and wpa_cli.

explain:

wpa_supplicant:It runs in the background as a core service program, handling tasks such as authentication and encryption of network connections.

wpa_cli:As a client tool of wpa_supplicant, users can send commands to wpa_supplicant through wpa_cli to implement network configuration, scanning, connection and other operations.

[] Add wireless tools package

Select:Target packages > Networking applications > [*] wireless tools



explain:

Wireless Tools: It is a wireless management software tool set for Linux. It helps users configure and manage wireless devices that support Wireless Extension by providing a set of simple and easy-to-use command line tools.

Notice:

Do not clean after configuring buildroot, otherwise the above configuration will be cleared.

If you use the command ./build.sh buildrootconfig, it will be saved automatically. Then, go to the buildroot folder and make all the software packages to download. After downloading, it will also speed up the compilation of the SDK.


Step 3 Modify the device tree

Content that needs to be modified

Device

Type

File Path

Luckfox Pico Max

Main Device Tree

<SDK Directory>/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-max.dts

Luckfox Pico Pro

<SDK Directory>/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-pro.dts

Luckfox Pico Plus

<SDK Directory>/sysdrv/source/kernel/arch/arm/boot/dts/rv1103g-luckfox-pico-plus.dts

Luckfox Pico Mini B

<SDK Directory>./sysdrv/source/kernel/arch/arm/boot/dts/rv1103g-luckfox-pico-mini.dts

 




Device

Type

File Path

Luckfox Pico Max

Include Device Tree

<SDK Directory>/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-pro-max-ipc.dtsi

Luckfox Pico Pro

Luckfox Pico Plus

<SDK Directory>/sysdrv/source/kernel/arch/arm/boot/dts/rv1103-luckfox-pico-ipc.dtsi

Luckfox Pico Mini B

 Modify the device tree

Edit rv1106g-luckfox-pico-max.dts device tree

sudo nano <SDK>/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-max.dts

Add code

    vcc_1v8: vcc-1v8 {

        compatible = "regulator-fixed";

        regulator-name = "vcc_1v8";

        regulator-always-on;

        regulator-boot-on;

        regulator-min-microvolt = <1800000>;

        regulator-max-microvolt = <1800000>;

    };

 

    vcc_3v3: vcc-3v3 {

        compatible = "regulator-fixed";

        regulator-name = "vcc_3v3";

        regulator-always-on;

        regulator-boot-on;

        regulator-min-microvolt = <3300000>;

        regulator-max-microvolt = <3300000>;

    };


Change "&sdmmc" to

&sdmmc {

    max-frequency = <50000000>;

    bus-width = <4>;          

    cap-sd-highspeed;          

    cap-sdio-irq;              

    keep-power-in-suspend;      

    non-removable;              

    sd-uhs-sdr50;        

    no-1-8-v;

    supports-sdio;        

    pinctrl-names = "default";

    pinctrl-0 = <&sdmmc0_clk &sdmmc0_cmd &sdmmc0_det &sdmmc0_bus4>;

    status = "okay";

};


Change "&gmac" to

&gmac {

    status = "disabled";

};

Edit rv1106-luckfox-pico-pro-max-ipc.dtsi device tree

sudo nano <SDK>/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-pro-max-ipc.dtsi

Add "&sfc" code

&sfc {

    status = "okay";

 

    flash@0 {

        compatible = "spi-nand";

        reg = <0>;

        spi-max-frequency = <80000000>;

        spi-rx-bus-width = <4>;

        spi-tx-bus-width = <1>;

    };

};



Step 4 Enable WIFI

[] Content that needs to be modified


 

Type

File Path

Luckfox Pico Max

SDK Global Configuration

<SDK Directory>/project/cfg/BoardConfig_IPC/BoardConfig-SPI_NAND-Buildroot-RV1106_Luckfox_Pico_Max-IPC.mk

Luckfox Pico Pro

<SDK Directory>/project/cfg/BoardConfig_IPC/BoardConfig-SPI_NAND-Buildroot-RV1106_Luckfox_Pico_Pro-IPC.mk

Luckfox Pico Plus

<SDK Directory>/project/cfg/BoardConfig_IPC/BoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Plus-IPC.mk

Luckfox Pico Mini B

<SDK Directory>/project/cfg/BoardConfig_IPC/BoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Mini_B-IPC.mk

 

Edit rv1106-luckfox-pico-pro-max-ipc.dtsi device tree

sudo nano <SDK>/project/cfg/BoardConfig_IPC/BoardConfig-SPI_NAND-Buildroot-RV1106_Luckfox_Pico_Max-IPC.mk

Add the following content

#enable wifi

export RK_ENABLE_WIFI=y


Step 5 Modify the global build script

Content that needs to be modified

Type

File Path

Global Build Script

<SDK Directory>/project/build.sh

Generate firmware configuration for WiFi driver (rtl8723bs)

sudo nano <SDK>/project/build.sh

Add (or uncomment) the following to the function build_app()

build_meta --export --media_dir $RK_PROJECT_PATH_MEDIA # for rtl8723bs


Copy the contents of the external directory in the SDK to the build directory of the root file system (rootfs)

Add (or uncomment) the following to function __PACKAGE_ROOTFS()

__COPY_FILES $SDK_ROOT_DIR/external $RK_PROJECT_PACKAGE_ROOTFS_DIR


Step6 Add rtl8723bs firmware to SDK


Create a folder in the SDK root directory

mkdir -p external/lib/firmware/rtlwifi/

Download rtl8723bs wifi firmware

wge thttps://raw.githubusercontent.com/wkennington/linux-firmware/master/rtlwifi/rtl8723bs_nic.bin

Copy the rtl8723bs firmware to the sdk/external/lib/firmware/rtlwifi/ directory

cp rtl8723bs_nic.bin sdk/external/lib/firmware/rtlwifi/


Step7 Compile SDK


Specified development board

luckfox@luckfox:~/luckfox-pico$ ./build.sh lunch

Execute Compilation

luckfox@luckfox:~/Luckfox-Pico/luckfox-pico$ ./build.sh


【Step8 WiFi Test】


Manually test wifi


[] Install the driver module

cd /oem/usr/ko

insmod libarc4.ko

insmod cfg80211.ko

insmod mac80211.ko

insmod r8723bs.ko


Under normal circumstances, ifconfig -a can be used to see the wlan0 device

ifconfig -a


Turn on Wi-Fi

ifconfig wlan0 up

View surrounding networks

iwlist wlan0 scan

The surrounding network information will be displayed in turn.


Notice:Here we take the wifi with ESSID spotpear-test as an example!


Configure Wi-Fi file

Edit wpa_supplicant.conf file

vi /etc/wpa_supplicant.conf

Modify to your own wifi settings as needed

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

ap_scan=1

network={

    ssid="YOUR_SSID"

    key_mgmt=WPA-PSK

    pairwise=CCMP TKIP

    group=TKIP CCMP

    psk="YOUR_PWD"

}

explain:

ssid="YOUR_SSID" is the user's WIFI name

psk="YOUR_PWD" is the user's WiFi password


Create a socket file

mkdir -p /var/run/wpa_supplicant

This file is created to allow wpa_supplicant (Wi-Fi authentication client) to work properly.


Connect to WIFI

wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlan0


Configuring Dynamic IP

udhcpc -i wlan0


Configuring Static IP

Or you can choose to configure a static IP

ifconfig wlan0 192.168.xxx.xxx netmask 255.255.255.0 up



View connection status

wpa_cli -iwlan0 status


You can see above that wpa_state=COMPLETED, which means the connection is successful and the IP address is output.


【Automatically test Wi-Fi】


Method 1: Add a new auto-start script in the firmware

Add the S98wifi_auto_connect script file in the /etc/init.d/ directory of the firmware

nano /etc/init.d/S98wifi_auto_connect

Add the following content:

#!/bin/sh

 

### BEGIN INIT INFO

# Provides:          wifi_auto_connect

# Required-Start:    $network

# Default-Start:     S

# Default-Stop:      0 6

### END INIT INFO

 

WLAN_IF="wlan0"

 

load_wifi_modules() {

    echo "Loading Wi-Fi driver modules..."

    cd /oem/usr/ko || exit 1

    insmod libarc4.ko

    insmod cfg80211.ko

    insmod mac80211.ko

    insmod r8723bs.ko

}

 

start_wifi() {

    sleep 4

    echo "Bringing up Wi-Fi interface..."

    ifconfig $WLAN_IF up

    mkdir -p /var/run/wpa_supplicant

    wpa_supplicant -B -c /etc/wpa_supplicant.conf -i $WLAN_IF

}

 

get_ip_address() {

    echo "Requesting IP address via DHCP..."

    #udhcpc -i $WLAN_IF

#ifconfig $WLAN_IF 192.168.xxx.xxx netmask 255.255.255.0 up

 

}

 

case "$1" in

    start)

        echo "Starting Wi-Fi auto-connect..."

        load_wifi_modules

 

        # 检查 wlan0 是否存在

        if ip link show $WLAN_IF >/dev/null 2>&1; then

            start_wifi

            sleep 5  # 给 wpa_supplicant 时间连接

            get_ip_address

        else

            echo "Error: $WLAN_IF not found"

        fi

        ;;

    stop)

        echo "Stopping Wi-Fi..."

        killall wpa_supplicant

        ifconfig $WLAN_IF down

        ;;

    *)

        echo "Usage: $0 {start|stop}"

        exit 1

        ;;

esac

Ctrl+O to save, Ctrl+X to exit

Grant permissions to the S98wifi_auto_connect script

chmod 775 /etc/init.d/S98wifi_auto_connect

Restart to take effect


Method 2: Add a new auto-start script in SDK

sudo nano <SDK>project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-init/etc/init.d/S98wifi_auto_connect

Add the following content:

#!/bin/sh

 

### BEGIN INIT INFO

# Provides:          wifi_auto_connect

# Required-Start:    $network

# Default-Start:     S

# Default-Stop:      0 6

### END INIT INFO

 

WLAN_IF="wlan0"

 

load_wifi_modules() {

    echo "Loading Wi-Fi driver modules..."

    cd /oem/usr/ko || exit 1

    insmod libarc4.ko

    insmod cfg80211.ko

    insmod mac80211.ko

    insmod r8723bs.ko

}

 

start_wifi() {

    sleep 4

    echo "Bringing up Wi-Fi interface..."

    ifconfig $WLAN_IF up

    mkdir -p /var/run/wpa_supplicant

    wpa_supplicant -B -c /etc/wpa_supplicant.conf -i $WLAN_IF

}

 

get_ip_address() {

    echo "Requesting IP address via DHCP..."

    #udhcpc -i $WLAN_IF

#ifconfig $WLAN_IF 192.168.xxx.xxx netmask 255.255.255.0 up

 

}

 

case "$1" in

    start)

        echo "Starting Wi-Fi auto-connect..."

        load_wifi_modules

 

        # 检查 wlan0 是否存在

        if ip link show $WLAN_IF >/dev/null 2>&1; then

            start_wifi

            sleep 5  # 给 wpa_supplicant 时间连接

            get_ip_address

        else

            echo "Error: $WLAN_IF not found"

        fi

        ;;

    stop)

        echo "Stopping Wi-Fi..."

        killall wpa_supplicant

        ifconfig $WLAN_IF down

        ;;

    *)

        echo "Usage: $0 {start|stop}"

        exit 1

        ;;

esac

Restart compiling SDK

sudo <SDK>/build.sh lunch

sudo <SDK>/build.sh


Notice

Since the dynamic IP is configured in the S98wifi_auto_connect script, the user will not be able to enter the system through the serial terminal if the network is abnormal after restart. Therefore, the function of configuring dynamic IP is blocked in the S98wifi_auto_connect script.

Since the user's gateway address is not clear, the function of configuring a static IP is also blocked. Users need to configure a dynamic IP or a static IP by themselves.


【WIFI connection SSH and camera】


Refer to the luckfox official ssh and camera tutorial. After ifconfig finds the corresponding WIFI IP, except that you need to change the WIFI corresponding IP, the other steps are exactly the same as the official tutorial.

https://wiki.luckfox.com/zh/Luckfox-Pico/Luckfox-Pico-RV1103/Luckfox-Pico-Plus-Mini/Luckfox-Pico-pinout/CSI-Camera/

https://wiki.luckfox.com/zh/Luckfox-Pico/Luckfox-Pico-RV1103/Luckfox-Pico-Plus-Mini/SSH-Telnet-Login/