Skip to content

Fix Xtensa ESP32/S3 standalone build (configMAX redefinition, lx7 mapping, missing ESP-IDF stubs)#69

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-building-issue
Draft

Fix Xtensa ESP32/S3 standalone build (configMAX redefinition, lx7 mapping, missing ESP-IDF stubs)#69
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-building-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

The GCC_XTENSA_ESP32 FreeRTOS port fails to build when used outside the ESP-IDF build system (e.g. with dmod-boot targeting ESP32-S3). Three root causes were identified and fixed.

Changes

1. config/arch/xtensa_esp32/FreeRTOSConfigArch.h — prevent configMAX_SYSCALL_INTERRUPT_PRIORITY redefinition

FreeRTOSConfig.h sets configMAX_SYSCALL_INTERRUPT_PRIORITY to 0 before the port's own FreeRTOSConfig_arch.h unconditionally redefines it to XCHAL_EXCM_LEVEL, producing a redefinition warning. Pre-defining it here causes the port's subsequent definition to be a no-op (identical replacement text).

2. cmake/arch_mapping.cmake — add lx7 (and lx6) → GCC_XTENSA_ESP32 mapping

dmod-boot sets DMOSI_ARCH_FAMILY=lx7 for ESP32-S3 (Xtensa LX7 core), but the mapping table had no entry for it, causing a FATAL_ERROR during CMake configuration. Both lx7 and lx6 are now mapped to GCC_XTENSA_ESP32 / xtensa_esp32.

3. config/arch/xtensa_esp32/sdkconfig.h (new) — minimal stub for standalone builds

The port's FreeRTOSConfig_arch.h unconditionally #include "sdkconfig.h", which is auto-generated by ESP-IDF's Kconfig system and not present in standalone builds. The stub provides the two required symbols:

  • CONFIG_FREERTOS_CORETIMER_0 1 — selects the FreeRTOS tick timer
  • CONFIG_FREERTOS_ISR_STACKSIZE 1792 — ISR stack size (ESP-IDF default, 16-byte aligned)

4. config/arch/xtensa_esp32/esp_idf_version.h (new) — minimal stub declaring IDF 4.1.0

The port's assembly and C files include esp_idf_version.h and branch on ESP_IDF_VERSION >= 4.2.0. Without this header both ESP_IDF_VERSION and ESP_IDF_VERSION_VAL resolve to 0 in preprocessor #if expressions, making 0 >= 0 evaluate to true. This activates code paths that reference XT_STK_TMP0/1/2 — Espressif-specific stack-frame offsets that exist only in ESP-IDF's xtensa component headers, not in the bare Xtensa toolchain sysroot — producing the "invalid symbolic operand" assembler errors at xtensa_context.S lines 194–196 and 256–258.

Declaring version 4.1.0 (< 4.2.0) causes the preprocessor to skip those code paths. For call0-ABI builds (ESP32-S3 with -mabi=call0), the register-window code in the < 4.2.0 branch is also bypassed via #ifndef __XTENSA_CALL0_ABI__, so context save/restore is correct.

In a real ESP-IDF build (via idf.py), the generated sdkconfig.h and esp_idf_version.h are found earlier in the include path and shadow these stubs automatically.

Copilot AI linked an issue May 15, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix building issue with FreeRTOS for ESP Fix Xtensa ESP32 build: prevent configMAX_SYSCALL_INTERRUPT_PRIORITY from being set to 0 May 15, 2026
Copilot AI requested a review from JohnAmadis May 15, 2026 08:24
@JohnAmadis
Copy link
Copy Markdown
Contributor

@copilot nie naprawiłeś problemu. Wciąż są błędy kompilacji. Proszę Cię, abyś sklonował repozytorium dmod-boot, a następnie wybrał w lib/dmosi-freertos swój branch i spróbował zbudować projekt dla ESP, a następnie doprowadził do porządku repozytorium dmosi-freertos, tak, aby się zbudowało pod tę architekturę.

…sp_idf_version.h stubs

Agent-Logs-Url: https://github.com/choco-technologies/dmosi-freertos/sessions/965b0de9-31ff-413a-8eb4-775e03614167

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 15, 2026

@copilot nie naprawiłeś problemu. Wciąż są błędy kompilacji. Proszę Cię, abyś sklonował repozytorium dmod-boot, a następnie wybrał w lib/dmosi-freertos swój branch i spróbował zbud...

Three root causes were found and fixed (commit 0a86c31):

  1. Missing lx7 arch mappingdmod-boot sets DMOSI_ARCH_FAMILY=lx7 for ESP32-S3, but cmake/arch_mapping.cmake had no entry for it. Added lx7 (and lx6) → GCC_XTENSA_ESP32.

  2. Missing sdkconfig.h stub — The port's FreeRTOSConfig_arch.h unconditionally #include "sdkconfig.h", which is normally generated by ESP-IDF. Added a minimal stub at config/arch/xtensa_esp32/sdkconfig.h providing CONFIG_FREERTOS_CORETIMER_0 and CONFIG_FREERTOS_ISR_STACKSIZE.

  3. "invalid symbolic operand" assembler errors — The port's assembly files use ESP_IDF_VERSION guards. Without a real esp_idf_version.h, both ESP_IDF_VERSION and ESP_IDF_VERSION_VAL resolve to 0 in preprocessor #if expressions, making 0 >= 0 evaluate to true. This causes the >= 4.2.0 code blocks (which reference XT_STK_TMP0/1/2 — Espressif-specific frame offsets absent in the bare Xtensa toolchain headers) to be compiled, producing the assembler errors. Added config/arch/xtensa_esp32/esp_idf_version.h stub declaring version 4.1.0, which causes the preprocessor to skip those code paths. With -mabi=call0 the register-window code in the < 4.2.0 path is also skipped, so context save/restore is correct for ESP32-S3.

Copilot AI changed the title Fix Xtensa ESP32 build: prevent configMAX_SYSCALL_INTERRUPT_PRIORITY from being set to 0 Fix Xtensa ESP32/S3 standalone build (configMAX redefinition, lx7 mapping, missing ESP-IDF stubs) May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix building issue

2 participants