From 4ead466d958983e883aa4ec6541a64c5c361f28d Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Tue, 4 Apr 2023 13:28:50 +0200 Subject: [PATCH] dist/tools/esptools: upgrade to gcc 12.2 --- cpu/esp32/doc.txt | 11 +++- dist/tools/esptools/export.sh | 46 ++++++++++++-- dist/tools/esptools/install.sh | 109 +++++++++++++++++++++++++-------- 3 files changed, 133 insertions(+), 33 deletions(-) diff --git a/cpu/esp32/doc.txt b/cpu/esp32/doc.txt index 6c92a80f73901..21ba43159d772 100644 --- a/cpu/esp32/doc.txt +++ b/cpu/esp32/doc.txt @@ -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) @@ -494,8 +495,10 @@ script takes an argument that specifies which tools to download and install: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $ dist/tools/esptools/install.sh -install.sh -tool = all | esp32 | esp32c3 | esp32s2 | esp32s3 | openocd | qemu +Usage: install.sh + install.sh gdb + = all | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu + = xtensa | riscv ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Thus, either all tools or only certain tools can be installed. @@ -522,7 +525,9 @@ paths of the installed tools using again the environment variable $ . dist/tools/esptools/export.sh Usage: export.sh -tool = all | esp32 | esp32c3 | esp32s2 | esp32s3 | openocd | qemu + export.sh gdb + = all | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu + = xtensa | riscv ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All the tools required for building a RIOT application for ESP32x SoCs should then diff --git a/dist/tools/esptools/export.sh b/dist/tools/esptools/export.sh index 19dee95036ca8..58ff15e284052 100755 --- a/dist/tools/esptools/export.sh +++ b/dist/tools/esptools/export.sh @@ -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 @@ -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 @@ -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 " - echo "tool = all | esp32 | esp32c3 | esp32s2 | esp32s3 | openocd | qemu" + echo " export.sh gdb " + echo " = all | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu" + echo " = 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 diff --git a/dist/tools/esptools/install.sh b/dist/tools/esptools/install.sh index b2f6b32355196..6fb489443024f 100755 --- a/dist/tools/esptools/install.sh +++ b/dist/tools/esptools/install.sh @@ -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 @@ -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" @@ -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} ..." && \ @@ -104,7 +113,7 @@ 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" @@ -112,10 +121,15 @@ install_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} ..." && \ @@ -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} ..." && \ @@ -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 " - echo "tool = all | esp32 | esp32c3 | esp32s2 | esp32s3 | openocd | qemu" + echo " install.sh gdb " + echo " = all | esp32 | esp32c3 | esp32s2 | esp32s3 | gdb | openocd | qemu" + echo " = 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