From 15cd49893c3c6c81d0c0966ab6d47da5948ae4e0 Mon Sep 17 00:00:00 2001 From: taocy Date: Mon, 8 Jun 2020 01:55:42 +0000 Subject: [PATCH 1/2] Add ARM architecture support to manage-config, Remove kernel options that are only supported by amd64 for arm64. --- Makefile | 2 +- manage-config | 54 ++++++++++++++++++++++++++++++++++++++++ patch/kconfig-inclusions | 20 +++++++-------- 3 files changed, 65 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 80b90a33c..437aa932c 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Optionally add/remove kernel options if [ -f ../manage-config ]; then - ../manage-config amd64 + ../manage-config $(CONFIGURED_ARCH) fi # Building a custom kernel from Debian kernel source diff --git a/manage-config b/manage-config index 36f92c380..7211a7276 100755 --- a/manage-config +++ b/manage-config @@ -29,12 +29,50 @@ case "$ARCH" in amd64) CONFIG_FILE_LOC=debian/build/build_amd64_none_amd64 ;; + arm64) + CONFIG_FILE_LOC=debian/build/build_arm64_none_arm64 + ;; + armhf) + CONFIG_FILE_LOC=debian/build/build_armhf_none_armmp + ;; *) CONFIG_FILE_LOC=debian/build/build_amd64_none_amd64 ;; esac CONFIG_FILE=${CONFIG_FILE_LOC}/.config +# Add multi-architecture support +# +# To remove the option for specify architecture from the kernel, +# add the arch tag such as [amd64] or [arm64] or [armhf] and options into the +# flat text file patch/kconfig-exclusions. +# if no tag appears, it is in effect for all architectures. +# +# Example: +# [amd64]CONFIG_SOUND +# [arm64]CONFIG_ISDN +# [armhf]CONFIG_ISDN +# +# To add the options for specify architecture into the kernel, +# add the arch tag such as [amd64] or [arm64] or [armhf] options into the +# flat text file patch/kconfig-inclusions. +# if no tag appears, it is in effect for all architectures. +# +# Example: +# [amd64]CONFIG_AD5064=y + +function match_arch(){ + opt=$1 + assigned_arch=$(expr $opt : '.*\[\(.*\)\]') + if [ ! -z "$assigned_arch" ]; then + if [ ! "$assigned_arch" = "$ARCH" ]; then + return 1 + else + opt=${opt#*]} + fi + fi +} + ret=0 if [ -e ../patch/kconfig-exclusions -o -e ../patch/kconfig-inclusions ]; then @@ -43,6 +81,10 @@ then if [ -f ../patch/kconfig-exclusions ]; then while read -r opt; do if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then + match_arch $opt + if [ $? = 1 ]; then + continue + fi scripts/config --file ${CONFIG_FILE} -d $opt fi done < ../patch/kconfig-exclusions; @@ -52,6 +94,10 @@ then if [ -f ../patch/kconfig-inclusions ]; then while read -r opt; do if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then + match_arch $opt + if [ $? = 1 ]; then + continue + fi echo $opt >> ${CONFIG_FILE} fi done < ../patch/kconfig-inclusions; @@ -66,6 +112,10 @@ then echo "Checking removed kernel options..." while read -r opt; do if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then + match_arch $opt + if [ $? = 1 ]; then + continue + fi s=$(scripts/config --file ${CONFIG_FILE} -k --state $opt) if [ ! "$s" = "undef" -a ! "$s" = "n" ]; then ret=1 @@ -84,6 +134,10 @@ then echo "Checking added kernel options..." while read -r opt; do if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then + match_arch $opt + if [ $? = 1 ]; then + continue + fi n=${opt%=*} v="${opt#*=}" s=$(scripts/config --file ${CONFIG_FILE} -k --state $n) diff --git a/patch/kconfig-inclusions b/patch/kconfig-inclusions index ad6d03655..316ed93cb 100644 --- a/patch/kconfig-inclusions +++ b/patch/kconfig-inclusions @@ -2,7 +2,7 @@ CONFIG_SENSORS_MAX6697=m CONFIG_SENSORS_DPS1900=m # For cig-cs6436 -CONFIG_SERIAL_8250_LPSS=m +[amd64]CONFIG_SERIAL_8250_LPSS=m # SFF_8436 CONFIG_EEPROM_SFF_8436=m # For Dell S6000 @@ -12,14 +12,14 @@ CONFIG_SENSORS_PMBUS=m CONFIG_SENSORS_DNI_DPS460=m CONFIG_I2C_MUX_GPIO=m CONFIG_GPIO_SYSFS=y -CONFIG_GPIO_SCH=m +[amd64]CONFIG_GPIO_SCH=m # For Dell Z9100 CONFIG_I2C_MUX_PCA954x=m # For Ingrasys S9100 CONFIG_I2C_GPIO=m CONFIG_GPIO_PCA953X=m # For Inventec d7032 -CONFIG_GPIO_ICH=m +[amd64]CONFIG_GPIO_ICH=m # For mitac ly1200 CONFIG_SENSORS_MAX31790=m # For optoe @@ -33,19 +33,19 @@ CONFIG_MLXSW_I2C=m CONFIG_MLXSW_MINIMAL=m CONFIG_I2C_MUX_REG=m CONFIG_I2C_MUX_MLXCPLD=m -CONFIG_I2C_MLXCPLD=m +[amd64]CONFIG_I2C_MLXCPLD=m CONFIG_SENSORS_IIO_HWMON=m -CONFIG_SENSORS_MLXREG_FAN=m +[amd64]CONFIG_SENSORS_MLXREG_FAN=m CONFIG_SENSORS_LM25066=m CONFIG_SENSORS_TPS53679=m CONFIG_SENSORS_UCD9000=m CONFIG_SENSORS_UCD9200=m CONFIG_SENSORS_XDPE122=m -CONFIG_MLX_WDT=y +[amd64]CONFIG_MLX_WDT=y CONFIG_LEDS_MLXREG=m CONFIG_DW_DMAC_PCI=m -CONFIG_MLX_PLATFORM=m -CONFIG_MELLANOX_PLATFORM=y -CONFIG_MLXREG_HOTPLUG=m -CONFIG_MLXREG_IO=m +[amd64]CONFIG_MLX_PLATFORM=m +[amd64]CONFIG_MELLANOX_PLATFORM=y +[amd64]CONFIG_MLXREG_HOTPLUG=m +[amd64]CONFIG_MLXREG_IO=m CONFIG_MAX1363=m From 05087cd3db60d6b83f359f38a30df76c579226a2 Mon Sep 17 00:00:00 2001 From: Tao Chengyi Date: Thu, 11 Jun 2020 16:28:44 +0800 Subject: [PATCH 2/2] Split options into multiple sections for different architectures --- manage-config | 80 ++++++++++++---------------------------- patch/kconfig-exclusions | 11 ++++++ patch/kconfig-inclusions | 29 ++++++++++----- 3 files changed, 54 insertions(+), 66 deletions(-) diff --git a/manage-config b/manage-config index 7211a7276..60a101cdd 100755 --- a/manage-config +++ b/manage-config @@ -19,6 +19,9 @@ # Example: # CONFIG_AD5064=y # +# If the option is required on all architectures, add it to the common section; +# if the option is only relevant to a specific architecture, add it to the +# section of the corresponding architecture. # Configuration file to change ARCH=amd64 @@ -41,103 +44,68 @@ case "$ARCH" in esac CONFIG_FILE=${CONFIG_FILE_LOC}/.config -# Add multi-architecture support -# -# To remove the option for specify architecture from the kernel, -# add the arch tag such as [amd64] or [arm64] or [armhf] and options into the -# flat text file patch/kconfig-exclusions. -# if no tag appears, it is in effect for all architectures. -# -# Example: -# [amd64]CONFIG_SOUND -# [arm64]CONFIG_ISDN -# [armhf]CONFIG_ISDN -# -# To add the options for specify architecture into the kernel, -# add the arch tag such as [amd64] or [arm64] or [armhf] options into the -# flat text file patch/kconfig-inclusions. -# if no tag appears, it is in effect for all architectures. -# -# Example: -# [amd64]CONFIG_AD5064=y - -function match_arch(){ - opt=$1 - assigned_arch=$(expr $opt : '.*\[\(.*\)\]') - if [ ! -z "$assigned_arch" ]; then - if [ ! "$assigned_arch" = "$ARCH" ]; then - return 1 - else - opt=${opt#*]} - fi - fi +function get_section_opts(){ + file=$1 + for((i=2;i<=$#;i++));do + eval section=\$$i + opts+=$(sed -n '/^\['${section}'\]/, /^\[.*\]/p' ${file} | grep -Ev '\[.*\]|^$|[#;]') + opts+=$'\n' + done + echo "$opts" } ret=0 -if [ -e ../patch/kconfig-exclusions -o -e ../patch/kconfig-inclusions ]; -then +exclusion_file="../patch/kconfig-exclusions" +inclusion_file="../patch/kconfig-inclusions" +if [ -e ${exclusion_file} -o -e ${inclusion_file} ]; then # Process any exclusions in the kernel - if [ -f ../patch/kconfig-exclusions ]; then + if [ -f ${exclusion_file} ]; then + exclusion_opts=$(get_section_opts ${exclusion_file} "common" ${ARCH}) while read -r opt; do if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then - match_arch $opt - if [ $? = 1 ]; then - continue - fi scripts/config --file ${CONFIG_FILE} -d $opt fi - done < ../patch/kconfig-exclusions; + done <<< ${exclusion_opts}; fi # Process any inclusions in the kernel - if [ -f ../patch/kconfig-inclusions ]; then + if [ -f ${inclusion_file} ]; then + inclusion_opts=$(get_section_opts ${inclusion_file} "common" ${ARCH}) while read -r opt; do if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then - match_arch $opt - if [ $? = 1 ]; then - continue - fi echo $opt >> ${CONFIG_FILE} fi - done < ../patch/kconfig-inclusions; + done <<< ${inclusion_opts}; fi # Update the .config file to be sure it's consistent make -C ${CONFIG_FILE_LOC} olddefconfig # Verify that the kernel options we want to remove are not in the updated configuration - if [ -f ../patch/kconfig-exclusions ]; then + if [ -f ${exclusion_file} ]; then echo echo "Checking removed kernel options..." while read -r opt; do if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then - match_arch $opt - if [ $? = 1 ]; then - continue - fi s=$(scripts/config --file ${CONFIG_FILE} -k --state $opt) if [ ! "$s" = "undef" -a ! "$s" = "n" ]; then ret=1 echo "Option $opt should not be set, but is set to [$s]" fi fi - done < ../patch/kconfig-exclusions; + done <<< ${exclusion_opts}; if [ $ret = 0 ]; then echo "No error" fi fi # Verify that the kernel options we want to add are now in the updated configuration - if [ -f ../patch/kconfig-inclusions ]; then + if [ -f ${inclusion_file} ]; then echo echo "Checking added kernel options..." while read -r opt; do if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then - match_arch $opt - if [ $? = 1 ]; then - continue - fi n=${opt%=*} v="${opt#*=}" s=$(scripts/config --file ${CONFIG_FILE} -k --state $n) @@ -146,7 +114,7 @@ then echo "Option $n should be set to [$v] instead of [$s]" fi fi - done < ../patch/kconfig-inclusions; + done <<< ${inclusion_opts}; if [ ! $ret = 2 ]; then echo "No error" fi diff --git a/patch/kconfig-exclusions b/patch/kconfig-exclusions index 3ed5d860c..c70c9e4bd 100644 --- a/patch/kconfig-exclusions +++ b/patch/kconfig-exclusions @@ -1,4 +1,15 @@ +[common] # Unset X86_PAT and STRICT_DEVMEM according to Broadcom's requirement +# Unset DEVMEN also for CENTEC arm64 arch CONFIG_STRICT_DEVMEM + +[amd64] +# Unset X86_PAT and STRICT_DEVMEM according to Broadcom's requirement CONFIG_X86_PAT CONFIG_MLXSW_PCI + +[arm64] + +[armhf] + + diff --git a/patch/kconfig-inclusions b/patch/kconfig-inclusions index 316ed93cb..e5577b07a 100644 --- a/patch/kconfig-inclusions +++ b/patch/kconfig-inclusions @@ -1,8 +1,11 @@ +[common] + +[amd64] # Enable MAX6697 for arista 7060 cx32s CONFIG_SENSORS_MAX6697=m CONFIG_SENSORS_DPS1900=m # For cig-cs6436 -[amd64]CONFIG_SERIAL_8250_LPSS=m +CONFIG_SERIAL_8250_LPSS=m # SFF_8436 CONFIG_EEPROM_SFF_8436=m # For Dell S6000 @@ -12,14 +15,14 @@ CONFIG_SENSORS_PMBUS=m CONFIG_SENSORS_DNI_DPS460=m CONFIG_I2C_MUX_GPIO=m CONFIG_GPIO_SYSFS=y -[amd64]CONFIG_GPIO_SCH=m +CONFIG_GPIO_SCH=m # For Dell Z9100 CONFIG_I2C_MUX_PCA954x=m # For Ingrasys S9100 CONFIG_I2C_GPIO=m CONFIG_GPIO_PCA953X=m # For Inventec d7032 -[amd64]CONFIG_GPIO_ICH=m +CONFIG_GPIO_ICH=m # For mitac ly1200 CONFIG_SENSORS_MAX31790=m # For optoe @@ -33,19 +36,25 @@ CONFIG_MLXSW_I2C=m CONFIG_MLXSW_MINIMAL=m CONFIG_I2C_MUX_REG=m CONFIG_I2C_MUX_MLXCPLD=m -[amd64]CONFIG_I2C_MLXCPLD=m +CONFIG_I2C_MLXCPLD=m CONFIG_SENSORS_IIO_HWMON=m -[amd64]CONFIG_SENSORS_MLXREG_FAN=m +CONFIG_SENSORS_MLXREG_FAN=m CONFIG_SENSORS_LM25066=m CONFIG_SENSORS_TPS53679=m CONFIG_SENSORS_UCD9000=m CONFIG_SENSORS_UCD9200=m CONFIG_SENSORS_XDPE122=m -[amd64]CONFIG_MLX_WDT=y +CONFIG_MLX_WDT=y CONFIG_LEDS_MLXREG=m CONFIG_DW_DMAC_PCI=m -[amd64]CONFIG_MLX_PLATFORM=m -[amd64]CONFIG_MELLANOX_PLATFORM=y -[amd64]CONFIG_MLXREG_HOTPLUG=m -[amd64]CONFIG_MLXREG_IO=m +CONFIG_MLX_PLATFORM=m +CONFIG_MELLANOX_PLATFORM=y +CONFIG_MLXREG_HOTPLUG=m +CONFIG_MLXREG_IO=m CONFIG_MAX1363=m + +[arm64] + +[armhf] + +