RTL88x2bu_chipset-driver-build with kernel-6.13 support

 Linux Driver for USB WiFi Adapters that are based on the RTL8812BU and RTL8822BU Chipsets

Thanks to morrownr

RTL88x2bu.SlackBuild
[code]
#!/bin/sh

# Slackware build script for RTL88x2bu driver

# Copyright 2025 JW(Shinichi Abe) <shin1.abe@nifty.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PRGNAM=RTL88x2bu
VERSION=${VERSION:-5.13.1}
GIT_SHORTVER=${GIT_SHORTVER:-20241206_139e4fc}
COMMIT=${COMMIT:-139e4fc2eeea7a140239d34c73b6bf4f69c1f74d}
KERNEL=${KERNEL:-$(uname -r)}
#KSHORT_VER=`uname -r | sed -e "s/-jw//"`
BUILD=${BUILD:-
2}
TAG=${TAG:-jw}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP

# Download source
# sh $CWD/fetch-RTL8812au-git_commit-source.sh
#
# fetch the commit git source
wget https://github.com/morrownr/88x2bu-20210702/archive/${COMMIT}/88x2bu-20210702-${COMMIT}.tar.gz

# Rename original git source name to "RTL88x2bu-${GIT_SHORTVER}"
tar xvf 88x2bu-20210702-${COMMIT}.tar.gz && mv 88x2bu-20210702-${COMMIT} RTL88x2bu-${GIT_SHORTVER}
rm 88x2bu-20210702-${COMMIT}.tar.gz

# Create tar.xz file for my packaging work
tar cJvf RTL88x2bu-${GIT_SHORTVER}.tar.xz RTL88x2bu-${GIT_SHORTVER}/ && rm -rf RTL88x2bu-${GIT_SHORTVER}/

echo "...DONE!"

rm -rf $PRGNAM-$GIT_SHORTVER
tar xvf $PRGNAM-${GIT_SHORTVER}.tar.xz

cd $PRGNAM-$GIT_SHORTVER
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

# Fix build for linux-6.13
zcat $CWD/001_RTL88x2bu_fix-build_for_linux-6.13.patch.gz | patch -p1 --verbose || exit 1


NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "}

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
make $NUMJOBS

mkdir -p $PKG/lib/modules/$KERNEL/kernel/drivers/net/wireless
install -m 0664 88x2bu.ko $PKG/lib/modules/$KERNEL/kernel/drivers/net/wireless/

mkdir -p $PKG/install
sed "s%@KERNEL@%$KERNEL%" $CWD/doinst.sh > $PKG/install/doinst.sh

find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

find $PKG -name perllocal.pod \
  -o -name ".packlist" \
  -o -name "*.bs" \
  | xargs rm -f

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
  docs LICENSE README.md supported-device-IDs \
  $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
#/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-${VERSION}_${KSHORT_VER}-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-${VERSION}_${KERNEL}-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}

001_RTL88x2bu_fix-build_for_linux-6.13.patch
[code]
diff -Nru a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c
--- a/os_dep/linux/ioctl_cfg80211.c    2025-01-21 17:47:07.510188310 +0900
+++ b/os_dep/linux/ioctl_cfg80211.c    2025-01-21 17:44:01.076172380 +0900
@@ -6911,7 +6911,10 @@
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) */
 
 static int cfg80211_rtw_set_monitor_channel(struct wiphy *wiphy
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0))
+    , struct net_device *dev
+    , struct cfg80211_chan_def *chandef
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
     , struct cfg80211_chan_def *chandef
 #else
     , struct ieee80211_channel *chan
diff -Nru a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c
--- a/os_dep/linux/os_intfs.c    2025-01-21 17:47:25.157189818 +0900
+++ b/os_dep/linux/os_intfs.c    2025-01-21 17:44:47.921176382 +0900
@@ -31,7 +31,7 @@
  * This declaration was created to resolve an error on Rockchip.
  * You can modify or add flags in the fs/Makefile.
  */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0))
     MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
 #endif

doinst.sh
[code]
chroot . /sbin/depmod -a @KERNEL@ 2>/dev/null


slack-desc
[code]
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':' except on otherwise blank lines.

         |-----handy-ruler------------------------------------------------------|
RTL88x2bu: RTL88x2bu (88x2bu.ko)
RTL88x2bu:
RTL88x2bu: Linux Driver for USB WiFi Adapters that are based on the RTL8812BU
RTL88x2bu: and RTL8822BU Chipsets
RTL88x2bu:
RTL88x2bu: HOME:https://github.com/morrownr/88x2bu-20210702
RTL88x2bu:
RTL88x2bu:
RTL88x2bu:
RTL88x2bu:
RTL88x2bu:


supported-device-IDs
[code]
USB Vendor and Device ID List for rtl8812bu and rtl8822bu chipset based USB WiFi Adapters

To determine your Device ID:

$ lsusb

Example output:

Bus 003 Device 011: ID 0bda:b812 Realtek Semiconductor Corp.

ID VendorID:DeviceID = 0bda:b812

We can search the list of driver supported IDs shown below.

Realtek default IDs (3)

ID 0BDA:B812 - Default ID for USB Single-function, WiFi only
ID 0BDA:B81A - Default ID
ID 0BDA:B82C - Default ID for USB multi-function (such as WiFi plus bluetooth)

Seller specific IDs (29)

ID 04CA:8602  /* LiteOn */
ID 056E:4011  /* Elecom */
ID 0846:9055  /* Netgear A6150 */
ID 0B05:1841  /* ASUS AC1300 USB-AC55 B1 */
ID 0B05:184C  /* ASUS U2 */
ID 0B05:1870  /* ASUS */
ID 0B05:1874  /* ASUS */
ID 0B05:19AA  /* ASUS - USB-AC58 rev A1 */
ID 0BDA:2102  /* CCNC */
ID 0E66:0025  /* Hawking HW12ACU */
ID 13B1:0043  /* Alpha - Linksys */
ID 13B1:0045  /* Linksys WUSB3600 v2 */
ID 2001:331E  /* Dlink - DWA-182 - D1 */
ID 2001:331C  /* Dlink - DWA-181 */
ID 2001:331F  /* Dlink - DWA-183 - D */
ID 20F4:805A  /* TRENDnet TEW-805UBH */
ID 20F4:808A  /* TRENDnet TEW-808UBM */
ID 2357:0115  /* TP-Link Archer T4U V3 */
ID 2357:0116  /* TP-LINK */
ID 2357:0117  /* TP-LINK */
ID 2357:012D  /* TP-Link Archer T3U v1 */
ID 2357:012E  /* TP-LINK */
ID 2357:0138  /* TP-Link Archer T3U Plus v1 */
ID 2C4E:0107  /* Mercusys MA30H */
ID 7392:B822  /* Edimax */
ID 7392:C822  /* Edimax */
ID 7392:D822  /* Edimax */
ID 7392:E822  /* Edimax */
ID 7392:F822  /* Edimax */

If your adapter matches one of the default or seller specific
IDs then this is the driver to use.

Info: location of file that contains the IDs: /os_dep/linux/usb_intf.c

If you are sure that your adapter contains either a rtl8812bu
or rtl8822bu chipset and the ID is not shown above, please provide
the follow information so that I can include your adapter in the
driver source code so that the driver will work with your adapter:

1. VendorID:DeviceID
2. Link to device on internet



===