socfpga.sh 916 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2010-2013 OpenWrt.org
  4. #
  5. SOCFPGA_BOARD_NAME=
  6. SOCFPGA_MODEL=
  7. socfpga_board_detect() {
  8. local machine
  9. local name
  10. machine=$(cat /proc/device-tree/model)
  11. case "$machine" in
  12. "Terasic SoCkit")
  13. name="socfpga-sockit"
  14. ;;
  15. *)
  16. name="generic"
  17. ;;
  18. esac
  19. [ -z "$SOCFPGA_BOARD_NAME" ] && SOCFPGA_BOARD_NAME="$name"
  20. [ -z "$SOCFPGA_MODEL" ] && SOCFPGA_MODEL="$machine"
  21. [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
  22. echo "$SOCFPGA_BOARD_NAME" > /tmp/sysinfo/board_name
  23. echo "$SOCFPGA_MODEL" > /tmp/sysinfo/model
  24. }
  25. socfpga_board_name() {
  26. local name
  27. [ -f /tmp/sysinfo/board_name ] || socfpga_board_detect
  28. [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
  29. # Name is too generic, use model
  30. if [ "$name" = "altr,socfpga-cyclone5" ] ; then
  31. socfpga_board_detect
  32. name=$(cat /tmp/sysinfo/board_name)
  33. fi
  34. [ -z "$name" ] && name="unknown"
  35. echo "$name"
  36. }