nh-magisk-wifi-firmware icon indicating copy to clipboard operation
nh-magisk-wifi-firmware copied to clipboard

[Request] RTL8812AU Support

Open SirFell opened this issue 5 years ago • 38 comments

Would be great if you could add support for rtl8812au wlan controller. Thanks.

SirFell avatar Dec 15 '18 00:12 SirFell

I can't find drivers for this anywhere. If you do, let me know with the link and I'll add it.

rithvikvibhu avatar Dec 15 '18 12:12 rithvikvibhu

https://github.com/aircrack-ng/rtl8812au this, but it lacks kernel headers like any other driver out there I could find. There were people on NetHunter repo issues that appear to have done it on Nexus 6P (device I also own) but they havent shared how exactly did they do it.

SirFell avatar Dec 15 '18 14:12 SirFell

https://github.com/offensive-security/kali-nethunter/issues/1122 https://github.com/offensive-security/kali-nethunter/issues/1128

Biggest problem is that I have no idea can you even get 1.1 kernel sources at this point. I personally run 7.1.2 w/ PureNexus & NetHunter 3.10.73-1.1

SirFell avatar Dec 15 '18 14:12 SirFell

Firmware for other chipsets are distributed as binaries so it's easy to just plug it in. This one uses dkms which builds (?) the module for a specific kernel. I have no experience with this or with building for other kernels.

Btw, why are you looking for 1.1 kernel sources?

rithvikvibhu avatar Dec 15 '18 14:12 rithvikvibhu

well i have no real experience on the topic but long story short, dkms installed driver just doesnt work, neither kali installs dkms version of driver it has on its apt repo

so far what i could have guessed is that dkms is missing something that would allow it to build for kernel installed which possibly can be worked around by either making kernel based on sources that would have what dkms is missing or making headers from sources to then use in drivers based on already made drivers.

SirFell avatar Dec 15 '18 14:12 SirFell

It does sound simple (like it ever is) - https://unix.stackexchange.com/a/258532, but I've never done this before. Also couldn't find anything related to using dkms for android kernels.

rithvikvibhu avatar Dec 15 '18 14:12 rithvikvibhu

And this is where we get to kernel headers: image

./build and ./source folders just dont exist: image

SirFell avatar Dec 15 '18 14:12 SirFell

Leaving this open in case someone stumbles upon this issue and finds a solution.

rithvikvibhu avatar Feb 09 '19 14:02 rithvikvibhu

i will see if i am able to build headers myself when i get more free time, if so i will post here

SirFell avatar Feb 09 '19 14:02 SirFell

I haven't dealt with this topic since last summer, so some links might become outdated. But this is how my TODO looked for working 6P with Asus USB-N56 and a pair of other adapters on 8812.

At the first stage, I could not find any kernel sources kernel 3.10.73-nethunter-angler-1.1 for NH version 7.1.1 that worked stably with external devices and had to use the available sources kernel 3.10.73-nethunter-angler-2.0 for version 7.1.2.

  1. Clone src or download/extract zip (kernel 3.10.73-nethunter-angler-2.0)

In this folder:

  1. Check toolchain in build.sh and download/install it if ness to external folder

  2. Run "make ARCH=arm64 mrproper"

  3. Run "./build.sh nethunter angler"

  4. Run "ARCH=arm64 make defconfig KBUILD_DEFCONFIG=nethunter_angler_defconfig" (in /KSRC/arch/arm64/configs)

  5. For additional initialisation run:

    "make ARCH=arm64 CROSS_COMPILE=/path_to_/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- modules_prepare"

  6. For create kernel headers/sources needed for build driver run:

    "make ARCH=arm64 CROSS_COMPILE=/path_to_/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- headers_install"

At this stage, you have the own kernel image and necessary kernel headers for build the 8812 driver.

  1. clone or download driver src (rtl8812au-5.1.5 from https://github.com/aircrack-ng/rtl8812au)

In this folder:

  1. modifying Makefile for building:

    CONFIG_PLATFORM_ARM64 = y

    CONFIG_RTL8812A = y

    ifeq ($(CONFIG_PLATFORM_ARM64), y)

    EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN

    EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT

    ARCH ?= arm64

    CROSS_COMPILE := /path_to_/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

    KVER ?= $(shell uname -r)

    KSRC := /path_to_your_kernel_src_dir/build (PATH TO YOUR KERNEL SOURCE FOLDER)

    MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/

    INSTALL_PREFIX :=

    endif

  2. make clean

  3. make

After make completion you must have 8812au.ko file in root or build/bin dir of driver_src.

The next problem was that default NH 7.1.2 with kernel 3.10.73-nethunter-angler-2.0 compared to 7.1.1 and 3.10.73-nethunter-angler-1.1 was extremely unstable on my 6P, it had several bugs that were inconvenient for me. Such as problems with the startup of scripts at the start of the android due to the settings of the se policy, the inaccessibility of vim outside the NH chroot, etc. As a result, I was forced to modify the default NH build system (kali-nethunter) for kernel 3.10.73-nethunter-angler-2.0 with some files from build sysytem for kernel 3.10.73-nethunter-angler-1.1

In /kali-nethunter/nethunetr-installer (download from https://github.com/offensive-security/kali-nethunter/):

Replace this default files with files from https://build.nethunter.com/nightly/3.15.4-20170629-1630/kernel-nethunter-angler-nougat-3.15.4-20170629-1630.zip:

1)busybox, sepolicy-inject and sepolicy-inject-M (which replaced with sepolicy-inject-N) in /kali-nethunetr/nethunter-installer/boot-patcher/arch/arm64/tools

2)02-no-verity-opt-encrypt in /kali-nethunetr/nethunter-installer/boot-patcher/patch.d/

3)patch.d-env in /kali-nethunetr/nethunter-installer/boot-patcher/

Now we add our own kernel image and support files to NH build system (what guarantees us compatibility of our 8812 driver with NH):

1)Image.gz-dtb in /path_to_your_kernel_src_dir/build/arch/arm64/boot/

to

/kali-nethunetr/nethunter-installer/devices/nougat/angler/

2)Modules files from

/path_to_your_kernel_src_dir/build/lib/modules/3.10.73-nethunter-angler-2.0/

to

/kali-nethunetr/nethunter-installer/devices/nougat/angler/modules/3.10.73-nethunter-angler-2.0

GOTO /kali-nethunter/nethunter-installer/

RUN in shell python build.py -d angler -n -fs full -su -nb

At this stage, we will get a standard image of NH that will be compatible with our driver. After standard flashing it into the phone, you can manually or via the start-up scripts load the 8812au.ko module previously copied to the phone.

I did not have time to integrate the 8812au.ko into the kernel image. I also encountered a serious bug that I didn’t have time to fix - unplug the 8812 adapter from the phone AFTER loading the 8812au.ko into the system (by insmod for example ) or down its interface (by iw etc.) ALWAYS causes the phone to reboot.

I think the problem is in some kernel power settings. And as long as I remember, even a simple plug to usb rt2800 or ath9k adapters causes the same problem.

8812au build with monitor mode on default. So after connect adapter and load module in system you can immediately capture packets. Beware of using some aircrack-ng scripts that by default try to down the interface for later up it in monitoring mode, after load module 8812au in system this procedure will cause a reboot phone.

alammer avatar Feb 25 '19 09:02 alammer

I found and added files for RTL8812AU. When you're free, let me know if it works.

rithvikvibhu avatar Apr 17 '19 03:04 rithvikvibhu

Sorry, been busy lately but found out that I need to downgrade my installation. Will probably do so this weekends and update you.

SirFell avatar May 03 '19 17:05 SirFell

Aaah my drivers added.. great work!

kimocoder avatar May 03 '19 19:05 kimocoder

@kimocoder Did it work for you?

rithvikvibhu avatar May 05 '19 12:05 rithvikvibhu

Haven't tested, busy with some work related stuff for some time

kimocoder avatar May 05 '19 12:05 kimocoder

@rithvikvibhu i am about to reflash rom onto my phone so probably can get back to you in ~2 hours give or take

SirFell avatar May 05 '19 12:05 SirFell

i guess im dumber than i thought and im having trouble pointing modprobe to module (am i even supposed to use modprobe?) since its not in /lib/modules/

SirFell avatar May 05 '19 16:05 SirFell

modprobe in AndroidSU before running "bootkali" remember. We're working on the issue

kimocoder avatar May 05 '19 17:05 kimocoder

yea modprobe on su throws me "no such file/directory" for 'modules.dep'

SirFell avatar May 05 '19 17:05 SirFell

Then you need to fix your kernel setup. Build with build.py from our NetHunter-Installer

kimocoder avatar May 05 '19 17:05 kimocoder

both py -2 build.py -d angler --nougat --rootfs full --nightly and py -2 build.py -d angler --nougat return updater process error 255 when flashed with TWRP

SirFell avatar May 05 '19 18:05 SirFell

I do it manually and run latest Oreo build and flashing only kernel the Magisk afterwards.

kimocoder avatar May 05 '19 18:05 kimocoder

It's my Oreo kernel in there and has all modules

kimocoder avatar May 05 '19 18:05 kimocoder

well i guess it wouldnt really be an option for now then as i would need to completely reflash to oreo from nougat and idea is to first test if this module works on nougat and only then update

Edit: i have tried to build (using build script) generic fs, oreo and nougat kernels, generic fs fails to flash through TWRP 3.3.0-0 on both stock nougat and oreo roms, would be nice if you could give more info on how to get it working.

SirFell avatar May 05 '19 19:05 SirFell

So i tried building from linux (19.04 ubuntu x64 VM) and zip built just fine and does not throw 255 error on install attempt, not sure if it will work if built with cygwin or something on windows, @rithvikvibhu if i can get card to work on oreo i will reinstall nougat with zips built from sources and report if i can get card to work on nougat. As a sidenote: Kimo, do you know of any "swipe up to wake" like in pureNexus but on 8.1.0 as i prefer that over double tap as ive seen you also have fine device that is Angler?

Edit: welp it didnt show any errors and appeared to flash fine but device seems to be bootlooping now at about moment system shouldve started

SirFell avatar May 06 '19 11:05 SirFell

We just pushed a new NetHunter release. Read more here https://www.kali.org/news/kali-linux-2019-2-release/

We still have issues that needs to be resolved, so we started on the 2019.3 allready. Will have mye drivers tested shortly. Remember, the rtl8812 stack is mashed under 1 module name (88XXau) but it supports 8811, 8812, 8814 and 8821 chipsets. And airmon-ng is supported now.

I'll be watching over here and may be at help 🙂

kimocoder avatar May 23 '19 14:05 kimocoder

I run a Nexus 6P with Android 8.1 kernel with all modules i wan't. My kernel is added to the build.py script, so Oreo is supported boys.

Went down to 8.0 to get Nexmon supported too yesterday, but Oreo kernel is available..

kimocoder avatar May 25 '19 18:05 kimocoder

Screenshot_20190525-202009

kimocoder avatar May 25 '19 18:05 kimocoder

Screenshot_20190525-202120

kimocoder avatar May 25 '19 18:05 kimocoder

Screenshot_20190525-202143

kimocoder avatar May 25 '19 18:05 kimocoder

@rithvikvibhu what you have to do, is rip out the firmware blob, if interested in learning howto make binaries of drivers, take a look at ulli-kroll's drivers/commits.

https://github.com/ulli-kroll

kimocoder avatar May 25 '19 18:05 kimocoder

Thanks, I'll go through at those repos soon. How portable are these firmware blobs? Between devices, arch, etc.

rithvikvibhu avatar May 28 '19 13:05 rithvikvibhu

So did anyone ever come up with firmware for this to work with android? Would be great if so and greatly appreciated especially seeing as how I'm not knowledgeable enough to contribute but would love to if I could.

Moonwalker86 avatar Sep 30 '19 12:09 Moonwalker86

Here you go..

https://github.com/kimocoder/DJY_88XXAU_For_4.4__4.9_4.14_4.19_Android_Kernel_Patch

kimocoder avatar Sep 30 '19 15:09 kimocoder

Wow! You are awesome my friend thank you so much!!

On Mon, Sep 30, 2019, 10:32 AM Christian Bremvåg [email protected] wrote:

Here you go..

https://github.com/kimocoder/DJY_88XXAU_For_4.4__4.9_4.14_4.19_Android_Kernel_Patch

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rithvikvibhu/nh-magisk-wifi-firmware/issues/11?email_source=notifications&email_token=AGNM7WPG26PKCISKFJRC7JLQMILYBA5CNFSM4GKR3SV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD76CDCY#issuecomment-536617355, or mute the thread https://github.com/notifications/unsubscribe-auth/AGNM7WLW3SHAVQEYP5S7VVLQMILYBANCNFSM4GKR3SVQ .

Moonwalker86 avatar Sep 30 '19 15:09 Moonwalker86

@SirFell

Take a look what I've done... Nexus 6P have it integrated in kernel :1st_place_medal:

IMG_20191219_053442

IMG_20191219_223704

IMG_20191219_042356_960

kimocoder avatar Dec 21 '19 08:12 kimocoder

Wow!! Bro, you have got to make all the little people out there a quick tutorial on how you accomplished this! Pretty sure you'll get moire than enough views just from the people that I know! Keep it up my friend, awesome work!!

On Sat, Dec 21, 2019, 2:18 AM Christian Bremvåg [email protected] wrote:

@SirFell https://github.com/SirFell

Take a look what I've done... Nexus 6P have it integrated in kernel 🥇

[image: IMG_20191219_053442] https://user-images.githubusercontent.com/4252297/71305348-b1202680-23d2-11ea-8e90-50343050f59b.jpg

[image: IMG_20191219_223704] https://user-images.githubusercontent.com/4252297/71305350-b1202680-23d2-11ea-921e-1bcbd494343c.jpg

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rithvikvibhu/nh-magisk-wifi-firmware/issues/11?email_source=notifications&email_token=AGNM7WPLDMIBKJMY72NPREDQZXGNRA5CNFSM4GKR3SV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHOXTZQ#issuecomment-568162790, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGNM7WNYZWA37MBBV2KWJUDQZXGNRANCNFSM4GKR3SVQ .

Moonwalker86 avatar Jan 06 '20 12:01 Moonwalker86

this patch will work with dreamlte s8 phone? https://github.com/kimocoder/DJY_88XXAU_For_4.4__4.9_4.14_4.19_Android_Kernel_Patch what kernel i should compile? only stock or custom like tgp s8? I prefer to have tgp 4.4.180 kernel. When i compile it from kernel source applying that patch and add line do that driver its compile but on my phone when i connect wifi usb nothing happen no wlan1 in andrax and dont have /lib/modules folder

unknown181818 avatar Jan 26 '20 10:01 unknown181818