windows_install_prerequisites.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/bash
  2. #
  3. # Setup script to configure an MSYS2 environment for ESP-IDF.
  4. #
  5. # Use of this script is optional, there is also a prebuilt MSYS2 environment available
  6. # which can be downloaded and used as-is.
  7. #
  8. # See http://esp-idf.readthedocs.io/en/latest/windows-setup.html for full details.
  9. if [ "$OSTYPE" != "msys" ]; then
  10. echo "This setup script expects to be run from an MSYS2 environment on Windows."
  11. exit 1
  12. fi
  13. if ! [ -x /bin/pacman ]; then
  14. echo "This setup script expects to use the pacman package manager from MSYS2."
  15. exit 1
  16. fi
  17. if [ "$MSYSTEM" != "MINGW32" ]; then
  18. echo "This setup script must be started from the 'MSYS2 MinGW 32-bit' start menu shortcut"
  19. echo "OR by running `cygpath -w /mingw32.exe`"
  20. echo "(The current MSYSTEM mode is $MSYSTEM but it expects it to be MINGW32)"
  21. exit 1
  22. fi
  23. # if update-core still exists, run it to get the latest core MSYS2 system
  24. # (which no longer needs or includes update-core!)
  25. #
  26. # If this step runs, it will require a full restart of MSYS2 before it
  27. # can continue.
  28. [ -x /usr/bin/update-core ] && /usr/bin/update-core
  29. set -e
  30. pacman --noconfirm -Syu # This step may require the terminal to be closed and restarted
  31. pacman --noconfirm -S --needed gettext-devel gcc git make ncurses-devel flex bison gperf vim mingw-w64-i686-python2-pip unzip winpty
  32. python -m pip install --upgrade pip
  33. pip install pyserial
  34. # Automatically download precompiled toolchain, unpack at /opt/xtensa-esp32-elf/
  35. TOOLCHAIN_ZIP=xtensa-esp32-elf-win32-1.22.0-61-gab8375a-5.2.0.zip
  36. echo "Downloading precompiled toolchain ${TOOLCHAIN_ZIP}..."
  37. cd ~
  38. curl -LO --retry 10 http://dl.espressif.com/dl/${TOOLCHAIN_ZIP}
  39. cd /opt
  40. unzip ~/${TOOLCHAIN_ZIP}
  41. rm ~/${TOOLCHAIN_ZIP}
  42. cat > /etc/profile.d/esp32_toolchain.sh << EOF
  43. # This file was created by ESP-IDF windows_install_prerequisites.sh
  44. # and will be overwritten if that script is run again.
  45. export PATH="\$PATH:/opt/xtensa-esp32-elf/bin"
  46. EOF
  47. # clean up pacman packages to save some disk space
  48. pacman --noconfirm -R unzip
  49. pacman --noconfirm -Scc
  50. cat << EOF
  51. ************************************************
  52. MSYS2 environment is now ready to use ESP-IDF.
  53. 1) Run 'source /etc/profile' to add the toolchain to
  54. your path in this terminal. This command produces no output.
  55. You only need to do this once, future terminals do this
  56. automatically when opened.
  57. 2) After ESP-IDF is set up (see setup guide), edit the file
  58. `cygpath -w /etc/profile`
  59. and add a line to set the variable IDF_PATH so it points to the
  60. IDF directory, ie:
  61. export IDF_PATH=/c/path/to/esp-idf/directory
  62. ************************************************
  63. EOF