0
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2024-12-15 07:29:46 +00:00
2024-12-08 17:18:55 +02:00

97 lines
3.6 KiB
Makefile

# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2016-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="kernel-firmware"
PKG_VERSION="20240312"
PKG_SHA256="b2327a54ad1897c828008caf63af5ee15469ba723a5016be58f2b44f07bd4b94"
PKG_LICENSE="other"
PKG_SITE="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/"
PKG_URL="https://cdn.kernel.org/pub/linux/kernel/firmware/linux-firmware-${PKG_VERSION}.tar.xz"
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"
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}"
)
}
# Install additional miscellaneous drivers
makeinstall_target() {
FW_TARGET_DIR=${INSTALL}/$(get_full_firmware_dir)
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
eval "(cd ${PKG_FW_SOURCE} && find "${fwline}" >/dev/null)" || die "ERROR: Firmware pattern does not exist: ${fwline}"
while read -r fwfile; do
[ -d "${PKG_FW_SOURCE}/${fwfile}" ] && continue
if [ -f "${PKG_FW_SOURCE}/${fwfile}" ]; then
mkdir -p "$(dirname "${FW_TARGET_DIR}/${fwfile}")"
cp -Lv "${PKG_FW_SOURCE}/${fwfile}" "${FW_TARGET_DIR}/${fwfile}"
else
echo "ERROR: Firmware file ${fwfile} does not exist - aborting"
exit 1
fi
done <<<"$(cd ${PKG_FW_SOURCE} && eval "find "${fwline}"")"
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
rm -fr ${FW_TARGET_DIR}/brcm/brcmfmac43430*-sdio.*
rm -fr ${FW_TARGET_DIR}/brcm/brcmfmac43455*-sdio.*
fi
# brcm pcie firmware is only needed by x86_64
[ "${TARGET_ARCH}" != "x86_64" ] && rm -fr ${FW_TARGET_DIR}/brcm/*-pcie.*
# add nvidia firmware for nouveau
if listcontains "${GRAPHIC_DRIVERS}" "nouveau"; then
cp -Lrv ${PKG_FW_SOURCE}/nvidia ${FW_TARGET_DIR}/
rm -rv ${FW_TARGET_DIR}/nvidia/tegra*
fi
# 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
# On Lakka use iwlwifi firmware from this package instead of separate LibreELEC package
if [ "${DISTRO}" = "Lakka" -a "${PROJECT}" = "Generic" ]; then
cp -Lv ${PKG_FW_SOURCE}/iwlwifi-* ${FW_TARGET_DIR}/
fi
# Cleanup - which may be project or device specific
find_file_path scripts/cleanup.sh && ${FOUND_PATH} ${FW_TARGET_DIR} || true
}