summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNathaniel Graff <nathaniel.graff@sifive.com>2019-05-06 14:42:02 -0700
committerNathaniel Graff <nathaniel.graff@sifive.com>2019-05-06 15:48:26 -0700
commit610c24a3c4059ba8a7eeba95046aba9f1e24359b (patch)
tree896f31afcd55d27f270aa9e0b21f5824ac11dab5 /scripts
parentab15b5e5f7f26261adee86303ecc086ad1026a29 (diff)
Add stdout-path if not specified and UART exists
Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/fixup-dts20
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/fixup-dts b/scripts/fixup-dts
index 503653c..92e96d0 100755
--- a/scripts/fixup-dts
+++ b/scripts/fixup-dts
@@ -85,6 +85,26 @@ if [ `grep -c 'local-external-interrupts-0 {' ${dts}` -ne 0 ]; then
fi
fi
+# Add a stdout-path to the chosen node if one doesn't exist and a serial port does
+
+if [ `grep -c 'stdout-path' ${dts}` -eq 0 ]; then
+ if [ `grep -c 'sifive,uart0' ${dts}` -ne 0 ]; then
+ echo "$0: stdout-path property not given, but a UART device exists."
+
+ serial_node=`grep -oP "serial@\d+" ${dts} | sort | uniq | head -n 1`
+ serial_path="/soc/${serial_node}:115200"
+
+ if [ `grep -c 'chosen' ${dts}` -eq 0 ]; then
+ ${SED} -i "/cpus/i chosen {\n};" ${dts}
+ fi
+
+ ${SED} -i "/chosen/a stdout-path=\"${serial_path}\";" ${dts}
+
+ echo -e "$0: \tAdded stdout-path ${serial_path}"
+ fi
+fi
+
+
# Add a test memory node if one doesn't exist
if [ `grep -c 'sifive,testram0' ${dts}` -eq 0 ]; then