summaryrefslogtreecommitdiff
path: root/scripts/fixup-dts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/fixup-dts')
-rwxr-xr-xscripts/fixup-dts19
1 files changed, 14 insertions, 5 deletions
diff --git a/scripts/fixup-dts b/scripts/fixup-dts
index ddbbd0c..5871d9b 100755
--- a/scripts/fixup-dts
+++ b/scripts/fixup-dts
@@ -4,6 +4,7 @@ set -e
set -o pipefail
unset dts
+unset SED
while [ "$1" != "" ]
do
@@ -20,13 +21,21 @@ then
exit 1
fi
+# When installed on MacOS with Homebrew, GNU sed is named gsed.
+# If gsed exists, use it.
+if [ `which gsed` == "" ]; then
+ SED=sed
+else
+ SED=gsed
+fi
+
# Add a PMP node if it doesn't exist
if [ `grep -c 'riscv,pmp' ${dts}` -eq 0 ]
then
echo "$0: PMP node not found in ${dts}."
- sed -i 's/ranges;/ranges;\n\t\tpmp: pmp@0 {\n\t\t\tcompatible = "riscv,pmp";\n\t\t\tregions = <1>;\n\t\t};/' ${dts}
+ ${SED} -i 's/ranges;/ranges;\n\t\tpmp: pmp@0 {\n\t\t\tcompatible = "riscv,pmp";\n\t\t\tregions = <1>;\n\t\t};/' ${dts}
echo -e "$0: \tAdded pmp@0"
fi
@@ -37,7 +46,7 @@ if [ `grep -c 'sifive,clic0' ${dts}` -ne 0 ]; then
if [ `grep -c 'sifive,numintbits' ${dts}` -eq 0 ]; then
echo "$0: Clic missing numintbits in ${dts}."
- sed -i 's/interrupt-controller@2000000 {/interrupt-controller@2000000 {\n\t\t\tsifive,numintbits = <2>;/g' ${dts}
+ ${SED} -i 's/interrupt-controller@2000000 {/interrupt-controller@2000000 {\n\t\t\tsifive,numintbits = <2>;/g' ${dts}
echo -e "$0: \tAdded numintbits to clic."
fi
@@ -49,7 +58,7 @@ if [ `grep -c 'global-external-interrupts {' ${dts}` -ne 0 ]; then
if [ `grep -c 'sifive,global-external-interrupts0' ${dts}` -eq 0 ]; then
echo "$0: Global external interrupts missing compat string in ${dts}."
- sed -i 's/global-external-interrupts {/global-external-interrupts {\n\t\t\tcompatible = "sifive,global-external-interrupts0";/g' ${dts}
+ ${SED} -i 's/global-external-interrupts {/global-external-interrupts {\n\t\t\tcompatible = "sifive,global-external-interrupts0";/g' ${dts}
echo -e "$0: \tAdded compat string to global-external-interrupts."
fi
@@ -61,7 +70,7 @@ if [ `grep -c 'local-external-interrupts-0 {' ${dts}` -ne 0 ]; then
if [ `grep -c 'sifive,local-external-interrupts0' ${dts}` -eq 0 ]; then
echo "$0: Local external interrupts missing compat string in ${dts}."
- sed -i 's/local-external-interrupts-0 {/local-external-interrupts {\n\t\t\tcompatible = "sifive,local-external-interrupts0";/g' ${dts}
+ ${SED} -i 's/local-external-interrupts-0 {/local-external-interrupts {\n\t\t\tcompatible = "sifive,local-external-interrupts0";/g' ${dts}
echo -e "$0: \tAdded compat string to local-external-interrupts-0."
fi
@@ -137,7 +146,7 @@ if [ `grep -c 'sifive,testram0' ${dts}` -eq 0 ]; then
echo -e "$0: \tWord size \t${word_size}"
# Create the test memory
- sed -i "s/ranges;/ranges;\n\t\ttest_memory: testram@${node_name_addr} {\n\t\t\tcompatible = \"sifive,testram0\";\n\t\t\treg = <${base_address} ${size}>;\n\t\t\treg-names = \"mem\";\n\t\t\tword-size-bytes = <${word_size}>;\n\t\t};/" ${dts}
+ ${SED} -i "s/ranges;/ranges;\n\t\ttest_memory: testram@${node_name_addr} {\n\t\t\tcompatible = \"sifive,testram0\";\n\t\t\treg = <${base_address} ${size}>;\n\t\t\treg-names = \"mem\";\n\t\t\tword-size-bytes = <${word_size}>;\n\t\t};/" ${dts}
echo -e "$0: \tAdded testram@${node_name_addr}"
# Break out of both loops