Skip to content
Draft
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
20 changes: 11 additions & 9 deletions Docker/Dockerfile.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive

# This line installs wget tool - you don't need to use it if you already have it
RUN apt-get update && apt-get install -y wget gcc g++ make git jq zip unzip libcurl4-openssl-dev gcovr openocd libusb-1.0-0 ca-certificates xz-utils
RUN apt-get update && apt-get install -y wget gcc g++ make git jq zip unzip libcurl4-openssl-dev gcovr openocd libusb-1.0-0 ca-certificates xz-utils python3 python3-pip python3-venv ninja-build

# This downloads an installation script and run it
RUN wget -O - https://raw.githubusercontent.com/JohnAmadis/choco-scripts/refs/heads/master/install-choco-scripts.sh | bash
Expand Down Expand Up @@ -38,7 +38,7 @@ ENV XTENSA_ESP_FILE_PATH=$TOOLS_DIR/$XTENSA_ESP_FILE_NAME
WORKDIR /tools
RUN wget https://github.com/espressif/crosstool-NG/releases/download/esp-$XTENSA_ESP_VERSION/$XTENSA_ESP_FILE_NAME

# Installs Xtensa tools (generic ESP toolchain, exposed as xtensa-esp32s3-elf- for Dmod)
# Installs Xtensa tools (ESP toolchain; includes xtensa-esp32s3-elf-* binaries natively)
WORKDIR /tools
RUN tar xf $XTENSA_ESP_FILE_PATH
RUN rm -f $XTENSA_ESP_FILE_PATH
Expand All @@ -47,15 +47,17 @@ RUN XTENSA_ESP_SRC_DIR="$(find $TOOLS_DIR -maxdepth 1 -mindepth 1 -type d \( -na
test -n "$XTENSA_ESP_SRC_DIR" && \
if [ "$XTENSA_ESP_SRC_DIR" != "$XTENSA_ESP_DIR_PATH" ]; then mv "$XTENSA_ESP_SRC_DIR" "$XTENSA_ESP_DIR_PATH"; fi
ENV XTENSA_ESP_BIN_DIR_PATH=$XTENSA_ESP_DIR_PATH/bin
RUN ln -sf $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp-elf-gcc $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp32s3-elf-gcc && \
ln -sf $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp-elf-g++ $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp32s3-elf-g++ && \
ln -sf $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp-elf-ld $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp32s3-elf-ld && \
ln -sf $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp-elf-objdump $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp32s3-elf-objdump && \
ln -sf $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp-elf-objcopy $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp32s3-elf-objcopy && \
ln -sf $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp-elf-ar $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp32s3-elf-ar && \
ln -sf $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp-elf-size $XTENSA_ESP_BIN_DIR_PATH/xtensa-esp32s3-elf-size
ENV PATH=$PATH:$XTENSA_ESP_BIN_DIR_PATH

# Installs ESP-IDF
ENV ESP_IDF_VERSION=v5.2.2
ENV IDF_TOOLS_PATH=/tools/.espressif
ENV IDF_PATH=/tools/esp-idf
WORKDIR /tools
RUN git clone --recursive --branch $ESP_IDF_VERSION https://github.com/espressif/esp-idf.git $IDF_PATH
RUN $IDF_PATH/install.sh esp32s3
RUN echo '. $IDF_PATH/export.sh >/dev/null 2>&1' >> /etc/bash.bashrc

# Installs cmake from the repository
ENV CMAKE_VERSION=3.31.3
ENV CMAKE_URL=https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-x86_64.sh
Expand Down
32 changes: 29 additions & 3 deletions configs/arch/xtensa/esp32s3/tools-cfg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,36 @@ endif()
# ==============================================================================
set(DMOD_ARCH "xtensa-esp32s3" CACHE STRING "Target architecture")
set(DMOD_CPU "esp32s3" CACHE STRING "Target CPU")

if(NOT DEFINED IDF_PATH)
if(DEFINED ENV{IDF_PATH} AND NOT "$ENV{IDF_PATH}" STREQUAL "")
set(IDF_PATH "$ENV{IDF_PATH}" CACHE PATH "ESP-IDF path")
else()
set(IDF_PATH "/tools/esp-idf" CACHE PATH "ESP-IDF path")
endif()
endif()

set(ESP_IDF_INCLUDE_FLAGS "")
if(EXISTS "${IDF_PATH}")
file(GLOB_RECURSE ESP_IDF_INCLUDE_DIRS LIST_DIRECTORIES true
"${IDF_PATH}/components/*/include"
"${IDF_PATH}/components/*/*/include"
"${IDF_PATH}/components/*/*/*/include"
)
list(APPEND ESP_IDF_INCLUDE_DIRS "${IDF_PATH}/components/esp_hw_support/include")
list(REMOVE_DUPLICATES ESP_IDF_INCLUDE_DIRS)

foreach(ESP_IDF_INCLUDE_DIR ${ESP_IDF_INCLUDE_DIRS})
string(APPEND ESP_IDF_INCLUDE_FLAGS " -I${ESP_IDF_INCLUDE_DIR}")
endforeach()
else()
message(WARNING "ESP-IDF directory not found: ${IDF_PATH}. ESP-IDF headers will not be available.")
endif()

set(COMMON_DEFINE_FLAGS "-DDMOD_ARCH=\\\"${DMOD_ARCH}\\\" -DDMOD_CPU=\\\"${DMOD_CPU}\\\"")
set(CPUCONFIG_CFLAGS "-mlongcalls -mtext-section-literals -fstrict-volatile-bitfields -Wno-frame-address ${COMMON_DEFINE_FLAGS}" CACHE STRING "C compiler flags")
set(CPUCONFIG_CXXFLAGS "-mlongcalls -mtext-section-literals -fstrict-volatile-bitfields -Wno-frame-address ${COMMON_DEFINE_FLAGS}" CACHE STRING "C++ compiler flags")
set(CPUCONFIG_ASMFLAGS "-mlongcalls -mtext-section-literals -fstrict-volatile-bitfields -Wno-frame-address ${COMMON_DEFINE_FLAGS}" CACHE STRING "ASM compiler flags")
set(CPUCONFIG_CFLAGS "-mlongcalls -mtext-section-literals -fstrict-volatile-bitfields -Wno-frame-address ${COMMON_DEFINE_FLAGS}${ESP_IDF_INCLUDE_FLAGS}" CACHE STRING "C compiler flags")
set(CPUCONFIG_CXXFLAGS "-mlongcalls -mtext-section-literals -fstrict-volatile-bitfields -Wno-frame-address ${COMMON_DEFINE_FLAGS}${ESP_IDF_INCLUDE_FLAGS}" CACHE STRING "C++ compiler flags")
set(CPUCONFIG_ASMFLAGS "-mlongcalls -mtext-section-literals -fstrict-volatile-bitfields -Wno-frame-address ${COMMON_DEFINE_FLAGS}${ESP_IDF_INCLUDE_FLAGS}" CACHE STRING "ASM compiler flags")
set(CPUCONFIG_LDFLAGS "-Wl,--gc-sections -Wl,-static -mlongcalls -mtext-section-literals" CACHE STRING "Linker flags")
set(CMAKE_C_COMPILER "${ESP32S3_GCC}" CACHE STRING "C compiler")
set(CMAKE_CXX_COMPILER "${ESP32S3_GXX}" CACHE STRING "C++ compiler")
Expand Down
16 changes: 13 additions & 3 deletions docs/tools-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,16 @@ The DMOD framework is available as a ready-to-use Docker image that contains all
The Docker image contains:

- **DMOD Tools:** dmf-get, todmm, todmfc, todmp, todmd, whereisdmf, mkdmrpkg
- **Compiler:** GCC arm-none-eabi (version 10.3-2021.10)
- **Compilers:**
- GCC arm-none-eabi (version 10.3-2021.10) — for ARM Cortex-M targets
- Xtensa ESP toolchain (version 14.2.0_20260121) — for ESP32/ESP32-S3/ESP32-S2 targets (`xtensa-esp32s3-elf-gcc`, `xtensa-esp-elf-gcc`, etc.)
- **Build system:** CMake (version 3.31.3), Make
- **Development tools:** OpenOCD, gcovr, git, jq, zip/unzip
- **Libraries:** libcurl, libusb
- **Configured environment variables:**
- `DMOD_DMF_DIR=/tools/dmf`
- `DMOD_DMFC_DIR=/tools/dmfc`
- `PATH` includes `/usr/local/bin` with DMOD tools
- `PATH` includes `/usr/local/bin` with DMOD tools, `/tools/gcc-arm-none-eabi/bin`, and `/tools/xtensa-esp-elf/bin`

### Using the Docker Image

Expand All @@ -374,13 +376,21 @@ docker run --rm -v $(pwd):/workspace -w /workspace \
chocotechnologies/dmod:1.0.4 dmf-get mymodule
```

**Build project in container:**
**Build project in container (x86_64):**
```bash
# Mount project directory and build
docker run --rm -v $(pwd):/project -w /project \
chocotechnologies/dmod:1.0.4 bash -c "cmake -B build && cmake --build build"
```

**Build project in container (ESP32-S3 / Xtensa):**
```bash
# Mount project directory and build for ESP32-S3
docker run --rm -v $(pwd):/project -w /project \
chocotechnologies/dmod:1.0.4 bash -c \
"mkdir -p build && cd build && cmake .. -DDMOD_TOOLS_NAME=arch/xtensa/esp32s3 && cmake --build ."
```

### Customizing the Image

You can extend the Docker image with additional tools:
Expand Down
Loading