#!/bin/bash # DCM Setup-Skript echo "Setting up DCM environment..." # Aktuelles Verzeichnis sichern CURRENT_DIR=$(pwd) # 1. Kopieren der Beispiel-DISTRO-Konfiguration, falls nicht vorhanden DISTRO_CONF_DIR="layers/meta-st/meta-st-openstlinux/conf/distro/" DISTRO_CONF_EXAMPLE="$DISTRO_CONF_DIR/openstlinux-eglfs.conf.example" DISTRO_CONF="$DISTRO_CONF_DIR/openstlinux-eglfs.conf" if [ -f "$DISTRO_CONF_EXAMPLE" ] && [ ! -f "$DISTRO_CONF" ]; then echo "Copying DISTRO configuration example to actual configuration..." cp "$DISTRO_CONF_EXAMPLE" "$DISTRO_CONF" echo "DISTRO configuration created." fi # Wenn bereits ein Build-Verzeichnis existiert, Backup erstellen oder entfernen BUILD_DIR="build-openstlinuxeglfs-stm32mp157c-dcm" if [ -d "$BUILD_DIR" ]; then echo "Existing build directory detected: $BUILD_DIR" read -p "Do you want to backup (b) or remove (r) the existing build directory? [b/r]: " choice if [ "$choice" = "b" ]; then BACKUP_DIR="${BUILD_DIR}.backup.$(date +%Y%m%d%H%M%S)" echo "Creating backup in $BACKUP_DIR..." mv "$BUILD_DIR" "$BACKUP_DIR" else echo "Removing existing build directory..." rm -rf "$BUILD_DIR" fi fi # Umgebung mit DCM-Maschine einrichten echo "Initializing Yocto environment with stm32mp157c-dcm machine..." export MACHINE=stm32mp157c-dcm export DISTRO=openstlinux-eglfs # Original ST-Setup-Skript ausführen source layers/meta-st/scripts/envsetup.sh # Überprüfen, ob die Umgebungseinrichtung erfolgreich war if [ -z "$BUILDDIR" ]; then echo "Error: Failed to initialize Yocto environment" return 1 fi # Prüfen, ob das richtige Build-Verzeichnis erstellt wurde if [ "$(basename $BUILDDIR)" != "build-openstlinuxeglfs-stm32mp157c-dcm" ]; then echo "Warning: Unexpected build directory name: $BUILDDIR" echo "Expected: build-openstlinuxeglfs-stm32mp157c-dcm" fi # Da das setup-Skript die Umgebung eingerichtet hat, müssen wir nun # manuell die bblayers.conf bearbeiten, um die erforderlichen Layer hinzuzufügen # Pfad zur bblayers.conf BBLAYERS_CONF="$BUILDDIR/conf/bblayers.conf" # Prüfen, ob die Datei existiert if [ ! -f "$BBLAYERS_CONF" ]; then echo "Error: bblayers.conf not found at $BBLAYERS_CONF" return 1 fi # Backup erstellen cp "$BBLAYERS_CONF" "$BBLAYERS_CONF.original" # Layer-Pfade META_OE_PATH="$CURRENT_DIR/layers/meta-openembedded/meta-oe" META_PYTHON_PATH="$CURRENT_DIR/layers/meta-openembedded/meta-python" META_DCM_PATH="$CURRENT_DIR/layers/meta-dcm" # Layer hinzufügen echo "Manually adding required layers to bblayers.conf..." # Hinzufügen von meta-oe if ! grep -q "$META_OE_PATH" "$BBLAYERS_CONF"; then echo "Adding meta-oe layer..." echo 'BBLAYERS =+ "'"$META_OE_PATH"'"' >> "$BBLAYERS_CONF" fi # Hinzufügen von meta-python if ! grep -q "$META_PYTHON_PATH" "$BBLAYERS_CONF"; then echo "Adding meta-python layer..." echo 'BBLAYERS =+ "'"$META_PYTHON_PATH"'"' >> "$BBLAYERS_CONF" fi # Hinzufügen von meta-dcm falls nicht bereits vorhanden if ! grep -q "$META_DCM_PATH" "$BBLAYERS_CONF"; then echo "Adding meta-dcm layer..." echo 'BBLAYERS =+ "'"$META_DCM_PATH"'"' >> "$BBLAYERS_CONF" fi echo "" echo "DCM environment setup completed successfully!" echo "Build directory: $BUILDDIR" echo "You can now run bitbake commands, for example:" echo " bitbake linux-stm32mp" echo ""