Skip to content

Commit

Permalink
dist/tools/esptools: upgrade to gcc 12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed May 2, 2023
1 parent c4b27d8 commit 4ead466
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 33 deletions.
11 changes: 8 additions & 3 deletions cpu/esp32/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ 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)
- 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 @@ -494,8 +495,10 @@ script takes an argument that specifies which tools to download and install:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ dist/tools/esptools/install.sh

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

Thus, either all tools or only certain tools can be installed.
Expand All @@ -522,7 +525,9 @@ paths of the installed tools using again the environment variable
$ . dist/tools/esptools/export.sh

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

All the tools required for building a RIOT application for ESP32x SoCs should then
Expand Down
46 changes: 41 additions & 5 deletions dist/tools/esptools/export.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/sh

ESP32_GCC_RELEASE="esp-2021r2-patch3"
ESP32_GCC_VERSION_DIR="8.4.0"
ESP32_GCC_RELEASE="esp-12.2.0_20230208"

ESP32_OPENOCD_VERSION="v0.11.0-esp32-20211220"
ESP32_OPENOCD_VERSION="v0.12.0-esp32-20230313"

if [ -z ${IDF_TOOLS_PATH} ]; then
IDF_TOOLS_PATH=${HOME}/.espressif
Expand Down Expand Up @@ -31,7 +30,7 @@ export_arch()
exit 1
esac

TOOLS_DIR=${TOOLS_PATH}/${TARGET_ARCH}/${ESP32_GCC_RELEASE}-${ESP32_GCC_VERSION_DIR}/${TARGET_ARCH}
TOOLS_DIR=${TOOLS_PATH}/${TARGET_ARCH}/${ESP32_GCC_RELEASE}/${TARGET_ARCH}
TOOLS_DIR_IN_PATH=`echo $PATH | grep ${TOOLS_DIR}`

if [ -e ${TOOLS_DIR} ] && [ -z ${TOOLS_DIR_IN_PATH} ]; then
Expand Down Expand Up @@ -98,16 +97,53 @@ export_qemu()
unset TOOLS_DIR
}

export_gdb()
{
case $1 in
xtensa)
GDB_ARCH="xtensa-esp-elf-gdb"
;;
riscv)
GDB_ARCH="riscv32-esp-elf-gdb"
;;
*)
echo "error: Unknown platform $1, use xtensa or riscv"
return
esac

GDB_VERSION="12.1_20221002"

TOOLS_DIR=${TOOLS_PATH}/${GDB_ARCH}/${GDB_VERSION}/${GDB_ARCH}
TOOLS_DIR_IN_PATH=`echo $PATH | grep ${TOOLS_DIR}`

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

unset TOOLS_DIR
}

if [ -z $1 ]; then
echo "Usage: export.sh <tool>"
echo "tool = all | esp32 | esp32c3 | esp32s2 | esp32s3 | openocd | qemu"
echo " export.sh gdb <platform>"
echo "<tool> = all | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu"
echo "<platform> = xtensa | riscv"
elif [ "$1" = "all" ]; then
ARCH_ALL="esp32 esp32c3 esp32s2 esp32s3"
for arch in ${ARCH_ALL}; do
export_arch $arch
done
export_gdb xtensa
export_gdb riscv
export_openocd
export_qemu
elif [ "$1" = "gdb" ]; then
if [ -z "$2" ]; then
echo "platform required: xtensa | riscv"
exit 1
fi
export_gdb $2
elif [ "$1" = "openocd" ]; then
export_openocd
elif [ "$1" = "qemu" ]; then
Expand Down
109 changes: 84 additions & 25 deletions dist/tools/esptools/install.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/sh

ESP32_GCC_RELEASE="esp-2021r2-patch3"
ESP32_GCC_VERSION_DIR="8.4.0"
ESP32_GCC_VERSION_DOWNLOAD="gcc8_4_0"
ESP32_GCC_RELEASE="esp-12.2.0_20230208"
ESP32_GCC_VERSION_DIR="12.2.0"
ESP32_GCC_VERSION_DOWNLOAD="12.2.0_20230208"

ESP32_OPENOCD_VERSION="v0.11.0-esp32-20211220"
ESP32_OPENOCD_VERSION_TGZ="0.11.0-esp32-20211220"
ESP32_OPENOCD_VERSION="v0.12.0-esp32-20230313"
ESP32_OPENOCD_VERSION_TGZ="0.12.0-esp32-20230313"

# set the tool path to the default if not already set
if [ -z "${IDF_TOOLS_PATH}" ]; then
Expand Down Expand Up @@ -37,23 +37,32 @@ PLATFORM=${PLATFORM_SYSTEM}-${PLATFORM_MACHINE}

# map different platform names to a unique OS name
case ${PLATFORM} in
linux-amd64|linux64|Linux-x86_64|FreeBSD-amd64)
OS=linux-amd64
linux-amd64|linux64|Linux-x86_64|FreeBSD-amd64|x86_64-linux-gnu)
OS=x86_64-linux-gnu
OS_OCD=linux-amd64
;;
linux-arm64|Linux-arm64|Linux-aarch64|Linux-armv8l)
OS=linux-arm64
linux-arm64|Linux-arm64|Linux-aarch64|Linux-armv8l|aarch64)
OS=aarch64-linux
OS_OCD=linux-arm64
;;
linux-armel|Linux-arm|Linux-armv7l)
OS=linux-armel
linux-armel|Linux-arm|Linux-armv7l|arm-linux-gnueabi)
OS=arm-linux-gnueabi
OS_OCD=linux-armel
;;
linux-armhf)
OS=linux-armhf
linux-armhf|arm-linux-gnueabihf)
OS=arm-linux-gnueabihf
OS_OCD=linux-armhf
;;
linux-i686|linux32|Linux-i686|FreeBSD-i386)
OS=linux-i686
linux-i686|linux32|Linux-i686|FreeBSD-i386|i586-linux-gnu|i686-linux-gnu)
OS=i686-linux-gnu
;;
Darwin-x86_64)
OS=macos
macos|osx|darwin|Darwin-x86_64|x86_64-apple-darwin)
OS=x86_64-apple-darwin
OS_OCD=macos
;;
macos-arm64|Darwin-arm64|aarch64-apple-darwin|arm64-apple-darwin)
OS=aarch64-apple-darwin
OS_OCD=macos-arm64
;;
*)
echo "error: OS architecture ${PLATFORM} not supported"
Expand Down Expand Up @@ -92,10 +101,10 @@ install_arch()
exit 1
esac

TOOLS_DIR=${TOOLS_PATH}/${TARGET_ARCH}/${ESP32_GCC_RELEASE}-${ESP32_GCC_VERSION_DIR}
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}-${ESP32_GCC_RELEASE}-${OS}.tar.gz
URL_TGZ=${TARGET_ARCH}-${ESP32_GCC_VERSION_DOWNLOAD}-${OS}.tar.xz
URL=${URL_PATH}/${ESP32_GCC_RELEASE}/${URL_TGZ}

echo "Creating directory ${TOOLS_DIR} ..." && \
Expand All @@ -104,18 +113,23 @@ install_arch()
echo "Downloading ${URL_TGZ} ..." && \
download ${URL} ${URL_TGZ} && \
echo "Extracting ${URL_TGZ} in ${TOOLS_DIR} ..." && \
tar xfz ${URL_TGZ} && \
tar xfJ ${URL_TGZ} && \
echo "Removing ${URL_TGZ} ..." && \
rm -f ${URL_TGZ} && \
echo "$1 toolchain installed in ${TOOLS_DIR}/$TARGET_ARCH"
}

install_openocd()
{
if [ "${OS_OCD}" = "" ]; then
echo "OS not supported by this OpenOCD version"
exit 1
fi

TOOLS_DIR=${TOOLS_PATH}/openocd-esp32/${ESP32_OPENOCD_VERSION}

URL_PATH=https://github.com/espressif/openocd-esp32/releases/download
URL_TGZ=openocd-esp32-${OS}-${ESP32_OPENOCD_VERSION_TGZ}.tar.gz
URL_TGZ=openocd-esp32-${OS_OCD}-${ESP32_OPENOCD_VERSION_TGZ}.tar.gz
URL=${URL_PATH}/${ESP32_OPENOCD_VERSION}/${URL_TGZ}

echo "Creating directory ${TOOLS_DIR} ..." && \
Expand All @@ -132,22 +146,23 @@ install_openocd()

install_qemu()
{
if [ ${OS} != "linux-amd64" ]; then
if [ ${OS} != "x86_64-linux-gnu" ]; then
echo "error: QEMU for ESP32 does not support OS ${OS}"
exit 1
fi

# qemu version depends on the version of ncurses lib
if [ "$(ldconfig -p | grep libncursesw.so.6)" != "" ]; then
ESP32_QEMU_VERSION="esp-develop-20220203"
ESP32_QEMU_VERSION="esp-develop-7.2.0-20230223"
URL_TGZ=esp-qemu-xtensa-softmmu-develop_7.2.0_20230223-${OS}.tar.bz2
else
ESP32_QEMU_VERSION="esp-develop-20210220"
URL_TGZ=qemu-${ESP32_QEMU_VERSION}.tar.bz2
fi

TOOLS_DIR=${TOOLS_PATH}/qemu-esp32/${ESP32_QEMU_VERSION}

URL_PATH=https://github.com/espressif/qemu/releases/download
URL_TGZ=qemu-${ESP32_QEMU_VERSION}.tar.bz2
URL=${URL_PATH}/${ESP32_QEMU_VERSION}/${URL_TGZ}

echo "Creating directory ${TOOLS_DIR} ..." && \
Expand All @@ -162,17 +177,61 @@ install_qemu()
echo "QEMU for ESP32 installed in ${TOOLS_DIR}"
}

install_gdb()
{
case $1 in
xtensa)
GDB_ARCH="xtensa-esp-elf-gdb"
;;
riscv)
GDB_ARCH="riscv32-esp-elf-gdb"
;;
*)
echo "error: Unknown platform $1, use xtensa or riscv"
exit 1
esac

GDB_VERSION="12.1_20221002"

TOOLS_DIR=${TOOLS_PATH}/${GDB_ARCH}/${GDB_VERSION}

URL_PATH=https://github.com/espressif/binutils-gdb/releases/download
URL_TGZ=${GDB_ARCH}-${GDB_VERSION}-${OS}.tar.gz
URL=${URL_PATH}/esp-gdb-v${GDB_VERSION}/${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 xfz ${URL_TGZ} && \
echo "Removing ${URL_TGZ} ..." && \
rm -f ${URL_TGZ} && \
echo "GDB for $1 installed in ${TOOLS_DIR}"
}

if [ -z "$1" ]; then
echo "Usage: install.sh <tool>"
echo "tool = all | esp32 | esp32c3 | esp32s2 | esp32s3 | openocd | qemu"
echo " install.sh gdb <platform>"
echo "<tool> = all | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu"
echo "<platform> = xtensa | riscv"
exit 1
elif [ "$1" = "all" ]; then
ARCH_ALL="esp32 esp32c3 esp32s2 esp32s3"
for arch in ${ARCH_ALL}; do
install_arch "$arch"
done
install_gdb xtensa
install_gdb riscv
install_openocd
install_qemu
elif [ "$1" = "gdb" ]; then
if [ -z "$2" ]; then
echo "platform required: xtensa | riscv"
exit 1
fi
install_gdb $2
elif [ "$1" = "openocd" ]; then
install_openocd
elif [ "$1" = "qemu" ]; then
Expand Down

0 comments on commit 4ead466

Please sign in to comment.