update-gateware.sh 835 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. if [ ! -e "$1"/mpfs_bitstream.spi ]; then
  3. echo "No gateware file found."
  4. exit 1
  5. fi
  6. if [ ! -d /lib/firmware ]
  7. then
  8. mkdir /lib/firmware
  9. fi
  10. cp "$1"/mpfs_dtbo.spi /lib/firmware/mpfs_dtbo.spi
  11. cp "$1"/mpfs_bitstream.spi /lib/firmware/mpfs_bitstream.spi
  12. mount -t debugfs none /sys/kernel/debug
  13. # Trash existing device tree overlay in case the rest of the process fails:
  14. flash_erase /dev/mtd0 0 1024
  15. # # Write device tree overlay
  16. dd if=/lib/firmware/mpfs_dtbo.spi of=/dev/mtd0 seek=1024
  17. # Fake the presence of a golden image for now.
  18. dd if=/dev/zero of=/dev/mtd0 count=4 bs=1
  19. # Initiate FPGA update.
  20. echo 1 > /sys/kernel/debug/fpga/microchip_exec_update
  21. # Reboot Linux for the gateware update to take effect.
  22. # FPGA reprogramming takes places between Linux shut-down and HSS restarting the board.
  23. reboot