mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-17 23:28:15 +00:00
Merge branch 'feature/universal_clang_toolchain_support' into 'master'
build: Adds support for universal Clang toolchain Closes LLVM-79 See merge request espressif/esp-idf!20090
This commit is contained in:
@@ -16,8 +16,13 @@ DEBUG_SHELL=${DEBUG_SHELL:-"0"}
|
||||
# Compiler flags to thoroughly check the IDF code in some CI jobs
|
||||
# (Depends on default options '-Wno-error=XXX' used in the IDF build system)
|
||||
|
||||
PEDANTIC_FLAGS="-Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
|
||||
export PEDANTIC_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes"
|
||||
if [ "$IDF_TOOLCHAIN" != "clang" ]; then
|
||||
PEDANTIC_FLAGS="-Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
|
||||
export PEDANTIC_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes"
|
||||
else
|
||||
export PEDANTIC_CFLAGS="-Werror"
|
||||
fi
|
||||
|
||||
export PEDANTIC_CXXFLAGS="${PEDANTIC_FLAGS}"
|
||||
|
||||
# ccache related settings.
|
||||
|
@@ -102,6 +102,7 @@ function(__build_set_default_build_specifications)
|
||||
"-Werror=all"
|
||||
"-Wno-error=unused-function"
|
||||
"-Wno-error=unused-variable"
|
||||
"-Wno-error=unused-but-set-variable"
|
||||
"-Wno-error=deprecated-declarations"
|
||||
"-Wextra"
|
||||
"-Wno-unused-parameter"
|
||||
|
@@ -6,26 +6,25 @@ set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
set(CMAKE_ASM_COMPILER clang)
|
||||
|
||||
set(CMAKE_AR xtensa-esp32-elf-ar)
|
||||
set(CMAKE_RANLIB xtensa-esp32-elf-gcc-ranlib)
|
||||
set(CMAKE_AR llvm-ar)
|
||||
set(CMAKE_RANLIB llvm-ranlib)
|
||||
set(CMAKE_OBJDUMP xtensa-esp32-elf-objdump)
|
||||
|
||||
# -freestanding is a hack to force Clang to use its own stdatomic.h,
|
||||
# without falling back to the (incompatible) GCC stdatomic.h
|
||||
# https://github.com/espressif/llvm-project/blob/d9341b81/clang/lib/Headers/stdatomic.h#L13-L18
|
||||
remove_duplicated_flags("--target=xtensa -mcpu=esp32 -ffreestanding ${CMAKE_C_FLAGS}"
|
||||
remove_duplicated_flags("--target=xtensa-esp-elf -mcpu=esp32 ${CMAKE_C_FLAGS}"
|
||||
UNIQ_CMAKE_C_FLAGS)
|
||||
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
|
||||
CACHE STRING "C Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=xtensa -mcpu=esp32 -ffreestanding ${CMAKE_CXX_FLAGS}"
|
||||
remove_duplicated_flags("--target=xtensa-esp-elf -mcpu=esp32 \
|
||||
${CMAKE_CXX_FLAGS}"
|
||||
UNIQ_CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
|
||||
CACHE STRING "C++ Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=xtensa -mcpu=esp32 ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS)
|
||||
remove_duplicated_flags("--target=xtensa-esp-elf -mcpu=esp32 ${CMAKE_ASM_FLAGS}"
|
||||
UNIQ_CMAKE_ASM_FLAGS)
|
||||
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"
|
||||
CACHE STRING "Assembler Base Flags"
|
||||
FORCE)
|
||||
|
32
tools/cmake/toolchain-clang-esp32c2.cmake
Normal file
32
tools/cmake/toolchain-clang-esp32c2.cmake
Normal file
@@ -0,0 +1,32 @@
|
||||
include($ENV{IDF_PATH}/tools/cmake/utilities.cmake)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
set(CMAKE_ASM_COMPILER clang)
|
||||
|
||||
set(CMAKE_AR llvm-ar)
|
||||
set(CMAKE_RANLIB llvm-ranlib)
|
||||
set(CMAKE_OBJDUMP riscv32-esp-elf-objdump)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 \
|
||||
${CMAKE_C_FLAGS}"
|
||||
UNIQ_CMAKE_C_FLAGS)
|
||||
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
|
||||
CACHE STRING "C Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 \
|
||||
${CMAKE_CXX_FLAGS}"
|
||||
UNIQ_CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
|
||||
CACHE STRING "C++ Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 \
|
||||
${CMAKE_ASM_FLAGS}"
|
||||
UNIQ_CMAKE_ASM_FLAGS)
|
||||
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"
|
||||
CACHE STRING "Assembler Base Flags"
|
||||
FORCE)
|
32
tools/cmake/toolchain-clang-esp32c3.cmake
Normal file
32
tools/cmake/toolchain-clang-esp32c3.cmake
Normal file
@@ -0,0 +1,32 @@
|
||||
include($ENV{IDF_PATH}/tools/cmake/utilities.cmake)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
set(CMAKE_ASM_COMPILER clang)
|
||||
|
||||
set(CMAKE_AR llvm-ar)
|
||||
set(CMAKE_RANLIB llvm-ranlib)
|
||||
set(CMAKE_OBJDUMP riscv32-esp-elf-objdump)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 \
|
||||
${CMAKE_C_FLAGS}"
|
||||
UNIQ_CMAKE_C_FLAGS)
|
||||
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
|
||||
CACHE STRING "C Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 \
|
||||
${CMAKE_CXX_FLAGS}"
|
||||
UNIQ_CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
|
||||
CACHE STRING "C++ Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 \
|
||||
${CMAKE_ASM_FLAGS}"
|
||||
UNIQ_CMAKE_ASM_FLAGS)
|
||||
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"
|
||||
CACHE STRING "Assembler Base Flags"
|
||||
FORCE)
|
32
tools/cmake/toolchain-clang-esp32c6.cmake
Normal file
32
tools/cmake/toolchain-clang-esp32c6.cmake
Normal file
@@ -0,0 +1,32 @@
|
||||
include($ENV{IDF_PATH}/tools/cmake/utilities.cmake)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
set(CMAKE_ASM_COMPILER clang)
|
||||
|
||||
set(CMAKE_AR llvm-ar)
|
||||
set(CMAKE_RANLIB llvm-ranlib)
|
||||
set(CMAKE_OBJDUMP riscv32-esp-elf-objdump)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac -mabi=ilp32 \
|
||||
${CMAKE_C_FLAGS}"
|
||||
UNIQ_CMAKE_C_FLAGS)
|
||||
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
|
||||
CACHE STRING "C Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac -mabi=ilp32 \
|
||||
${CMAKE_CXX_FLAGS}"
|
||||
UNIQ_CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
|
||||
CACHE STRING "C++ Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac -mabi=ilp32 \
|
||||
${CMAKE_ASM_FLAGS}"
|
||||
UNIQ_CMAKE_ASM_FLAGS)
|
||||
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"
|
||||
CACHE STRING "Assembler Base Flags"
|
||||
FORCE)
|
32
tools/cmake/toolchain-clang-esp32h2.cmake
Normal file
32
tools/cmake/toolchain-clang-esp32h2.cmake
Normal file
@@ -0,0 +1,32 @@
|
||||
include($ENV{IDF_PATH}/tools/cmake/utilities.cmake)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
set(CMAKE_ASM_COMPILER clang)
|
||||
|
||||
set(CMAKE_AR llvm-ar)
|
||||
set(CMAKE_RANLIB llvm-ranlib)
|
||||
set(CMAKE_OBJDUMP riscv32-esp-elf-objdump)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 \
|
||||
${CMAKE_C_FLAGS}"
|
||||
UNIQ_CMAKE_C_FLAGS)
|
||||
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
|
||||
CACHE STRING "C Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 \
|
||||
${CMAKE_CXX_FLAGS}"
|
||||
UNIQ_CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
|
||||
CACHE STRING "C++ Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc -mabi=ilp32 \
|
||||
${CMAKE_ASM_FLAGS}"
|
||||
UNIQ_CMAKE_ASM_FLAGS)
|
||||
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"
|
||||
CACHE STRING "Assembler Base Flags"
|
||||
FORCE)
|
@@ -6,26 +6,25 @@ set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
set(CMAKE_ASM_COMPILER clang)
|
||||
|
||||
set(CMAKE_AR xtensa-esp32-elf-ar)
|
||||
set(CMAKE_RANLIB xtensa-esp32-elf-gcc-ranlib)
|
||||
set(CMAKE_OBJDUMP xtensa-esp32-elf-objdump)
|
||||
|
||||
# -freestanding is a hack to force Clang to use its own stdatomic.h,
|
||||
# without falling back to the (incompatible) GCC stdatomic.h
|
||||
# https://github.com/espressif/llvm-project/blob/d9341b81/clang/lib/Headers/stdatomic.h#L13-L18
|
||||
remove_duplicated_flags("--target=xtensa -mcpu=esp32s2 -ffreestanding ${CMAKE_C_FLAGS}"
|
||||
set(CMAKE_AR llvm-ar)
|
||||
set(CMAKE_RANLIB llvm-ranlib)
|
||||
set(CMAKE_OBJDUMP xtensa-esp32s2-elf-objdump)
|
||||
|
||||
remove_duplicated_flags("--target=xtensa-esp-elf -mcpu=esp32s2 ${CMAKE_C_FLAGS}"
|
||||
UNIQ_CMAKE_C_FLAGS)
|
||||
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
|
||||
CACHE STRING "C Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=xtensa -mcpu=esp32s2 -ffreestanding ${CMAKE_CXX_FLAGS}"
|
||||
remove_duplicated_flags("--target=xtensa-esp-elf -mcpu=esp32s2 \
|
||||
${CMAKE_CXX_FLAGS}"
|
||||
UNIQ_CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
|
||||
CACHE STRING "C++ Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=xtensa -mcpu=esp32s2 ${CMAKE_ASM_FLAGS}"
|
||||
remove_duplicated_flags("--target=xtensa-esp-elf -mcpu=esp32s2 ${CMAKE_ASM_FLAGS}"
|
||||
UNIQ_CMAKE_ASM_FLAGS)
|
||||
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"
|
||||
CACHE STRING "Assembler Base Flags"
|
||||
|
@@ -6,26 +6,24 @@ set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
set(CMAKE_ASM_COMPILER clang)
|
||||
|
||||
set(CMAKE_AR xtensa-esp32-elf-ar)
|
||||
set(CMAKE_RANLIB xtensa-esp32-elf-gcc-ranlib)
|
||||
set(CMAKE_OBJDUMP xtensa-esp32-elf-objdump)
|
||||
set(CMAKE_AR llvm-ar)
|
||||
set(CMAKE_RANLIB llvm-ranlib)
|
||||
set(CMAKE_OBJDUMP xtensa-esp32s3-elf-objdump)
|
||||
|
||||
# -freestanding is a hack to force Clang to use its own stdatomic.h,
|
||||
# without falling back to the (incompatible) GCC stdatomic.h
|
||||
# https://github.com/espressif/llvm-project/blob/d9341b81/clang/lib/Headers/stdatomic.h#L13-L18
|
||||
remove_duplicated_flags("--target=xtensa -mcpu=esp32s3 -ffreestanding ${CMAKE_C_FLAGS}"
|
||||
remove_duplicated_flags("--target=xtensa-esp-elf -mcpu=esp32s3 ${CMAKE_C_FLAGS}"
|
||||
UNIQ_CMAKE_C_FLAGS)
|
||||
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
|
||||
CACHE STRING "C Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=xtensa -mcpu=esp32s3 -ffreestanding ${CMAKE_CXX_FLAGS}"
|
||||
remove_duplicated_flags("--target=xtensa-esp-elf -mcpu=esp32s3 \
|
||||
${CMAKE_CXX_FLAGS}"
|
||||
UNIQ_CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
|
||||
CACHE STRING "C++ Compiler Base Flags"
|
||||
FORCE)
|
||||
|
||||
remove_duplicated_flags("--target=xtensa -mcpu=esp32s3 ${CMAKE_ASM_FLAGS}"
|
||||
remove_duplicated_flags("--target=xtensa-esp-elf -mcpu=esp32s3 ${CMAKE_ASM_FLAGS}"
|
||||
UNIQ_CMAKE_ASM_FLAGS)
|
||||
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"
|
||||
CACHE STRING "Assembler Base Flags"
|
||||
|
@@ -95,6 +95,12 @@ tools/test_apps/system/cxx_no_except:
|
||||
temporary: true
|
||||
reason: the other targets are not tested yet
|
||||
|
||||
tools/test_apps/system/cxx_pthread_bluetooth:
|
||||
enable:
|
||||
- if: IDF_TARGET in ["esp32", "esp32c2", "esp32c3", "esp32s2", "esp32s3"]
|
||||
temporary: true
|
||||
reason: the other targets are not supported yet
|
||||
|
||||
tools/test_apps/system/eh_frame:
|
||||
enable:
|
||||
- if: IDF_TARGET in ["esp32c2", "esp32c3", "esp32h4"]
|
||||
|
@@ -0,0 +1,6 @@
|
||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||
# in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(cpp_pthread)
|
51
tools/test_apps/system/cxx_pthread_bluetooth/README.md
Normal file
51
tools/test_apps/system/cxx_pthread_bluetooth/README.md
Normal file
@@ -0,0 +1,51 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||
|
||||
# C++ pthread Example
|
||||
|
||||
(See the README.md file in the upper level 'examples' directory for more information about examples.)
|
||||
|
||||
Support for the [C++ threads](http://www.cplusplus.com/reference/thread/thread/) in ESP-IDF is implemented on top of the [ESP-pthread](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/esp_pthread.html#overview) component. Thus, C++ threads created using the standard thread class constructor will automatically inherit the current ESP-pthread configuration. This example demonstrates how to leverage the thread configuration functions provided by ESP-pthread (e.g., `esp_pthread_get_default_config()` and `esp_pthread_set_cfg()`) to modify the stack sizes, priorities, names, and core affinities of the C++ threads.
|
||||
|
||||
**Note: Due to the use of the C++ threads, this example is written in C++ instead of C.**
|
||||
|
||||
## How to use example
|
||||
|
||||
### Hardware Required
|
||||
|
||||
This example should be able to run on any commonly available ESP32 development board.
|
||||
|
||||
### Configure the project
|
||||
|
||||
```
|
||||
idf.py menuconfig
|
||||
```
|
||||
|
||||
* The default ESP-pthread configuration may also be modified under `Component config > PThreads`
|
||||
|
||||
### Build and Flash
|
||||
|
||||
Build the project and flash it to the board, then run monitor tool to view serial output:
|
||||
|
||||
```
|
||||
idf.py -p PORT flash monitor
|
||||
```
|
||||
|
||||
(Replace PORT with the name of the serial port to use.)
|
||||
|
||||
(To exit the serial monitor, type ``Ctrl-]``.)
|
||||
|
||||
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
|
||||
|
||||
## Example Output
|
||||
|
||||
The following log output should appear when the example runs (note that the bootloader log has been omitted).
|
||||
|
||||
```
|
||||
...
|
||||
I (380) Thread 1: Core id: 0, prio: 5, minimum free stack: 2068 bytes.
|
||||
I (0) pthread: This thread (with the default name) may run on any core.Core id: 1, prio: 5, minimum free stack: 2056 bytes.
|
||||
I (390) Thread 1: This is the INHERITING thread with the same parameters as our parent, including name. Core id: 0, prio: 5, minimum free stack: 2092 bytes.
|
||||
I (410) Thread 2: Core id: 1, prio: 5, minimum free stack: 2088 bytes.
|
||||
I (410) main: core id: 0, prio: 1, minimum free stack: 2928 bytes.
|
||||
```
|
@@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "cpp_pthread.cpp"
|
||||
INCLUDE_DIRS ".")
|
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <esp_pthread.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
const auto sleep_time = seconds
|
||||
{
|
||||
5
|
||||
};
|
||||
|
||||
void print_thread_info(const char *extra = nullptr)
|
||||
{
|
||||
std::stringstream ss;
|
||||
if (extra) {
|
||||
ss << extra;
|
||||
}
|
||||
ss << "Core id: " << xPortGetCoreID()
|
||||
<< ", prio: " << uxTaskPriorityGet(nullptr)
|
||||
<< ", minimum free stack: " << uxTaskGetStackHighWaterMark(nullptr) << " bytes.";
|
||||
ESP_LOGI(pcTaskGetName(nullptr), "%s", ss.str().c_str());
|
||||
}
|
||||
|
||||
void thread_func_inherited()
|
||||
{
|
||||
while (true) {
|
||||
print_thread_info("This is the INHERITING thread with the same parameters as our parent, including name. ");
|
||||
std::this_thread::sleep_for(sleep_time);
|
||||
}
|
||||
}
|
||||
|
||||
void spawn_another_thread()
|
||||
{
|
||||
// Create a new thread, it will inherit our configuration
|
||||
std::thread inherits(thread_func_inherited);
|
||||
|
||||
while (true) {
|
||||
print_thread_info();
|
||||
std::this_thread::sleep_for(sleep_time);
|
||||
}
|
||||
}
|
||||
|
||||
void thread_func_any_core()
|
||||
{
|
||||
while (true) {
|
||||
print_thread_info("This thread (with the default name) may run on any core.");
|
||||
std::this_thread::sleep_for(sleep_time);
|
||||
}
|
||||
}
|
||||
|
||||
void thread_func()
|
||||
{
|
||||
while (true) {
|
||||
print_thread_info();
|
||||
std::this_thread::sleep_for(sleep_time);
|
||||
}
|
||||
}
|
||||
|
||||
esp_pthread_cfg_t create_config(const char *name, int core_id, int stack, int prio)
|
||||
{
|
||||
auto cfg = esp_pthread_get_default_config();
|
||||
cfg.thread_name = name;
|
||||
cfg.pin_to_core = core_id;
|
||||
cfg.stack_size = stack;
|
||||
cfg.prio = prio;
|
||||
return cfg;
|
||||
}
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
// Create a thread using deafult values that can run on any core
|
||||
auto cfg = esp_pthread_get_default_config();
|
||||
esp_pthread_set_cfg(&cfg);
|
||||
std::thread any_core(thread_func_any_core);
|
||||
|
||||
// Create a thread on core 0 that spawns another thread, they will both have the same name etc.
|
||||
cfg = create_config("Thread 1", 0, 3 * 1024, 5);
|
||||
cfg.inherit_cfg = true;
|
||||
esp_pthread_set_cfg(&cfg);
|
||||
std::thread thread_1(spawn_another_thread);
|
||||
|
||||
// Create a thread on core 1.
|
||||
cfg = create_config("Thread 2", 1, 3 * 1024, 5);
|
||||
esp_pthread_set_cfg(&cfg);
|
||||
std::thread thread_2(thread_func);
|
||||
|
||||
// Let the main task do something too
|
||||
while (true) {
|
||||
std::stringstream ss;
|
||||
ss << "core id: " << xPortGetCoreID()
|
||||
<< ", prio: " << uxTaskPriorityGet(nullptr)
|
||||
<< ", minimum free stack: " << uxTaskGetStackHighWaterMark(nullptr) << " bytes.";
|
||||
ESP_LOGI(pcTaskGetName(nullptr), "%s", ss.str().c_str());
|
||||
std::this_thread::sleep_for(sleep_time);
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0x9000
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=n
|
@@ -371,10 +371,10 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "LLVM for Xtensa (ESP32, ESP32-S2) based on clang",
|
||||
"description": "Toolchain for all Espressif chips based on clang",
|
||||
"export_paths": [
|
||||
[
|
||||
"xtensa-esp32-elf-clang",
|
||||
"esp-clang",
|
||||
"bin"
|
||||
]
|
||||
],
|
||||
@@ -382,10 +382,15 @@
|
||||
"info_url": "https://github.com/espressif/llvm-project",
|
||||
"install": "on_request",
|
||||
"license": "Apache-2.0",
|
||||
"name": "xtensa-clang",
|
||||
"name": "esp-clang",
|
||||
"supported_targets": [
|
||||
"esp32",
|
||||
"esp32s2"
|
||||
"esp32s2",
|
||||
"esp32s3",
|
||||
"esp32c3",
|
||||
"esp32h4",
|
||||
"esp32c2",
|
||||
"esp32c6"
|
||||
],
|
||||
"version_cmd": [
|
||||
"clang",
|
||||
@@ -396,26 +401,36 @@
|
||||
"versions": [
|
||||
{
|
||||
"linux-amd64": {
|
||||
"sha256": "b0148627912dacf4a4cab4596ba9467cb8dd771522ca27b9526bc57b88ff366f",
|
||||
"size": 125101504,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-14.0.0-20220415/xtensa-esp32-elf-llvm14_0_0-esp-14.0.0-20220415-linux-amd64.tar.xz"
|
||||
"sha256": "30379631cc1cdf6526940494964371a90aa7a940c4ff7333d9ffab35e6c0f978",
|
||||
"size": 198800680,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-15.0.0-20221014/llvm-esp-15.0.0-20221014-linux-amd64.tar.xz"
|
||||
},
|
||||
"linux-arm64": {
|
||||
"sha256": "c40c1c1d7ee94fc5967641aaffcbca263018b2df4f1d4249636c1adff0e35542",
|
||||
"size": 204969304,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-15.0.0-20221014/llvm-esp-15.0.0-20221014-linux-arm64.tar.xz"
|
||||
},
|
||||
"linux-armhf": {
|
||||
"sha256": "3931c81cdaa44a47739663b647e68778d3ed9532d67096618d6901ae3adfb3c1",
|
||||
"size": 196967420,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-15.0.0-20221014/llvm-esp-15.0.0-20221014-linux-armhf.tar.xz"
|
||||
},
|
||||
"macos": {
|
||||
"sha256": "1a78c598825ef168c0c5668aff7848825a7b9d014bffd1f2f2484ceea9df3841",
|
||||
"size": 107100188,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-14.0.0-20220415/xtensa-esp32-elf-llvm14_0_0-esp-14.0.0-20220415-macos.tar.xz"
|
||||
"sha256": "e7066b1dd74cbd42c3e5d140013b0b357c190b5361a1c2fd92e29efa34305cff",
|
||||
"size": 164130904,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-15.0.0-20221014/llvm-esp-15.0.0-20221014-macos.tar.xz"
|
||||
},
|
||||
"macos-arm64": {
|
||||
"sha256": "1a78c598825ef168c0c5668aff7848825a7b9d014bffd1f2f2484ceea9df3841",
|
||||
"size": 107100188,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-14.0.0-20220415/xtensa-esp32-elf-llvm14_0_0-esp-14.0.0-20220415-macos.tar.xz"
|
||||
"sha256": "02b8af2bd934d4352da3743fc86c00d9258309d307c5af7f2be0cf85551535d3",
|
||||
"size": 154036240,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-15.0.0-20221014/llvm-esp-15.0.0-20221014-macos-arm64.tar.xz"
|
||||
},
|
||||
"name": "14.0.0-38679f0333",
|
||||
"name": "15.0.0-32e64117af",
|
||||
"status": "recommended",
|
||||
"win64": {
|
||||
"sha256": "793e7bd9c40fcb9a4fababaaccf3e4c5b8d9554d406af1b1fbee51806bf8c5dd",
|
||||
"size": 174294128,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-14.0.0-20220415/xtensa-esp32-elf-llvm14_0_0-esp-14.0.0-20220415-win64.zip"
|
||||
"sha256": "eba58ea6f9018c43748e938986f32c039a6dc49a384d994e9e515502b04c83f0",
|
||||
"size": 230488412,
|
||||
"url": "https://github.com/espressif/llvm-project/releases/download/esp-15.0.0-20221014/llvm-esp-15.0.0-20221014-win64.tar.xz"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Reference in New Issue
Block a user