Skip to content
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
42 changes: 32 additions & 10 deletions gdb-xtensa-esp32-elf/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#
# This script is partially based on:
# https://github.com/espressif/binutils-gdb/blob/esp-gdb-v11.1_20220318/build_esp_gdb.sh
# and
# https://github.com/espressif/binutils-gdb/blob/esp-gdb-16.2/build_esp_gdb.sh
###

# The tool name should be 'xtensa-esp-elf', the same as how Espressif names it
Expand All @@ -20,6 +22,7 @@ export CPPFLAGS="$CPPFLAGS -I$PREFIX/include"

export ESP_CHIP_ARCHITECTURE=xtensa
export GDB_DIST="$PWD"/dist
GDB_REPO_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

# Disable PLATFORM selection for the xtensaconfig build. This disables the bin-wrapper script from being
# included in the xtensaconfig output. We don't really want it- it's used to at
Expand All @@ -35,23 +38,35 @@ unset PREFIX

# Build xtensa-config libs
mkdir -p "${GDB_DIST}"/lib
pushd xtensaconfig
pushd xtensa-dynconfig || exit 1
make clean
make CONF_DIR="${GDB_REPO_ROOT}/xtensa-overlays"
# AR="$TARGET_HOST-ar" CC="$TARGET_HOST-gcc"
if [ -z "$MACOSX_DEPLOYMENT_TARGET" ]; then
TARGET_ESP_ARCH=${ESP_CHIP_ARCHITECTURE} DESTDIR="${GDB_DIST}" PLATFORM=$PLATFORM make install
TARGET_ESP_ARCH=xtensa DESTDIR="${GDB_DIST}" PLATFORM=$PLATFORM make install
else
TARGET_ESP_ARCH=${ESP_CHIP_ARCHITECTURE} DESTDIR="${GDB_DIST}" PLATFORM=$PLATFORM make install CFLAGS="-Wl,-L,$(xcode-select -p)/SDKs/MacOSX.sdk/usr/lib -Wl,-lSystem"
TARGET_ESP_ARCH=xtensa DESTDIR="${GDB_DIST}" PLATFORM=$PLATFORM make install CFLAGS="-Wl,-L,$(xcode-select -p)/SDKs/MacOSX.sdk/usr/lib -Wl,-lSystem"
fi
popd
popd || exit 1
# Install xtensa-config libs
mkdir -p "$TARGET_PREFIX"/lib
cp -R "${GDB_DIST}"/lib "$TARGET_PREFIX"/

# Build wrappers
pushd esp-toolchain-bin-wrappers/gnu-debugger/unix || exit 1
if [ -z "$MACOSX_DEPLOYMENT_TARGET" ]; then
RUST_TARGET_TRIPLET="x86_64-unknown-linux-gnu"
else
RUST_TARGET_TRIPLET="aarch64-apple-darwin"
fi
rustup target add "$RUST_TARGET_TRIPLET"
cargo install --target=$RUST_TARGET_TRIPLET --no-track --path ./ --root $GDB_DIST
popd || exit 1

# Restore PREFIX variable
PREFIX=${_PREFIX}

if [ `uname` == Darwin ]; then
if [ "$(uname)" == "Darwin" ]; then
EXTRA_CONFIGURE_FLAGS=""
else
EXTRA_CONFIGURE_FLAGS="--with-debuginfod"
Expand Down Expand Up @@ -90,16 +105,23 @@ make install

mkdir -p "$TARGET_PREFIX"/bin/

echo "Renaming things..."
# rename gdb to have python version in filename
mv ${TARGET_PREFIX}/bin/xtensa-esp-elf-gdb ${TARGET_PREFIX}/bin/xtensa-esp-elf-gdb-${PY_VER}

# Wrapper scripts for esp32* variants
cp "$SRC_DIR"/xtensa-esp32*-elf-gdb "$TARGET_PREFIX"/bin/
# Set up the wrappers
cp $GDB_DIST/bin/esp-elf-gdb-wrapper $TARGET_PREFIX/bin/xtensa-esp32-elf-gdb 2> /dev/null || true
cp $GDB_DIST/bin/esp-elf-gdb-wrapper $TARGET_PREFIX/bin/xtensa-esp32s2-elf-gdb 2> /dev/null || true
mv $GDB_DIST/bin/esp-elf-gdb-wrapper $TARGET_PREFIX/bin/xtensa-esp32s3-elf-gdb 2> /dev/null || true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

did you confirm that these select the correct architecture (based on $1 arg to the rust wrapper i guess)? i think you can do it like this once the conda package is installed (eg to a test environment):

❯ xtensa-esp32s3-elf-gdb --batch --ex 'show environment' | rg XTENSA_GNU_CONFIG
XTENSA_GNU_CONFIG=/home/noah/.espressif/tools/xtensa-esp-elf-gdb/16.2_20250324/xtensa-esp-elf-gdb/lib/xtensa_esp32s3.so

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

$ xtensa-esp32-elf-gdb --batch --ex 'show environment' | grep 'XTENSA'
XTENSA_GNU_CONFIG=/Users/avery/micromamba/envs/memfault/lib/xtensa_esp32.so

Seems to work!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

xtensa-esp32s3-elf-gdb --batch --ex 'show environment' | grep 'XTENSA'
XTENSA_GNU_CONFIG=/Users/avery/micromamba/envs/memfault/lib/xtensa_esp32s3.so

chmod +x "$TARGET_PREFIX"/bin/*

# Symlink every binary from the build into /bin
pushd "${PREFIX}"/bin
pushd "${PREFIX}"/bin || exit 1
ln -s ../"${TARGET_DIR}"/bin/* ./
popd
popd || exit 1

# Same for lib
pushd "${PREFIX}"/lib
pushd "${PREFIX}"/lib || exit 1
ln -s ../"${TARGET_DIR}"/lib/* ./
popd
popd || exit 1
42 changes: 16 additions & 26 deletions gdb-xtensa-esp32-elf/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
c_compiler:
- gcc # [linux]
- clang # [osx]
- vs2019 # [win and x86_64]
- vs2022 # [win and arm64]
c_compiler_version: # [unix]
- 12 # [linux]
- 15 # [osx]
- 16 # [osx]
- 7 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
- 9 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
- 10 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
Expand All @@ -17,13 +15,13 @@ cxx_compiler:
- vs2022 # [win and arm64]
cxx_compiler_version: # [unix]
- 12 # [linux]
- 15 # [osx]
- 16 # [osx]
- 7 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
- 9 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
- 10 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
- 10 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
llvm_openmp: # [osx]
- 15 # [osx]
- 16 # [osx]
fortran_compiler: # [unix or win64]
- gfortran # [linux64 or (osx and x86_64)]
- gfortran # [aarch64 or ppc64le or armv7l or s390x]
Expand All @@ -36,12 +34,6 @@ fortran_compiler_version: # [unix or win64]
- 9 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
- 10 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
- 10 # [os.environ.get("CF_CUDA_ENABLED", "False") == "True" and linux64]
m2w64_c_compiler: # [win]
- m2w64-toolchain # [win]
m2w64_cxx_compiler: # [win]
- m2w64-toolchain # [win]
m2w64_fortran_compiler: # [win]
- m2w64-toolchain # [win]

cuda_compiler:
- None
Expand Down Expand Up @@ -90,28 +82,23 @@ cgo_compiler:
target_goos:
- linux # [linux]
- darwin # [osx]
- windows # [win]
target_goarch:
- amd64 # [x86_64]
- arm64 # [arm64 or aarch64]
- ppc64le # [ppc64le]
target_goexe:
- # [unix]
- .exe # [win]
target_gobin:
- '${PREFIX}/bin/' # [unix]
- '%PREFIX%\bin\' # [win]

# Rust Compiler Options
rust_compiler:
- rust

macos_machine: # [osx]
- x86_64-apple-darwin13.4.0 # [osx and x86_64]
- arm64-apple-darwin20.0.0 # [osx and arm64]
MACOSX_DEPLOYMENT_TARGET: # [osx]
- 11.0 # [osx and arm64]
- 10.9 # [osx and x86_64]
VERBOSE_AT:
- V=1
VERBOSE_CM:
Expand Down Expand Up @@ -327,7 +314,7 @@ dcap:
eclib:
- '20230424'
elfutils:
- 0.189.memfault1
- 0.189.memfault2
exiv2:
- 0.27
expat:
Expand Down Expand Up @@ -608,9 +595,11 @@ ntl:
# we build for the oldest version possible of numpy for forward compatibility
numpy:
# part of a zip_keys: python, python_impl, numpy
- 1.21
- 1.21
- 1.21
- 1.22
- 1.23
- 1.26
- 1.26
- 1.26
occt:
- '7.7'
openblas:
Expand Down Expand Up @@ -671,14 +660,18 @@ pybind11_abi:
- 4
python:
# part of a zip_keys: python, python_impl, numpy
- 3.8.* *_cpython
- 3.9.* *_cpython
- 3.10.* *_cpython
- 3.11.* *_cpython
- 3.12.* *_cpython
- 3.13.* *_cp313
- 3.14.* *_cp314
python_impl:
# part of a zip_keys: python, python_impl, numpy
- cpython
- cpython
- cpython
- cpython
- cpython
pytorch:
- '2.0'
pyqt:
Expand Down Expand Up @@ -707,7 +700,6 @@ ruby:
- 2.5
- 2.6
r_base:
- 4.1 # [win]
- 4.2 # [not win]
scotch:
- 6.0.9
Expand Down Expand Up @@ -764,8 +756,6 @@ uhd:
- 4.4.0
urdfdom:
- 3.1
vc: # [win]
- 14 # [win]
vlfeat:
- 0.9.21
volk:
Expand All @@ -791,7 +781,7 @@ zeromq:
zfp:
- 1.0
zlib:
- 1.2
- 1.3
zlib_ng:
- 2.0
zstd:
Expand Down
12 changes: 5 additions & 7 deletions gdb-xtensa-esp32-elf/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{% set name = "xtensa-esp32-elf-gdb" %}
{% set version = "12.1_20221002" %}
{% set version = "16.3_20250913" %}

package:
name: {{ name }}
version: {{ version }}.memfault4
version: {{ version }}.memfault1

source:
- git_url: https://github.com/espressif/binutils-gdb.git
git_rev: esp-gdb-v{{ version }}

# wrapper scripts for esp32 variants
- path: xtensa-esp32-elf-gdb
- path: xtensa-esp32s2-elf-gdb
- path: xtensa-esp32s3-elf-gdb

build:
number: '0'
skip: True # [win]
Expand All @@ -23,6 +18,7 @@ requirements:
- {{ compiler('fortran') }}
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- rust
- make
- bison # [linux]
host:
Expand All @@ -35,13 +31,15 @@ requirements:
- mpfr {{ mpfr }}
- gmp {{ gmp }}
- expat {{ expat }}
- zstd {{ zstd }}
# For libdebuginfod:
- elfutils
run:
- python {{ python }}
- ncurses {{ ncurses }}
- xz {{ xz }}
- zlib {{ zlib }} # [not osx]
- zstd {{ zstd }}
- libiconv {{ libiconv }}
- mpfr {{ mpfr }}
- gmp {{ gmp }} # [not osx]
Expand Down
3 changes: 0 additions & 3 deletions gdb-xtensa-esp32-elf/xtensa-esp32-elf-gdb

This file was deleted.

3 changes: 0 additions & 3 deletions gdb-xtensa-esp32-elf/xtensa-esp32s2-elf-gdb

This file was deleted.

3 changes: 0 additions & 3 deletions gdb-xtensa-esp32-elf/xtensa-esp32s3-elf-gdb

This file was deleted.