Skip to content

dist/tools: improve the esptools, enhance documentation#21625

Merged
crasbe merged 1 commit intoRIOT-OS:masterfrom
crasbe:pr/esptools_export
Jul 28, 2025
Merged

dist/tools: improve the esptools, enhance documentation#21625
crasbe merged 1 commit intoRIOT-OS:masterfrom
crasbe:pr/esptools_export

Conversation

@crasbe
Copy link
Copy Markdown
Contributor

@crasbe crasbe commented Jul 25, 2025

Contribution description

The esptools/export.sh script has to be sourced, otherwise the exported variables are not persistent in the environment, rendering the script useless. The commit adds a check to the script that it runs in the correct environment and enhances the documentation to make it clearer that the "source" prefix command is important.

The documentation mentioned that, but I did not understand what "sourcing a script" means and I did not pay attention to the dot in front of the script. Sorry @gschorcht for not reading the documentation well enough 👀

Open for discussion: Should the script terminate before doing anything (as it does now) or should it print out the warning instead of the Extending PATH by ... message?

Testing procedure: Sourcing

Pre: Make sure your PATH variable does not contain the latest ESP SDK version yet.

Current situation on master: Calling the dist/tools/esptools/export.sh script without a . or source command in the front suggests to be adding the SDK path to the PATH variable, while it actually doesn't (well it does, but to the environment of the script, which is lost after the script terminates):

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ dist/tools/esptools/export.sh esp32h2
Extending PATH by /home/cbuec/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ dist/tools/esptools/export.sh esp32h2
Extending PATH by /home/cbuec/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin

With this PR, an error message is printed:

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ dist/tools/esptools/export.sh esp32h2
Please run the script prefixed with the 'source' command.

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ source dist/tools/esptools/export.sh esp32h2
Extending PATH by /home/cbuec/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ source dist/tools/esptools/export.sh esp32h2
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin

Testing Procedure: Version Check

Testing procedure:

  1. Make sure there is nothing related to the ESP-SDK in your PATH:
cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib
  1. Export a platform of your choice:
cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . ./dist/tools/esptools/export.sh esp32s3
Extending PATH by /home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib
  1. Manipulate the PATH so that the version number is older (or newer, doesn't matter).
cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ PATH="/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-12.0.0_2
0241119/xtensa-esp-elf/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/s
bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib"
  1. Run the export script again and observe the warning message.
cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . ./dist/tools/esptools/export.sh esp32s3
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-12.0.0_20241119/xtensa-esp-elf/bin". Please check your ~/.bashrc or ~/.profile.
Extending PATH by /home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin
  1. Repeat with QEMU and GDB.

Issues/PRs references

Came up in #21616 (comment)

@crasbe crasbe requested a review from gschorcht as a code owner July 25, 2025 20:08
@crasbe crasbe added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jul 25, 2025
@github-actions github-actions bot added Area: doc Area: Documentation Area: tools Area: Supplementary tools Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: cpu Area: CPU/MCU ports labels Jul 25, 2025
@riot-ci
Copy link
Copy Markdown

riot-ci commented Jul 25, 2025

Murdock results

✔️ PASSED

bd0f8b7 dist/tools: various improvements of esptools scripts, enh. docs

Success Failures Total Runtime
1 0 1 01m:25s

Artifacts

@gschorcht
Copy link
Copy Markdown
Contributor

I still wonder whether the output regarding the permanent setting of the PATH variable should be inside of the if ... then ... fi or inside. The question is whether it really makes sense to print the output even if the path has already been set.

@benpicco added these lines there, maybe he has an strong opinion.

My suggestion would be that could be part of this PR:

diff --git a/dist/tools/esptools/export.sh b/dist/tools/esptools/export.sh
index defd527abf..dc04187327 100755
--- a/dist/tools/esptools/export.sh
+++ b/dist/tools/esptools/export.sh
@@ -47,10 +47,10 @@ export_arch()
     if [ -e "${TOOLS_DIR}" ] && [ -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"
+        echo "To make this permanent, add this line to your ~/.bashrc or ~/.profile:"
+        echo PATH="\$PATH:${TOOLS_DIR}/bin"
+    fi
 
     unset TOOLS_DIR
 }

@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Jul 27, 2025

Sure, why not. I'll add it later.

@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Jul 27, 2025

I also added the version check now, but this has to be tested more extensively.

@crasbe crasbe added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Jul 27, 2025
@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Jul 28, 2025

@gschorcht one thing I noticed is that no warning etc is printed when the toolchain is not present. For example, I don't have qemu installed and running the script just does nothing:

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . ./dist/tools/esptools/export.sh qemu xtensa

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib

Perhaps that should at least print an error message?

@gschorcht
Copy link
Copy Markdown
Contributor

@gschorcht one thing I noticed is that no warning etc is printed when the toolchain is not present. For example, I don't have qemu installed and running the script just does nothing:

Yes, but this is only true for the additional tools, that is, gdb, qemu and openocd. For the compiler, there are the following lines in export_arch:

    if [ ! -e "${TOOLS_DIR}" ]; then
        echo "${TOOLS_DIR} does not exist - please run"
        echo "\${RIOTBASE}/dist/tools/esptools/install.sh $1"
        return
    fi

We have just to these lines also to export_gdb, export_qemu and export_openocd.

@gschorcht
Copy link
Copy Markdown
Contributor

BTW, since the export_* functions grow now more and more due to the different checks and outputs which are the same for the different tools, we should think about a common function for exporting a tool and doing all the checks and the outputs.

export_tool()
{
    if [ ! -e "${TOOLS_DIR}" ]; then
        echo "${TOOLS_DIR} does not exist - please run"
        echo "\${RIOTBASE}/dist/tools/esptools/install.sh $1"
        exit(1)
    fi

    echo "$PATH" | tr ':' '\n' | while read -r entry; do
        if echo "$entry" | grep -q "^${TOOLS_PATH}/${TARGET_ARCH}/.*/${TARGET_ARCH}/bin$"; then
            if [ "$entry" != "${TOOLS_DIR}/bin" ]; then
                echo "Warning: PATH contains outdated entry: \"$entry\"." \
		     "Please check your ~/.bashrc or ~/.profile.">&2
            fi
	fi
    done
    unset entry

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

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

It makes no sense to repeat the same code again and again.

@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Jul 28, 2025

The new export_checks function appears to work as intended. Below are some test traces:

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ dist/tools/esptools/install.sh qemu esp32c3
Creating directory /home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606 ...
Downloading qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 12.9M  100 12.9M    0     0  11.4M      0  0:00:01  0:00:01 --:--:-- 16.5M
Extracting qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz in /home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606 ...
Removing qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz ...
QEMU for ESP32 installed in /home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606
Use following command to extend the PATH variable:
. dist/tools/esptools/export.sh qemu

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . ./dist/tools/esptools/export.sh qemu
Extending PATH by /home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606/qemu/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606/qemu/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . ./dist/tools/esptools/export.sh qemu

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606/qemu/bin:...

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ PATH="/home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-dev
elop-8.0.0-20240606/qemu/bin:..."

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . ./dist/tools/esptools/export.sh qemu
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-8.0.0-20240606/qemu/bin". Please check your ~/.bashrc or ~/.profile.
Extending PATH by /home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606/qemu/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606/qemu/bin
cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh openocd
/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016 does not exist - please run
${RIOTBASE}/dist/tools/esptools/install.sh openocd
/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32 does not exist - please run
${RIOTBASE}/dist/tools/esptools/install.sh openocd

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ dist/tools/esptools/install.sh openocd
Creating directory /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016 ...
Downloading openocd-esp32-linux-amd64-0.12.0-esp32-20241016.tar.gz ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 2342k  100 2342k    0     0  3530k      0 --:--:-- --:--:-- --:--:-- 3530k
Extracting openocd-esp32-linux-amd64-0.12.0-esp32-20241016.tar.gz in /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016 ...
Removing openocd-esp32-linux-amd64-0.12.0-esp32-20241016.tar.gz ...
OpenOCD for ESP32x SoCs installed in /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/
Use following command to extend the PATH variable:
. dist/tools/esptools/export.sh openocd

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh openocd
Extending PATH by /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/bin
Extending PATH by /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin:/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ PATH="/home/cbuec/.espressif/tools/openocd-esp32/v0.11.0-esp32
-20241016/openocd-esp32/bin:/home/cbuec/.espressif/tools/openocd-esp32/v0.11.0-esp32-20241016/bin:/home/cbue
c/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin:/usr/lib/wsl/lib"

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh openocd
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/openocd-esp32/v0.11.0-esp32-20241016/bin". Please check your ~/.bashrc or ~/.profile.
Extending PATH by /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/bin
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/openocd-esp32/v0.11.0-esp32-20241016/openocd-esp32/bin". Please check your ~/.bashrc or ~/.profile.
Extending PATH by /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin

Note here: There was a bug in install.sh, it requested you to call export.sh gdb instead of export.sh gdb xtensa.

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh gdb xtensa
/home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb does not exist - please run
${RIOTBASE}/dist/tools/esptools/install.sh gdb xtensa
cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ dist/tools/esptools/install.sh gdb xtensa
Creating directory /home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403 ...
Downloading xtensa-esp-elf-gdb-14.2_20240403-x86_64-linux-gnu.tar.gz ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 29.5M  100 29.5M    0     0  12.0M      0  0:00:02  0:00:02 --:--:-- 13.8M
Extracting xtensa-esp-elf-gdb-14.2_20240403-x86_64-linux-gnu.tar.gz in /home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403 ...
Removing xtensa-esp-elf-gdb-14.2_20240403-x86_64-linux-gnu.tar.gz ...
GDB for xtensa installed in /home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403
Use following command to extend the PATH variable:
. dist/tools/esptools/export.sh gdb

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh gdb xtensa
Extending PATH by /home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh gdb xtensa

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ PATH="/home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/13.2_202
40403/xtensa-esp-elf-gdb/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local
/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib"

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh gdb xtensa
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/13.2_20240403/xtensa-esp-elf-gdb/bin". Please check your ~/.bashrc or ~/.profile.
Extending PATH by /home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh gdb xtensa
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/xtensa-esp-elf-gdb/13.2_20240403/xtensa-esp-elf-gdb/bin". Please check your ~/.bashrc or ~/.profile.
cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh esp32s3
/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf does not exist - please run
${RIOTBASE}/dist/tools/esptools/install.sh esp32s3

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ dist/tools/esptools/install.sh esp32s3
Creating directory /home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119 ...
Downloading xtensa-esp-elf-14.2.0_20241119-x86_64-linux-gnu.tar.xz ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  166M  100  166M    0     0  14.4M      0  0:00:11  0:00:11 --:--:-- 15.0M
Extracting xtensa-esp-elf-14.2.0_20241119-x86_64-linux-gnu.tar.xz in /home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119 ...
Removing xtensa-esp-elf-14.2.0_20241119-x86_64-linux-gnu.tar.xz ...
esp32s3 toolchain installed in /home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf
Use following command to extend the PATH variable:
. dist/tools/esptools/export.sh esp32s3

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh esp32s3
Extending PATH by /home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ PATH="/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-13.2.0_2
0241119/xtensa-esp-elf/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/s
bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib"

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh esp32s3
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20241119/xtensa-esp-elf/bin". Please check your ~/.bashrc or ~/.profile.
Extending PATH by /home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh esp32s3
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20241119/xtensa-esp-elf/bin". Please check your ~/.bashrc or ~/.profile.

@crasbe crasbe removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Jul 28, 2025
@crasbe crasbe changed the title dist/tools: add environment check to esptools/export.sh, enhance documentation dist/tools: improve the esptools, enhance documentation Jul 28, 2025
@gschorcht
Copy link
Copy Markdown
Contributor

Note here: There was a bug in install.sh, it requested you to call export.sh gdb instead of export.sh gdb xtensa.

Not really a bug, it stems from a time when no additional parameters were required for the architecture because xtensa was the only architecture 😉

@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Jul 28, 2025

Should be correct now:

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh openocd
/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32 does not exist - please run
${RIOTBASE}/dist/tools/esptools/install.sh openocd

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ dist/tools/esptools/install.sh openocd
Creating directory /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016 ...
Downloading openocd-esp32-linux-amd64-0.12.0-esp32-20241016.tar.gz ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 2342k  100 2342k    0     0  1189k      0  0:00:01  0:00:01 --:--:-- 1967k
Extracting openocd-esp32-linux-amd64-0.12.0-esp32-20241016.tar.gz in /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016 ...
Removing openocd-esp32-linux-amd64-0.12.0-esp32-20241016.tar.gz ...
OpenOCD for ESP32x SoCs installed in /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/
Use following command to extend the PATH variable:
. dist/tools/esptools/export.sh openocd

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh openocd
Extending PATH by /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh openocd

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $OPENOCD
/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin/openocd -s /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/share/openocd/scripts

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ PATH="/home/cbuec/.espressif/tools/openocd-esp32/v0.11.0-esp32
-20241016/openocd-esp32/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/
sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib"

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh openocd
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/openocd-esp32/v0.11.0-esp32-20241016/openocd-esp32/bin". Please check your ~/.bashrc or ~/.profile.
Extending PATH by /home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin
To make this permanent, add this line to your ~/.bashrc or ~/.profile:
PATH=$PATH:/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh openocd
Warning: PATH contains outdated entry: "/home/cbuec/.espressif/tools/openocd-esp32/v0.11.0-esp32-20241016/openocd-esp32/bin". Please check your ~/.bashrc or ~/.profile.

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ echo $PATH
/home/cbuec/.espressif/tools/openocd-esp32/v0.12.0-esp32-20241016/openocd-esp32/bin:/home/cbuec/.espressif/tools/openocd-esp32/v0.11.0-esp32-20241016/openocd-esp32/bin:/home/cbuec/.local/bin:/home/cbuec/.cargo/bin:/home/cbuec/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib

I also added the distinction between qemu/qemu xtensa and qemu riscv:

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh qemu
/home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606/qemu does not exist - please run
${RIOTBASE}/dist/tools/esptools/install.sh qemu

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh qemu riscv
/home/cbuec/.espressif/tools/qemu-riscv32-softmmu/esp-develop-9.0.0-20240606/qemu does not exist - please run
${RIOTBASE}/dist/tools/esptools/install.sh qemu riscv

cbuec@W11nMate:~/RIOTstuff/riot-esp32c6/RIOT$ . dist/tools/esptools/export.sh qemu xtensa
/home/cbuec/.espressif/tools/qemu-xtensa-softmmu/esp-develop-9.0.0-20240606/qemu does not exist - please run
${RIOTBASE}/dist/tools/esptools/install.sh qemu xtensa

Copy link
Copy Markdown
Contributor

@gschorcht gschorcht left a comment

Choose a reason for hiding this comment

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

Looks good, please squash.

The esptools/export.sh script has to be sourced, otherwise
the exported variables are not persistent in the environment,
rendering the script useless. The commit adds a check to the
script that it runs in the correct environment and enhances the
documentation to make it clearer that the "source" prefix command
is important.

The PR also introduces a version check for the PATH variable
to notify the user if an old version is present.
@crasbe crasbe force-pushed the pr/esptools_export branch from 6524a6f to bd0f8b7 Compare July 28, 2025 19:13
@crasbe crasbe added this pull request to the merge queue Jul 28, 2025
Merged via the queue into RIOT-OS:master with commit cfaa76b Jul 28, 2025
25 checks passed
@crasbe crasbe deleted the pr/esptools_export branch July 28, 2025 23:03
@gschorcht
Copy link
Copy Markdown
Contributor

Thanks a lot for your work on these scripts.

@benpicco benpicco added this to the Release 2025.10 milestone Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants