Skip to content
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

dist/tools/esptools: add support for installing esp8266 toolchain #21094

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions cpu/esp32/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ toolchain (Debian/Ubuntu package names):
The shell script `$RIOTBASE/dist/tools/esptools/install.sh` is used to
install Espressif's precompiled versions of the following tools:

- ESP32 vendor toolchain (for ESP32, ESP32-S2, ESP32-S3 and ESP32-C3)
- ESP32 vendor toolchain (for ESP8266, ESP32, ESP32-S2, ESP32-S3 and ESP32-C3)
- GDB for ESP32x SoCs based on Xtensa or RISC-V
- OpenOCD for ESP32 (for ESP32, ESP32-S2, ESP32-S3 and ESP32-C3)
- QEMU for ESP32 (only for ESP32)
Expand All @@ -499,7 +499,7 @@ $ dist/tools/esptools/install.sh

Usage: install.sh <tool>
install.sh gdb <platform>
<tool> = all | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu
<tool> = all | esp8266 | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu
<platform> = xtensa | riscv
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
11 changes: 6 additions & 5 deletions cpu/esp8266/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ system using the `BUILD_IN_DOCKER` variable:

## Manual Toolchain Installation {#esp8266_manual_toolchain_installation}

A more difficult way to install the toolchain is the manual installation of
A more simple way to install the toolchain is the manual installation of
mguetschow marked this conversation as resolved.
Show resolved Hide resolved
all required components as described below.

@note To install the toolchain manually, a 64-bit Linux system is required.
Expand All @@ -325,17 +325,18 @@ The Xtensa GCC compiler for ESP8266 configured for use with RIOT-OS can
be downloaded and installed as precompiled binary archive from
[GitHub](https://github.com/gschorcht/xtensa-esp8266-elf):

The shell script `$RIOTBASE/dist/tools/esptools/install.sh` is used to
install the custom ESP8266 toolchain:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mkdir -p $HOME/esp
cd $HOME/esp
git clone https://github.com/gschorcht/xtensa-esp8266-elf
$ dist/tools/esptools/install.sh esp8266
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Once the compiler is installed, you have to expand your `PATH` variable by
the directory with Xtensa GCC binaries:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export PATH=$HOME/esp/xtensa-esp8266-elf/bin:$PATH
$ . dist/tools/esptools/export.sh esp8266
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[Back to table of contents](#esp8266_toc)
Expand Down
18 changes: 16 additions & 2 deletions dist/tools/esptools/export.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

ESP32_GCC_RELEASE="esp-12.2.0_20230208"
ESP8266_GCC_RELEASE="esp-5.2.0_20191018"

ESP32_OPENOCD_VERSION="v0.12.0-esp32-20230313"

Expand All @@ -13,6 +14,10 @@
export_arch()
{
case $1 in
esp8266)
TARGET_ARCH="xtensa-esp8266-elf"
ESP32_GCC_RELEASE=${ESP8266_GCC_RELEASE}
;;
esp32)
TARGET_ARCH="xtensa-esp32-elf"
;;
Expand All @@ -31,20 +36,29 @@
esac

TOOLS_DIR="${TOOLS_PATH}/${TARGET_ARCH}/${ESP32_GCC_RELEASE}/${TARGET_ARCH}"
TOOLS_DIR_IN_PATH="$(echo $PATH | grep "${TOOLS_DIR}")"

Check warning on line 39 in dist/tools/esptools/export.sh

View workflow job for this annotation

GitHub Actions / static-tests

Double quote to prevent globbing and word splitting. [SC2086]

if [ -e "${TOOLS_DIR}" ] && [ -z "${TOOLS_DIR_IN_PATH}" ]; then
if [ ! -e "${TOOLS_DIR}" ]; then
echo "${TOOLS_DIR} does not exist - please run"
echo $(echo $0 | sed 's/export/install/') $1

Check warning on line 43 in dist/tools/esptools/export.sh

View workflow job for this annotation

GitHub Actions / static-tests

Double quote to prevent globbing and word splitting. [SC2086]

Check warning on line 43 in dist/tools/esptools/export.sh

View workflow job for this annotation

GitHub Actions / static-tests

Quote this to prevent word splitting. [SC2046]
exit 1
fi

if [ -z "${TOOLS_DIR_IN_PATH}" ]; then
echo "Extending PATH by ${TOOLS_DIR}/bin"
export PATH="${TOOLS_DIR}/bin:${PATH}"
fi

echo "To make this permanent, add this line to your ~/.bashrc or ~/.profile:"
echo PATH="\$PATH:${TOOLS_DIR}/bin"

unset TOOLS_DIR
}

export_openocd()
{
TOOLS_DIR="${TOOLS_PATH}/openocd-esp32/${ESP32_OPENOCD_VERSION}"
TOOLS_DIR_IN_PATH="$(echo $PATH | grep "${TOOLS_DIR}")"

Check warning on line 61 in dist/tools/esptools/export.sh

View workflow job for this annotation

GitHub Actions / static-tests

Double quote to prevent globbing and word splitting. [SC2086]
OPENOCD_DIR="${TOOLS_DIR}/openocd-esp32"

if [ -e "${OPENOCD_DIR}" ] && [ -z "${TOOLS_DIR_IN_PATH}" ]; then
Expand All @@ -67,7 +81,7 @@
# map different platform names to a unique OS name
case "${PLATFORM}" in
linux-amd64|linux64|Linux-x86_64|FreeBSD-amd64)
OS="linux-amd64"

Check warning on line 84 in dist/tools/esptools/export.sh

View workflow job for this annotation

GitHub Actions / static-tests

OS appears unused. Verify use (or export if used externally). [SC2034]
;;
*)
echo "error: OS architecture ${PLATFORM} not supported"
Expand All @@ -87,7 +101,7 @@
fi

TOOLS_DIR="${TOOLS_PATH}/qemu-esp32/${ESP32_QEMU_VERSION}/qemu"
TOOLS_DIR_IN_PATH="$(echo $PATH | grep "${TOOLS_DIR}")"

Check warning on line 104 in dist/tools/esptools/export.sh

View workflow job for this annotation

GitHub Actions / static-tests

Double quote to prevent globbing and word splitting. [SC2086]

if [ -e "${TOOLS_DIR}" ] && [ -z "${TOOLS_DIR_IN_PATH}" ]; then
echo "Extending PATH by ${TOOLS_DIR}/bin"
Expand All @@ -114,7 +128,7 @@
GDB_VERSION="12.1_20221002"

TOOLS_DIR="${TOOLS_PATH}/${GDB_ARCH}/${GDB_VERSION}/${GDB_ARCH}"
TOOLS_DIR_IN_PATH="$(echo $PATH | grep "${TOOLS_DIR}")"

Check warning on line 131 in dist/tools/esptools/export.sh

View workflow job for this annotation

GitHub Actions / static-tests

Double quote to prevent globbing and word splitting. [SC2086]

if [ -e "${TOOLS_DIR}" ] && [ -z "${TOOLS_DIR_IN_PATH}" ]; then
echo "Extending PATH by ${TOOLS_DIR}/bin"
Expand All @@ -130,7 +144,7 @@
echo "<tool> = all | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu"
echo "<platform> = xtensa | riscv"
elif [ "$1" = "all" ]; then
ARCH_ALL="esp32 esp32c3 esp32s2 esp32s3"
ARCH_ALL="esp8266 esp32 esp32c3 esp32s2 esp32s3"
for arch in ${ARCH_ALL}; do
export_arch "$arch"
done
Expand All @@ -151,7 +165,7 @@
elif [ "$1" = "qemu" ]; then
export_qemu
else
export_arch $1

Check warning on line 168 in dist/tools/esptools/export.sh

View workflow job for this annotation

GitHub Actions / static-tests

Double quote to prevent globbing and word splitting. [SC2086]
fi

unset ESP32_GCC_RELEASE
Expand Down
42 changes: 26 additions & 16 deletions dist/tools/esptools/install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/sh

ESP32_GCC_RELEASE="esp-12.2.0_20230208"
ESP32_GCC_VERSION_DIR="12.2.0"

Check warning on line 4 in dist/tools/esptools/install.sh

View workflow job for this annotation

GitHub Actions / static-tests

ESP32_GCC_VERSION_DIR appears unused. Verify use (or export if used externally). [SC2034]
ESP32_GCC_VERSION_DOWNLOAD="12.2.0_20230208"

ESP8266_GCC_RELEASE="esp-5.2.0_20191018"

ESP32_OPENOCD_VERSION="v0.12.0-esp32-20230313"
ESP32_OPENOCD_VERSION_TGZ="0.12.0-esp32-20230313"

Expand Down Expand Up @@ -84,6 +86,10 @@
install_arch()
{
case "$1" in
esp8266)
TARGET_ARCH="xtensa-esp8266-elf"
ESP32_GCC_RELEASE=${ESP8266_GCC_RELEASE}
;;
esp32)
TARGET_ARCH="xtensa-esp32-elf"
;;
Expand All @@ -103,19 +109,23 @@

TOOLS_DIR="${TOOLS_PATH}/${TARGET_ARCH}/${ESP32_GCC_RELEASE}"

URL_PATH="https://github.com/espressif/crosstool-NG/releases/download"
URL_TGZ="${TARGET_ARCH}-${ESP32_GCC_VERSION_DOWNLOAD}-${OS}.tar.xz"
URL="${URL_PATH}/${ESP32_GCC_RELEASE}/${URL_TGZ}"

echo "Creating directory ${TOOLS_DIR} ..." && \
mkdir -p "${TOOLS_DIR}" && \
cd "${TOOLS_DIR}" && \
echo "Downloading ${URL_TGZ} ..." && \
download "${URL}" "${URL_TGZ}" && \
echo "Extracting ${URL_TGZ} in ${TOOLS_DIR} ..." && \
tar xfJ "${URL_TGZ}" && \
echo "Removing ${URL_TGZ} ..." && \
rm -f "${URL_TGZ}" && \
if [ "$1" = "esp8266" ]; then
git clone https://github.com/gschorcht/xtensa-esp8266-elf ${TOOLS_DIR}/${TARGET_ARCH}

Check warning on line 113 in dist/tools/esptools/install.sh

View workflow job for this annotation

GitHub Actions / static-tests

Double quote to prevent globbing and word splitting. [SC2086]
else
URL_PATH="https://github.com/espressif/crosstool-NG/releases/download"
URL_TGZ="${TARGET_ARCH}-${ESP32_GCC_VERSION_DOWNLOAD}-${OS}.tar.xz"
URL="${URL_PATH}/${ESP32_GCC_RELEASE}/${URL_TGZ}"

echo "Creating directory ${TOOLS_DIR} ..." && \
mkdir -p "${TOOLS_DIR}" && \
cd "${TOOLS_DIR}" && \
echo "Downloading ${URL_TGZ} ..." && \
download "${URL}" "${URL_TGZ}" && \
echo "Extracting ${URL_TGZ} in ${TOOLS_DIR} ..." && \
tar xfJ "${URL_TGZ}" && \
echo "Removing ${URL_TGZ} ..." && \
rm -f "${URL_TGZ}"
fi
echo "$1 toolchain installed in ${TOOLS_DIR}/$TARGET_ARCH"
}

Expand Down Expand Up @@ -214,11 +224,11 @@
if [ -z "$1" ]; then
echo "Usage: install.sh <tool>"
echo " install.sh gdb <platform>"
echo "<tool> = all | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu"
echo "<tool> = all | esp8266 | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu"
echo "<platform> = xtensa | riscv"
exit 1
elif [ "$1" = "all" ]; then
ARCH_ALL="esp32 esp32c3 esp32s2 esp32s3"
ARCH_ALL="esp8266 esp32 esp32c3 esp32s2 esp32s3"
for arch in ${ARCH_ALL}; do
install_arch "$arch"
done
Expand All @@ -241,4 +251,4 @@
fi

echo "Use following command to extend the PATH variable:"
echo ". $(dirname "$0")/export.sh"
echo ". $(dirname "$0")/export.sh $1"
Loading