forceflash 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # forceflash script - be very careful when using this, because it can flash
  3. # the wrong ROM image on the wrong machine if you tell it to. YOU HAVE BEEN WARNED.
  4. # This script is for re-flashing a new image for the same machine when the board name was changed
  5. #
  6. # Copyright (C) 2014, 2015 Francis Rowe <info@gluglug.org.uk>
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. ## Don't add here. errors are expected.
  22. # set -u -e -v
  23. set -v
  24. if [[ $EUID -ne 0 ]]; then
  25. echo "This script must be run as root"
  26. exit 1
  27. fi
  28. if (( $# != 1 )); then
  29. echo "Usage: ./forceflash yourrom.rom"
  30. echo "usage: ./forceflash path/to/yourrom.rom"
  31. echo "You need to specify exactly 1 file"
  32. exit 1
  33. fi
  34. if [ ! -f $1 ]; then
  35. echo "File not found!"
  36. exit 1
  37. fi
  38. path="unknown"
  39. if [ -f "DEBLOB" ]; then
  40. path="./flashrom/flashrom"
  41. elif [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]; then
  42. path="./flashrom/i686/flashrom"
  43. elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]; then
  44. path="./flashrom/x86_64/flashrom"
  45. else
  46. echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
  47. exit 1
  48. fi
  49. $(echo $path) -p internal:boardmismatch=force -w $1