From a05d6003dabcff878bd234efcbe2000b9d68a70d Mon Sep 17 00:00:00 2001 From: Li Qing Qiao Date: Tue, 8 Sep 2020 17:09:51 +0800 Subject: [PATCH] feat(tools): Add xtensa-lx106-elf toolchain url --- export.sh | 100 +++++++++++++++++++++++++++++++++ install.sh | 18 ++++++ tools/idf_tools.py | 4 +- tools/tools.json | 137 +++++++-------------------------------------- 4 files changed, 140 insertions(+), 119 deletions(-) create mode 100755 export.sh create mode 100755 install.sh diff --git a/export.sh b/export.sh new file mode 100755 index 00000000..38a0b828 --- /dev/null +++ b/export.sh @@ -0,0 +1,100 @@ +# This script should be sourced, not executed. + +function realpath_int() { + wdir="$PWD"; [ "$PWD" = "/" ] && wdir="" + arg=$1 + case "$arg" in + /*) scriptdir="${arg}";; + *) scriptdir="$wdir/${arg#./}";; + esac + scriptdir="${scriptdir%/*}" + echo "$scriptdir" +} + + +function idf_export_main() { + # The file doesn't have executable permissions, so this shouldn't really happen. + # Doing this in case someone tries to chmod +x it and execute... + if [[ -n "${BASH_SOURCE}" && ( "${BASH_SOURCE[0]}" == "${0}" ) ]]; then + echo "This script should be sourced, not executed:" + echo ". ${BASH_SOURCE[0]}" + return 1 + fi + + if [[ -z "${IDF_PATH}" ]] + then + # If using bash, try to guess IDF_PATH from script location + if [[ -n "${BASH_SOURCE}" ]] + then + if [[ "$OSTYPE" == "darwin"* ]]; then + script_dir="$(realpath_int $BASH_SOURCE)" + else + script_name="$(readlink -f $BASH_SOURCE)" + script_dir="$(dirname $script_name)" + fi + export IDF_PATH="${script_dir}" + else + echo "IDF_PATH must be set before sourcing this script" + return 1 + fi + fi + + old_path=$PATH + + echo "Adding ESP-IDF tools to PATH..." + # Call idf_tools.py to export tool paths + export IDF_TOOLS_EXPORT_CMD=${IDF_PATH}/export.sh + export IDF_TOOLS_INSTALL_CMD=${IDF_PATH}/install.sh + idf_exports=$(${IDF_PATH}/tools/idf_tools.py export) || return 1 + eval "${idf_exports}" + + echo "Checking if Python packages are up to date..." + python ${IDF_PATH}/tools/check_python_dependencies.py || return 1 + + + # Allow calling some IDF python tools without specifying the full path + # ${IDF_PATH}/tools is already added by 'idf_tools.py export' + IDF_ADD_PATHS_EXTRAS="${IDF_PATH}/components/esptool_py/esptool" + IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/partition_table/" + export PATH="${IDF_ADD_PATHS_EXTRAS}:${PATH}" + + if [[ -n "$BASH" ]] + then + path_prefix=${PATH%%${old_path}} + paths="${path_prefix//:/ }" + if [ -n "${paths}" ]; then + echo "Added the following directories to PATH:" + else + echo "All paths are already set." + fi + for path_entry in ${paths} + do + echo " ${path_entry}" + done + else + echo "Updated PATH variable:" + echo " ${PATH}" + fi + + # Clean up + unset old_path + unset paths + unset path_prefix + unset path_entry + unset IDF_ADD_PATHS_EXTRAS + unset idf_exports + + # Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system + # to check whether we are using a private Python environment + + echo "Done! You can now compile ESP8266-RTOS-SDK projects." + echo "Go to the project directory and run:" + echo "" + echo " make" + echo "" +} + +idf_export_main + +unset realpath_int +unset idf_export_main diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..d026e3c9 --- /dev/null +++ b/install.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e +set -u + +export IDF_PATH=$(cd $(dirname $0); pwd) + +echo "Installing ESP-IDF tools" +${IDF_PATH}/tools/idf_tools.py install + +echo "Installing Python environment and packages" +${IDF_PATH}/tools/idf_tools.py install-python-env + +basedir="$(dirname $0)" +echo "All done! You can now run:" +echo "" +echo " . ${basedir}/export.sh" +echo "" diff --git a/tools/idf_tools.py b/tools/idf_tools.py index 7cdd1823..21c8f690 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -800,7 +800,7 @@ def get_python_env_path(): idf_version = match.group(1) idf_python_env_path = os.path.join(global_idf_tools_path, 'python_env', - 'idf{}_py{}_env'.format(idf_version, python_ver_major_minor)) + 'rtos{}_py{}_env'.format(idf_version, python_ver_major_minor)) if sys.platform == 'win32': subdir = 'Scripts' @@ -1066,7 +1066,7 @@ def action_install_python_env(args): subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--user', 'virtualenv'], stdout=sys.stdout, stderr=sys.stderr) - subprocess.check_call([sys.executable, '-m', 'virtualenv', '--no-site-packages', idf_python_env_path], + subprocess.check_call([sys.executable, '-m', 'virtualenv', idf_python_env_path], stdout=sys.stdout, stderr=sys.stderr) run_args = [virtualenv_python, '-m', 'pip', 'install', '--no-warn-script-location'] requirements_txt = os.path.join(global_idf_path, 'requirements.txt') diff --git a/tools/tools.json b/tools/tools.json index 5bbed7e8..aa4cabf3 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -1,10 +1,10 @@ { "tools": [ { - "description": "Toolchain for Xtensa (ESP32) based on GCC", + "description": "Toolchain for Xtensa (ESP8266) based on GCC", "export_paths": [ [ - "xtensa-esp32-elf", + "xtensa-lx106-elf", "bin" ] ], @@ -12,9 +12,9 @@ "info_url": "https://github.com/espressif/crosstool-NG", "install": "always", "license": "GPL-3.0-with-GCC-exception", - "name": "xtensa-esp32-elf", + "name": "xtensa-lx106-elf", "version_cmd": [ - "xtensa-esp32-elf-gcc", + "xtensa-lx106-elf-gcc", "--version" ], "version_regex": "\\(crosstool-NG\\s+(?:crosstool-ng-)?([0-9a-z\\.\\-]+)\\)\\s*([0-9\\.]+)", @@ -22,81 +22,31 @@ "versions": [ { "linux-amd64": { - "sha256": "39db59b13f25e83e53c55f56979dbfce77b7f23126ad79de833509ad902d3f0a", - "size": 63025996, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-linux-amd64.tar.gz" - }, - "linux-armel": { - "sha256": "4ffd19839fcb241af3111da7c419448b80be3bd844da570e95f8f3d5a7eccf79", - "size": 61164309, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-linux-armel.tar.gz" + "sha256": "706a02853759c2f85d912f68df4f5b4566ecb41422de5afe35a45d064eb8e494", + "size": 37049855, + "url": "https://dl.espressif.com/dl/xtensa-lx106-elf-linux64-1.22.0-100-ge567ec7-5.2.0.tar.gz" }, "linux-i686": { - "sha256": "85c02a4310bb97ac46e6f943b0de10e9e9572596c7d33d09b6f93f8bace3b784", - "size": 65016647, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-linux-i686.tar.gz" + "sha256": "a94df9788a73a362f01f32a6f9d46b8630a0aab708eec8d6523e72342f382769", + "size": 38388423, + "url": "https://dl.espressif.com/dl/xtensa-lx106-elf-linux32-1.22.0-100-ge567ec7-5.2.0.tar.gz" }, "macos": { - "sha256": "adb256394c948ca424ec6ef1d9bee91baa99a304d8ace8e6701303da952eb007", - "size": 69674700, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-macos.tar.gz" + "sha256": "4e3b2e6ba8ab7ff4dc4b70d90a181763b2077e4b6a69106241f8c175bab18184", + "size": 43153405, + "url": "https://dl.espressif.com/dl/xtensa-lx106-elf-macos-1.22.0-100-ge567ec7-5.2.0.tar.gz" }, - "name": "esp32-2019r1-8.2.0", + "name": "1.22.0-100-ge567ec7-5.2.0", "status": "recommended", "win32": { - "sha256": "ff00dbb02287219a61873c3b2649a50b94e80c82e607c336383f2838abbefbde", - "size": 73245169, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-win32.zip" + "sha256": "0756bb6e768fb986ec557bf1136a8978e106d7d2cca1bbb21fca5d566a30e468", + "size": 39567257, + "url": "https://dl.espressif.com/dl/xtensa-lx106-elf-win32-1.22.0-100-ge567ec7-5.2.0.zip" }, "win64": { - "sha256": "ff00dbb02287219a61873c3b2649a50b94e80c82e607c336383f2838abbefbde", - "size": 73245169, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-win32.zip" - } - } - ] - }, - { - "description": "Toolchain for ESP32 ULP coprocessor", - "export_paths": [ - [ - "esp32ulp-elf-binutils", - "bin" - ] - ], - "export_vars": {}, - "info_url": "https://github.com/espressif/binutils-esp32ulp", - "install": "always", - "license": "GPL-2.0-or-later", - "name": "esp32ulp-elf", - "version_cmd": [ - "esp32ulp-elf-as", - "--version" - ], - "version_regex": "\\(GNU Binutils\\)\\s+([0-9a-z\\.\\-]+)", - "versions": [ - { - "linux-amd64": { - "sha256": "c1bbcd65e1e30c7312a50344c8dbc70c2941580a79aa8f8abbce8e0e90c79566", - "size": 8246604, - "url": "https://dl.espressif.com/dl/binutils-esp32ulp-linux64-2.28.51-esp32ulp-20180809.tar.gz" - }, - "macos": { - "sha256": "c92937d85cc9a90eb6c6099ce767ca021108c18c94e34bd7b1fa0cde168f94a0", - "size": 5726662, - "url": "https://dl.espressif.com/dl/binutils-esp32ulp-macos-2.28.51-esp32ulp-20180809.tar.gz" - }, - "name": "2.28.51.20170517", - "status": "recommended", - "win32": { - "sha256": "92dc83e69e534c9f73d7b939088f2e84f757d2478483415d17fe9dd1c236f2fd", - "size": 12231559, - "url": "https://dl.espressif.com/dl/binutils-esp32ulp-win32-2.28.51-esp32ulp-20180809.zip" - }, - "win64": { - "sha256": "92dc83e69e534c9f73d7b939088f2e84f757d2478483415d17fe9dd1c236f2fd", - "size": 12231559, - "url": "https://dl.espressif.com/dl/binutils-esp32ulp-win32-2.28.51-esp32ulp-20180809.zip" + "sha256": "0756bb6e768fb986ec557bf1136a8978e106d7d2cca1bbb21fca5d566a30e468", + "size": 39567257, + "url": "https://dl.espressif.com/dl/xtensa-lx106-elf-win32-1.22.0-100-ge567ec7-5.2.0.zip" } } ] @@ -167,53 +117,6 @@ } ] }, - { - "description": "OpenOCD for ESP32", - "export_paths": [ - [ - "openocd-esp32", - "bin" - ] - ], - "export_vars": { - "OPENOCD_SCRIPTS": "${TOOL_PATH}/openocd-esp32/share/openocd/scripts" - }, - "info_url": "https://github.com/espressif/openocd-esp32", - "install": "always", - "license": "GPL-2.0-only", - "name": "openocd-esp32", - "version_cmd": [ - "openocd", - "--version" - ], - "version_regex": "Open On-Chip Debugger\\s+([a-z0-9.-]+)\\s+", - "versions": [ - { - "linux-amd64": { - "sha256": "e5b5579edffde090e426b4995b346e281843bf84394f8e68c8e41bd1e4c576bd", - "size": 1681596, - "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190313/openocd-esp32-linux64-0.10.0-esp32-20190313.tar.gz" - }, - "macos": { - "sha256": "09504eea5aa92646a117f16573c95b34e04b4010791a2f8fefcd2bd8c430f081", - "size": 1760536, - "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190313/openocd-esp32-macos-0.10.0-esp32-20190313.tar.gz" - }, - "name": "v0.10.0-esp32-20190313", - "status": "recommended", - "win32": { - "sha256": "b86a7f9f39dfc4d8e289fc819375bbb7a5e9fcb8895805ba2b5faf67b8b25ce2", - "size": 2098513, - "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190313/openocd-esp32-win32-0.10.0-esp32-20190313.zip" - }, - "win64": { - "sha256": "b86a7f9f39dfc4d8e289fc819375bbb7a5e9fcb8895805ba2b5faf67b8b25ce2", - "size": 2098513, - "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190313/openocd-esp32-win32-0.10.0-esp32-20190313.zip" - } - } - ] - }, { "description": "menuconfig tool", "export_paths": [