Skip to content

Commit e780251

Browse files
committed
🪚 Improve esp-idf feature
1 parent 13958d4 commit e780251

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

features/esp-idf/install.sh

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,41 @@
22

33
set -e
44

5-
VERSION=${VERSION:-5.3}
6-
TARGETS=${TARGETS:-all}
7-
ESP_DIR="/opt/esp"
8-
IDF_PATH="${ESP_DIR}/esp-idf"
5+
VERSION="5.3"
6+
IDF_DIR="/embedded/esp"
7+
IDF_PY="${IDF_DIR}/tools/idf.py"
98

10-
echo "📥 Installing ESP-IDF v${VERSION} for targets: ${TARGETS}"
9+
echo "📥 Installing ESP-IDF v${VERSION} for all targets"
10+
11+
# Check if already installed and version matches
12+
if [ -x "$IDF_PY" ]; then
13+
INSTALLED_VERSION=$("$IDF_PY" --version 2>/dev/null || echo "")
14+
if [[ "$INSTALLED_VERSION" == *"v$VERSION"* ]]; then
15+
echo "✔ ESP-IDF v${VERSION} already installed!"
16+
exit 0
17+
else
18+
echo "❗️ ESP IDF version doesn't match: ${INSTALLED_VERSION}"
19+
exho "🚀 Let's install v${VERSION}"
20+
fi
21+
fi
1122

1223
# Install dependencies
13-
apt-get update
14-
apt-get install -y \
24+
apt-get update && apt-get install -y \
1525
git wget flex bison gperf python3 python3-pip cmake ninja-build ccache \
1626
libffi-dev libssl-dev dfu-util libusb-1.0-0
1727

18-
echo "✅ ESP-IDF v${VERSION} installed!"
28+
# Clean esp directory
29+
rm -rf "${IDF_DIR:?}/"* "${IDF_DIR:?}"/.[!.]* 2>/dev/null || true
30+
31+
# Clone ESP-IDF
32+
git clone -b "release/${VERSION}" --recursive https://github.com/espressif/esp-idf.git "$IDF_DIR"
33+
34+
# Install the tools for all targets
35+
"$IDF_DIR/install.sh" all
36+
37+
# Configure login shell environment
38+
echo "export IDF_PATH=${IDF_DIR}" >> /etc/profile.d/esp-idf.sh
39+
echo "source ${IDF_DIR}/export.sh" >> /etc/profile.d/esp-idf.sh
40+
chmod +x /etc/profile.d/esp-idf.sh
41+
42+
echo "✅ ESP-IDF v${VERSION} installed!"

0 commit comments

Comments
 (0)