summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-16 12:59:47 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-16 12:59:47 +0100
commit062d7e0868d7918d386c11fb4e97f5019c2f66ce (patch)
tree1109c2f0a3c3c16bcc5a15e0b60b8c0f36da2aea
parent76f293633fb5feefcc7acd74d4edeea69b60ea5c (diff)
downloadvyos-build-062d7e0868d7918d386c11fb4e97f5019c2f66ce.tar.gz
vyos-build-062d7e0868d7918d386c11fb4e97f5019c2f66ce.zip
Kernel: T3223: retrieve firmware information from Kernel module binary itself
-rwxr-xr-xpackages/linux-kernel/build-linux-firmware.sh39
-rwxr-xr-xpackages/linux-kernel/list-required-firmware.py133
-rw-r--r--packages/linux-kernel/x86_64_vyos_defconfig54
3 files changed, 29 insertions, 197 deletions
diff --git a/packages/linux-kernel/build-linux-firmware.sh b/packages/linux-kernel/build-linux-firmware.sh
index 4483c9ae..95d8ca56 100755
--- a/packages/linux-kernel/build-linux-firmware.sh
+++ b/packages/linux-kernel/build-linux-firmware.sh
@@ -12,10 +12,6 @@ LINUX_SRC="linux"
LINUX_FIRMWARE="linux-firmware"
KERNEL_VAR_FILE=${CWD}/kernel-vars
-# Some firmware files might not be easy to extract (e.g. Intel iwlwifi drivers)
-# thus we simply ammend them "manually"
-ADD_FW_FILES="iwlwifi*"
-
if [ ! -d ${LINUX_SRC} ]; then
echo "Kernel source missing"
exit 1
@@ -30,13 +26,12 @@ fi
result=()
# Retrieve firmware blobs from source files
-cd ${LINUX_SRC}
-FW_FILES=$(../list-required-firmware.py -c ../x86_64_vyos_defconfig -s drivers/net 2>/dev/null)
+FW_FILES=$(find ${LINUX_SRC}/debian/linux-image/lib/modules/${KERNEL_VERSION}${KERNEL_SUFFIX}/kernel/drivers/net -name *.ko | xargs modinfo | grep "^firmware:" | awk '{print $2}')
# Debian package will use the descriptive Git commit as version
GIT_COMMIT=$(cd ${CWD}/${LINUX_FIRMWARE}; git describe --always)
VYOS_FIRMWARE_NAME="vyos-linux-firmware"
-VYOS_FIRMWARE_DIR="${CWD}/${VYOS_FIRMWARE_NAME}_${GIT_COMMIT}-0_all"
+VYOS_FIRMWARE_DIR="${VYOS_FIRMWARE_NAME}_${GIT_COMMIT}-0_all"
if [ -d ${VYOS_FIRMWARE_DIR} ]; then
# remove Debian package folder and deb file from previous runs
rm -rf ${VYOS_FIRMWARE_DIR}*
@@ -46,36 +41,22 @@ mkdir -p ${VYOS_FIRMWARE_DIR}
# Copy firmware file from linux firmware repository into
# assembly folder for the vyos-firmware package
SED_REPLACE="s@${CWD}/${LINUX_FIRMWARE}/@@"
-for FW_PATH in ${FW_FILES}; do
- FW_FILE=$(basename $FW_PATH)
- res=()
- for tmp in $(find ${CWD}/linux-firmware -type f -name ${FW_FILE} | sed -e ${SED_REPLACE})
- do
- res+=( "$tmp" )
- done
-
- for FILE in ${res[@]}; do
+for FILE in ${FW_FILES}; do
+ if [ -f ${LINUX_FIRMWARE}/${FILE} ]; then
FW_DIR="${VYOS_FIRMWARE_DIR}/lib/firmware/$(dirname ${FILE})"
mkdir -p ${FW_DIR}
echo "I: install firmware: ${FILE}"
- cp ${CWD}/linux-firmware/${FILE} ${FW_DIR}
- done
-done
-
-# Install additional firmware files that could not be autodiscovered
-for FW in ${ADD_FW_FILES}
-do
- FW_DIR="${VYOS_FIRMWARE_DIR}/lib/firmware/$(dirname ${FW})"
- mkdir -p ${FW_DIR}
- echo "I: install firmware: ${FW}"
- cp ${CWD}/linux-firmware/${FW} ${FW_DIR}
+ cp ${CWD}/${LINUX_FIRMWARE}/${FILE} ${FW_DIR}
+ else
+ echo "I: firmware file not found: ${FILE}"
+ fi
done
echo "I: Create linux-firmware package"
-cd ${CWD}
+rm -f ${VYOS_FIRMWARE_NAME}_*.deb
fpm --input-type dir --output-type deb --name ${VYOS_FIRMWARE_NAME} \
--maintainer "VyOS Package Maintainers <maintainers@vyos.net>" \
--description "Binary firmware for various drivers in the Linux kernel" \
- --version ${GIT_COMMIT} --deb-compression gz -C ${VYOS_FIRMWARE_DIR}
+ --architecture all --version ${GIT_COMMIT} --deb-compression gz -C ${VYOS_FIRMWARE_DIR}
rm -rf ${VYOS_FIRMWARE_DIR}
diff --git a/packages/linux-kernel/list-required-firmware.py b/packages/linux-kernel/list-required-firmware.py
deleted file mode 100755
index 1cbf7b8e..00000000
--- a/packages/linux-kernel/list-required-firmware.py
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright (C) 2020 Daniil Baturin
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 or later as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-
-import re
-import os
-import sys
-import glob
-import argparse
-import subprocess
-
-# Loads the kernel config -- only options set to y or m
-def load_config(path):
- with open(path, 'r') as f:
- config = f.read()
- targets = re.findall(r'(.*)=(?:y|m)', config)
- return targets
-
-# Finds subdir targets from the Makefile
-# that are enabled by the kernel build config
-def find_enabled_subdirs(config, makefile_path):
- try:
- with open(makefile_path, 'r') as f:
- makefile = f.read()
- except OSError:
- # Shouldn't happen due to the way collect_source_files()
- # calls this function.
- return []
-
- dir_stmts = re.findall(r'obj-\$\((.*)\)\s+\+=\s+(.*)/(?:\n|$)', makefile)
- subdirs = []
-
- for ds in dir_stmts:
- config_key, src_dir = ds
-
- if args.debug:
- print("Processing make targets from {0} ({1})".format(ds[1], ds[0]), file=sys.stderr)
- if config_key in config:
- subdirs.append(src_dir)
- elif args.debug:
- print("{0} is disabled in the config, ignoring {1}".format(ds[0], ds[1]), file=sys.stderr)
-
- return subdirs
-
-# For filtering
-def file_loads_firmware(file):
- with open(file, 'r') as f:
- source = f.read()
- if re.search(r'MODULE_FIRMWARE\((.*)\)', source):
- return True
-
-# Find all source files that reference firmware
-def collect_source_files(config, path):
- files = []
-
- makefile = os.path.join(path, "Makefile")
-
- # Find and process all C files in this directory
- # This is a compromise: sometimes there are single-file modules,
- # that in fact may be disabled in the config,
- # so this approach can create occasional false positives.
- c_files = glob.glob("{0}/*.c".format(path))
- files = list(filter(file_loads_firmware, c_files))
-
- # Now walk the subdirectories
- enabled_subdirs = find_enabled_subdirs(config, makefile)
- subdirs = glob.glob("{0}/*/".format(path))
- for d in subdirs:
- dir_name = d.rstrip("/")
-
- if os.path.exists(os.path.join(d, "Makefile")):
- # If there's a makefile, it's an independent module
- # or a high level dir
- if os.path.basename(dir_name) in enabled_subdirs:
- files = files + collect_source_files(config, d)
- else:
- # It's simply a subdirectory of the current module
- # Some modules, like iwlwifi, keep their firmware-loading files
- # in subdirs, so we have to handle this case
- c_files = glob.iglob("{0}/**/*.c".format(d), recursive=True)
- files += list(filter(file_loads_firmware, c_files))
-
- return files
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument("-s", "--source-dir", action="append", help="Kernel source directory to process", required=True)
- parser.add_argument("-c", "--kernel-config", action="store", help="Kernel configuration")
- parser.add_argument("-d", "--debug", action="store_true", help="Enable Debug output")
- parser.add_argument("-f", "--list-source-files", action="store_true", help="List source files that reference firmware and exit")
- args = parser.parse_args()
-
- if not args.kernel_config:
- args.kernel_config = ".config"
-
- config = load_config(args.kernel_config)
-
- # Collect source files that reference firmware
- for directory in args.source_dir:
- source_files = collect_source_files(config, directory)
-
- if args.list_source_files:
- for sf in source_files:
- print(sf)
- else:
- fw_files = []
- for sf in source_files:
- i_file = re.sub(r'\.c', r'.i', sf)
- res = subprocess.run(["make {0} 2>&1".format(i_file)], shell=True, capture_output=True)
- if res.returncode != 0:
- print("Failed to preprocess file {0}".format(sf), file=sys.stderr)
- print(res.stdout.decode(), file=sys.stderr)
- else:
- with open(i_file, 'r') as f:
- source = f.read()
- fw_statements = re.findall(r'__UNIQUE_ID_firmware.*"firmware"\s+"="\s+(.*);', source)
- fw_files += list(map(lambda s: re.sub(r'(\s|")', r'', s), fw_statements))
-
- for fw in fw_files:
- print(fw)
diff --git a/packages/linux-kernel/x86_64_vyos_defconfig b/packages/linux-kernel/x86_64_vyos_defconfig
index 65291b9d..860eacd4 100644
--- a/packages/linux-kernel/x86_64_vyos_defconfig
+++ b/packages/linux-kernel/x86_64_vyos_defconfig
@@ -1,6 +1,6 @@
#
# Automatically generated file; DO NOT EDIT.
-# Linux/x86 5.10.3 Kernel Configuration
+# Linux/x86 5.10.6 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Debian 8.3.0-6) 8.3.0"
CONFIG_CC_IS_GCC=y
@@ -2280,9 +2280,8 @@ CONFIG_CHELSIO_T4VF=m
CONFIG_CHELSIO_LIB=m
CONFIG_CHELSIO_INLINE_CRYPTO=y
# CONFIG_CHELSIO_IPSEC_INLINE is not set
-CONFIG_NET_VENDOR_CISCO=y
-CONFIG_ENIC=m
-CONFIG_NET_VENDOR_CORTINA=y
+# CONFIG_NET_VENDOR_CISCO is not set
+# CONFIG_NET_VENDOR_CORTINA is not set
# CONFIG_CX_ECAT is not set
# CONFIG_DNET is not set
# CONFIG_NET_VENDOR_DEC is not set
@@ -2366,13 +2365,9 @@ CONFIG_NET_VENDOR_NETERION=y
CONFIG_S2IO=m
CONFIG_VXGE=m
# CONFIG_VXGE_DEBUG_TRACE_ALL is not set
-CONFIG_NET_VENDOR_NETRONOME=y
-CONFIG_NFP=m
-# CONFIG_NFP_DEBUG is not set
-CONFIG_NET_VENDOR_NI=y
-# CONFIG_NI_XGE_MANAGEMENT_ENET is not set
-CONFIG_NET_VENDOR_8390=y
-CONFIG_NE2K_PCI=m
+# CONFIG_NET_VENDOR_NETRONOME is not set
+# CONFIG_NET_VENDOR_NI is not set
+# CONFIG_NET_VENDOR_8390 is not set
CONFIG_NET_VENDOR_NVIDIA=y
CONFIG_FORCEDETH=m
CONFIG_NET_VENDOR_OKI=y
@@ -2380,8 +2375,7 @@ CONFIG_NET_VENDOR_OKI=y
CONFIG_NET_VENDOR_PACKET_ENGINES=y
CONFIG_HAMACHI=m
CONFIG_YELLOWFIN=m
-CONFIG_NET_VENDOR_PENSANDO=y
-# CONFIG_IONIC is not set
+# CONFIG_NET_VENDOR_PENSANDO is not set
CONFIG_NET_VENDOR_QLOGIC=y
CONFIG_QLA3XXX=m
CONFIG_QLCNIC=m
@@ -2391,11 +2385,8 @@ CONFIG_NETXEN_NIC=m
CONFIG_QED=m
CONFIG_QED_SRIOV=y
CONFIG_QEDE=m
-CONFIG_NET_VENDOR_QUALCOMM=y
-# CONFIG_QCOM_EMAC is not set
-# CONFIG_RMNET is not set
-CONFIG_NET_VENDOR_RDC=y
-CONFIG_R6040=m
+# CONFIG_NET_VENDOR_QUALCOMM is not set
+# CONFIG_NET_VENDOR_RDC is not set
CONFIG_NET_VENDOR_REALTEK=y
CONFIG_8139CP=m
CONFIG_8139TOO=m
@@ -2406,22 +2397,16 @@ CONFIG_8139TOO_8129=y
CONFIG_R8169=m
CONFIG_NET_VENDOR_RENESAS=y
CONFIG_NET_VENDOR_ROCKER=y
-CONFIG_NET_VENDOR_SAMSUNG=y
-# CONFIG_SXGBE_ETH is not set
+# CONFIG_NET_VENDOR_SAMSUNG is not set
# CONFIG_NET_VENDOR_SEEQ is not set
-CONFIG_NET_VENDOR_SOLARFLARE=y
-CONFIG_SFC=m
-CONFIG_SFC_MCDI_MON=y
-CONFIG_SFC_SRIOV=y
-CONFIG_SFC_MCDI_LOGGING=y
-CONFIG_SFC_FALCON=m
+# CONFIG_NET_VENDOR_SOLARFLARE is not set
CONFIG_NET_VENDOR_SILAN=y
CONFIG_SC92031=m
CONFIG_NET_VENDOR_SIS=y
CONFIG_SIS900=m
CONFIG_SIS190=m
# CONFIG_NET_VENDOR_SMSC is not set
-CONFIG_NET_VENDOR_SOCIONEXT=y
+# CONFIG_NET_VENDOR_SOCIONEXT is not set
# CONFIG_NET_VENDOR_STMICRO is not set
# CONFIG_NET_VENDOR_SUN is not set
CONFIG_NET_VENDOR_SYNOPSYS=y
@@ -2436,9 +2421,7 @@ CONFIG_VIA_RHINE=m
# CONFIG_VIA_RHINE_MMIO is not set
CONFIG_VIA_VELOCITY=m
# CONFIG_NET_VENDOR_WIZNET is not set
-CONFIG_NET_VENDOR_XILINX=y
-# CONFIG_XILINX_AXI_EMAC is not set
-# CONFIG_XILINX_LL_TEMAC is not set
+# CONFIG_NET_VENDOR_XILINX is not set
# CONFIG_FDDI is not set
# CONFIG_HIPPI is not set
# CONFIG_NET_SB1000 is not set
@@ -2581,7 +2564,7 @@ CONFIG_ATH9K_PCI=y
# CONFIG_ATH9K_DFS_CERTIFIED is not set
# CONFIG_ATH9K_DYNACK is not set
# CONFIG_ATH9K_WOW is not set
-# CONFIG_ATH9K_CHANNEL_CONTEXT is not set
+CONFIG_ATH9K_CHANNEL_CONTEXT=y
CONFIG_ATH9K_PCOEM=y
# CONFIG_ATH9K_PCI_NO_EEPROM is not set
CONFIG_ATH9K_HTC=m
@@ -2695,6 +2678,7 @@ CONFIG_MT7601U=m
CONFIG_MT76_CORE=m
CONFIG_MT76_LEDS=y
CONFIG_MT76_USB=m
+CONFIG_MT76_SDIO=m
CONFIG_MT76x02_LIB=m
CONFIG_MT76x02_USB=m
CONFIG_MT76x0_COMMON=m
@@ -2706,9 +2690,10 @@ CONFIG_MT76x2U=m
CONFIG_MT7603E=m
CONFIG_MT7615_COMMON=m
CONFIG_MT7615E=m
-# CONFIG_MT7663U is not set
-# CONFIG_MT7663S is not set
-# CONFIG_MT7915E is not set
+CONFIG_MT7663_USB_SDIO_COMMON=m
+CONFIG_MT7663U=m
+CONFIG_MT7663S=m
+CONFIG_MT7915E=m
CONFIG_WLAN_VENDOR_MICROCHIP=y
# CONFIG_WILC1000_SDIO is not set
CONFIG_WLAN_VENDOR_RALINK=y
@@ -3717,7 +3702,6 @@ CONFIG_MFD_VIPERBOARD=m
# CONFIG_MFD_RC5T583 is not set
# CONFIG_MFD_SEC_CORE is not set
# CONFIG_MFD_SI476X_CORE is not set
-# CONFIG_MFD_SL28CPLD is not set
# CONFIG_MFD_SM501 is not set
# CONFIG_MFD_SKY81452 is not set
# CONFIG_ABX500_CORE is not set