lenovobios_firstflash 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # lenovobios_firstflash: flashes libreboot on an X60/T60 while Lenovo BIOS is running
  3. #
  4. # Copyright (C) 2014, 2015 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: ./lenovobios_firstflash yourrom.rom"
  28. echo "usage: ./lenovobios_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. bucts="unknown"
  37. flashromsst="unknown"
  38. flashrommacronix="unknown"
  39. if [ -f "DEBLOB" ]; then
  40. bucts="./bucts/bucts"
  41. flashromsst="./flashrom/flashrom_lenovobios_sst"
  42. flashrommacronix="./flashrom/flashrom_lenovobios_macronix"
  43. elif [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]; then
  44. bucts="./bucts/i686/bucts"
  45. flashromsst="./flashrom/i686/flashrom_lenovobios_sst"
  46. flashrommacronix="./flashrom/i686/flashrom_lenovobios_macronix"
  47. elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]; then
  48. bucts="./bucts/x86_64/bucts"
  49. flashromsst="./flashrom/x86_64/flashrom_lenovobios_sst"
  50. flashrommacronix="./flashrom/x86_64/flashrom_lenovobios_macronix"
  51. else
  52. echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
  53. exit 1
  54. fi
  55. # Set bucts
  56. # this means we are working in src
  57. if [ ! -f "$bucts" ]; then
  58. echo "BUCTS failed. Make sure BUC.TS is 1, or else you will brick your machine. ABORTING so as to protect against bricking the machine."
  59. exit 1
  60. fi
  61. $(echo $bucts) 1
  62. $(echo $flashromsst) -p internal -w $1
  63. $(echo $flashrommacronix) -p internal -w $1