FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" SRC_URI += "file://stm32-arch.cfg" SRC_URI += "file://disable-media.cfg" #SRC_URI += "file://stm32mp157c_defconfig" SRC_URI += "file://fragment-01-dcm.config" # Setze KERNEL_DEFCONFIG auf einen gültigen Wert KERNEL_DEFCONFIG = "stm32_defconfig" # Optional: Zusätzliche Fragmente KERNEL_CONFIG_FRAGMENTS += "${WORKDIR}/fragment-01-dcm.config" KERNEL_CONFIG_FRAGMENTS += "${WORKDIR}/stm32-arch.cfg" KERNEL_CONFIG_FRAGMENTS += "${WORKDIR}/disable-media.cfg" # Reduziere die Anzahl der parallelen Jobs # PARALLEL_MAKE = "-j 1" # Verbessere den Konfigurationsprozess do_configure() { # Pfad zu den tatsächlichen Kernel-Quellen KERNEL_SRC="${TOPDIR}/tmp-glibc/work-shared/stm32mp157c-dcm/kernel-source" if [ -d "${KERNEL_SRC}" ] && [ -f "${KERNEL_SRC}/Makefile" ]; then bbplain "Verwende Kernel-Quellen aus: ${KERNEL_SRC}" # Erstelle Build-Verzeichnis mkdir -p ${B} # Verwende die STM32-Konfigurationsdatei, wenn vorhanden if [ -f "${KERNEL_SRC}/arch/arm/configs/stm32_defconfig" ]; then bbplain "Verwende STM32-Konfigurationsdatei" cp ${KERNEL_SRC}/arch/arm/configs/stm32_defconfig ${B}/.config elif [ -f "${KERNEL_SRC}/arch/arm/configs/multi_v7_defconfig" ]; then bbplain "Verwende multi_v7_defconfig" cp ${KERNEL_SRC}/arch/arm/configs/multi_v7_defconfig ${B}/.config elif [ -f "${WORKDIR}/defconfig" ]; then bbplain "Verwende benutzerdefinierte Konfigurationsdatei" cp ${WORKDIR}/defconfig ${B}/.config else bbfatal "Keine passende Konfigurationsdatei gefunden!" fi # Wende Konfigurationsfragmente an if [ -n "${KERNEL_CONFIG_FRAGMENTS}" ]; then for f in ${KERNEL_CONFIG_FRAGMENTS}; do # Überprüfe, ob die Datei existiert, bevor sie angewendet wird if [ -f "$f" ]; then bbplain "Wende Konfigurationsfragment an: $f" cat $f >> ${B}/.config else bbwarn "Konfigurationsfragment nicht gefunden: $f" fi done fi # Deaktiviere problematische Treiber # echo "# Deaktiviere problematische Treiber" >> ${B}/.config # echo "CONFIG_VIDEO_ATMEL_ISI=n" >> ${B}/.config # echo "CONFIG_VIDEO_MICROCHIP_ISC=n" >> ${B}/.config # Stelle sicher, dass DRM-Unterstützung aktiviert bleibt # echo "# DRM-Unterstützung für HDMI/DVI" >> ${B}/.config # echo "CONFIG_DRM=y" >> ${B}/.config # echo "CONFIG_DRM_STM=y" >> ${B}/.config # echo "CONFIG_DRM_PANEL=y" >> ${B}/.config # echo "CONFIG_DRM_BRIDGE=y" >> ${B}/.config # echo "CONFIG_DRM_PANEL_BRIDGE=y" >> ${B}/.config # Aktualisiere die Konfiguration bbplain "Aktualisiere Konfiguration mit make olddefconfig" cd ${KERNEL_SRC} make O=${B} ARCH=arm CROSS_COMPILE=${TARGET_PREFIX} olddefconfig # Überprüfe, ob die .config-Datei erstellt wurde if [ ! -f "${B}/.config" ]; then bbfatal "Konfigurationsdatei ${B}/.config wurde nicht erstellt!" else bbplain "Konfigurationsdatei ${B}/.config wurde erfolgreich erstellt" ls -la ${B}/.config fi else bbfatal "Kernel-Quellverzeichnis nicht gefunden oder nicht vollständig!" fi if [ -f ${TOPDIR}/../layers/meta-dcm/recipes-kernel/linux/linux-stm32mp/stm32mp157c-dcm.dts ]; then DST_ST_PATH="${KERNEL_SRC}/arch/arm/boot/dts/st" bbplain "DTS gefunden, kopiere nach ${DST_ST_PATH}" mkdir -p ${DST_ST_PATH} cp -f ${TOPDIR}/../layers/meta-dcm/recipes-kernel/linux/linux-stm32mp/stm32mp157c-dcm.dts ${DST_ST_PATH} if [ -f ${DST_ST_PATH}/Makefile ]; then # Prüfen, ob stm32mp157c-dcm.dtb bereits in der Makefile enthalten ist if ! grep -q "stm32mp157c-dcm.dtb" ${DST_ST_PATH}/Makefile; then # DTB ist noch nicht enthalten, füge es nach stm32mp157c-dk2.dtb ein sed -i 's/stm32mp157c-dk2.dtb \\/stm32mp157c-dk2.dtb \\\n\tstm32mp157c-dcm.dtb \\/g' ${DST_ST_PATH}/Makefile bbplain "stm32mp157c-dcm.dtb wurde zur Makefile hinzugefügt." else bbplain "stm32mp157c-dcm.dtb ist bereits in der Makefile enthalten." fi fi fi # Vorverarbeiten von DTS-Dateien if [ -d "${KERNEL_SRC}/arch/arm/boot/dts/st" ]; then DST_ST_PATH="${KERNEL_SRC}/arch/arm/boot/dts/st" DTS_FILES=$(find ${DST_ST_PATH} -name "stm32mp157c-dcm.dts" 2>/dev/null) for dts_file in ${DTS_FILES}; do dirname_dts=$(dirname ${dts_file}) basename_dts=$(basename ${dts_file}) mkdir -p ${B}/preprocessed_dts bbplain "Vorverarbeiten von $dts_file mit CPP..." ${CC} -E -nostdinc -undef -x assembler-with-cpp -I${DST_ST_PATH} -I${KERNEL_SRC}/include -I${KERNEL_SRC}/arch/arm/boot/dts -I${KERNEL_SRC}/scripts/dtc/include-prefixes \ -o ${B}/preprocessed_dts/${basename_dts} ${dts_file} cp ${B}/preprocessed_dts/${basename_dts} ${dts_file} done fi } # Entfernung problematischer Treiber do_configure:append() { KERNEL_SRC="${TOPDIR}/tmp-glibc/work-shared/stm32mp157c-dcm/kernel-source" # Kopiere die Konfigurationsdatei nach ${KERNEL_SRC} für den Fall, dass sie dort verwendet wird bbplain "Kopiere .config nach ${KERNEL_SRC}" cp ${B}/.config ${KERNEL_SRC}/ # Entferne problematische Treiber # if [ -d "${KERNEL_SRC}/drivers/media/platform/atmel" ]; then # bbplain "Entferne problematischen Atmel-ISI-Treiber2" # rm -rf ${KERNEL_SRC}/drivers/media/platform/atmel # fi # if [ -d "${KERNEL_SRC}/drivers/media/platform/microchip" ]; then # bbplain "Entferne problematischen Microchip-ISC-Treiber" # rm -rf ${KERNEL_SRC}/drivers/media/platform/microchip # fi # Erzeuge auto.conf bbplain "Erzeuge auto.conf" mkdir -p ${B}/include/config cd ${KERNEL_SRC} make O=${B} ARCH=arm CROSS_COMPILE=${TARGET_PREFIX} olddefconfig } do_configure:prepend() { bbplain "Source directory: ${S}" bbplain "Build directory: ${B}" # Überprüfe, ob das Verzeichnis existiert if [ ! -d "${S}" ]; then bbplain "Erstelle Quellverzeichnis: ${S}" mkdir -p "${S}" fi # Erstelle .scmversion touch "${S}/.scmversion" # Stellen Sie sicher, dass das Verzeichnis sauber ist # cd ${S} # oe_runmake mrproper # Konfigurationsdatei in den Kernel-Quellbaum kopieren # cp ${WORKDIR}/stm32mp157c_defconfig ${S}/arch/arm/configs/ } # Überschreibe die Kompilierungsfunktion do_compile() { KERNEL_SRC="${TOPDIR}/tmp-glibc/work-shared/stm32mp157c-dcm/kernel-source" bbplain "Kompiliere Kernel mit Quellen aus: ${KERNEL_SRC}" cd ${KERNEL_SRC} unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE # Überprüfe die Konfiguration if [ ! -f "${B}/.config" ]; then bbfatal "Keine Konfigurationsdatei im Build-Verzeichnis gefunden!" fi # Überprüfe, ob auto.conf existiert if [ ! -f "${B}/include/config/auto.conf" ]; then bbplain "Auto.conf nicht gefunden, erstelle es" make O=${B} ARCH=arm CROSS_COMPILE=${TARGET_PREFIX} olddefconfig fi # Baue den Kernel bbplain "Baue den Kernel ..." make O=${B} ARCH=arm CROSS_COMPILE=${TARGET_PREFIX} -j 1 zImage # Baue die Device Tree Blobs if [ -d "${KERNEL_SRC}/arch/arm/boot/dts/st" ]; then bbplain "Baue Device Tree Blobs..." make O=${B} ARCH=arm CROSS_COMPILE=${TARGET_PREFIX} -j 1 dtbs fi } # Überschreibe die Install-Funktion do_install() { KERNEL_SRC="${TOPDIR}/tmp-glibc/work-shared/stm32mp157c-dcm/kernel-source" cd ${KERNEL_SRC} # Kopiere den Kernel install -d ${D}/boot if [ -f "${B}/arch/arm/boot/zImage" ]; then install -m 0644 ${B}/arch/arm/boot/zImage ${D}/boot/ elif [ -f "${B}/vmlinux" ]; then install -m 0644 ${B}/vmlinux ${D}/boot/ fi # Kopiere die DTBs if [ -d "${KERNEL_SRC}/arch/arm/boot/dts/st" ]; then bbplain "Installiere DTBs..." install -m 0644 ${B}/arch/arm/boot/dts/st/stm32mp*.dtb ${D}/boot/ fi }