2020-04-02 19:10:02 -04:00
|
|
|
#!/usr/bin/env bash
|
2016-08-17 11:08:22 -04:00
|
|
|
#
|
2017-03-20 23:17:19 -04:00
|
|
|
# Setup script to configure an MSYS2 environment for ESP-IDF.
|
|
|
|
#
|
|
|
|
# Use of this script is optional, there is also a prebuilt MSYS2 environment available
|
|
|
|
# which can be downloaded and used as-is.
|
|
|
|
#
|
2018-06-18 03:07:16 -04:00
|
|
|
# See https://docs.espressif.com/projects/esp-idf/en/latest/get-started/windows-setup.html for full details.
|
2016-08-17 11:08:22 -04:00
|
|
|
|
|
|
|
if [ "$OSTYPE" != "msys" ]; then
|
|
|
|
echo "This setup script expects to be run from an MSYS2 environment on Windows."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if ! [ -x /bin/pacman ]; then
|
|
|
|
echo "This setup script expects to use the pacman package manager from MSYS2."
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-03-20 23:17:19 -04:00
|
|
|
if [ "$MSYSTEM" != "MINGW32" ]; then
|
|
|
|
echo "This setup script must be started from the 'MSYS2 MinGW 32-bit' start menu shortcut"
|
|
|
|
echo "OR by running `cygpath -w /mingw32.exe`"
|
|
|
|
echo "(The current MSYSTEM mode is $MSYSTEM but it expects it to be MINGW32)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-08-17 11:08:22 -04:00
|
|
|
|
|
|
|
# if update-core still exists, run it to get the latest core MSYS2 system
|
|
|
|
# (which no longer needs or includes update-core!)
|
|
|
|
#
|
|
|
|
# If this step runs, it will require a full restart of MSYS2 before it
|
|
|
|
# can continue.
|
|
|
|
[ -x /usr/bin/update-core ] && /usr/bin/update-core
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2017-03-20 23:17:19 -04:00
|
|
|
pacman --noconfirm -Syu # This step may require the terminal to be closed and restarted
|
2016-08-17 11:08:22 -04:00
|
|
|
|
2018-09-30 23:58:51 -04:00
|
|
|
pacman --noconfirm -S --needed gettext-devel gcc git make ncurses-devel flex bison gperf vim \
|
2020-03-31 04:58:03 -04:00
|
|
|
mingw-w64-i686-python-pip mingw-w64-i686-python-cryptography unzip winpty mingw-w64-i686-gcc
|
2016-08-17 11:08:22 -04:00
|
|
|
|
2018-09-30 23:58:51 -04:00
|
|
|
# if IDF_PATH is set, install requirements now as well
|
2018-12-03 19:02:49 -05:00
|
|
|
if [ -n "$IDF_PATH" ]; then
|
|
|
|
python -m pip install -r "$IDF_PATH/requirements.txt"
|
2018-09-30 23:58:51 -04:00
|
|
|
fi
|
2016-08-17 11:08:22 -04:00
|
|
|
|
2017-03-20 23:17:19 -04:00
|
|
|
# Automatically download precompiled toolchain, unpack at /opt/xtensa-esp32-elf/
|
2020-03-25 06:43:21 -04:00
|
|
|
TOOLCHAIN_ZIP=xtensa-esp32-elf-gcc8_2_0-esp-2020r1-win32.zip
|
2016-08-17 11:08:22 -04:00
|
|
|
echo "Downloading precompiled toolchain ${TOOLCHAIN_ZIP}..."
|
|
|
|
cd ~
|
2019-11-01 10:00:27 -04:00
|
|
|
curl -LO --retry 10 https://dl.espressif.com/dl/${TOOLCHAIN_ZIP}
|
2019-06-11 09:58:03 -04:00
|
|
|
mkdir -p /opt
|
2016-08-17 11:08:22 -04:00
|
|
|
cd /opt
|
2017-09-20 21:15:09 -04:00
|
|
|
rm -rf /opt/xtensa-esp32-elf # for upgrades
|
2016-08-17 11:08:22 -04:00
|
|
|
unzip ~/${TOOLCHAIN_ZIP}
|
|
|
|
rm ~/${TOOLCHAIN_ZIP}
|
|
|
|
|
|
|
|
cat > /etc/profile.d/esp32_toolchain.sh << EOF
|
2017-03-20 23:17:19 -04:00
|
|
|
# This file was created by ESP-IDF windows_install_prerequisites.sh
|
|
|
|
# and will be overwritten if that script is run again.
|
2018-11-26 17:36:43 -05:00
|
|
|
export PATH="/opt/xtensa-esp32-elf/bin:\$PATH"
|
2016-08-17 11:08:22 -04:00
|
|
|
EOF
|
|
|
|
|
2017-09-20 21:15:09 -04:00
|
|
|
# clean up pacman package cache to save some disk space
|
2016-08-17 11:08:22 -04:00
|
|
|
pacman --noconfirm -Scc
|
|
|
|
|
2017-03-20 23:17:19 -04:00
|
|
|
cat << EOF
|
|
|
|
************************************************
|
|
|
|
MSYS2 environment is now ready to use ESP-IDF.
|
2016-08-17 11:08:22 -04:00
|
|
|
|
2017-03-20 23:17:19 -04:00
|
|
|
1) Run 'source /etc/profile' to add the toolchain to
|
|
|
|
your path in this terminal. This command produces no output.
|
|
|
|
You only need to do this once, future terminals do this
|
|
|
|
automatically when opened.
|
|
|
|
|
|
|
|
2) After ESP-IDF is set up (see setup guide), edit the file
|
|
|
|
`cygpath -w /etc/profile`
|
|
|
|
and add a line to set the variable IDF_PATH so it points to the
|
|
|
|
IDF directory, ie:
|
|
|
|
|
|
|
|
export IDF_PATH=/c/path/to/esp-idf/directory
|
|
|
|
|
|
|
|
************************************************
|
|
|
|
EOF
|