From 44117b623d72a6a3f312be42bbb865b1aaaa99b6 Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Thu, 6 Mar 2025 16:37:00 +0800 Subject: [PATCH] refactor(esp_rom): remove specific chip name when including rom header --- .../esp_rom/include/esp_rom_libc_stubs.h | 36 ------------------- components/esp_system/fpga_overrides_clk.c | 32 +++-------------- .../port/soc/esp32c61/CMakeLists.txt | 1 - components/hal/include/hal/sha_types.h | 28 ++------------- components/newlib/src/newlib_init.c | 2 +- .../newlib/src/picolibc/picolibc_init.c | 2 +- 6 files changed, 9 insertions(+), 92 deletions(-) delete mode 100644 components/esp_rom/include/esp_rom_libc_stubs.h diff --git a/components/esp_rom/include/esp_rom_libc_stubs.h b/components/esp_rom/include/esp_rom_libc_stubs.h deleted file mode 100644 index e873bc42a4..0000000000 --- a/components/esp_rom/include/esp_rom_libc_stubs.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#include "sdkconfig.h" - -//TODO: IDF-9526, refactor this - -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32C2 -#include "esp32c2/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32C6 -#include "esp32c6/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32C61 -#include "esp32c61/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32C5 -#include "esp32c5/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32H2 -#include "esp32h2/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32H21 -#include "esp32h21/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32P4 -#include "esp32p4/rom/libc_stubs.h" -#elif CONFIG_IDF_TARGET_ESP32H4 -#include "esp32h4/rom/libc_stubs.h" -#endif diff --git a/components/esp_system/fpga_overrides_clk.c b/components/esp_system/fpga_overrides_clk.c index bd50439549..732a5ba732 100644 --- a/components/esp_system/fpga_overrides_clk.c +++ b/components/esp_system/fpga_overrides_clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -10,34 +10,12 @@ #include "soc/system_reg.h" #endif // not CONFIG_IDF_TARGET_ESP32 #include "soc/rtc.h" -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/rom/rtc.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/rom/rtc.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/rom/rtc.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/rom/rtc.h" -#elif CONFIG_IDF_TARGET_ESP32C2 -#include "esp32c2/rom/rtc.h" -#elif CONFIG_IDF_TARGET_ESP32C6 -#include "esp32c6/rom/rtc.h" +#include "rom/rtc.h" + +#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32C61 #include "esp_private/esp_pmu.h" -#elif CONFIG_IDF_TARGET_ESP32C61 -#include "esp32c61/rom/rtc.h" -#include "esp_private/esp_pmu.h" -#elif CONFIG_IDF_TARGET_ESP32H2 -#include "esp32h2/rom/rtc.h" -#elif CONFIG_IDF_TARGET_ESP32H21 -#include "esp32h21/rom/rtc.h" -#include "esp_private/esp_pmu.h" -#elif CONFIG_IDF_TARGET_ESP32P4 -#include "esp32p4/rom/rtc.h" -#elif CONFIG_IDF_TARGET_ESP32C5 -#include "esp32c5/rom/rtc.h" -#elif CONFIG_IDF_TARGET_ESP32H4 -#include "esp32h4/rom/rtc.h" #endif + #include "esp_log.h" #include "esp_rom_sys.h" #include "esp_rom_uart.h" diff --git a/components/esp_system/port/soc/esp32c61/CMakeLists.txt b/components/esp_system/port/soc/esp32c61/CMakeLists.txt index 23b1cb7466..4764e7e4d4 100644 --- a/components/esp_system/port/soc/esp32c61/CMakeLists.txt +++ b/components/esp_system/port/soc/esp32c61/CMakeLists.txt @@ -1,4 +1,3 @@ -# TODO: IDF-9526, refactor this set(srcs "clk.c" "reset_reason.c" "system_internal.c" diff --git a/components/hal/include/hal/sha_types.h b/components/hal/include/hal/sha_types.h index 360cda5636..e6e2278791 100644 --- a/components/hal/include/hal/sha_types.h +++ b/components/hal/include/hal/sha_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,31 +9,7 @@ #include "sdkconfig.h" /* Use enum from rom for backwards compatibility */ -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32C2 -#include "esp32c2/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32C6 -#include "esp32c6/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32C61 -#include "esp32c61/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32C5 -#include "esp32c5/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32H2 -#include "esp32h2/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32H21 -#include "esp32h21/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32P4 -#include "esp32p4/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32H4 -#include "esp32h4/rom/sha.h" -#endif +#include "rom/sha.h" #ifdef __cplusplus extern "C" { diff --git a/components/newlib/src/newlib_init.c b/components/newlib/src/newlib_init.c index 112f1bc545..f4a250756f 100644 --- a/components/newlib/src/newlib_init.c +++ b/components/newlib/src/newlib_init.c @@ -20,7 +20,7 @@ #include "esp_attr.h" #include "soc/soc_caps.h" #include "esp_rom_caps.h" -#include "esp_rom_libc_stubs.h" +#include "rom/libc_stubs.h" extern int _printf_float(struct _reent *rptr, void *pdata, diff --git a/components/newlib/src/picolibc/picolibc_init.c b/components/newlib/src/picolibc/picolibc_init.c index a4c4f12d34..2e0fc30f14 100644 --- a/components/newlib/src/picolibc/picolibc_init.c +++ b/components/newlib/src/picolibc/picolibc_init.c @@ -23,7 +23,7 @@ #include "soc/soc_caps.h" #include "esp_rom_caps.h" #include "esp_heap_caps.h" -#include "esp_rom_libc_stubs.h" +#include "rom/libc_stubs.h" #if !(CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2) static void esp_cleanup_r(struct _reent *rptr)