macbook21_firstflash 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # macbook21_firstflash script: initial flashing script for MacBook2,1
  3. #
  4. # Copyright (C) 2014 Francis Rowe <info@gluglug.org.uk>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. ## Don't add here. errors are expected.
  20. # set -u -e -v
  21. set -v
  22. if [[ $EUID -ne 0 ]]; then
  23. echo "This script must be run as root"
  24. exit 1
  25. fi
  26. if (( $# != 1 )); then
  27. echo "Usage: ./macbook21_firstflash yourrom.rom"
  28. echo "usage: ./macbook21_firstflash path/to/yourrom.rom"
  29. echo "You need to specify exactly 1 file"
  30. exit 1
  31. fi
  32. if [ ! -f $1 ]; then
  33. echo "File not found!"
  34. exit 1
  35. fi
  36. # boardmismatch=force is for people upgrading from libreboot 5th release, where the new ROM's are "ThinkPad X60 / X60s / X60t"
  37. # and the old ones are "ThinkPad X60 / X60s" and flashrom complains otherwise
  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:laptop=force_I_want_a_brick -w $1