From 610c24a3c4059ba8a7eeba95046aba9f1e24359b Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Mon, 6 May 2019 14:42:02 -0700 Subject: Add stdout-path if not specified and UART exists Signed-off-by: Nathaniel Graff --- scripts/fixup-dts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'scripts/fixup-dts') 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 -- cgit v1.2.3