You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.5 KiB

  1. #!/bin/bash
  2. RED='\033[0;31m'
  3. GREEN='\033[0;32m'
  4. NC='\033[0m'
  5. set -e
  6. have_input_image=0
  7. usage()
  8. {
  9. echo "Usage: $0 -i <4mb_top_image>.rom"
  10. }
  11. args=$(getopt -o i:h -- "$@")
  12. if [ $? -ne 0 ] ; then
  13. usage
  14. exit 1
  15. fi
  16. eval set -- "$args"
  17. while [ $# -gt 0 ]
  18. do
  19. case "$1" in
  20. -i)
  21. INPUT_IMAGE=$2
  22. have_input_image=1
  23. shift
  24. ;;
  25. -h)
  26. usage
  27. exit 1
  28. ;;
  29. --)
  30. shift
  31. break
  32. ;;
  33. *)
  34. echo "Invalid option: $1"
  35. exit 1
  36. ;;
  37. esac
  38. shift
  39. done
  40. OUTPUT_IMAGE=${INPUT_IMAGE%%.*}_prepared_12mb.rom
  41. if [ "$have_input_image" -gt 0 ] ; then
  42. echo "creating"
  43. echo "output/${OUTPUT_IMAGE}"
  44. echo "from"
  45. echo "${INPUT_IMAGE}"
  46. echo "---------------------------------------------------------"
  47. else
  48. echo "no input image provided"
  49. usage
  50. exit 1
  51. fi
  52. rm -rf output
  53. mkdir output && cd output
  54. dd if=/dev/zero of=${OUTPUT_IMAGE} bs=4M count=2
  55. cp ../${INPUT_IMAGE} .
  56. dd if=${INPUT_IMAGE} oflag=append conv=notrunc of=${OUTPUT_IMAGE} bs=4M
  57. echo "0x00000000:0x007fffff ifdmegbe" > x230-layout.txt
  58. echo "0x00800000:0x00bfffff bios" >> x230-layout.txt
  59. rm ${INPUT_IMAGE}
  60. echo "---------------------------------------------------------"
  61. echo -e "${RED}CAUTION: internal flashing is NOT encouraged${NC}"
  62. echo ""
  63. echo "prepared files for internal flashing in output directory."
  64. echo "template flashrom command (please adapt the chip name) :"
  65. echo ""
  66. echo "cd output"
  67. echo -e "${GREEN}flashrom -p internal:laptop=force_I_want_a_brick,spispeed=128 --layout x230-layout.txt --image bios -c "MX25L3206E" -w ${OUTPUT_IMAGE}${NC}"