From ee8a3d9675c233e94efa417c82558799db1e1cea Mon Sep 17 00:00:00 2001 From: ColorfulRhino <131405023+ColorfulRhino@users.noreply.github.com> Date: Sat, 30 Mar 2024 15:20:12 +0100 Subject: [PATCH] Kernel config hooks: Use `custom_kernel_config` instead of `armbian_kernel_config` Since `armbian_kernel_config` is "NOT for user consumption. Do NOT use this hook, this is internal to Armbian." `custom_kernel_config` is able to overwrite previously set values. --- config/boards/rpi5b.conf | 2 +- config/sources/families/include/meson64_common.inc | 2 +- lib/functions/compilation/kernel-config.sh | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/boards/rpi5b.conf b/config/boards/rpi5b.conf index 8fda42bd99..275b87438f 100644 --- a/config/boards/rpi5b.conf +++ b/config/boards/rpi5b.conf @@ -11,7 +11,7 @@ function post_family_config__rename_linux_family() { declare -g LINUXFAMILY=bcm2712 } -function armbian_kernel_config__rpi5b_16k_variant() { +function custom_kernel_config__rpi5b_16k_variant() { display_alert "rpi5b" "Enabling 16K page size" "info" kernel_config_modifying_hashes+=( "CONFIG_ARM64_16K_PAGES=y" diff --git a/config/sources/families/include/meson64_common.inc b/config/sources/families/include/meson64_common.inc index 9e71856ab2..9c79747c63 100644 --- a/config/sources/families/include/meson64_common.inc +++ b/config/sources/families/include/meson64_common.inc @@ -53,7 +53,7 @@ esac # Use custom vendor driver for wireless rtl88x2cs # See https://github.com/armbian/build/pull/6227 # @TODO Only use for BOARDFAMILY="jethub" devices? -function armbian_kernel_config__enable_rtl88x2cs_driver() { +function custom_kernel_config__enable_rtl88x2cs_driver() { kernel_config_modifying_hashes+=("CONFIG_RTL8822CS=m") if [[ -f .config ]]; then display_alert "Enabling rtl88x2cs driver in kernel config" "armbian-kernel" "wrn" diff --git a/lib/functions/compilation/kernel-config.sh b/lib/functions/compilation/kernel-config.sh index fbfa275f46..4cff8d8f4a 100644 --- a/lib/functions/compilation/kernel-config.sh +++ b/lib/functions/compilation/kernel-config.sh @@ -88,13 +88,16 @@ function kernel_config_initialize() { display_alert "Kernel configuration" "${LINUXCONFIG}" "info" } +# These kernel config hooks are always called twice, once without being in kernel directory and once with current directory being the kernel work directory. +# You must check with "if [[ -f .config ]]; then" in which of the two phases you are. Otherwise, functions like "kernel_config_set_y" won't work. function call_extensions_kernel_config() { # Run the core-armbian config modifications here, built-in extensions: call_extension_method "armbian_kernel_config" <<- 'ARMBIAN_KERNEL_CONFIG' *Armbian-core default hook point for pre-olddefconfig Kernel config modifications* NOT for user consumption. Do NOT use this hook, this is internal to Armbian. Instead, use `custom_kernel_config` which runs later and can undo anything done by this step. - Important: this hook might be run multiple times, and one of them might not have a .config in place. + IMPORTANT: this hook might be run multiple times, and one of them might not have a .config in place! + Therefore, please check with "if [[ -f .config ]]; then" if you want to modify the kernel config. Either way, the hook _must_ add representative changes to the `kernel_config_modifying_hashes` array, for kernel config hashing. Please note: Manually changing options doesn't check the validity of the .config file. Check for warnings in your build log. ARMBIAN_KERNEL_CONFIG @@ -105,7 +108,8 @@ function call_extensions_kernel_config() { Called after ${LINUXCONFIG}.config is put in place (.config). A good place to customize the .config directly. Armbian default Kconfig modifications have already been applied and can be overriden. - Important: this hook might be run multiple times, and one of them might not have a .config in place. + IMPORTANT: this hook might be run multiple times, and one of them might not have a .config in place! + Therefore, please check with "if [[ -f .config ]]; then" if you want to modify the kernel config. Either way, the hook _must_ add representative changes to the `kernel_config_modifying_hashes` array, for kernel config hashing. Please note: Manually changing options doesn't check the validity of the .config file. Check for warnings in your build log. CUSTOM_KERNEL_CONFIG