Skip to content

Commit a37a8bf

Browse files
authored
Add ARM architecture support to manage-config (sonic-net#146)
There are some kernel compilation options that are only supported on certain architectures, such as CONFIG_SERIAL_8250_LPSS depends on X86. 1. Split options into multiple sections for different architectures, section [common] for all architectures. 2. blacklist CONFIG_STRICT_DEVMEM for centec arm64 platform
1 parent 138cb67 commit a37a8bf

File tree

4 files changed

+53
-11
lines changed

4 files changed

+53
-11
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
9494

9595
# Optionally add/remove kernel options
9696
if [ -f ../manage-config ]; then
97-
../manage-config amd64
97+
../manage-config $(CONFIGURED_ARCH)
9898
fi
9999

100100
# Building a custom kernel from Debian kernel source

manage-config

+32-10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
# Example:
2020
# CONFIG_AD5064=y
2121
#
22+
# If the option is required on all architectures, add it to the common section;
23+
# if the option is only relevant to a specific architecture, add it to the
24+
# section of the corresponding architecture.
2225

2326
# Configuration file to change
2427
ARCH=amd64
@@ -29,39 +32,58 @@ case "$ARCH" in
2932
amd64)
3033
CONFIG_FILE_LOC=debian/build/build_amd64_none_amd64
3134
;;
35+
arm64)
36+
CONFIG_FILE_LOC=debian/build/build_arm64_none_arm64
37+
;;
38+
armhf)
39+
CONFIG_FILE_LOC=debian/build/build_armhf_none_armmp
40+
;;
3241
*)
3342
CONFIG_FILE_LOC=debian/build/build_amd64_none_amd64
3443
;;
3544
esac
3645
CONFIG_FILE=${CONFIG_FILE_LOC}/.config
3746

47+
function get_section_opts(){
48+
file=$1
49+
for((i=2;i<=$#;i++));do
50+
eval section=\$$i
51+
opts+=$(sed -n '/^\['${section}'\]/, /^\[.*\]/p' ${file} | grep -Ev '\[.*\]|^$|[#;]')
52+
opts+=$'\n'
53+
done
54+
echo "$opts"
55+
}
56+
3857
ret=0
39-
if [ -e ../patch/kconfig-exclusions -o -e ../patch/kconfig-inclusions ];
40-
then
58+
exclusion_file="../patch/kconfig-exclusions"
59+
inclusion_file="../patch/kconfig-inclusions"
60+
if [ -e ${exclusion_file} -o -e ${inclusion_file} ]; then
4161

4262
# Process any exclusions in the kernel
43-
if [ -f ../patch/kconfig-exclusions ]; then
63+
if [ -f ${exclusion_file} ]; then
64+
exclusion_opts=$(get_section_opts ${exclusion_file} "common" ${ARCH})
4465
while read -r opt; do
4566
if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then
4667
scripts/config --file ${CONFIG_FILE} -d $opt
4768
fi
48-
done < ../patch/kconfig-exclusions;
69+
done <<< ${exclusion_opts};
4970
fi
5071

5172
# Process any inclusions in the kernel
52-
if [ -f ../patch/kconfig-inclusions ]; then
73+
if [ -f ${inclusion_file} ]; then
74+
inclusion_opts=$(get_section_opts ${inclusion_file} "common" ${ARCH})
5375
while read -r opt; do
5476
if [ ! -z "$opt" ] && [[ ! "$opt" =~ ^#.* ]]; then
5577
echo $opt >> ${CONFIG_FILE}
5678
fi
57-
done < ../patch/kconfig-inclusions;
79+
done <<< ${inclusion_opts};
5880
fi
5981

6082
# Update the .config file to be sure it's consistent
6183
make -C ${CONFIG_FILE_LOC} olddefconfig
6284

6385
# Verify that the kernel options we want to remove are not in the updated configuration
64-
if [ -f ../patch/kconfig-exclusions ]; then
86+
if [ -f ${exclusion_file} ]; then
6587
echo
6688
echo "Checking removed kernel options..."
6789
while read -r opt; do
@@ -72,14 +94,14 @@ then
7294
echo "Option $opt should not be set, but is set to [$s]"
7395
fi
7496
fi
75-
done < ../patch/kconfig-exclusions;
97+
done <<< ${exclusion_opts};
7698
if [ $ret = 0 ]; then
7799
echo "No error"
78100
fi
79101
fi
80102

81103
# Verify that the kernel options we want to add are now in the updated configuration
82-
if [ -f ../patch/kconfig-inclusions ]; then
104+
if [ -f ${inclusion_file} ]; then
83105
echo
84106
echo "Checking added kernel options..."
85107
while read -r opt; do
@@ -92,7 +114,7 @@ then
92114
echo "Option $n should be set to [$v] instead of [$s]"
93115
fi
94116
fi
95-
done < ../patch/kconfig-inclusions;
117+
done <<< ${inclusion_opts};
96118
if [ ! $ret = 2 ]; then
97119
echo "No error"
98120
fi

patch/kconfig-exclusions

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1+
[common]
12
# Unset X86_PAT and STRICT_DEVMEM according to Broadcom's requirement
3+
# Unset DEVMEN also for CENTEC arm64 arch
24
CONFIG_STRICT_DEVMEM
5+
6+
[amd64]
7+
# Unset X86_PAT and STRICT_DEVMEM according to Broadcom's requirement
38
CONFIG_X86_PAT
49
CONFIG_MLXSW_PCI
10+
11+
[arm64]
12+
13+
[armhf]
14+
15+

patch/kconfig-inclusions

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[common]
2+
3+
[amd64]
14
# Enable MAX6697 for arista 7060 cx32s
25
CONFIG_SENSORS_MAX6697=m
36
CONFIG_SENSORS_DPS1900=m
@@ -49,3 +52,9 @@ CONFIG_MELLANOX_PLATFORM=y
4952
CONFIG_MLXREG_HOTPLUG=m
5053
CONFIG_MLXREG_IO=m
5154
CONFIG_MAX1363=m
55+
56+
[arm64]
57+
58+
[armhf]
59+
60+

0 commit comments

Comments
 (0)