windows_install_prerequisites.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 https://docs.espressif.com/projects/esp-idf/en/latest/get-started/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 \
  32. mingw-w64-i686-python-pip mingw-w64-i686-python-cryptography unzip winpty
  33. # if IDF_PATH is set, install requirements now as well
  34. if [ -n "$IDF_PATH" ]; then
  35. python -m pip install -r "$IDF_PATH/requirements.txt"
  36. fi
  37. # Automatically download precompiled toolchain, unpack at /opt/xtensa-esp32-elf/
  38. TOOLCHAIN_ZIP=xtensa-esp32-elf-win32-1.22.0-97-gc752ad5-5.2.0.zip
  39. echo "Downloading precompiled toolchain ${TOOLCHAIN_ZIP}..."
  40. cd ~
  41. curl -LO --retry 10 http://dl.espressif.com/dl/${TOOLCHAIN_ZIP}
  42. cd /opt
  43. rm -rf /opt/xtensa-esp32-elf # for upgrades
  44. unzip ~/${TOOLCHAIN_ZIP}
  45. rm ~/${TOOLCHAIN_ZIP}
  46. cat > /etc/profile.d/esp32_toolchain.sh << EOF
  47. # This file was created by ESP-IDF windows_install_prerequisites.sh
  48. # and will be overwritten if that script is run again.
  49. export PATH="/opt/xtensa-esp32-elf/bin:\$PATH"
  50. EOF
  51. # clean up pacman package cache to save some disk space
  52. pacman --noconfirm -Scc
  53. cat << EOF
  54. ************************************************
  55. MSYS2 environment is now ready to use ESP-IDF.
  56. 1) Run 'source /etc/profile' to add the toolchain to
  57. your path in this terminal. This command produces no output.
  58. You only need to do this once, future terminals do this
  59. automatically when opened.
  60. 2) After ESP-IDF is set up (see setup guide), edit the file
  61. `cygpath -w /etc/profile`
  62. and add a line to set the variable IDF_PATH so it points to the
  63. IDF directory, ie:
  64. export IDF_PATH=/c/path/to/esp-idf/directory
  65. ************************************************
  66. EOF