17 WIFI & BT
1 WIFI & BT Introduction
1.1 WIFI
WiFi (Wireless Fidelity) is a wireless communication technology based on IEEE 802.11 standards. Its core function is to connect devices to LAN (Local Area Network) wirelessly. Over the years, WiFi has almost been the first choice for high-speed wireless communication under short-distance conditions. It has two frequency bands available: 2.4GHz and 5GHz. It is commonly used for video streaming, OTA upgrades, etc. The communication speed is significantly higher than Bluetooth.
On hardware, it typically uses SDIO interface to communicate with the main controller chip. When used, it needs to be paired with an antenna to receive and transmit electromagnetic wave signals. Our embedded board generally uses external antennas, as shown in the figure:

For routers and other devices with high communication requirements, the antennas used are generally like this:

Some friends may be curious. In the past, feature phones with large antennas could be seen. Starting from touchscreen phones, it seems you can't see the existence of antennas anymore. Actually, in the early days, they were integrated into the phone's frame, or the phone's frame itself was the antenna. With the high integration of circuits, antenna sizes have become smaller and smaller. We can observe our own phones. The small strips on the frame are actually antennas responsible for various functions (WiFi, Bluetooth, GPS, GMS, etc.).
1.2 Classic Bluetooth (SPP) and Bluetooth Low Energy (BLE)
Regarding classic Bluetooth and Bluetooth Low Energy, you can refer to my summary table below:
| Comparison Item | BLE (Bluetooth Low Energy) | Classic Bluetooth (SPP) |
|---|---|---|
| Transmission Distance | Short distance, communication range is about 10 meters | Longer communication distance, up to 100 meters |
| Transmission Rate | 1Mbps or lower | 3Mbps or higher |
| Bluetooth Power Consumption | Extremely low power consumption, suitable for battery-powered devices | Higher power consumption: Classic Bluetooth is designed for speed and transmission capacity, requires continuous power supply |
| Hardware Cost | Low cost: BLE chips and modules are inexpensive | Slightly higher than BLE price |
| Development Difficulty | Low complexity: Simple protocol stack, easy to develop | Higher complexity: More complex protocol stack, more difficult development |
| Typical Applications | Sensors, IoT devices | Bluetooth printers, high-speed data exchange (image transmission, file transfer), etc. |

Some friends may wonder what black technology BLE uses to achieve such low power consumption?
Actually, the power consumption of BLE during data transmission is not at all lower than SPP! The key to power saving is that after transmitting data with high power consumption, it enters a sleep state for a period of time, as shown in the figure below. It only transmits data when connection events occur:

Let's look at the power consumption chart:

Understanding why BLE has low power consumption, we also understand why we don't use BLE when we have high data volume requirements, because most of the time it is in "sleep" state.
1.3 Introduction to RTL8723DS Module
RTL8723DS is an SDIO interface single-frequency single-channel Bluetooth WiFi integrated module based on the RTL8723DS chip, mainly used for smart home, IoT devices, and other embedded system designs requiring Bluetooth and WiFi functions.
This WiFi module provides SDIO interface to connect to the host processor, and provides high-speed UART interface for BT. It also has PCM interface for audio data transmission, directly connected to external audio codec through BT controller. Using 1x1 802.11b/g/n MIMO technology, theoretical WiFi throughput can reach 150Mbps.
Bluetooth supports BT2.1+EDR/BT3.0 and BT4.2, supports dual-mode Bluetooth, compatible with both BLE and SPP, meeting different development needs.
2 WIFI & BT Module Board Card Location

3 WIFI & BT Connectivity Testing
3.1 Device Tree Parsing
Tips
The file path below: out/kernel/src_tmp/linux-5.10/arch/arm64/boot/dts/rockchip/ Need to compile the source code first.
This board's WiFi and BT use SDMMC2 peripheral and UART8 respectively. Let's parse the device tree files:
Basic definition layer (rk3568.dtsi)
sdmmc2: dwmmc@fe000000 {
compatible = "rockchip,rk3568-dw-mshc",
"rockchip,rk3288-dw-mshc";
reg = <0x0 0xfe000000 0x0 0x4000>;
interrupts = <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
max-frequency = <150000000>;
clocks = <&cru HCLK_SDMMC2>, <&cru CLK_SDMMC2>,
<&cru SCLK_SDMMC2_DRV>, <&cru SCLK_SDMMC2_SAMPLE>;
clock-names = "biu", "ciu", "ciu-drive", "ciu-sample";
fifo-depth = <0x100>;
resets = <&cru SRST_SDMMC2>;
reset-names = "reset";
status = "disabled";
};
........
uart8: serial@fe6c0000 {
compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart";
reg = <0x0 0xfe6c0000 0x0 0x100>;
interrupts = <GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cru SCLK_UART8>, <&cru PCLK_UART8>;
clock-names = "baudclk", "apb_pclk";
reg-shift = <2>;
reg-io-width = <4>;
dmas = <&dmac0 16>, <&dmac0 17>;
pinctrl-names = "default";
pinctrl-0 = <&uart8m0_xfer>;
status = "disabled";
};sdmmc2controller: Address 0xfe000000, supports maximum frequency 150MHz, configures clock, reset and FIFO depthuart8controller: Address 0xfe6c0000, used for Bluetooth communication, supports DMA transfer
sdmmc2 {
sdmmc2m0_bus4: sdmmc2m0-bus4 {
rockchip,pins =
/* sdmmc2_d0m0 */
<3 RK_PC6 3 &pcfg_pull_up_drv_level_2>,
/* sdmmc2_d1m0 */
<3 RK_PC7 3 &pcfg_pull_up_drv_level_2>,
/* sdmmc2_d2m0 */
<3 RK_PD0 3 &pcfg_pull_up_drv_level_2>,
/* sdmmc2_d3m0 */
<3 RK_PD1 3 &pcfg_pull_up_drv_level_2>;
};
sdmmc2m0_clk: sdmmc2m0-clk {
rockchip,pins =
/* sdmmc2_clkm0 */
<3 RK_PD3 3 &pcfg_pull_up_drv_level_2>;
};
sdmmc2m0_cmd: sdmmc2m0-cmd {
rockchip,pins =
/* sdmmc2_cmdm0 */
<3 RK_PD2 3 &pcfg_pull_up_drv_level_2>;
};
};
uart8 {
uart8m0_xfer: uart8m0-xfer {
rockchip,pins =
/* uart8_rxm0 */
<2 RK_PC6 2 &pcfg_pull_up>,
/* uart8_txm0 */
<2 RK_PC5 3 &pcfg_pull_up>;
};
uart8m0_rtsn: uart8m0-rtsn {
rockchip,pins =
/* uart8m0_rtsn */
<2 RK_PB1 3 &pcfg_pull_none>;
};
};sdiopins: GPIO3_PC6~PD3 configured as SDIO function, supports 4-bit data busuart8pins: GPIO2_PC5/PC6 used for TX/RX, GPIO2_PB1 used for RTS control
Finally, let's look at the board-level configuration layer (excerpted from rk3568-toybrick.dtsi and rk3568-toybrick-x0.dtsi)
//Basic definition (in rk3568-toybrick.dtsi):
sdio_pwrseq: sdio-pwrseq {
compatible = "mmc-pwrseq-simple"; // Simple MMC power sequence controller
clocks = <&rk809 1>; // Use RK809 PMIC's clock output 1
clock-names = "ext_clock"; // External clock name
pinctrl-names = "default"; // Pin control state name
pinctrl-0 = <&wifi_enable_h>; // WiFi enable pin configuration
post-power-on-delay-ms = <200>; // Power-on delay 200ms
reset-gpios = <&gpio3 RK_PD5 GPIO_ACTIVE_LOW>; // Reset GPIO, low level active
};
//Board-level override configuration (in rk3568-toybrick-x0.dtsi):
&sdio_pwrseq {
post-power-on-delay-ms = <20>; // Shorten delay to 20ms
status = "okay"; // Explicitly enable status
};
......
wireless_wlan: wireless-wlan {
compatible = "wlan-platdata"; // WiFi platform data compatibility
rockchip,grf = <&grf>; // Associate general register file
wifi_chip_type = "rtl8723ds"; // Explicitly specify chip model
status = "okay"; // Enable status
};
&wireless_wlan {
pinctrl-names = "default"; // Pin control state
pinctrl-0 = <&wifi_host_wake_irq>; // Host wake interrupt pin
WIFI,host_wake_irq = <&gpio3 RK_PD4 GPIO_ACTIVE_HIGH>; // Host wake interrupt GPIO
};
......
&wireless_bluetooth {
compatible = "bluetooth-platdata"; // Bluetooth platform data compatibility
clocks = <&rk809 1>; // Use RK809's clock 1
clock-names = "ext_clock"; // External clock name
uart_rts_gpios = <&gpio2 RK_PB1 GPIO_ACTIVE_LOW>; // UART RTS control GPIO
pinctrl-names = "default", "rts_gpio"; // Two pin states: default and RTS GPIO
pinctrl-0 = <&uart8m0_rtsn>; // Default state: UART8 RTS pin
pinctrl-1 = <&uart8_gpios>; // RTS GPIO state: GPIO mode
BT,reset_gpio = <&gpio3 RK_PA0 GPIO_ACTIVE_HIGH>; // Bluetooth reset GPIO
BT,wake_gpio = <&gpio3 RK_PA2 GPIO_ACTIVE_HIGH>; // Bluetooth wake GPIO
BT,wake_host_irq = <&gpio3 RK_PA1 GPIO_ACTIVE_HIGH>; // Bluetooth wake host interrupt
status = "okay"; // Enable status
};
......
&sdmmc2 {
max-frequency = <150000000>; // Maximum operating frequency 150MHz
supports-sdio; // Support SDIO protocol
bus-width = <4>; // 4-bit data bus width
disable-wp; // Disable write protection detection
cap-sd-highspeed; // Support SD high-speed mode
cap-sdio-irq; // Support SDIO interrupt
keep-power-in-suspend; // Keep power in suspend
mmc-pwrseq = <&sdio_pwrseq>; // Associate power sequence controller
non-removable; // Non-removable device
pinctrl-names = "default"; // Pin control state
pinctrl-0 = <&sdmmc2m0_bus4 &sdmmc2m0_cmd &sdmmc2m0_clk>; // Pin multiplexing configuration
sd-uhs-sdr104; // Support UHS-I SDR104 mode
status = "okay"; // Enable status
};
......
&uart8 {
status = "okay"; // Enable UART8
pinctrl-names = "default"; // Pin control state
pinctrl-0 = <&uart8m0_xfer &uart8m0_ctsn>; // TX/RX and CTS pin configuration
};Due to space limitations, here are explanations for several key nodes:
mmc-pwrseq: Key attribute binding WiFi module to SDMMC2 interfacecap-sdio-irq: Enable SDIO interrupt support, improve data transfer efficiencykeep-power-in-suspend: Ensure WiFi module keeps power during suspend, support wake functionnon-removable: Mark as on-board fixed device, does not support hot-pluggingsd-uhs-sdr104: Support high-speed transfer mode, maximum transfer rate 104MB/suart_rts_gpios: Bluetooth UART flow control signal, ensure data transfer reliability- Dual pin state management: Implement UART and GPIO mode switching through
pinctrl-0andpinctrl-1
3.2 WIFI & BT Connection Testing Method
Since the current version of Linux kernel does not have pre-installed WiFi and Bluetooth test commands, we directly use the factory-built system for testing.
If BLE can be paired successfully, communication can be verified, because the pairing process itself is a specific form of communication, and successful pairing is a prerequisite for successfully establishing a communication link (i.e., connection).
However, successful WiFi connection only represents that the device has established a logical link with devices like routers, but it cannot ensure the connection is successful. You still need to perform network tests, such as opening a web page or using ping command, etc.
3.3 Specific Demonstration of WIFI & BT Connection Testing
After connecting the antenna, power on and enter the system:

(Note: With software updates, the interface after entering the system may be different)
BLE Testing
I used my phone's Bluetooth to pair with the development board. Find the other device in settings and pair. Click connect. Android and HarmonyOS will pop up various confirmation pairing code requests. Click pair on both devices respectively:


Pairing successful, Bluetooth test normal.
WiFi Connection Testing
Use the board to connect to the phone hotspot "OPPOA5" for testing. After successful connection, you can see the connection information in settings:

Let's open the browser to test if the network is normal:

Successfully accessed Weibo, network connection is normal.
4 WIFI & BT Usage - Official Library Method
Data Path
hap package: /05-Development-Materials/01-OpenHarmony-Development-Materials/Peripheral-Test-APP/HAP/NET_TEST.hap
Source code: /05-Development-Materials/01-OpenHarmony-Development-Materials/Peripheral-Test-APP/SRC/NATEWORK_TEST
See: Ethernet Testing
