2022-02-05 14:23:32 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# Copyright (C) 2016-present Team LibreELEC (https://libreelec.tv)
|
|
|
|
|
|
|
|
PKG_NAME="kernel-firmware"
|
2023-08-15 22:10:48 +00:00
|
|
|
PKG_VERSION="20230804"
|
2022-02-05 14:23:32 +00:00
|
|
|
PKG_LICENSE="other"
|
|
|
|
PKG_SITE="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/"
|
2022-06-30 10:28:25 +00:00
|
|
|
PKG_URL="https://cdn.kernel.org/pub/linux/kernel/firmware/linux-firmware-${PKG_VERSION}.tar.xz"
|
2022-02-05 14:23:32 +00:00
|
|
|
PKG_NEED_UNPACK="${PROJECT_DIR}/${PROJECT}/packages/${PKG_NAME} ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/packages/${PKG_NAME}"
|
|
|
|
PKG_LONGDESC="kernel-firmware: kernel related firmware"
|
|
|
|
PKG_TOOLCHAIN="manual"
|
|
|
|
|
2022-06-30 10:28:25 +00:00
|
|
|
configure_package() {
|
|
|
|
PKG_FW_SOURCE=${PKG_BUILD}/.copied-firmware
|
|
|
|
}
|
|
|
|
|
|
|
|
post_patch() {
|
|
|
|
(
|
|
|
|
cd ${PKG_BUILD}
|
|
|
|
mkdir -p "${PKG_FW_SOURCE}"
|
|
|
|
./copy-firmware.sh --verbose "${PKG_FW_SOURCE}"
|
|
|
|
|
|
|
|
# copy extra firmware files (or overwrite upstream ones)
|
|
|
|
if [ -d ${PKG_DIR}/extra-firmware ]; then
|
|
|
|
cp -r ${PKG_DIR}/extra-firmware/* "${PKG_FW_SOURCE}"
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
# Install additional miscellaneous drivers
|
|
|
|
makeinstall_target() {
|
2022-06-30 10:28:25 +00:00
|
|
|
FW_TARGET_DIR=${INSTALL}/$(get_full_firmware_dir)
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
if find_file_path config/kernel-firmware.dat; then
|
|
|
|
FW_LISTS="${FOUND_PATH}"
|
|
|
|
else
|
|
|
|
FW_LISTS="${PKG_DIR}/firmwares/any.dat ${PKG_DIR}/firmwares/${TARGET_ARCH}.dat"
|
|
|
|
fi
|
|
|
|
|
|
|
|
FW_LISTS+=" ${PROJECT_DIR}/${PROJECT}/config/kernel-firmware-any.dat ${PROJECT_DIR}/${PROJECT}/config/kernel-firmware-${TARGET_ARCH}.dat"
|
|
|
|
|
|
|
|
FW_LISTS+=" ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/config/kernel-firmware-any.dat ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/config/kernel-firmware-${TARGET_ARCH}.dat"
|
|
|
|
|
|
|
|
for fwlist in ${FW_LISTS}; do
|
|
|
|
[ -f "${fwlist}" ] || continue
|
|
|
|
|
|
|
|
while read -r fwline; do
|
|
|
|
[ -z "${fwline}" ] && continue
|
|
|
|
[[ ${fwline} =~ ^#.* ]] && continue
|
|
|
|
[[ ${fwline} =~ ^[[:space:]] ]] && continue
|
|
|
|
|
2022-06-30 10:28:25 +00:00
|
|
|
eval "(cd ${PKG_FW_SOURCE} && find "${fwline}" >/dev/null)" || die "ERROR: Firmware pattern does not exist: ${fwline}"
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
while read -r fwfile; do
|
2022-06-30 10:28:25 +00:00
|
|
|
[ -d "${PKG_FW_SOURCE}/${fwfile}" ] && continue
|
2022-02-05 14:23:32 +00:00
|
|
|
|
2022-06-30 10:28:25 +00:00
|
|
|
if [ -f "${PKG_FW_SOURCE}/${fwfile}" ]; then
|
2022-02-05 14:23:32 +00:00
|
|
|
mkdir -p "$(dirname "${FW_TARGET_DIR}/${fwfile}")"
|
2022-06-30 10:28:25 +00:00
|
|
|
cp -Lv "${PKG_FW_SOURCE}/${fwfile}" "${FW_TARGET_DIR}/${fwfile}"
|
2022-02-05 14:23:32 +00:00
|
|
|
else
|
|
|
|
echo "ERROR: Firmware file ${fwfile} does not exist - aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-06-30 10:28:25 +00:00
|
|
|
done <<< "$(cd ${PKG_FW_SOURCE} && eval "find "${fwline}"")"
|
2022-02-05 14:23:32 +00:00
|
|
|
done < "${fwlist}"
|
|
|
|
done
|
|
|
|
|
|
|
|
PKG_KERNEL_CFG_FILE=$(kernel_config_path) || die
|
|
|
|
|
|
|
|
# The following files are RPi specific and installed by brcmfmac_sdio-firmware-rpi instead.
|
|
|
|
# They are also not required at all if the kernel is not suitably configured.
|
|
|
|
if listcontains "${FIRMWARE}" "brcmfmac_sdio-firmware-rpi" || \
|
|
|
|
! grep -q "^CONFIG_BRCMFMAC_SDIO=y" ${PKG_KERNEL_CFG_FILE}; then
|
2022-06-30 10:28:25 +00:00
|
|
|
rm -fr ${FW_TARGET_DIR}/brcm/brcmfmac43430*-sdio.*
|
|
|
|
rm -fr ${FW_TARGET_DIR}/brcm/brcmfmac43455*-sdio.*
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# brcm pcie firmware is only needed by x86_64
|
2022-06-30 10:28:25 +00:00
|
|
|
[ "${TARGET_ARCH}" != "x86_64" ] && rm -fr ${FW_TARGET_DIR}/brcm/*-pcie.*
|
|
|
|
|
|
|
|
# Upstream doesn't name the file correctly so we need to symlink it
|
|
|
|
if [ -f "${FW_TARGET_DIR}/rtl_bt/rtl8723bs_config-OBDA8723.bin" ]; then
|
|
|
|
#cd "${FW_TARGET_DIR}/rtl_bt"
|
|
|
|
ln -s "rtl8723bs_config-OBDA8723.bin" "${FW_TARGET_DIR}/rtl_bt/rtl8723bs_config.bin"
|
|
|
|
fi
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# Cleanup - which may be project or device specific
|
|
|
|
find_file_path scripts/cleanup.sh && ${FOUND_PATH} ${FW_TARGET_DIR} || true
|
|
|
|
}
|