添加构建Allwinner H616四核2GB RAM SoC WiFi(蓝莓)

This commit is contained in:
root
2023-09-19 11:24:52 +08:00
commit c97506efcc
10383 changed files with 16797445 additions and 0 deletions

View File

@@ -0,0 +1,202 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com
#
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
function kernel_drivers_create_patches_hash_only() {
hash_only="yes" kernel_drivers_create_patches "${@}"
}
function kernel_drivers_create_patches() {
if [[ "${EXTRAWIFI}" == "no" ]]; then
display_alert "Skipping driver harness as requested" "EXTRAWIFI = ${EXTRAWIFI} - returning" "debug"
return 0
fi
kernel_drivers_patch_hash="undetermined" # outer scope
kernel_drivers_patch_file="undetermined" # outer scope
declare hash_files # any changes in these files will trigger a cache miss; also any changes in misc .patch with "wireless" at start or "wifi" anywhere in the name
calculate_hash_for_files "${SRC}/lib/functions/compilation/patch/drivers_network.sh" "${SRC}/lib/functions/compilation/patch/drivers-harness.sh" "${SRC}"/patch/misc/wireless*.patch
declare hash_variables="undetermined"
do_normalize_src_path="no" calculate_hash_for_variables "${KERNEL_DRIVERS_SKIP[*]}"
declare hash_variables_short="${hash_variables:0:8}"
# Sanity check, the KERNEL_GIT_SHA1 gotta be sane.
[[ "${KERNEL_GIT_SHA1}" =~ ^[0-9a-f]{40}$ ]] || exit_with_error "KERNEL_GIT_SHA1 is not sane: '${KERNEL_GIT_SHA1}'"
declare cache_key_base="sha1_${KERNEL_GIT_SHA1}_${LINUXFAMILY}_${BRANCH}"
declare cache_key="${cache_key_base}_${hash_files}-${hash_variables_short}"
display_alert "Cache key base:" "$cache_key_base" "debug"
display_alert "Cache key:" "$cache_key" "debug"
declare cache_dir_base="${SRC}/cache/patch/kernel-drivers"
mkdir -p "${cache_dir_base}"
declare cache_target_file="${cache_dir_base}/${cache_key}.patch"
# outer scope variables:
kernel_drivers_patch_file="${cache_target_file}" # outer scope
kernel_drivers_patch_hash="${hash_files}" # outer scope
if [[ "${hash_only:-"no"}" == "yes" ]]; then
display_alert "Hash-only kernel driver requested" "$kernel_drivers_patch_hash - returning" "debug"
return 0
fi
declare kernel_work_dir="${1}"
declare kernel_git_revision="${2}"
# If the target file exists, we can skip the patch creation.
if [[ -f "${cache_target_file}" ]]; then
# Make sure the file is larger than 512 bytes. Old versions of this code left small/empty files on failure.
if [[ $(stat -c%s "${cache_target_file}") -gt 512 ]]; then
display_alert "Using cached drivers patch file for ${LINUXFAMILY}-${BRANCH}" "${cache_key}" "cachehit"
return
else
display_alert "Removing invalid/small cached drivers patch file for ${LINUXFAMILY}-${BRANCH}" "${cache_key}" "warn"
run_host_command_logged rm -fv "${cache_target_file}"
fi
fi
display_alert "Creating patches for kernel drivers" "version: 'sha1_${KERNEL_GIT_SHA1}' family: '${LINUXFAMILY}-${BRANCH}'" "info"
# if it does _not_ exist, fist clear the base, so no old patches are left over
run_host_command_logged rm -fv "${cache_dir_base}/*_${LINUXFAMILY}_${BRANCH}*"
# also clean up old-style cache base, used before we introduced KERNEL_GIT_SHA1
run_host_command_logged rm -fv "${cache_dir_base}/${KERNEL_MAJOR_MINOR}_${LINUXFAMILY}*"
# since it does not exist, go create it. this requires working tree.
declare target_patch_file="${cache_target_file}"
display_alert "Preparing patch for drivers" "version: sha1_${KERNEL_GIT_SHA1} kernel_work_dir: ${kernel_work_dir}" "debug"
kernel_drivers_prepare_harness "${kernel_work_dir}" "${kernel_git_revision}"
}
function kernel_drivers_prepare_harness() {
declare kernel_work_dir="${1}"
declare kernel_git_revision="${2}"
# outer scope variable: target_patch_file
declare -a all_drivers=(
driver_generic_bring_back_ipx
driver_mt7921u_add_pids
driver_rtl8152_rtl8153
driver_rtl8189ES
driver_rtl8189FS
driver_rtl8192EU
driver_rtl8811_rtl8812_rtl8814_rtl8821
driver_xradio_xr819
driver_rtl8811CU_rtl8821C
driver_rtl8188EU_rtl8188ETV
driver_rtl88x2bu
driver_rtw88
driver_rtl88x2cs
driver_rtl8822cs_bt
driver_rtl8723DS
driver_rtl8723DU
driver_rtl8822BS
driver_uwe5622_allwinner
driver_rtl8723cs
)
declare -a skip_drivers=("${KERNEL_DRIVERS_SKIP[@]}")
declare -a drivers=()
# Produce 'drivers' array by removing any drivers in 'skip_drivers' from 'all_drivers'
for driver in "${all_drivers[@]}"; do
for skip in "${skip_drivers[@]}"; do
if [[ "${driver}" == "${skip}" ]]; then
display_alert "Skipping kernel driver as instructed by KERNEL_DRIVERS_SKIP" "${driver}" "info"
continue 2 # 2: continue the _outer_ loop
fi
done
drivers+=("${driver}")
done
# change cwd to the kernel working dir
cd "${kernel_work_dir}" || exit_with_error "Failed to change directory to ${kernel_work_dir}"
#run_host_command_logged git status
run_host_command_logged git reset --hard "${kernel_git_revision}"
# git: remove tracked files, but not those in .gitignore
run_host_command_logged git clean -fd # no -x here
for driver in "${drivers[@]}"; do
display_alert "Preparing driver" "${driver}" "info"
# reset variables used by each driver
declare version="${KERNEL_MAJOR_MINOR}"
declare kernel_work_dir="${1}"
declare kernel_git_revision="${2}"
# for compatibility with `master`-based code
declare kerneldir="${kernel_work_dir}"
# change cwd to the kernel working dir
cd "${kernel_work_dir}" || exit_with_error "Failed to change directory to ${kernel_work_dir}"
# invoke the driver; non-armbian-next code.
"${driver}"
# recover from possible cwd changes in the driver code
cd "${kernel_work_dir}" || exit_with_error "Failed to change directory to ${kernel_work_dir}"
done
# git: check if there are modifications
if [[ -n "$(git status --porcelain)" ]]; then
display_alert "Drivers have modifications" "exporting patch into ${target_patch_file}" "info"
export_changes_as_patch_via_git_format_patch
else
exit_with_error "Applying drivers didn't produce changes."
fi
}
function export_changes_as_patch_via_git_format_patch() {
# git: add all modifications
run_host_command_logged git add .
declare -a common_envs=(
"HOME=${HOME}"
"PATH=${PATH}"
)
# git: commit the changes
declare -a git_params=(
"-c" "commit.gpgsign=false" # force gpgsign off; the user might have it enabled and it will fail.
)
declare -a commit_params=(
"--quiet" # otherwise too much output
-m "drivers for ${LINUXFAMILY}-${BRANCH} version ${KERNEL_MAJOR_MINOR} git sha1 ${KERNEL_GIT_SHA1}"
--author="${MAINTAINER} <${MAINTAINERMAIL}>"
)
declare -a commit_envs=(
"GIT_COMMITTER_NAME=${MAINTAINER}"
"GIT_COMMITTER_EMAIL=${MAINTAINERMAIL}"
)
run_host_command_logged env -i "${common_envs[@]@Q}" "${commit_envs[@]@Q}" git "${git_params[@]@Q}" commit "${commit_params[@]@Q}"
# export the commit as a patch
declare formatpatch_params=(
"-1" "--stdout"
"--unified=3" # force 3 lines of diff context
"--keep-subject" # do not add a prefix to the subject "[PATCH] "
# "--no-encode-email-headers" # do not encode email headers - @TODO does not exist under focal, disable
'--signature' "Armbian generated patch from drivers for kernel ${version} and family ${LINUXFAMILY}"
'--stat=120' # 'wider' stat output; default is 80
'--stat-graph-width=10' # shorten the diffgraph graph part, it's too long
"--zero-commit" # Output an all-zero hash in each patchs From header instead of the hash of the commit.
)
declare target_patch_file_tmp="${target_patch_file}.tmp"
# The redirect ">" is escaped here, so it's run inside the subshell, not in the current shell.
run_host_command_logged env -i "${common_envs[@]@Q}" git format-patch "${formatpatch_params[@]@Q}" ">" "${target_patch_file_tmp}"
# move the tmp to final, if it worked.
run_host_command_logged mv -v "${target_patch_file_tmp}" "${target_patch_file}"
}

View File

@@ -0,0 +1,735 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com
#
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
function driver_generic_bring_back_ipx() {
#
# Returning headers needed for some wireless drivers
#
if linux-version compare "${version}" ge 5.4; then
display_alert "Reverting upstream-removed" "IPX stuff needed for Wireless Drivers" "info"
process_patch_file "${SRC}/patch/misc/wireless-bring-back-headers.patch" "applying"
fi
}
driver_mt7921u_add_pids() {
# Add two popular cheap USB devices to the table
if linux-version compare "${version}" ge 6.1 && linux-version compare "${version}" lt 6.2; then
display_alert "Mediatek MT7921u" "Add Comfast CF952A and Netgear AXE3000" "info"
process_patch_file "${SRC}/patch/misc/wireless-mt7921u-add-pids.patch" "applying"
fi
}
driver_rtl8152_rtl8153() {
# Updated USB network drivers for RTL8152/RTL8153 based dongles that also support 2.5Gbs variants
if linux-version compare "${version}" ge 5.4 && linux-version compare "${version}" le 5.12 && [ "$LINUXFAMILY" != mvebu64 ] && [ "$LINUXFAMILY" != rk322x ] && [ "$LINUXFAMILY" != odroidxu4 ]; then
# attach to specifics tag or branch
local rtl8152ver="branch:master"
display_alert "Adding" "Drivers for 2.5Gb RTL8152/RTL8153 USB dongles ${rtl8152ver}" "info"
fetch_from_repo "$GITHUB_SOURCE/igorpecovnik/realtek-r8152-linux" "rtl8152" "${rtl8152ver}" "yes"
cp -R "${SRC}/cache/sources/rtl8152/${rtl8152ver#*:}"/{r8152.c,compatibility.h} \
"$kerneldir/drivers/net/usb/"
fi
}
driver_rtl8189ES() {
# Wireless drivers for Realtek 8189ES chipsets
if linux-version compare "${version}" ge 3.14; then
# attach to specifics tag or branch
local rtl8189esver="branch:master"
display_alert "Adding" "Wireless drivers for Realtek 8189ES chipsets ${rtl8189esver}" "info"
fetch_from_repo "$GITHUB_SOURCE/jwrdegoede/rtl8189ES_linux" "rtl8189es" "${rtl8189esver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl8189es"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8189es/"
cp -R "${SRC}/cache/sources/rtl8189es/${rtl8189esver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8189es"
# Makefile
cp "${SRC}/cache/sources/rtl8189es/${rtl8189esver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8189es/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8189es/${rtl8189esver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8189es/${rtl8189esver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8189es/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8189ES) += rtl8189es/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8189es\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl8189es/Makefile"
process_patch_file "${SRC}/patch/misc/wireless-rtl8189es-Fix-uninitialized-cfg80211-chan-def.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8189es-Fix-p2p-go-advertising.patch" "applying"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl8189es-Fix-VFS-import.patch" "applying"
# fix compilation for kernels >= 5.4.251
process_patch_file "${SRC}/patch/misc/wireless-rtl8189es-Fix-building-on-5.4.251-kernel.patch" "applying"
fi
}
driver_rtl8189FS() {
# Wireless drivers for Realtek 8189FS chipsets
if linux-version compare "${version}" ge 3.14; then
# attach to specifics tag or branch
local rtl8189fsver="branch:rtl8189fs"
display_alert "Adding" "Wireless drivers for Realtek 8189FS chipsets ${rtl8189fsver}" "info"
fetch_from_repo "$GITHUB_SOURCE/jwrdegoede/rtl8189ES_linux" "rtl8189fs" "${rtl8189fsver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl8189fs"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8189fs/"
cp -R "${SRC}/cache/sources/rtl8189fs/${rtl8189fsver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8189fs"
# Makefile
cp "${SRC}/cache/sources/rtl8189fs/${rtl8189fsver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8189fs/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8189fs/${rtl8189fsver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8189fs/${rtl8189fsver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8189fs/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8189FS) += rtl8189fs/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8189fs\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl8189fs/Makefile"
process_patch_file "${SRC}/patch/misc/wireless-rtl8189fs-fix-p2p-go-advertising.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8189fs-fix-and-enable-secondary-iface.patch" "applying"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl8189fs-Fix-VFS-import.patch" "applying"
# fix compilation for kernels >= 5.4.251
process_patch_file "${SRC}/patch/misc/wireless-rtl8189fs-Fix-building-on-5.4.251-kernel.patch" "applying"
fi
}
driver_rtl8192EU() {
# Wireless drivers for Realtek 8192EU chipsets
if linux-version compare "${version}" ge 3.14; then
# attach to specifics tag or branch
local rtl8192euver="branch:realtek-4.4.x"
display_alert "Adding" "Wireless drivers for Realtek 8192EU chipsets ${rtl8192euver}" "info"
fetch_from_repo "$GITHUB_SOURCE/Mange/rtl8192eu-linux-driver" "rtl8192eu" "${rtl8192euver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl8192eu"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8192eu/"
cp -R "${SRC}/cache/sources/rtl8192eu/${rtl8192euver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8192eu"
# Makefile
cp "${SRC}/cache/sources/rtl8192eu/${rtl8192euver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8192eu/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8192eu/${rtl8192euver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8192eu/${rtl8192euver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8192eu/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8192EU) += rtl8192eu/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8192eu\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
process_patch_file "${SRC}/patch/misc/wireless-rtl8192eu-Fix-p2p-go-advertising.patch" "applying"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl8192eu-Fix-VFS-import.patch" "applying"
# fix compilation for kernels >= 5.4.251
process_patch_file "${SRC}/patch/misc/wireless-rtl8192eu-Fix-building-on-5.4.251-kernel.patch" "applying"
fi
}
driver_rtl8811_rtl8812_rtl8814_rtl8821() {
# Wireless drivers for Realtek 8811, 8812, 8814 and 8821 chipsets
if linux-version compare "${version}" ge 3.14; then
# attach to specifics tag or branch
local rtl8812auver="commit:450db78f7bd23f0c611553eb475fa5b5731d6497"
display_alert "Adding" "Wireless drivers for Realtek 8811, 8812, 8814 and 8821 chipsets ${rtl8812auver}" "info"
fetch_from_repo "$GITHUB_SOURCE/aircrack-ng/rtl8812au" "rtl8812au" "${rtl8812auver}" "yes"
cd "$kerneldir" || exit
# Brief detour. Turns out that HardKernel's vendor odroidxu4 kernel already has this driver
# "slipstreamed" into it, complete with a bunch of PDF files and other junk.
# See https://github.com/hardkernel/linux/tree/odroid-5.4.y/drivers/net/wireless/rtl8812au
# If we remove them here, the resulting patch will contain binary diffs which are unsupported by patch(1).
# So if building for the odroidxu4/current, we'll leave the original files in place, and just overwrite
# the possibly-updated source files (not PDFs and such). Thanks, HardKernel.
if [[ "${LINUXFAMILY}/${BRANCH}" == "odroidxu4/current" ]]; then
display_alert "Skipping" "Removing rtl8812au files from odroidxu4 kernel" "info"
else
rm -rf "$kerneldir/drivers/net/wireless/rtl8812au"
fi
mkdir -p "$kerneldir/drivers/net/wireless/rtl8812au/"
cp -R "${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8812au"
# Makefile
cp "${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8812au/Makefile"
# Kconfig
cp "${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8812au/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_88XXAU) += rtl8812au/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8812au\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
# fix compilation for kernels >= 6.3
process_patch_file "${SRC}/patch/misc/wireless-rtl8812au-6.3.patch" "applying"
fi
}
driver_xradio_xr819() {
# Wireless drivers for Xradio XR819 chipsets
if linux-version compare "${version}" ge 4.19 && [[ "$LINUXFAMILY" == sunxi* ]]; then
display_alert "Adding" "Wireless drivers for Xradio XR819 chipsets" "info"
fetch_from_repo "$GITHUB_SOURCE/dbeinder/xradio" "xradio" "branch:karabek_rebase" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/xradio"
mkdir -p "$kerneldir/drivers/net/wireless/xradio/"
cp "${SRC}"/cache/sources/xradio/karabek_rebase/*.{h,c} \
"$kerneldir/drivers/net/wireless/xradio/"
# Makefile
cp "${SRC}/cache/sources/xradio/karabek_rebase/Makefile" \
"$kerneldir/drivers/net/wireless/xradio/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/xradio/karabek_rebase/Kconfig"
cp "${SRC}/cache/sources/xradio/karabek_rebase/Kconfig" \
"$kerneldir/drivers/net/wireless/xradio/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_WLAN_VENDOR_XRADIO) += xradio/" \
>> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/xradio\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
# add support for K5.13+
process_patch_file "${SRC}/patch/misc/wireless-xradio-5.13.patch" "applying"
# add support for K5.19+
process_patch_file "${SRC}/patch/misc/wireless-xradio-code-cleanup.patch" "applying"
# add support for K5.19+
process_patch_file "${SRC}/patch/misc/wireless-xradio-insmod-rmmod-fx.patch" "applying"
# add support for K5.19+
process_patch_file "${SRC}/patch/misc/wireless-xradio-5.19.patch" "applying"
# add support for K6.0+
process_patch_file "${SRC}/patch/misc/wireless-xradio-6.0.patch" "applying"
# add support for K6.1+
process_patch_file "${SRC}/patch/misc/wireless-xradio-6.1.patch" "applying"
# add support for K6.2+
process_patch_file "${SRC}/patch/misc/wireless-xradio-6.2.patch" "applying"
# vmmaped stack memory access fix
process_patch_file "${SRC}/patch/misc/wireless-xradio-vmmaped-stack-fix.patch" "applying"
# add support for aarch64
if [[ $ARCH == arm64 ]]; then
process_patch_file "${SRC}/patch/misc/wireless-xradio-aarch64.patch" "applying"
fi
fi
}
driver_rtl8811CU_rtl8821C() {
# Wireless drivers for Realtek RTL8811CU and RTL8821C chipsets
if linux-version compare "${version}" ge 3.14; then
# attach to specifics tag or branch
local rtl8811cuver="commit:9e2772540f66a69170f43864a6560d0d190d97b1"
display_alert "Adding" "Wireless drivers for Realtek RTL8811CU and RTL8821C chipsets ${rtl8811cuver}" "info"
fetch_from_repo "$GITHUB_SOURCE/morrownr/8821cu-20210916" "rtl8811cu" "${rtl8811cuver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl8811cu"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8811cu/"
cp -R "${SRC}/cache/sources/rtl8811cu/${rtl8811cuver#*:}"/{core,hal,include,os_dep,platform,*.mk} \
"$kerneldir/drivers/net/wireless/rtl8811cu"
# Makefile
cp "${SRC}/cache/sources/rtl8811cu/${rtl8811cuver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8811cu/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8811cu/${rtl8811cuver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8811cu/${rtl8811cuver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8811cu/Kconfig"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl8811cu/Makefile"
# Address ARM related bug $GITHUB_SOURCE/aircrack-ng/rtl8812au/issues/233
sed -i "s/^CONFIG_MP_VHT_HW_TX_MODE.*/CONFIG_MP_VHT_HW_TX_MODE = n/" \
"$kerneldir/drivers/net/wireless/rtl8811cu/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8821CU) += rtl8811cu/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8811cu\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
process_patch_file "${SRC}/patch/misc/wireless-rtl8811cu-Fix-p2p-go-advertising.patch" "applying"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl8811cu-Fix-VFS-import.patch" "applying"
fi
}
driver_rtl8188EU_rtl8188ETV() {
# Wireless drivers for Realtek 8188EU 8188EUS and 8188ETV chipsets
if linux-version compare "${version}" ge 3.14 &&
linux-version compare "${version}" lt 5.15; then
# attach to specifics tag or branch
local rtl8188euver="branch:v5.7.6.1"
display_alert "Adding" "Wireless drivers for Realtek 8188EU 8188EUS and 8188ETV chipsets ${rtl8188euver}" "info"
fetch_from_repo "$GITHUB_SOURCE/aircrack-ng/rtl8188eus" "rtl8188eu" "${rtl8188euver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl8188eu"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8188eu/"
cp -R "${SRC}/cache/sources/rtl8188eu/${rtl8188euver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8188eu"
# Makefile
cp "${SRC}/cache/sources/rtl8188eu/${rtl8188euver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8188eu/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8188eu/${rtl8188euver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8188eu/${rtl8188euver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8188eu/Kconfig"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl8188eu/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8188EU) += rtl8188eu/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8188eu\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
process_patch_file "${SRC}/patch/misc/wireless-rtl8188eu.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-realtek-8188eu-5.12.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8188eu-Fix-uninitialized-cfg80211-chan-def.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8188eu-Fix-p2p-go-advertising.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8188eu-Fix-misleading-indentation.patch" "applying"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl8188eu-Fix-VFS-import.patch" "applying"
fi
}
driver_rtl88x2bu() {
# Wireless drivers for Realtek 88x2bu chipsets
if linux-version compare "${version}" ge 5.0; then
# attach to specifics tag or branch
local rtl88x2buver="commit:2590672d717e2516dd2e96ed66f1037a6815bced"
display_alert "Adding" "Wireless drivers for Realtek 88x2bu chipsets ${rtl88x2buver}" "info"
fetch_from_repo "$GITHUB_SOURCE/morrownr/88x2bu-20210702" "rtl88x2bu" "${rtl88x2buver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl88x2bu"
mkdir -p "$kerneldir/drivers/net/wireless/rtl88x2bu/"
cp -R "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}"/{core,hal,include,os_dep,platform,halmac.mk,rtl8822b.mk} \
"$kerneldir/drivers/net/wireless/rtl88x2bu"
# Makefile
cp "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl88x2bu/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl88x2bu/Kconfig"
# Adjust path
sed -i "s/include \$(src)\/rtl8822b.mk /include \$(TopDIR)\/drivers\/net\/wireless\/rtl88x2bu\/rtl8822b.mk/" \
"$kerneldir/drivers/net/wireless/rtl88x2bu/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8822BU) += rtl88x2bu/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i "/source \"drivers\/net\/wireless\/ti\/Kconfig\"/a source \"drivers\/net\/wireless\/rtl88x2bu\/Kconfig\"" \
"$kerneldir/drivers/net/wireless/Kconfig"
process_patch_file "${SRC}/patch/misc/wireless-rtl88x2bu-Fix-p2p-go-advertising.patch" "applying"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl88x2bu-Fix-VFS-import.patch" "applying"
# fix compilation for kernels >= 6.3
process_patch_file "${SRC}/patch/misc/wireless-rtl88x2bu-6.3.0.patch" "applying"
# fix compilation for kernels >= 6.3.13 < 6.4 and >= 6.5
process_patch_file "${SRC}/patch/misc/wireless-rtl88x2bu-wireless-ignore-stale-kickoff-removal.patch" "applying"
fi
}
driver_rtw88() {
# Quite a few kernel families have KERNEL_DRIVERS_SKIP listing this driver. If so, this won't even be called.
# Upstream wireless RTW88 drivers (wireless-next-2023-08-25)
if linux-version compare "${version}" ge 6.1; then
display_alert "Adding" "Upstream wireless RTW88 drivers" "info"
process_patch_file "${SRC}/patch/misc/rtw88/${version}/001-drivers-net-wireless-realtek-rtw88-upstream-wireless.patch" "applying"
process_patch_file "${SRC}/patch/misc/rtw88/hack/002-rtw88-usb-make-work-queues-high-priority.patch" "applying"
process_patch_file "${SRC}/patch/misc/rtw88/hack/003-rtw88-decrease-the-log-level-of-tx-report.patch" "applying"
fi
}
driver_rtl88x2cs() {
# Wireless drivers for Realtek 88x2cs chipsets
if linux-version compare "${version}" ge 5.9 && linux-version compare "${version}" lt 6.1; then
# attach to specifics tag or branch
local rtl88x2csver="branch:tune_for_jethub"
display_alert "Adding" "Wireless drivers for Realtek 88x2cs chipsets ${rtl88x2csver}" "info"
fetch_from_repo "$GITHUB_SOURCE/jethome-ru/rtl88x2cs" "rtl88x2cs" "${rtl88x2csver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl88x2cs"
mkdir -p "$kerneldir/drivers/net/wireless/rtl88x2cs/"
cp -R "${SRC}/cache/sources/rtl88x2cs/${rtl88x2csver#*:}"/{core,hal,include,os_dep,platform,halmac.mk,ifcfg-wlan0,rtl8822c.mk,runwpa,wlan0dhcp} \
"$kerneldir/drivers/net/wireless/rtl88x2cs"
# Makefile
cp "${SRC}/cache/sources/rtl88x2cs/${rtl88x2csver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl88x2cs/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl88x2cs/${rtl88x2csver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl88x2cs/${rtl88x2csver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl88x2cs/Kconfig"
# Adjust path
sed -i "s/include \$(src)\/rtl8822c.mk/include \$(TopDIR)\/drivers\/net\/wireless\/rtl88x2cs\/rtl8822c.mk/" \
"$kerneldir/drivers/net/wireless/rtl88x2cs/Makefile"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl88x2cs/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8822CS) += rtl88x2cs/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl88x2cs\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl88x2cs-Fix-VFS-import.patch" "applying"
fi
}
#_bt for blueteeth
driver_rtl8822cs_bt() {
# Bluetooth support for Realtek 8822CS (hci_ver 0x8) chipsets
# both of these patches were upstreamed in 5.18
if linux-version compare "${version}" ge 5.11 && linux-version compare "${version}" lt 5.18; then
display_alert "Adding" "Bluetooth support for Realtek 8822CS (hci_ver 0x8) chipsets" "info"
process_patch_file "${SRC}/patch/misc/bluetooth-rtl8822cs-hci_ver-0x8.patch" "applying"
process_patch_file "${SRC}/patch/misc/Bluetooth-hci_h5-Add-power-reset-via-gpio-in-h5_btrt.patch" "applying"
fi
}
driver_rtl8723DS() {
# Wireless drivers for Realtek 8723DS chipsets
if linux-version compare "${version}" ge 5.0; then
# attach to specifics tag or branch
local rtl8723dsver="branch:master"
display_alert "Adding" "Wireless drivers for Realtek 8723DS chipsets ${rtl8723dsver}" "info"
fetch_from_repo "$GITHUB_SOURCE/lwfinger/rtl8723ds" "rtl8723ds" "${rtl8723dsver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl8723ds"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8723ds/"
cp -R "${SRC}/cache/sources/rtl8723ds/${rtl8723dsver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8723ds"
# Makefile
cp "${SRC}/cache/sources/rtl8723ds/${rtl8723dsver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8723ds/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8723ds/${rtl8723dsver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8723ds/${rtl8723dsver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8723ds/Kconfig"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl8723ds/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8723DS) += rtl8723ds/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8723ds\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723ds-Fix-p2p-go-advertising.patch" "applying"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl8723ds-Fix-VFS-import.patch" "applying"
fi
}
driver_rtl8723DU() {
# Wireless drivers for Realtek 8723DU chipsets
if linux-version compare "${version}" ge 5.0; then
local rtl8723duver="branch:master"
display_alert "Adding" "Wireless drivers for Realtek 8723DU chipsets ${rtl8723duver}" "info"
fetch_from_repo "$GITHUB_SOURCE/lwfinger/rtl8723du" "rtl8723du" "${rtl8723duver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl8723du"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8723du/"
cp -R "${SRC}/cache/sources/rtl8723du/${rtl8723duver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8723du"
# Makefile
cp "${SRC}/cache/sources/rtl8723du/${rtl8723duver#*:}"/Makefile \
"$kerneldir/drivers/net/wireless/rtl8723du/Makefile"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl8723du/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8723DU) += rtl8723du/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8723du\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723du-5.19.2.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723du-Fix-uninitialized-cfg80211-chan-def.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723du-Fix-p2p-go-advertising.patch" "applying"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl8723du-Fix-VFS-import.patch" "applying"
# fix compilation for kernels >= 6.3
process_patch_file "${SRC}/patch/misc/wireless-rtl8723du-6.3.patch" "applying"
fi
}
driver_rtl8822BS() {
# Wireless drivers for Realtek 8822BS chipsets
if linux-version compare "${version}" ge 4.4 && linux-version compare "${version}" le 5.16; then
# attach to specifics tag or branch
display_alert "Adding" "Wireless drivers for Realtek 8822BS chipsets ${rtl8822bsver}" "info"
local rtl8822bsver="branch:local_rtl8822bs"
fetch_from_repo "$GITHUB_SOURCE/150balbes/wifi" "rtl8822bs" "${rtl8822bsver}" "yes"
cd "$kerneldir" || exit
rm -rf "$kerneldir/drivers/net/wireless/rtl8822bs"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8822bs/"
cp -R "${SRC}/cache/sources/rtl8822bs/${rtl8822bsver#*:}"/{core,hal,include,os_dep,platform,bluetooth,getAP,rtl8822b.mk} \
"$kerneldir/drivers/net/wireless/rtl8822bs"
# Remove some leftover binary files that shouldn't be there. firmware?
rm -fv "$kerneldir/drivers/net/wireless/rtl8822bs/bluetooth/rtl8822b_config.bin" "$kerneldir/drivers/net/wireless/rtl8822bs/bluetooth/rtl8822b_fw.bin"
# Makefile
cp "${SRC}/cache/sources/rtl8822bs/${rtl8822bsver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8822bs/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8822bs/${rtl8822bsver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8822bs/${rtl8822bsver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8822bs/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8822BS) += rtl8822bs/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8822bs\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
process_patch_file "${SRC}/patch/misc/wireless-rtl8822bs-Fix-uninitialized-cfg80211-chan-def.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8822bs-Fix-p2p-go-advertising.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8822bs-Fix-misleading-indentation.patch" "applying"
# fix compilation for kernels >= 5.4
process_patch_file "${SRC}/patch/misc/wireless-rtl8822bs-Fix-VFS-import.patch" "applying"
fi
}
driver_uwe5622_allwinner() {
# Unisoc uwe5622 wireless Support
if linux-version compare "${version}" ge 5.15 && linux-version compare "${version}" le 6.5 && [[ "$LINUXFAMILY" == sunxi* || "$LINUXFAMILY" == rockchip64 ]]; then
display_alert "Adding" "Drivers for Unisoc uwe5622 found on some Allwinner and Rockchip boards" "info"
if linux-version compare "${version}" ge 6.3; then
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-allwinner-v6.3.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-allwinner-bugfix-v6.3.patch" "applying"
else
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-allwinner.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-allwinner-bugfix.patch" "applying"
fi
if linux-version compare "${version}" ge 6.4; then
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-v6.4-post.patch" "applying"
fi
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-warnings.patch" "applying"
# Add to section Makefile
echo "obj-\$(CONFIG_SPARD_WLAN_SUPPORT) += uwe5622/" >> "$kerneldir/drivers/net/wireless/Makefile"
# Don't add this to legacy (<5.0) kernels.
if linux-version compare "${version}" ge 5.0 && linux-version compare "${version}" lt 6.1; then
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-park-link-pre-v6.1.patch" "applying"
fi
if linux-version compare "${version}" ge 6.1; then
if linux-version compare "${version}" ge 6.2 && linux-version compare "${version}" lt 6.3; then # only for 6.2.y
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-park-link-v6.2-only.patch" "applying"
else # assume 6.1.y y > 30
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-park-link-v6.1-post.patch" "applying"
fi
process_patch_file "${SRC}/patch/misc/wireless-driver-for-uwe5622-v6.1.patch" "applying"
fi
fi
}
driver_rtl8723cs() {
# Realtek rtl8723cs wireless support.
# Driver has been borrowed from sunxi 6.1 megous patch archive.
# Applies only from linux 6.1 onwards, so older kernel archives does not require to be altered
# It was disabled from d1/bcm2711 as that kernel is not fully in sync with mainline and as its probably not needed there anyway
if [[ "$LINUXFAMILY" == bcm2711 || "$LINUXFAMILY" == d1 ]]; then
return 0
fi
if linux-version compare "${version}" ge 6.1; then
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Add-a-new-driver-v5.12.2-7-g2de5ec386.20201013_beta.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Make-the-driver-compile-and-probe-drop-rockchip-platform.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Enable-OOB-interrupt.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Load-the-MAC-address-from-local-mac-address.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Modify-makefile-options-to-better-suit-PinePhone-Allwinn.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Enable-monitor-mode.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Disable-power-saving.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-aes_encrypt-aes_encrypt_128-to-avoid-symbol-name-conflic.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Enable-wifi-power-saving-mode.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Enable-TDLS-802.11z-support-direct-sta-sta-connection.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Disable-CONFIG_CONCURRENT_MODE.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Set-CONFIG_RTW_SDIO_PM_KEEP_POWER-n-to-fix-suspend-38.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Resume-wifi-in-a-workqueue.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Port-to-5.11.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Enable-WoWLAN.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Port-to-5.12.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Fix-misleading-indentation.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Disable-use-of-NAPI.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Fix-indentation.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Fix-compile-warnings.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Port-to-5.15.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Clear-wowlan_last_wake_reason-prior-to-suspend.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Forward-port-to-5.17.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Port-to-5.18.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Fix-some-compilation-warnings.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Adapt-to-API-changes-in-stable-5.19.2-and-6.0.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Port-to-6.0.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Port-to-6.1.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Port-to-6.1-rc1.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/dt-bindings-net-bluetooth-Add-rtl8723bs-bluetooth.patch" "applying"
if linux-version compare "${version}" ge 6.2 && linux-version compare "${version}" lt 6.3; then # landed in 6.1.30/6.3.4 # keep for 6.2
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/bluetooth-btrtl-quirk-local-ext-features.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/Bluetooth-btrtl-add-support-for-the-RTL8723CS.patch" "applying"
fi
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/Bluetooth-hci_h5-Add-support-for-binding-RTL8723CS-with-device-.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/bluetooth-h5-Don-t-re-initialize-rtl8723cs-on-resume.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/bluetooth-btrtl-add-rtl8703bs.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Fix-symbol-conflicts-with-rtw88-driver.patch" "applying"
fi
if linux-version compare "${version}" ge 6.3; then
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Port-to-6.3.patch" "applying"
fi
if linux-version compare "${version}" ge 6.5; then
process_patch_file "${SRC}/patch/misc/wireless-rtl8723cs/8723cs-Port-to-6.5.patch" "applying"
fi
}

View File

@@ -0,0 +1,228 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com
#
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
# advanced_patch <patch_kind> <{patch_dir}> <board> <target> <branch> <description>
#
# parameters:
# <patch_kind>: u-boot, kernel, atf
# <{patch_dir}>: u-boot: u-boot, u-boot-neo; kernel: sun4i-default, sunxi-next, ...
# <board>: cubieboard, cubieboard2, cubietruck, ...
# <target>: optional subdirectory
# <description>: additional description text
# calls:
# ${patch_kind} ${patch_dir} $board $target $branch $description
# kernel: advanced_patch "kernel" "$KERNELPATCHDIR" "$BOARD" "" "$BRANCH" "$LINUXFAMILY-$BRANCH"
# u-boot: advanced_patch "u-boot" "$BOOTPATCHDIR" "$BOARD" "$target_patchdir" "$BRANCH" "${LINUXFAMILY}-${BOARD}-${BRANCH}"
function advanced_patch() {
local patch_kind="$1"
local patch_dir="$2"
local board="$3"
local target="$4"
local branch="$5"
local description="$6"
display_alert "Started patching process for" "${patch_kind} $description" "info"
display_alert "Looking for user patches in" "userpatches/${patch_kind}/${patch_dir}" "info"
local names=()
local dirs=(
"$USERPATCHES_PATH/${patch_kind}/${patch_dir}/target_${target}:[\e[33mu\e[0m][\e[34mt\e[0m]"
"$USERPATCHES_PATH/${patch_kind}/${patch_dir}/board_${board}:[\e[33mu\e[0m][\e[35mb\e[0m]"
"$USERPATCHES_PATH/${patch_kind}/${patch_dir}/branch_${branch}:[\e[33mu\e[0m][\e[33mb\e[0m]"
"$USERPATCHES_PATH/${patch_kind}/${patch_dir}:[\e[33mu\e[0m][\e[32mc\e[0m]"
"$SRC/patch/${patch_kind}/${patch_dir}/target_${target}:[\e[32ml\e[0m][\e[34mt\e[0m]" # used for u-boot "spi" stuff
"$SRC/patch/${patch_kind}/${patch_dir}/board_${board}:[\e[32ml\e[0m][\e[35mb\e[0m]" # used for u-boot board-specific stuff
"$SRC/patch/${patch_kind}/${patch_dir}/branch_${branch}:[\e[32ml\e[0m][\e[33mb\e[0m]" # NOT used, I think.
"$SRC/patch/${patch_kind}/${patch_dir}:[\e[32ml\e[0m][\e[32mc\e[0m]" # used for everything
)
local links=()
# required for "for" command
# @TODO these shopts leak for the rest of the build script! either make global, or restore them after this function
shopt -s nullglob dotglob
# get patch file names
for dir in "${dirs[@]}"; do
for patch in ${dir%%:*}/*.patch; do
names+=($(basename "${patch}"))
done
# add linked patch directories
if [[ -d ${dir%%:*} ]]; then
local findlinks
findlinks=$(find "${dir%%:*}" -maxdepth 1 -type l -print0 2>&1 | xargs -0)
[[ -n $findlinks ]] && readarray -d '' links < <(find "${findlinks}" -maxdepth 1 -type f -follow -print -iname "*.patch" -print | grep "\.patch$" | sed "s|${dir%%:*}/||g" 2>&1)
fi
done
# merge static and linked
names=("${names[@]}" "${links[@]}")
# remove duplicates
local names_s=($(echo "${names[@]}" | tr ' ' '\n' | LC_ALL=C sort -u | tr '\n' ' '))
# apply patches
for name in "${names_s[@]}"; do
for dir in "${dirs[@]}"; do
if [[ -f ${dir%%:*}/$name ]]; then
if [[ -s ${dir%%:*}/$name ]]; then
process_patch_file "${dir%%:*}/$name" "${dir##*:}"
else
display_alert "* ${dir##*:} $name" "skipped"
fi
break # next name
fi
done
done
}
# process_patch_file <file> <description>
#
# parameters:
# <file>: path to patch file
# <status>: additional status text
#
process_patch_file() {
local patch="${1}"
local status="${2}"
local -i patch_date
local relative_patch="${patch##"${SRC}"/}" # ${FOO##prefix} remove prefix from FOO
# detect and remove files which patch will create
lsdiff -s --strip=1 "${patch}" | grep '^+' | awk '{print $2}' | xargs -I % sh -c 'rm -f %'
# shellcheck disable=SC2015 # noted, thanks. I need to handle exit code here.
patch --batch -p1 -N --input="${patch}" --quiet --reject-file=- && { # "-" discards rejects
display_alert "* $status ${relative_patch}" "" "info"
} || {
display_alert "* $status ${relative_patch}" "failed" "err"
exit_with_error "Patching error, exiting."
}
return 0 # short-circuit above, avoid exiting with error
}
function userpatch_create() {
declare patch_type="${1}"
declare -a common_git_params=(
"-c" "commit.gpgsign=false"
"-c" "user.name='${MAINTAINER}'"
"-c" "user.email='${MAINTAINERMAIL}'"
)
# export the commit as a patch
declare formatpatch_params=(
"-1" "HEAD" "--stdout"
"--unified=5" # force 5 lines of diff context
"--keep-subject" # do not add a prefix to the subject "[PATCH] "
'--signature' "'Created with Armbian build tools https://github.com/armbian/build'"
'--stat=120' # 'wider' stat output; default is 80
'--stat-graph-width=10' # shorten the diffgraph graph part, it's too long
"--zero-commit" # Output an all-zero hash in each patchs From header instead of the hash of the commit.
)
# if stdin is not a terminal, bail out
[[ -t 0 ]] || exit_with_error "patching: stdin is not a terminal"
[[ -t 1 ]] || exit_with_error "patching: stdout is not a terminal"
# Display a header with instructions about MAINTAINER and MAINTAINERMAIL
display_alert "Starting" "interactive patching process for ${patch_type}" "ext"
# create commit to start from clean source; don't fail.
display_alert "Creating commit to start from clean source" "" "info"
run_host_command_logged git "${common_git_params[@]}" add . "||" true
run_host_command_logged git "${common_git_params[@]}" commit -q -m "'Previous changes made by Armbian'" "||" true
display_alert "Patches will be created" "with the following maintainer information" "info"
display_alert "MAINTAINER (Real name): " "${MAINTAINER}" "info"
display_alert "MAINTAINERMAIL (Email): " "${MAINTAINERMAIL}" "info"
display_alert "If those are not correct, set them in your environment, command line, or config file and restart the process" "" ""
mkdir -p "${DEST}/patch"
declare patch="${DEST}/patch/${patch_type}-${LINUXFAMILY}-${BRANCH}.patch"
# prompt to alter source
display_alert "Make your changes in this directory:" "$(pwd)" "wrn"
if [[ "${ARMBIAN_RUNNING_IN_CONTAINER}" == "yes" ]]; then
display_alert "You are running in a container" "Path shown above might not match host system, be aware." "wrn"
fi
# If the ${patch} file already exists, offer to apply it before continuing patching.
if [[ -f "${patch}" ]]; then
display_alert "A previously-created patch file already exists!" "${patch}" "wrn"
declare apply_patch
read -r -e -p "Do you want to apply it before continuing? [y/N] " apply_patch
if [[ "${apply_patch}" == "y" ]]; then
display_alert "Applying patch" "${patch}" "info"
run_host_command_logged git "${common_git_params[@]}" apply "${patch}" || display_alert "Patch failed to apply, continuing..." "${patch}" "wrn"
fi
fi
# Enter a loop, waiting for ENTER, then showing the git diff, and have the user confirm he is happy with patch
declare user_happy="no"
while [[ "${user_happy}" != "yes" ]]; do
display_alert "Press <ENTER> after you are done" "editing files in $(pwd)" "wrn"
# Wait for user to press ENTER
declare stop_patching
read -r -e -p "Press ENTER to show a preview of your patch, or type 'stop' to stop patching..." stop_patching
[[ "${stop_patching}" == "stop" ]] && exit_with_error "Aborting due to" "user request"
# Detect if there are any changes done to the working tree
declare -i changes_in_working_tree
changes_in_working_tree=$(git "${common_git_params[@]}" status --porcelain | wc -l)
if [[ ${changes_in_working_tree} -lt 1 ]]; then
display_alert "No changes detected!" "No changes in the working tree, please edit files and try again" "wrn"
continue # no changes, loop again
fi
display_alert "OK, here's how your diff looks like" "showing patch diff" "info"
git "${common_git_params[@]}" diff | run_tool_batcat --file-name "${patch}" -
# Prompt the user if he is happy with the patch
display_alert "Are you happy with this patch?" "Type 'yes' to accept, 'stop' to stop patching, or anything else to keep patching" "wrn"
# Wait for user to type yes or no
read -r -e -p "Are you happy with the diff above? Type 'y' or 'yes' to accept, 'stop' to stop patching, anything else to keep patching: " -i "" user_happy
declare first_uppercase_character_of_user_happy="${user_happy:0:1}"
first_uppercase_character_of_user_happy="${first_uppercase_character_of_user_happy^^}"
[[ "${first_uppercase_character_of_user_happy}" == "Y" ]] && break
[[ "${first_uppercase_character_of_user_happy}" == "S" ]] && exit_with_error "Aborting due to user request"
display_alert "Not happy? No problem!" "just keep on editing the files..." "wrn"
done
display_alert "OK, user is happy with diff" "proceeding with patch creation" "ext"
run_host_command_logged git add .
# create patch out of changes
if ! git "${common_git_params[@]}" diff-index --quiet --cached HEAD; then
# Default the patch_commit_message.
# Get a list of all the filenames in the git diff into a bash array...
declare -a changed_filenames=($(git "${common_git_params[@]}" diff-index --cached --name-only HEAD))
display_alert "Names of the changed files" "${changed_filenames[*]@Q}" "info"
declare patch_commit_message="Patching ${patch_type} ${LINUXFAMILY} files ${changed_filenames[*]@Q}"
# If Git is configured, create proper patch and ask for a name
display_alert "Add / change patch name" "${patch_commit_message}" "wrn"
read -e -p "Patch Subject: " -i "${patch_commit_message}" patch_commit_message
[[ -z "${patch_commit_message}" ]] && patch_commit_message="Patching something unknown and mysterious"
run_host_command_logged git "${common_git_params[@]}" commit -s -m "'${patch_commit_message}'"
run_host_command_logged git "${common_git_params[@]}" format-patch "${formatpatch_params[@]}" ">" "${patch}"
display_alert "You will find your patch here:" "${patch}" "info"
run_tool_batcat --file-name "${patch}" "${patch}"
display_alert "You will find your patch here:" "${patch}" "info"
display_alert "Now you can manually move the produced patch to your userpatches or core patches to have it included in the next build" "${patch}" "ext"
else
display_alert "No changes found, skipping patch creation" "" "err"
fi
}