Rockchip · AI & Linux Hub

Android et BSP

Porter un pilote Realtek Wi-Fi à Rockchip: RTL8723CS

Porter un pilote Realtek Wi-Fi à Rockchip: RTL8723CS

Cet article couvre l’ensemble technique de la source bilingue RK-SM-YF-210 V1.0. Il utilise les interfaces du noyau RTL8723CS et Rockchip BSP. La source ne spécifie pas une version du noyau; ses exigences WIFI_HAL s’appliquent à Android 8.0 et plus tard. Pour ArmSoM, c’est une référence de plate-forme : vérifiez les interfaces sans fil, SoC, BSP et noyau. Aucune validation matérielle n’a été effectuée. Les chiffres proviennent du seul PDF bilingue, y compris l’assurance-chômage chinoise; il n’existe pas de chiffres anglais distincts.

1 Objet {#1-purpose}

Aidez les développeurs à porter un pilote Realtek Wi-Fi à Rockchip. L’exemple ci-dessous est rtl8723cs.

2 Changements de pilote {#2-driver-changes}

2.1 Ajouter le pilote au noyau {#21-add-the-driver-to-the-kernel}

Le répertoire courant est drivers/net/wireless/rockchip_wlan/. Ajouter à son Makefile:

obj-$(CONFIG_RTL8723CS) += rtl8723cs/

Ajouter à Kconfig dans le même répertoire :

source "drivers/net/wireless/rockchip_wlan/rtl8723cs/Kconfig"

Renommer le paquet pilote en rtl8723cs et le placer dans drivers/net/wireless/rockchip_wlan/rtl8723cs.

2.2 Modifier le pilote Makefile {#22-modify-the-driver-makefile}

Le pilote Realtek est par défaut sur PC. Passer à Rockchip : changer CONFIG_PLATFORM_I386_PC = y en n et CONFIG_PLATFORM_ARM_RK3188 = n en y. Rockchip utilise un pilote .ko; changez son nom de module en 8723cs.

ifeq ($(CONFIG_PLATFORM_ARM_RK3188), y)
EXTRA_CFLAGS+= -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_ANDROID -DCONFIG_PLATFORM_ROCKCHIPS
……
#EXTRA_CFLAGS += -DRTW_ENABLE_WIFI_CONTROL_FUNC //注意这个要注释掉 Need to comment this out
……
MODULE_NAME := 8723cs
Endif

L’extrait source contient des ellipses et se termine par Endif, conservé ici. Vérifiez le mot clé de clôture GNU Make, minuscule endif. Commenter la ligne RTW_ENABLE_WIFI_CONTROL_FUNC. Pour Android 8.0 et plus tard aussi changer CONFIG_RTW_WIFI_HAL = n en CONFIG_RTW_WIFI_HAL = y.

2.3 Modifier les fonctions d’entrée {#23-modify-entry-functions}

L’entrée Realtek est rtw_drv_entry : USB utilise os_dep/linux/usb_intf.c, SDIO utilise os_dep/linux/sdio_intf.c et PCIe utilise os_dep/linux/pci_intf.c.

  1. Changer static int __init rtw_drv_entry(void) en static int rtw_drv_entry(void).
  2. Changer static void __exit rtw_drv_halt(void) en static void rtw_drv_halt(void).
  3. Commenter module_init(rtw_drv_entry); et module_exit(rtw_drv_halt);.
  4. Ajoutez les enveloppes d’entrée Rockchip.

Fonctions d'entrée avant modification (source bilingue)

Fonctions d’entrée avant modification (source bilingue)

Enveloppes d'entrée après modification (les lignes de log sont déjà coupées à droite dans la source)

Enveloppes d’entrée après modification (les lignes de log sont déjà coupées à droite dans la source)

Le code suivant est transcrit. Deux lignes de log contenant DRIVERVERSION sont coupées par l’image originale; les commentaires les identifient sans inventer de caractères manquants. Les corps de fonction originaux sont effondrés dans la capture d’écran, donc ce n’est pas un fichier source complet.

#include <linux/rfkill-wlan.h>
extern int get_wifi_chip_type(void);
extern int rockchip_wifi_power(int on);
extern int rockchip_wifi_set_carddetect(int val);

int rockchip_wifi_init_module_rtkwifi(void)
{
#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
    int type = get_wifi_chip_type();
    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
#endif
    printk("\n");
    printk("=======================================================\n");
    printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
    printk("=======================================================\n");
    /* Source log line clipped after DRIVERVERSION; see original figure. */
    rockchip_wifi_power(1);
    rockchip_wifi_set_carddetect(1);
    return rtw_drv_entry();
}

void rockchip_wifi_exit_module_rtkwifi(void)
{
#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
    int type = get_wifi_chip_type();
    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
#endif
    printk("\n");
    printk("=======================================================\n");
    printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
    printk("=======================================================\n");
    /* Source log line clipped after DRIVERVERSION; see original figure. */
    rtw_drv_halt();
    rockchip_wifi_set_carddetect(0);
    rockchip_wifi_power(0);
}
#ifdef CONFIG_WIFI_BUILD_MODULE
module_init(rockchip_wifi_init_module_rtkwifi);
module_exit(rockchip_wifi_exit_module_rtkwifi);
#else
#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
late_initcall(rockchip_wifi_init_module_rtkwifi);
module_exit(rockchip_wifi_exit_module_rtkwifi);
#else
EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
#endif
#endif
//module_init(rtw_drv_entry);
//module_exit(rtw_drv_halt);

2.4 Support de l’adresse MAC Rockchip (facultatif) {#24-rockchip-mac-address-support-optional}

Si le projet l’exige, modifier rtl8723cs/core/rtw_ieee80211.c: ajouter #include <linux/rfkill-wlan.h> et prendre en charge rockchip_wifi_mac_addr(mac) dans void rtw_macaddr_cfg(u8 *out, const u8 *hw_mac_addr).

Changements d'adresse MAC

Changements d’adresse MAC

/* Use the mac address stored in the Efuse */
if (hw_mac_addr) {
    _rtw_memcpy(mac, hw_mac_addr, ETH_ALEN);
}
if (!rockchip_wifi_mac_addr(mac)) {
    printk("Get mac address from flash:[%02x:%02x:%02x:%02x:%02x:%02x]\n", mac[0], mac[1],
        mac[2], mac[3], mac[4], mac[5]);
}

2.5 Support WOWLAN (facultatif) {#25-wowlan-support-optional}

Comme le requiert le projet, changer CONFIG_WOWLAN = n et CONFIG_GPIO_WAKEUP = n en y dans le pilote Makefile. Ajouter le support rockchip_wifi_get_oob_irq() dans platform/platform_ops.c:

Changements d'interruption de réveil

Changements d’interruption de réveil

#include <linux/rfkill-wlan.h>
extern unsigned int oob_irq;
int platform_wifi_power_on(void)
{
    int ret = 0;
    oob_irq = rockchip_wifi_get_oob_irq();
    return ret;
}

Référence

Documentation officielle de ArmSoM; source RK-SM-YF-210 V1.0, pages 5 à 10.

Explorer ce sujet → · Parcours →