Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions tools/install_idf.sh
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
Comment on lines +27 to +33

Copy link
Copy Markdown

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 1 but 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 subsequent idf.py build invocations will fail because those component directories are missing or stuck at the wrong revision. The script should either add --recurse-submodules to the initial clone and run git submodule update --init --recursive after the reset, or otherwise ensure submodules are synced to the requested release.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex fix comments

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Updated the ESP-IDF installer helper to clone with --recurse-submodules and synchronize submodules after checking out the requested release, ensuring dependent components are available for builds. tools/install_idf.shL27-L36

Testing

  • bash -n tools/install_idf.sh

View task →

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
Loading