summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNathaniel Graff <nathaniel.graff@sifive.com>2019-06-03 15:42:09 -0700
committerNathaniel Graff <nathaniel.graff@sifive.com>2019-06-03 16:10:12 -0700
commitd29a5d443cabe9373016bb158203c9dcd6f32279 (patch)
tree0e140dbead440599c1580a8cabeddabab4a6acf7 /scripts
parentf2c7f75ceef24aec9891d75c2b4fb5db5b847868 (diff)
Detect when we need to add metal,entry for FPGA targets
Automatically add a 0x400000 byte offset to the entry point of FPGA and Arty targets Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/fixup-dts25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/fixup-dts b/scripts/fixup-dts
index 278b835..37c2105 100755
--- a/scripts/fixup-dts
+++ b/scripts/fixup-dts
@@ -105,6 +105,31 @@ if [ `grep -c 'stdout-path' ${dts}` -eq 0 ]; then
fi
+# FPGA targets need a 0x400000 byte offset into their SPI flash
+
+# Is the target an FPGA?
+if [ `echo ${dts} | grep -c 'arty'` -ne 0 -o `echo ${dts} | grep -c 'fpga'` -ne 0 ] ; then
+ # Is there a metal,entry property in the chosen node?
+ if [ `grep -c 'metal,entry' ${dts}` -eq 0 ] ; then
+ echo "$0: FPGA target needs metal,entry property to set boot offset."
+
+ # Find the SPI device with the lowest base address
+ first_spi_node=`grep -oE "spi@[[:xdigit:]]+?" ${dts} | sort | head -n 1`
+
+ # Get the DTS node label of that SPI device
+ spi_entry_label=`grep -oE "[^[:space:]]+?:\s+?${first_spi_node}" ${dts} | cut -d ':' -f 1`
+
+ if [ `grep -c 'chosen' ${dts}` -eq 0 ]; then
+ ${SED} -i "/cpus/i chosen {\n};" ${dts}
+ fi
+
+ ${SED} -i "/chosen/a metal,entry = <&${spi_entry_label} 0x400000>;" ${dts}
+
+ echo -e "$0: \tAdded metal,entry for SPI node ${first_spi_node} with label ${spi_entry_label}"
+ fi
+fi
+
+
# Add a test memory node if one doesn't exist
if [ `grep -c 'sifive,testram0' ${dts}` -eq 0 ]; then