flash_macbook21applebios 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. set -u -e
  20. # These are the tested platforms
  21. if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]; then
  22. echo "Running on i686. ok."
  23. arch=i686
  24. sleep 5
  25. elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]; then
  26. echo "Running on x86_64. ok."
  27. arch=x86_64
  28. sleep 5
  29. else
  30. echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
  31. exit 1
  32. fi
  33. if [ ! -f ".binarchive" ]; then
  34. # In a src archive or git
  35. arch=.
  36. fi
  37. if [[ $EUID -ne 0 ]]; then
  38. echo "This script must be run as root"
  39. exit 1
  40. fi
  41. if (( $# != 1 )); then
  42. echo "usage: $0 path/to/yourrom.rom"
  43. echo "You need to specify exactly 1 file"
  44. exit 1
  45. fi
  46. if [ ! -f "$1" ]; then
  47. echo "File not found!"
  48. exit 1
  49. fi
  50. set -v
  51. # flashrom doesn't recognize the machine unless you use that switch:
  52. # laptop=force_I_want_a_brick
  53. # after flashing libreboot and booting the machine, flashing normally will just work.
  54. ./flashrom/$arch/flashrom -p internal:laptop=force_I_want_a_brick -w $1