Skip to content

Instantly share code, notes, and snippets.

@Ewoodss
Created October 25, 2024 13:24
Show Gist options
  • Save Ewoodss/df1213907d2ac69d531fb542c4f6b326 to your computer and use it in GitHub Desktop.
Save Ewoodss/df1213907d2ac69d531fb542c4f6b326 to your computer and use it in GitHub Desktop.
Nvidia Custom board dtbo loading
#!/bin/bash
# Path to the extlinux.conf file
CONFIG_FILE="/boot/extlinux/extlinux.conf"
dtsFile="$1"
dtboFile=/boot/$(basename $dtsFile .dts).dtbo
dtb=$(ls /boot/dtb/*.dtb)
dtbFile=$(realpath $dtb)
# Check if the config file exists
if [ ! -f "$CONFIG_FILE" ]; then
echo "Error: $CONFIG_FILE not found."
exit 1
fi
echo "Compiling $dtsFile to $dtboFile"
dtc -I dts -O dtb -o $dtboFile -@ $dtsFile
# FDT line to add or update
FDT_LINE="FDT $dtbFile"
OVERLAYS_LINE="OVERLAYS $dtboFile"
# Define a function to update or add a line to the config file
update_config_line() {
local line_key="$1"
local line_value="$2"
local file_path="$3"
if grep -q "^$line_key " "$file_path"; then
echo "Line starting with '$line_key' found. Updating it..."
# If line exists, replace it
sed -i "s|^$line_key .*|$line_value|" "$file_path"
else
echo "Line starting with '$line_key' not found. Adding it..."
# If line doesn't exist, append it
echo "$line_value" >> "$file_path"
fi
}
# Update or add FDT line
update_config_line "FDT" "$FDT_LINE" "$CONFIG_FILE"
# Update or add OVERLAYS line
update_config_line "OVERLAYS" "$OVERLAYS_LINE" "$CONFIG_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment