Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: add dtscat script #40

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions tools/dtscat
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is a baisc script that concatenates the given Device Tree Sources.
# Useful for when you have a single DTS
# Author: tim-arney
#!/bin/bash

usage() {
cmd=$(basename "$0")
echo "usage: $cmd <base_dts> [<overlay1> ... <overlayN>]" >&2
exit 1
}

if [ "$#" -lt 1 ]
then
usage
fi

BASE="$1"
shift
OVERLAYS="$*"

if [ ! -f "$BASE" ]
then
echo "error: file not found: $BASE" >&2
exit 1
fi

if ! grep '/dts-v1/;' "$BASE" > /dev/null
then
echo "error: '/dts-v1/;' tag not found in $BASE, are you sure this is a base file?" >&2
exit 1
fi

for OVERLAY in $OVERLAYS
do
if [ ! -f "$OVERLAY" ]
then
echo "error: file not found: $OVERLAY" >&2
exit 1
fi

if grep '/dts-v1/;' "$OVERLAY" > /dev/null
then
echo "error: '/dts-v1/;' tag found in $OVERLAY, should only be present in the base file" >&2
exit 1
fi
done

cat "$BASE" $OVERLAYS

Loading