Last active
October 9, 2018 17:31
-
-
Save simos/fdc2633bab0a5b17945c26b611c4fcdc to your computer and use it in GitHub Desktop.
Script to build the ESP32 toolchain on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Adapted from https://raw.githubusercontent.com/lpodkalicki/blog/master/esp32/tools/build_esp32_toolchain.sh | |
# This gist came from: https://gist.github.com/simos/fdc2633bab0a5b17945c26b611c4fcdc | |
# Configuration | |
BASE_DIR=~/esp | |
TOOLCHAIN_BASE_URL=https://dl.espressif.com/dl/ | |
TOOLCHAIN_FILENAME=xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz | |
# ------------------------------------------- | |
# 0. Parse arguments | |
while [[ $# -gt 1 ]] | |
do | |
key="$1" | |
case $key in | |
-d|--directory) | |
BASE_DIR="$2" | |
shift | |
;; | |
*) | |
# unknown option | |
;; | |
esac | |
shift # past argument or value | |
done | |
# ------------------------------------------- | |
# 1. Prepare base directory | |
if [ -d "$BASE_DIR" ]; then | |
echo "Base directory already exists: $BASE_DIR, exiting..." | |
exit 1 | |
fi | |
mkdir -p $BASE_DIR | |
cd $BASE_DIR | |
# ------------------------------------------- | |
# 2. Collect and install tools | |
echo "Installing required packages" | |
sudo apt-get update | |
sudo apt-get install -y git wget make libncursesw5-dev flex bison gperf python python-serial python-pip | |
echo | |
# ------------------------------------------- | |
# 3. Download and unpack binary toolchain for ESP32 | |
TOOLCHAIN_URL="$TOOLCHAIN_BASE_URL/$TOOLCHAIN_FILENAME" | |
echo "Downloading toolchain" | |
wget $TOOLCHAIN_URL | |
tar -xzf $TOOLCHAIN_FILENAME | |
TOOLCHAIN_DIR="$BASE_DIR/xtensa-esp32-elf/bin" | |
export PATH=$PATH:$TOOLCHAIN_DIR | |
echo "export PATH=\$PATH:$TOOLCHAIN_DIR" >> ~/.bashrc | |
echo | |
# ------------------------------------------- | |
# 4. Get ESP-IDF from GitHub | |
echo "Downloading ESP-IDF from Github" | |
git clone --recursive https://github.com/espressif/esp-idf.git | |
IDF_DIR="$BASE_DIR/esp-idf" | |
export IDF_PATH=$IDF_DIR | |
echo "export IDF_PATH=$IDF_DIR" >> ~/.bashrc | |
echo | |
# ------------------------------------------- | |
# 5. Install required Python packages for ESP-IDF | |
echo "Installing required Python package for ESP-IDF" | |
/usr/bin/python -m pip install --user -r /home/ubuntu/esp/esp-idf/requirements.txt | |
echo "-------------------------------------------" | |
echo "Base directory: $BASE_DIR" | |
echo "ESP-Toolchain directory: $TOOLCHAIN_DIR" | |
echo "ESP-IDF directory: $IDF_DIR" | |
echo "SUCCESS!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment