Invalid character escape '\U' in esp32 project

I want to run pio in a existing esp32 project. I copy the platformio.ini to that project folder and run the command
pio init --ide vscode
but it error with Invalid character escape '\U'
I have ever try to build a demo esp32 project with pio and it works.
This is my second project

system: win10
PlatformIO Core, version 6.1.5

Here is the full log

C:\Users\22380\Documents\GitHub\wireless-esp8266-dap> pio init --ide vscode
Resolving esp32dev dependencies...
Already up-to-date.
Updating metadata for the vscode IDE...
Error: Processing esp32dev (platform: espressif32; board: esp32dev; framework: espidf)
------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (5.2.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (jlink) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf @ 3.40402.0 (4.4.2)
 - tool-cmake @ 3.16.4
 - tool-esptoolpy @ 1.40201.0 (4.2.1)
 - tool-idf @ 1.0.1
 - tool-mconf @ 1.4060000.20190628 (406.0.0)
 - tool-ninja @ 1.9.0
 - tool-openocd-esp32 @ 2.1100.20220706 (11.0)
 - toolchain-esp32ulp @ 1.22851.191205 (2.28.51)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
Reading CMake configuration...
-- Building ESP-IDF components for target esp32
-- Project sdkconfig file C:/Users/22380/Documents/GitHub/wireless-esp8266-dap/sdkconfig.esp32dev
Loading defaults file C:/Users/22380/Documents/GitHub/wireless-esp8266-dap/sdkconfig.defaults...

Loading defaults file C:/Users/22380/Documents/GitHub/wireless-esp8266-dap/sdkconfig.defaults.esp32...

C:/Users/22380/Documents/GitHub/wireless-esp8266-dap/sdkconfig.defaults.esp32:894 CONFIG_USB_DESC_CUSTOM_VID was replaced with CONFIG_TINYUSB_DESC_CUSTOM_VID

C:/Users/22380/Documents/GitHub/wireless-esp8266-dap/sdkconfig.defaults.esp32:895 CONFIG_USB_DESC_CUSTOM_PID was replaced with CONFIG_TINYUSB_DESC_CUSTOM_PID

-- App "wireless_esp_dap" version: v0.2.1
-- Adding linker script C:/Users/22380/Documents/GitHub/wireless-esp8266-dap/.pio/build/esp32dev/esp-idf/esp_system/ld/memory.ld
-- Adding linker script C:/Users/22380/.platformio/packages/framework-espidf/components/esp_system/ld/esp32/sections.ld.in
-- Adding linker script C:/Users/22380/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/22380/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.api.ld
-- Adding linker script C:/Users/22380/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/22380/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script C:/Users/22380/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script C:/Users/22380/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script C:/Users/22380/.platformio/packages/framework-espidf/components/esp_rom/esp32/ld/esp32.rom.newlib-time.ld
-- Adding linker script C:/Users/22380/.platformio/packages/framework-espidf/components/soc/esp32/ld/esp32.peripherals.ld
-- Websocket transport is disabled so the esp_websocket_client component will not be built
-- Configuring incomplete, errors occurred!
See also "C:/Users/22380/Documents/GitHub/wireless-esp8266-dap/.pio/build/esp32dev/CMakeFiles/CMakeOutput.log".

fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository: C:/Users/22380/.platformio/packages/framework-espidf/components/openthread/openthread/../../../.git/modules/components/openthread/openthread
CMake Error at C:/Users/22380/.platformio/packages/framework-espidf/tools/cmake/component.cmake:297 (foreach):
  Syntax error in cmake code at

    C:/Users/22380/.platformio/packages/framework-espidf/tools/cmake/component.cmake:297

  when parsing string

    config;include;C:\Users\22380\.platformio\packages\framework-espidf/components/esp_ringbuf/include/;C:\Users\22380\.platformio\packages\framework-espidf/components/

  Invalid character escape '\U'.
Call Stack (most recent call first):
  C:/Users/22380/.platformio/packages/framework-espidf/tools/cmake/component.cmake:473 (__component_add_include_dirs)
  C:/Users/22380/.platformio/packages/framework-espidf/tools/cmake/component.cmake:593 (idf_component_register)
  components/DAP/CMakeLists.txt:6 (register_component)



============================================== [FAILED] Took 5.12 seconds ==============================================

I am willing to provide more information if you need
Thanks

Is this a custom component of the project? I don’t see it in ESP-IDF.

So what it seems upset about is that \ initiates an escaped character and \Uas part of C:\Users.. is not a valid escaped cahracter. It may be expecting Linux-style paths here with only /.

  • Did you add the C:\Users\22380\.platformio\packages\framework-espidf/components/esp_ringbuf/include/ path in by hand somewhere?
  • What’s the content of the components/DAP/CMakeLists.txt file?
  • Does the project compile on a Linux system / virtual machine?

Yes, it is my custom component

No, I have ever seach it. I guess it is the path generated by cmake

set(COMPONENT_ADD_INCLUDEDIRS "config include $ENV{IDF_PATH}/components/esp_ringbuf/include/ $ENV{IDF_PATH}/components/")
set(COMPONENT_SRCS "./source/DAP.c ./source/DAP_vendor.c ./source/JTAG_DP.c ./source/SW_DP.c ./source/SWO.c  ./source/spi_op.c ./source/spi_switch.c ./source/dap_utility.c")

register_component()

It seems that $ENV{IDF_PATH} has something wrong, I find it set in one project cmake

get_property(__idf_env_set GLOBAL PROPERTY __IDF_ENV_SET)
if(NOT __idf_env_set)
    # Infer an IDF_PATH relative to the tools/cmake directory
    get_filename_component(_idf_path "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
    file(TO_CMAKE_PATH "${_idf_path}" _idf_path)

    # Get the path set in environment
    set(idf_path $ENV{IDF_PATH})
    file(TO_CMAKE_PATH "${idf_path}" idf_path)

    # Environment IDF_PATH should match the inferred IDF_PATH. If not, warn the user.
    if(idf_path)
        if(NOT idf_path STREQUAL _idf_path)
            message(WARNING "IDF_PATH environment variable is different from inferred IDF_PATH.
                            Check if your project's top-level CMakeLists.txt includes the right
                            CMake files. Environment IDF_PATH will be used for the build.")
        endif()
    else()
        message(WARNING "IDF_PATH environment variable not found. Setting IDF_PATH to '${_idf_path}'.")
        set(idf_path ${_idf_path})
        set(ENV{IDF_PATH} ${_idf_path})
    endif()

    # Include other CMake modules required
    set(CMAKE_MODULE_PATH
        "${idf_path}/tools/cmake"
        "${idf_path}/tools/cmake/third_party"
        ${CMAKE_MODULE_PATH})
    include(build)

    set(IDF_PATH ${idf_path})

    include(GetGitRevisionDescription)
    include(git_submodules)
    include(crosstool_version_check)
    include(kconfig)
    include(component)
    include(utilities)
    include(targets)
    include(ldgen)
    include(version)

    __build_init("${idf_path}")

    set_property(GLOBAL PROPERTY __IDF_ENV_SET 1)
endif()

ps:I didn’t write this project, I plan to contribute to it

No, Now I build it in Win10, but last successful compilation is in linux, I plan to relocate my environment
Thanks

It may be that $ENV{IDF_PATH} is expected to be a Linux-style path with /, but PlatformIO uses the real Windows path here.

Does that also fail when you use native ESP-IDF on Windows (not through PlatformIO)? If not, try opening an issue at Issues · platformio/platform-espressif32 · GitHub about this.

Yes, you are right, I changed it to absolute path and it compiled successfully, I will try later to see if the native esp-idf can compile

set(COMPONENT_ADD_INCLUDEDIRS "config include C:/Users/22380/.platformio/packages/framework-espidf/components/esp_ringbuf/include/ C:/Users/22380/.platformio/packages/framework-espidf/components/")
set(COMPONENT_SRCS "./source/DAP.c ./source/DAP_vendor.c ./source/JTAG_DP.c ./source/SW_DP.c ./source/SWO.c  ./source/spi_op.c ./source/spi_switch.c ./source/dap_utility.c")

register_component()

The native esp-idf can be compiled, but is it possible that the above cmake incorrectly set the IDF_PATH.
If so, I need to raise issuse to the project owner, if not, I will raise issuse to platformio
But my cmake level is limited I’m not sure

Setting IDF_PATH is something that happens in the PlatformIO build scripts

So if that’s wrong better open an issue in platform-espressif32.

I open an issue now