avrtools.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. function print_centered {
  3. [[ $# == 0 ]] && return 1
  4. declare -i TERM_COLS="$(tput cols)"
  5. declare -i str_len="${#1}"
  6. [[ $str_len -ge $TERM_COLS ]] && {
  7. echo "$1";
  8. return 0;
  9. }
  10. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  11. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  12. filler=""
  13. for (( i = 0; i < filler_len; i++ )); do
  14. filler="${filler}${ch}"
  15. done
  16. printf "%s%s%s" "$filler" "$1" "$filler"
  17. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  18. printf "\n"
  19. return 0
  20. }
  21. print_centered "$(tput setaf 10)"
  22. print_centered ""
  23. print_centered " ---- "
  24. print_centered "-| |-"
  25. print_centered "-| |-"
  26. print_centered "-| |-"
  27. print_centered "-| |-"
  28. print_centered " ---- "
  29. print_centered "ChipTools v1.0"
  30. echo -n "$(tput setaf 7)"
  31. sudo apt install libudev-dev curl libelf-dev libusb-1.0-0-dev libusb-dev libftdi-dev libftdi1-dev libhidapi-dev build-essential -y
  32. sudo apt install python3-pip python3-sphinx -y
  33. curl http://wareck.free.fr/cross_compilation/avr_toolchain/avr_toolchain.tar.xz | tar -xJ
  34. sudo cp -r avr /usr/local
  35. rm -r -f avr
  36. cd ~
  37. wget -c https://github.com/flashrom/flashrom/archive/refs/tags/v1.3.0.tar.gz
  38. tar xvfz v1.3.0.tar.gz
  39. rm v1.3.0.tar.gz
  40. cd flashrom-1.3.0
  41. make
  42. sudo make install
  43. cd ~
  44. rm -r -f flashrom-1.3.0
  45. if ! grep "/usr/local/avr/bin" ~/.bashrc >/dev/null
  46. then
  47. echo "export PATH=XXXXPATH::/usr/local/avr/bin" >> ~/.bashrc
  48. sed -i -e "s/XXXX/$/g" ~/.bashrc
  49. source ~/.bashrc
  50. fi
  51. echo -e "\nDone."