Install Sunplus WiFi & BT module (AP6256) on SP7021 demo board V3

The goal of this document is to illustrate how to install and use Sunplus WIFI & BT module on SP7021 demo board V3. Refer to picture of Sunplus WiFi & BT module:

Main part of Sunplus WIFI & BT module is AP6256 which is from AMPAK Technology. AP6256 is 802.11ac/a/b/g/n dual-Band 1T1R WiFi +Bluetooth 5.0 SiP stamp type module. Its WiFi can accomplish up to speed of 433.3 Mbps with dual stream. AP6256 consists of Broadcom BCM43456. It is a highly integrated single-chip solution that integrates a single-stream 802.11ac MAC, baseband and radio, Bluetooth 5.0, and FM receiver. Please follow the following steps to install and use Sunplus WIFI & BT module:

1. Install hardware

Install Sunplus WIFI & BT module to Plus 1 demo board V3. There is a Raspberry Pi compatible 40-pin header in Plus 1 demo board V3. Please plug the module in as shown below:

Refer to schematics of Sunplus WIFI & BT module “AP6256 WIFI BT MODULE_REL_200207.pdf”.

2. Modify device-tree source

WIFI function uses SDIO interface. You need to add or modify dts node sdio in device-tree source file, linux/kernel/arch/arm/boot/dts/sp7021-demov3.dts, as shown below:

&sdio { bus-width = <4>; max-frequency = <52000000>; non-removable; disable-wp; cap-sd-highspeed; cap-sdio-irq; no-sd; no-mmc; };

Note that sdio is a label to node sdio@9c008400.

pins_sdio: pinmux_sdio-pins { sunplus,pins = < SPPCTL_IOPAD(17, SPPCTL_PCTL_G_PMUX, MUXF_SDIO_D1, 0) SPPCTL_IOPAD(18, SPPCTL_PCTL_G_PMUX, MUXF_SDIO_D0, 0) SPPCTL_IOPAD(16, SPPCTL_PCTL_G_PMUX, MUXF_SDIO_CLK, 0) SPPCTL_IOPAD(14, SPPCTL_PCTL_G_PMUX, MUXF_SDIO_CMD, 0) SPPCTL_IOPAD(15, SPPCTL_PCTL_G_PMUX, MUXF_SDIO_D3, 0) SPPCTL_IOPAD(13, SPPCTL_PCTL_G_PMUX, MUXF_SDIO_D2, 0) >; };

Node pinmux_sdio-pins is sub-node of node pctl. The first line of pin-ctrl settings, sunplus,pins, is for signal SDIO_D1 which is connected to pin G_MX17 in hardware. So, it is set to number 17. The second line of pin-ctrl settings is for signal SDIO_D0 which is connected to pin G_MX18 in hardware. So, it is set to number 18. The same for other pins.

Bluetooth function uses UART interface. You need to add or modify dts node uart4 in device-tree source file, linux/kernel/arch/arm/boot/dts/sp7021-demov3.dts, as shown below:

&uart4 { pinctrl-names = "default"; pinctrl-0 = <&uart4_pins>; };

Note that uart4 is a label to node serial@9c008780.

Also, modify dts node in device-tree source file, linux/kernel/arch/arm/boot/dts/sp7021-demov3.dts, as shown below:

Note that node pinmux_uart4-pins is sub-node of node pctl.

Please note that to comply with Linux rules, after version 5.10.59, 4 property-names of pin node of SP7021 are changed as shown in table below:

5.4.35

5.10.59

5.4.35

5.10.59

sppctl,function

function

sppctl,groups

groups

sppctl,pins

sunplus,pins

sppctl,zero_func

sunplus,zerofunc

3. Enable wireless protocols

Run make kconfig in project top directory. When “Linux/arm Kernel Configuration” menu pops up, move cursor to go to “Networking support” --> “Wireless”. Enable “cfg80211 – wireless configuration API”, “cfg80211 wireless extension compatibility” and “Generic IEEE 802.11 Networking Stack (mac80211)”. Refer to screenshot below:

4. Enable Broadcom wireless driver

Move cursor to go to “Device Drivers” --> “Network device support” --> “Wireless LAN”. Enable “Broadcom FullMAC wireless cards support”. Refer to screenshot below:

Note that firmware is set to be placed at folder /etc/firmware/. Remember to copy firmware files: fw_bcm43456c5_ag.bin, fw_bcm43456c5_ag_apsta.bin, fw_bcmdhd.bin, nvram.txt, and config.txt, to the folder.

Move cursor to select “Enable Chip Interface” to “SDIO bus interface support“.

Move cursor to select “Interrupt type” to “In-Band Interrupt”.

5. Enable Bluetooth protocols

Move cursor to go to “Networking support” --> “Bluetooth subsystem support”. Enable “Bluetooth Classic (BR/EDR) features”, “RFCOMM protocol support”, “RFCOMM TTY support”, “BNEP protocol support“, “Multicast filter support“, “Protocol filter support”, and “HIDP protocol support”. Refer to screenshot below:

6. Enable Bluetooth HCI UART driver and UART protocol

Move cursor to go to “Bluetooth device drivers”. Enable “HCI UART driver”, and then enable “UART (H4) protocol support”. Refer to screenshot below:

Finally, save configuration.

7. Build Linux image

Go to top folder. Run make all to build Linux image.

8. Boot Linux

Boot Linux with the built image. During booting, you will see Bluetooth related log messages:

Bluetooth HCI, RFCOMM, BNEP, HIDP modules are loaded.

9. Probe WiFi module

After Linux boots up successfully, run modprobe bcmdhd to insert module bcmdhd.ko (Broadcom WiFi driver). Refer to log below (loglevel is set to 8):

Run lsmod to list the loaded modules:

Module bcmdhd and its dependencies 8021q and cfg80211 have been loaded.

10. Check out report of wireless net-interface devices

Run ifconfig wlan0 to check out status report of wireless LAN device wlan0. Refer to screenshot below:

11. Initialize Broadcom Bluetooth device

Run application, brcm_patchram_plus, to initialize Broadcom Bluetooth device as below:

Note that /etc/firmware/BCM4345C5_003.006.006.0058.0135.hcd is firmware file to load. Remember to copy the firmware file BCM4345C5_003.006.006.0058.0135.hcd to the folder /etc/firmware/. /dev/ttyS4 is serial port that Bluetooth of AP6256 is connected. Refer to screenshot below:

12. Check out report of Bluetooth device

Run hciconfig to check out report of Bluetooth device hci0. Refer to screenshot below:

13. Scan Bluetooth devices

Run hcitool scan to check out Bluetooth devices nearby. Refer to screenshot below:

Two Bluetooth devices were found.

14. Raspberry Pi OS

Note that you may need to install Bluetooth related packages, like bluetooth, blueman, bluez, bluez-hcidump, pi-bluetooth, bluez-firmware, and etc for Bluetooth devices operation. Please run apt-get install to install them.

Refer to screenshots of Raspbian which lists the Wifi devices:

Refer to screenshots of Raspbian which lists the Bluetooth devices: