BeagleBone dtc_compile bash function

Here's a little shortcut that saves some typing when compiling Device Tree overlays on your BeagleBone. Add this to your /etc/profile file:

dtc_compile () {
  if [ -z "$1" ]
  then
    echo "Usage: # dtc-compile [input_file].dts"
  else
    FILENAME="${1%.*}"
    dtc -O dtb -o $FILENAME.dtbo -b 0 -@ $1
  fi
}

Then either log out and back in or source the file with # . /etc/profile. Now any time you have an overlay to compile you can just run:

# dtc_compile my_overlay.dts

and the compiled .dtbo file will be created in the same directory.