forked from m5stack/M5Tab5-UserDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add ESP-IDF installation helper #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| ESP_IDF_VERSION=${ESP_IDF_VERSION:-v5.4.2} | ||
| ESP_IDF_TARGET=${ESP_IDF_TARGET:-esp32p4} | ||
| ESP_IDF_ROOT=${ESP_IDF_ROOT:-$HOME/.espressif} | ||
|
|
||
| IDF_PATH="${ESP_IDF_ROOT}/esp-idf-${ESP_IDF_VERSION}" | ||
| REPO_URL="https://github.com/espressif/esp-idf.git" | ||
|
|
||
| for cmd in git python3 bash; do | ||
| if ! command -v "$cmd" >/dev/null 2>&1; then | ||
| echo "Error: '$cmd' is required but was not found in PATH." >&2 | ||
| echo "Please install $cmd before running this script." >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| mkdir -p "${ESP_IDF_ROOT}" | ||
|
|
||
| if [ -d "${IDF_PATH}" ] && [ ! -d "${IDF_PATH}/.git" ]; then | ||
| echo "Error: ${IDF_PATH} exists but is not a git repository." >&2 | ||
| echo "Please remove or rename it before running this script." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -d "${IDF_PATH}/.git" ]; then | ||
| echo "Cloning ESP-IDF ${ESP_IDF_VERSION} into ${IDF_PATH}" | ||
| git clone --depth 1 --branch "${ESP_IDF_VERSION}" "${REPO_URL}" "${IDF_PATH}" | ||
| else | ||
| echo "Updating existing ESP-IDF checkout at ${IDF_PATH}" | ||
| git -C "${IDF_PATH}" fetch --depth 1 origin "${ESP_IDF_VERSION}" | ||
| git -C "${IDF_PATH}" reset --hard FETCH_HEAD | ||
| fi | ||
|
|
||
| if [ ! -x "${IDF_PATH}/install.sh" ]; then | ||
| echo "Error: install.sh not found or not executable in ${IDF_PATH}." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| "${IDF_PATH}/install.sh" "${ESP_IDF_TARGET}" | ||
|
|
||
| export IDF_PATH | ||
|
|
||
| # shellcheck source=/dev/null | ||
| source "${IDF_PATH}/export.sh" | ||
|
|
||
| idf.py --version | ||
|
|
||
| echo | ||
| cat <<INSTRUCTIONS | ||
| ESP-IDF is installed at: ${IDF_PATH} | ||
| To use ESP-IDF in new shells, run: | ||
| export IDF_PATH="${IDF_PATH}" | ||
| source "${IDF_PATH}/export.sh" | ||
| Then, verify with: | ||
| idf.py --version | ||
| INSTRUCTIONS | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Clone/update ESP-IDF without submodules
The helper clones or updates ESP-IDF with
--depth 1but never fetches the repository’s submodules. ESP-IDF depends heavily on submodules (e.g. Wi‑Fi, USB, NimBLE); a shallow clone without them will succeed, yet subsequentidf.py buildinvocations will fail because those component directories are missing or stuck at the wrong revision. The script should either add--recurse-submodulesto the initial clone and rungit submodule update --init --recursiveafter the reset, or otherwise ensure submodules are synced to the requested release.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codex fix comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
--recurse-submodulesand synchronize submodules after checking out the requested release, ensuring dependent components are available for builds. tools/install_idf.shL27-L36Testing
bash -n tools/install_idf.shView task →