Merge branch 'feature/linux_esp_time_new' into 'master'

feat(esp_timer): Adds support Linux target

Closes IDF-5723

See merge request espressif/esp-idf!49358
This commit is contained in:
Konstantin Kondrashov
2026-06-12 09:05:22 +03:00
32 changed files with 965 additions and 159 deletions
@@ -1,3 +1,4 @@
idf_build_get_property(target IDF_TARGET)
idf_build_get_property(arch IDF_TARGET_ARCH)
set(srcs "memory_checks.c"
@@ -13,12 +14,18 @@ if(CONFIG_IDF_TARGET_ESP32)
list(APPEND srcs "ref_clock_impl_rmt_pcnt.c")
elseif(CONFIG_SOC_GPTIMER_SUPPORTED)
list(APPEND srcs "ref_clock_impl_timergroup.c")
elseif(CONFIG_IDF_TARGET_LINUX)
list(APPEND srcs "ref_clock_impl_linux.c")
endif()
if("${arch}" STREQUAL "xtensa")
set(priv_requires perfmon esp_driver_pcnt esp_driver_gptimer esp_driver_rmt esp_netif)
if(${target} STREQUAL "linux")
set(priv_requires "")
else()
set(priv_requires esp_driver_pcnt esp_driver_gptimer esp_driver_rmt esp_netif)
if("${arch}" STREQUAL "xtensa")
set(priv_requires perfmon esp_driver_pcnt esp_driver_gptimer esp_driver_rmt esp_netif)
else()
set(priv_requires esp_driver_pcnt esp_driver_gptimer esp_driver_rmt esp_netif)
endif()
endif()
idf_component_register(SRCS ${srcs}
@@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <assert.h>
#include <time.h>
void ref_clock_init(void)
{
}
void ref_clock_deinit(void)
{
}
uint64_t ref_clock_get(void)
{
struct timespec current_time;
assert(clock_gettime(CLOCK_MONOTONIC, &current_time) == 0);
uint64_t ref_ticks = current_time.tv_sec * 1000000;
ref_ticks += (current_time.tv_nsec / 1000);
return ref_ticks;
}
@@ -12,7 +12,9 @@
#include "unity.h"
#include "unity_test_runner.h"
#include "test_utils.h"
#ifndef CONFIG_IDF_TARGET_LINUX
#include "esp_newlib.h"
#endif // !CONFIG_IDF_TARGET_LINUX
#include "memory_checks.h"
#ifdef CONFIG_HEAP_TRACING
@@ -99,8 +101,10 @@ void tearDown(void)
/* some FreeRTOS stuff is cleaned up by idle task */
vTaskDelay(5);
#ifndef CONFIG_IDF_TARGET_LINUX
/* clean up some of the newlib's lazy allocations */
esp_reent_cleanup();
#endif // !CONFIG_IDF_TARGET_LINUX
/* We want the teardown to have this file in the printout if TEST_ASSERT fails */
const char *real_testfile = Unity.TestFile;
@@ -9,8 +9,10 @@
#include "test_utils.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#ifndef CONFIG_IDF_TARGET_LINUX
#include "esp_netif.h"
#include "lwip/sockets.h"
#endif // !CONFIG_IDF_TARGET_LINUX
#include "sdkconfig.h"
#include "memory_checks.h"
@@ -23,6 +25,7 @@ const esp_partition_t *get_test_data_partition(void)
return result;
}
#ifndef CONFIG_IDF_TARGET_LINUX
void test_case_uses_tcpip(void)
{
// Can be called more than once, does nothing on subsequent calls
@@ -50,6 +53,7 @@ void test_case_uses_tcpip(void)
test_utils_set_leak_level(0, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_GENERAL);
test_utils_set_leak_level(CONFIG_UNITY_CRITICAL_LEAK_LEVEL_LWIP, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_LWIP);
}
#endif // !CONFIG_IDF_TARGET_LINUX
// wait user to send "Enter" key or input parameter
static void wait_user_control(char* parameter_buf, uint8_t buf_len)