Steps to Compile Youling's RTL8723BS Wifi Driver

999 views
Skip to first unread message

BrokenE39

unread,
Apr 26, 2020, 2:16:04 AM4/26/20
to Android-x86
First of all, thank you Youling257 for making the drivers available. I tried your BT driver on 8.1 and it works great. I didn't notice any lag at all compared to the upstream driver in 7.1 (the last time it detected my headphones).

I found his / her reply in another thread regarding RTL8723BS and decide to try compiling the Rockchip driver for myself. Replacing the RTL8723BS folder in Staging was not the correct way as I found out. I would like someone to review and comment on the steps below to see if they are correct or make sense:

  • Extract the Rockchip driver folder to /kernel/drivers/net/wireless/realtek/
  • In /kernel/drivers/net/wireless/realtek, modify the Kconfig file to add "source "drivers/net/wireless/realtek/rtl8723bs/Kconfig" "
  • In the same directory, modify the Makefile to add "obj-$(CONFIG_RTL8723BS) += rtl8723bs/
  • In /kernel/drivers/net/wireless/realtek/rtl8723bs, modify the Makefile and change
    • CONFIG_PLATFORM_I386_PC = n
    • CONFIG_PLATFORM_ANDROID_INTEL_X86 = y
  • Make sure to uncheck the Staging version of the driver before doing a clean compile

youling 257

unread,
Apr 26, 2020, 3:40:22 AM4/26/20
to Android-x86
kernel.mk support build kernel header and install to system/usr/share ?

Daniel Cheung

unread,
Apr 26, 2020, 4:40:57 PM4/26/20
to andro...@googlegroups.com
kernel.mk support build kernel header and install to system/usr/share ?

Not sure. I'm reading the kernel.mk file in /device/generic/common/build/tasks and can't find any reference to system/usr/share

On Sun, Apr 26, 2020 at 12:40 AM youling 257 <youli...@gmail.com> wrote:
kernel.mk support build kernel header and install to system/usr/share ?

--
You received this message because you are subscribed to the Google Groups "Android-x86" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-x86/62feb5fd-0edc-4c32-be8f-10df936e36a6%40googlegroups.com.

youling 257

unread,
Apr 27, 2020, 1:51:10 AM4/27/20
to Android-x86
mkdir 1
cd 1
git init
git checkout FETCH_HEAD
make android-x86_64_defconfig -C . O=../64
cd ../64
time make targz-pkg -i -j8

cd ..
mkdir 2
cd 2
git init
git checkout FETCH_HEAD
cd rtl8723bs
time make KSRC=../../64 -j8

cd ../1
make android-x86_64_defconfig -C . O=../headers
cd ../headers
make modules_prepare -j8
rm source
cp ../64/Module.symvers .

cd ../2/rtl8723bs
time make KSRC=../../headers -j8


android-x86_64_defconfig

Daniel Cheung

unread,
Apr 28, 2020, 12:27:27 AM4/28/20
to andro...@googlegroups.com
I'm getting Makefile:180: recipe for target 'sub-make' failed when I tried the first make command for directory 1.

--
You received this message because you are subscribed to the Google Groups "Android-x86" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.

Daniel Cheung

unread,
Apr 28, 2020, 12:30:28 AM4/28/20
to andro...@googlegroups.com
Sorry, forgot to add the error was Can't find default configuration "arch/x86/configs/android-x86_64_defconfig"

XiaoTao Liu

unread,
Apr 28, 2020, 8:55:14 AM4/28/20
to Android-x86
What a coincidence. I am looking for RTL8723BS wifi solution for android x86 7.1.2 too these days, as the wifi disconnect from time to time with the orginial driver. 
Have you successfully compile the driver? Could you share it?


On Tuesday, April 28, 2020 at 12:30:28 PM UTC+8, BrokenE39 wrote:
Sorry, forgot to add the error was Can't find default configuration "arch/x86/configs/android-x86_64_defconfig"

To unsubscribe from this group and stop receiving emails from it, send an email to andro...@googlegroups.com.

Daniel Cheung

unread,
Apr 28, 2020, 11:27:07 PM4/28/20
to andro...@googlegroups.com
Let me check if I did it right. I didn't follow Youling's instruction regarding pulling it from GitHub and executing the make command. Here are the steps I took:

    • Extract the Rockchip driver folder to /kernel/drivers/net/wireless/realtek/
    • In /kernel/drivers/net/wireless/realtek, modify the Kconfig file to add "source "drivers/net/wireless/realtek/rtl8723bs/Kconfig" "
    • In the same directory, modify the Makefile to add "obj-$(CONFIG_RTL8723BS) += rtl8723bs/
    • In /kernel/drivers/net/wireless/realtek/rtl8723bs, modify the Makefile and change
      • CONFIG_PLATFORM_I386_PC = n
      • CONFIG_PLATFORM_ANDROID_INTEL_X86 = y
    • In /kernel/drivers/staging, modify the Kconfig file and removed "source "drivers/staging/rtl8723bs" "
    Then run the kernel configurator, make sure RTL8723BS shows up under wifi instead of staging section and select it. Build the ISO as usual.

    I'm going to test it for a few days and see how it works. There were no errors during the compile process and it manage to detect my access point. Waking from sleep still have problem re-connect but I just have to cycle the switch from settings and it would connect again. Previously, I would have to reboot to get it to reconnect but that only works 50% of the time.

    To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/android-x86/25208ace-b142-4efd-af43-45b8ee066534%40googlegroups.com.

    youling 257

    unread,
    Apr 29, 2020, 12:58:58 AM4/29/20
    to Android-x86
    please use CONFIG_PLATFORM_I386_PC = y CONFIG_PLATFORM_ANDROID_INTEL_X86 = n 

    在 2020年4月29日星期三 UTC+8上午11:27:07,BrokenE39写道:
    Let me check if I did it right. I didn't follow Youling's instruction regarding pulling it from GitHub and executing the make command. Here are the steps I took:

    • Extract the Rockchip driver folder to /kernel/drivers/net/wireless/realtek/
    • In /kernel/drivers/net/wireless/realtek, modify the Kconfig file to add "source "drivers/net/wireless/realtek/rtl8723bs/Kconfig" "
    • In the same directory, modify the Makefile to add "obj-$(CONFIG_RTL8723BS) += rtl8723bs/
    • In /kernel/drivers/net/wireless/realtek/rtl8723bs, modify the Makefile and change
      • CONFIG_PLATFORM_I386_PC = n
      • CONFIG_PLATFORM_ANDROID_INTEL_X86 = y
    • In /kernel/drivers/staging, modify the Kconfig file and removed "source "drivers/staging/rtl8723bs" "
    Then run the kernel configurator, make sure RTL8723BS shows up under wifi instead of staging section and select it. Build the ISO as usual.

    I'm going to test it for a few days and see how it works. There were no errors during the compile process and it manage to detect my access point. Waking from sleep still have problem re-connect but I just have to cycle the switch from settings and it would connect again. Previously, I would have to reboot to get it to reconnect but that only works 50% of the time.

    youling 257

    unread,
    Apr 29, 2020, 1:06:08 AM4/29/20
    to Android-x86
    open Androidx86 7.1 terminal, 
    su
    mount -o remount,rw /
    tar xzvf /sdcard/linux-5.7.0-rc3-android-x86_64+-x86.tar.gz
    cp -f -a /sdcard/8723bs.ko /system/lib/modules/5.7.0-rc3-android-x86_64+/kernel/drivers/net/wireless
    /system/xbin/depmod -a 5.7.0-rc3-android-x86_64+
    you install Androidx86 on which partition? when you boot Androidx86 see detect found at which /dev/??
    mkdir /data/1
    busybox mount /dev/block/?? /data/1
    open root explorer /data/1 folder, you can see android-7.1 folder, initrd.img kernel ramdisk.img files.
    rename /boot/vmlinuz-5.7.0-rc3-android-x86_64+ to kernel, copy to data/1/android-7.1 folder, replace kernel.

    在 2020年4月28日星期二 UTC+8下午8:55:14,XiaoTao Liu写道:

    Daniel Cheung

    unread,
    Apr 29, 2020, 1:16:59 AM4/29/20
    to andro...@googlegroups.com
    So what exactly is the difference between the CONFIG_PLATFORM switch? I mean my device is an Intel Atom so I thought that is the correct one to use.

    To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/android-x86/d23f5951-b3d7-4f0d-94d5-d2b6a62a93bf%40googlegroups.com.
    Message has been deleted

    BrokenE39

    unread,
    Jun 21, 2020, 10:02:01 PM6/21/20
    to Android-x86
    I went back to reviewed youling's instruction and my mistake was not downloading and copying the config file to the kernel config folder. While I managed to run all the commands posted. When I try to run insmod, I'm getting an "exec format error". Is this because I'm not building against the correct kernel when building the module?

    BrokenE39

    unread,
    Jun 21, 2020, 11:36:48 PM6/21/20
    to Android-x86
    Hmm when I point the KSRC in make rtl8723bs to the original Android X86 out/obj/kernel, I'm getting incompatible pointer error:

    /home/daniel/2/rtl8723bs/os_dep/linux/rtw_proc.c:67:15: warning: ‘struct proc_ops’ declared inside parameter list will not be visible outside of this definition or declaration
      const struct proc_ops *proc_ops, void * data)
                   ^~~~~~~~
    /home/daniel/2/rtl8723bs/os_dep/linux/rtw_proc.c: In function ‘rtw_proc_create_entry’:
    /home/daniel/2/rtl8723bs/os_dep/linux/rtw_proc.c:72:71: error: passing argument 4 of ‘proc_create_data’ from incompatible pointer type [-Werror=incompatible-pointer-types]
      entry = proc_create_data(name,  S_IFREG | S_IRUGO | S_IWUGO, parent, proc_ops, data);
                                                                           ^~~~~~~~
    In file included from /home/daniel/2/rtl8723bs/include/../os_dep/linux/rtw_proc.h:18:0,
                     from /home/daniel/2/rtl8723bs/include/osdep_intf.h:128,
                     from /home/daniel/2/rtl8723bs/include/drv_types.h:104,
                     from /home/daniel/2/rtl8723bs/os_dep/linux/rtw_proc.c:17:
    /home/daniel/android9/kernel/include/linux/proc_fs.h:44:31: note: expected ‘const struct file_operations *’ but argument is of type ‘const struct proc_ops *’
     extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
                                   ^~~~~~~~~~~~~~~~
    /home/daniel/2/rtl8723bs/os_dep/linux/rtw_proc.c: At top level:
    /home/daniel/2/rtl8723bs/os_dep/linux/rtw_proc.c:235:21: error: variable ‘rtw_drv_proc_seq_proc_ops’ has initializer but incomplete type
     static const struct proc_ops rtw_drv_proc_seq_proc_ops = {
                         ^~~~~~~~
    make1.txt

    youling 257

    unread,
    Jun 21, 2020, 11:49:56 PM6/21/20
    to Android-x86
    why you not notice this commit https://github.com/youling257/rockchip_wlan/commit/af0df860505dfdc5834068bf3c8e5253efec6bbe
    do you think what you can do fix your build?

    在 2020年6月22日星期一 UTC+8上午11:36:48,BrokenE39写道:
    Message has been deleted

    youling 257

    unread,
    Jun 22, 2020, 12:14:36 AM6/22/20
    to Android-x86
    Now, my rockchip_wlan rtl8723bs master branch only support build with KSRC is kernel ≥ 5.6
    if KSRC kernel source code < 5.6
    mkdir 2
    cd 2
    git init
    git checkout FETCH_HEAD
    git reset --hard 443ce25ea0bb8e0b116e31541e534ac550be5dc8

    BrokenE39

    unread,
    Jun 22, 2020, 12:16:11 AM6/22/20
    to Android-x86
    I'm not a software developer and I'm relatively new with working with code repo. When I fetch the head, this is the message that I got:

    HEAD is now at 1ba598d rtl8723bs: Fix build for kernel 5.8

    So I explore the tip in github, I do see that commit in there so I assume it is included when I fetched head. I did not modify any code in the rtl8723bs source code that I checked out, I simply pointed it to a different kernel source (Android 9 R2) instead of 1 folder in your instruction. I'm not exactly sure why the error is being thrown if your commit address this exact problem. Just a reminder Android 9 R2 is using kernel 4.19. 

    youling 257

    unread,
    Jun 22, 2020, 12:20:22 AM6/22/20
    to Android-x86
    git revert af0df860505dfdc5834068bf3c8e5253efec6bbe , or git reset --hard 443ce25ea0bb8e0b116e31541e534ac550be5dc8

    在 2020年6月22日星期一 UTC+8下午12:16:11,BrokenE39写道:

    Daniel Cheung

    unread,
    Jun 27, 2020, 10:11:29 PM6/27/20
    to andro...@googlegroups.com
    Sorry about the late update, I finally managed to get it to compile correctly. Some more testing to be done since the using the staging driver with youling's BT firmware causes audio to cut in and out and constant disconnecting during video playback on Youtube and Plex. Here are the steps that I done to get it to compile:

    Check out the driver
    mkdir rtl_driver (name it whatever you want)
    cd rtl_driver
    git init
    git checkout FETCH_HEAD
    git revert af0df860505dfdc5834068bf3c8e5253efec6bbe
     
    Remove the rtl8723bs staging driver folder in kernel/drivers/staging/rtlwifi

    Remove reference to rtl8723bs from KConfig and Makefile files in kernel/driver/staging

    Go to rtl_driver folder where you downloaded youling's driver and copy rtl8723bs folder to kernel/drivers/net/wireless/realtek

    Add reference to rtl8723bs in KConfig and Makefile files in kernel/driver/net/wireless/realtek
    In Kconfig add source "drivers/net/wireless/realtek/rtl8723bs/Kconfig"
    In Makefile add obj-$(CONFIG_RTL8723BS) += rtl8723bs/

    Modify the Makefile file inside /kernel/driver/net/wireless/realtek/rtl8723bs
    Go to line 244 and find the line that looks like include $(TOP_DIR)/halphydm/phydm.mk
    Replace the $(TOP_DIR) part with the actual directory path to phydm.mk
    Mine looks like include ~/android9/kernel/drivers/netwireless/realtek/rtl8723bs/hal/phydm/phydm.mk

    I have to make this change because it would complain that the phydm.mk file is not found when I compile it with the Android 9R2 project, it kept looking in the OUT directory.

    Finally, make sure you select the module when you're inside the kernel configuration tool and go compile the entire Android project. The ko module file should be in the OUT directory. Be warn, if the Android source is different from the one used to build the ISO image that you used to install, you could get exec format error if you simply try to compile the driver and run insmod. My old VM died and lost the matching Android source files. When I tried to compile the driver against a new fetch of the same Android 9R2 branch, I kept getting the exec format error but the live image would give me proper Wifi connection. So this tells me that there's some kind of kernel difference or the source was updated. If you were getting a crash after waking up with Android 9R2, consider re-fetching the source and build a new image since there is a patch to fix that annoying crash.


    --
    You received this message because you are subscribed to the Google Groups "Android-x86" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.

    ouija

    unread,
    Nov 18, 2020, 11:56:23 PM11/18/20
    to Android-x86

    With kernel 4.19 that comes from original Android-x86 sources (for 8.1r5), I had no issues compiling the driver as per @BrokenE39 outlined here, but recently am testing a build with a kernel version 5.8, these instructions were no longer valid it seems, as I was getting the following error when compiling: rtl8723bs/core/rtw_cmd.c:17:23: fatal error: drv_types.h: No such file or directory

    After much trial and error, I finally managed to resolve this,  using the latest source from https://github.com/youling257/rockchip_wlan (v5.2.17.1 - commit #1ba598d)

    My steps were as follows:

    1.   Clone the latest branch of youling257's driver somewhere on your machine via git clone https://github.com/youling257/rockchip_wlan.git
    2.  Move the rtl8723bs folder to ./kernel/driver/net/wireless/realtek/
    3.  Add references for this to the ./kernel/driver/net/wireless/realtek/Makefile and ./kernel/driver/net/wireless/realtek/Kconfig files:

      • In Kconfig add source "drivers/net/wireless/realtek/rtl8723bs/Kconfig"
      • In Makefile add obj-$(CONFIG_RTL8723BS) += rtl8723bs/
    1. Modify ./kernel/driver/net/wireless/realtek/rtl8723bs/Makefile to avoid issues with include paths during source compile:
      • Delete/replace line 24:  EXTRA_CFLAGS += -I$(src)/include  with the following three new lines:
        • EXTRA_CFLAGS += -I/android-x86/kernel/drivers/net/wireless/realtek/rtl8723bs/include
        • EXTRA_CFLAGS += -I/android-x86/kernel/drivers/net/wireless/realtek/rtl8723bs/hal/phydm
        • EXTRA_CFLAGS += -I/android-x86/kernel/drivers/net/wireless/realtek/rtl8723bs/platform
      • Modify the values above after EXTRA_CFLAGS += -I/ with the full path to your Android-x86 source files!
      • Then replace line 156 (now line 158 after completing the above edit) from this: 
        • export TopDIR ?= $(shell pwd)
      • To instead be:
        • export TopDIR ?= /android-x86/kernel/drivers/net/wireless/realtek/rtl8723bs/
      • And again ensure to modify this line above with the full path to your Android-x86 source files!
    2. Remove inclusion of the original driver by deleting the references to rtl8723bs from KConfig and Makefile files in kernel/driver/staging folder

    And you should now be able to build without issues related to files not being found when compiling (such as phydm.mk or drv_types.h).

    Hope this helps anyone else looking to build with newer kernel versions!   Thanks to @BrokenE39 for his tips, and @youling257 for his driver!

    Daniel Cheung

    unread,
    Nov 19, 2020, 12:08:44 AM11/19/20
    to andro...@googlegroups.com
    Did you also use 
    git revert af0df860505dfdc5834068bf3c8e5253efec6bbe

    I only have to do that to make it work with 4.19. I believe if the target is 5.2 then you don't need to revert it back to that version. 

    --
    You received this message because you are subscribed to the Google Groups "Android-x86" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.

    ouija

    unread,
    Nov 19, 2020, 5:10:48 AM11/19/20
    to Android-x86
    As mentioned, I am using the latest version of source -- I did not revert it back to that previous version.  :)

    BrokenE39

    unread,
    Dec 6, 2020, 12:45:55 AM12/6/20
    to Android-x86
    Hey Ouija,

    I followed your instructions in modifying the MakeFile but still getting the same error that you initially had.



    /home/daniel/Android9/kernel/drivers/net/wireless/realtek/rtl8723bs/core/rtw_cmd.c:17:23: fatal error: drv_types.h: No such file or directory
    compilation terminated.
    /home/daniel/Android9/kernel/scripts/Makefile.build:280: recipe for target 'drivers/net/wireless/realtek/rtl8723bs/core/rtw_cmd.o' failed
    make[6]: *** [drivers/net/wireless/realtek/rtl8723bs/core/rtw_cmd.o] Error 1
    /home/daniel/Android9/kernel/scripts/Makefile.build:497: recipe for target 'drivers/net/wireless/realtek/rtl8723bs' failed
    make[5]: *** [drivers/net/wireless/realtek/rtl8723bs] Error 2
    /home/daniel/Android9/kernel/scripts/Makefile.build:497: recipe for target 'drivers/net/wireless/realtek' failed
    make[4]: *** [drivers/net/wireless/realtek] Error 2
    /home/daniel/Android9/kernel/scripts/Makefile.build:497: recipe for target 'drivers/net/wireless' failed
    make[3]: *** [drivers/net/wireless] Error 2
    /home/daniel/Android9/kernel/scripts/Makefile.build:497: recipe for target 'drivers/net' failed

    My MakeFile have these changes similar to your instruction:

    EXTRA_CFLAGS += -I/~/Android9/kernel/drivers/net/wireless/realtek/rtl8723bs/include
    EXTRA_CFLAGS += -I/~/Android9/kernel/drivers/net/wireless/realtek/rtl8723bs/hal/phydm
    EXTRA_CFLAGS += -I/~/Android9/kernel/drivers/net/wireless/realtek/rtl8723bs/platform

    export TopDIR ?= ~/Android9/kernel/drivers/net/wireless/realtek/rtl8723bs

    Not exactly sure if I'm referring to the source directory correctly since it's in my home directory.

    ouija

    unread,
    Dec 7, 2020, 5:18:49 PM12/7/20
    to Android-x86
    Try using the full path instead of the tilde (~) and see if that helps?  It's not finding the /include path specifically when it complains about fatal error: drv_types.h: No such file or directory

    Note that I was also using Android 8.1r5 source when building and haven't tried this method with Android 9, but you're getting the same error I was, so I'm hoping that simply using the full path will help.

    Daniel Cheung

    unread,
    Dec 7, 2020, 5:39:30 PM12/7/20
    to andro...@googlegroups.com
    Yes it was the ~ causing the trouble. Had the specify /home/name/src instead of just ~/src.

    On Mon, Dec 7, 2020 at 2:18 PM ouija <djo...@gmail.com> wrote:
    Try using the full path instead of the tilde (~) and see if that helps?  It's not finding the /include path specifically when it complains about fatal error: drv_types.h: No such file or directory

    Note that I was also using Android 8.1r5 source when building and haven't tried this method with Android 9, but you're getting the same error I was, so I'm hoping that simply using the full path will help.

    --
    You received this message because you are subscribed to the Google Groups "Android-x86" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.

    BrokenE39

    unread,
    May 5, 2022, 10:37:33 PM5/5/22
    to Android-x86
    Once again I'm trying to compile the driver with Android 8.1 R6 since the default staging driver is having the same performance issue. When trying to follow my previous steps, I'm now running into C90 error like this:

    ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

    I don't recall seeing this before and wondering if other members of the community has a solution for this, especially with commit af0df860505dfdc5834068bf3c8e5253efec6bbe as instructed by the code author.
    Reply all
    Reply to author
    Forward
    0 new messages