From fcedf442cec8e20323961e411fbfe6b99e69015b Mon Sep 17 00:00:00 2001 From: morris Date: Thu, 21 Mar 2019 12:21:01 +0800 Subject: [PATCH] move common source files from esp32 to esp_common --- components/esp32/CMakeLists.txt | 10 ++-------- components/esp32/brownout.c | 2 +- components/esp32/component.mk | 1 - components/esp32/cpu_start.c | 2 +- components/esp32/esp_timer_esp32.c | 10 +++++----- components/esp32/freertos_hooks.c | 2 +- components/esp32/panic.c | 2 +- components/esp32/pm_esp32.c | 6 +++--- components/esp32/pm_trace.c | 2 +- components/esp32/reset_reason.c | 2 +- components/esp32/sleep_modes.c | 2 +- components/esp32/system_api.c | 2 +- components/esp32/task_wdt.c | 2 +- components/esp32/test/CMakeLists.txt | 6 +++--- components/esp32/test/test_esp_timer.c | 2 +- components/esp_common/CMakeLists.txt | 19 +++++++++++++++++++ components/esp_common/component.mk | 9 +++++++++ .../include/esp_private}/esp_timer_impl.h | 2 +- .../include/esp_private}/pm_impl.h | 2 +- .../include/esp_private}/pm_trace.h | 0 .../include/esp_private/system_internal.h} | 0 .../{esp32 => esp_common/src}/dbg_stubs.c | 0 .../src}/esp_err_to_name.c | 0 .../{esp32 => esp_common/src}/esp_timer.c | 2 +- .../src}/ets_timer_legacy.c | 2 +- .../{esp32 => esp_common/src}/pm_locks.c | 2 +- .../{esp32 => esp_common/src}/stack_check.c | 0 27 files changed, 56 insertions(+), 35 deletions(-) create mode 100644 components/esp_common/CMakeLists.txt create mode 100644 components/esp_common/component.mk rename components/{esp32 => esp_common/include/esp_private}/esp_timer_impl.h (98%) rename components/{esp32 => esp_common/include/esp_private}/pm_impl.h (99%) rename components/{esp32 => esp_common/include/esp_private}/pm_trace.h (100%) rename components/{esp32/esp_system_internal.h => esp_common/include/esp_private/system_internal.h} (100%) rename components/{esp32 => esp_common/src}/dbg_stubs.c (100%) rename components/{esp32 => esp_common/src}/esp_err_to_name.c (100%) rename components/{esp32 => esp_common/src}/esp_timer.c (99%) rename components/{esp32 => esp_common/src}/ets_timer_legacy.c (99%) rename components/{esp32 => esp_common/src}/pm_locks.c (99%) rename components/{esp32 => esp_common/src}/stack_check.c (100%) diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index 87107125df..18ce3aa18a 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -16,15 +16,11 @@ else() "coexist.c" "cpu_start.c" "crosscore_int.c" - "dbg_stubs.c" "dport_access.c" "dport_panic_highint_hdl.S" "esp_adapter.c" - "esp_err_to_name.c" - "esp_timer.c" "esp_timer_esp32.c" "esp_himem.c" - "ets_timer_legacy.c" "fast_crypto_ops.c" "freertos_hooks.c" "gdbstub.c" @@ -36,14 +32,12 @@ else() "panic.c" "phy_init.c" "pm_esp32.c" - "pm_locks.c" "pm_trace.c" "reset_reason.c" "restore.c" "sleep_modes.c" "spiram.c" "spiram_psram.c" - "stack_check.c" "system_api.c" "task_wdt.c" "wifi_init.c" @@ -56,7 +50,7 @@ else() # app_update is added here because cpu_start.c uses esp_ota_get_app_description() function. set(COMPONENT_PRIV_REQUIRES app_trace app_update bootloader_support log mbedtls nvs_flash - pthread smartconfig_ack spi_flash vfs wpa_supplicant xtensa-debug-module espcoredump) + pthread smartconfig_ack spi_flash vfs wpa_supplicant xtensa-debug-module espcoredump esp_common) set(COMPONENT_ADD_LDFRAGMENTS linker.lf ld/esp32_fragments.lf) @@ -134,7 +128,7 @@ else() # disable stack protection in files which are involved in initialization of that feature set_source_files_properties( - stack_check.c cpu_start.c + cpu_start.c PROPERTIES COMPILE_FLAGS -fno-stack-protector) endif() diff --git a/components/esp32/brownout.c b/components/esp32/brownout.c index fe94cdbf45..439fd75243 100644 --- a/components/esp32/brownout.c +++ b/components/esp32/brownout.c @@ -21,7 +21,7 @@ #include "soc/cpu.h" #include "soc/rtc_cntl_reg.h" #include "esp32/rom/ets_sys.h" -#include "esp_system_internal.h" +#include "esp_private/system_internal.h" #include "driver/rtc_cntl.h" #include "freertos/FreeRTOS.h" diff --git a/components/esp32/component.mk b/components/esp32/component.mk index a90c5e5b4d..6a656736f6 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -53,5 +53,4 @@ esp32_out.ld: $(COMPONENT_PATH)/ld/esp32.ld ../include/sdkconfig.h COMPONENT_EXTRA_CLEAN := esp32_out.ld $(COMPONENT_BUILD_DIR)/esp32.project.ld # disable stack protection in files which are involved in initialization of that feature -stack_check.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS)) cpu_start.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS)) diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index adb44f576e..b9411abcb1 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -69,7 +69,7 @@ #include "esp_clk_internal.h" #include "esp_timer.h" #include "esp_pm.h" -#include "pm_impl.h" +#include "esp_private/pm_impl.h" #include "trax.h" #include "esp_ota_ops.h" diff --git a/components/esp32/esp_timer_esp32.c b/components/esp32/esp_timer_esp32.c index 70b840370f..cac4b819be 100644 --- a/components/esp32/esp_timer_esp32.c +++ b/components/esp32/esp_timer_esp32.c @@ -20,7 +20,7 @@ #include "esp_intr_alloc.h" #include "esp_log.h" #include "esp32/clk.h" -#include "esp_timer_impl.h" +#include "esp_private/esp_timer_impl.h" #include "soc/frc_timer_reg.h" #include "soc/rtc.h" #include "freertos/FreeRTOS.h" @@ -78,7 +78,7 @@ /* ALARM_OVERFLOW_VAL is used as timer alarm value when there are not timers * enabled which need to fire within the next timer overflow period. This alarm * is used to perform timekeeping (i.e. to track timer overflows). - * Due to the 0xffffffff cannot recognize the real overflow or the scenario that + * Due to the 0xffffffff cannot recognize the real overflow or the scenario that * ISR happens follow set_alarm, so change the ALARM_OVERFLOW_VAL to resolve this problem. * Set it to 0xefffffffUL. The remain 0x10000000UL(about 3 second) is enough to handle ISR. */ @@ -129,9 +129,9 @@ static bool s_mask_overflow; //The timer_overflow_happened read alarm register to tell if overflow happened. //However, there is a monent that overflow happens, and before ISR function called -//alarm register is set to another value, then you call timer_overflow_happened, +//alarm register is set to another value, then you call timer_overflow_happened, //it will return false. -//So we store the overflow value when new alarm is to be set. +//So we store the overflow value when new alarm is to be set. static bool s_overflow_happened; #ifdef CONFIG_PM_DFS_USE_RTC_TIMER_REF @@ -157,7 +157,7 @@ static inline bool IRAM_ATTR timer_overflow_happened() } return ((REG_READ(FRC_TIMER_CTRL_REG(1)) & FRC_TIMER_INT_STATUS) != 0 && - ((REG_READ(FRC_TIMER_ALARM_REG(1)) == ALARM_OVERFLOW_VAL && TIMER_IS_AFTER_OVERFLOW(REG_READ(FRC_TIMER_COUNT_REG(1))) && !s_mask_overflow) || + ((REG_READ(FRC_TIMER_ALARM_REG(1)) == ALARM_OVERFLOW_VAL && TIMER_IS_AFTER_OVERFLOW(REG_READ(FRC_TIMER_COUNT_REG(1))) && !s_mask_overflow) || (!TIMER_IS_AFTER_OVERFLOW(REG_READ(FRC_TIMER_ALARM_REG(1))) && TIMER_IS_AFTER_OVERFLOW(REG_READ(FRC_TIMER_COUNT_REG(1)))))); } diff --git a/components/esp32/freertos_hooks.c b/components/esp32/freertos_hooks.c index 4e2d713386..d60411dc73 100644 --- a/components/esp32/freertos_hooks.c +++ b/components/esp32/freertos_hooks.c @@ -22,7 +22,7 @@ #include "sdkconfig.h" #include "esp_pm.h" -#include "pm_impl.h" +#include "esp_private/pm_impl.h" //We use just a static array here because it's not expected many components will need //an idle or tick hook. diff --git a/components/esp32/panic.c b/components/esp32/panic.c index ff7288df96..71996d1d8a 100644 --- a/components/esp32/panic.c +++ b/components/esp32/panic.c @@ -40,7 +40,7 @@ #include "esp_spi_flash.h" #include "esp32/cache_err_int.h" #include "esp_app_trace.h" -#include "esp_system_internal.h" +#include "esp_private/system_internal.h" #include "sdkconfig.h" #include "esp_ota_ops.h" #if CONFIG_SYSVIEW_ENABLE diff --git a/components/esp32/pm_esp32.c b/components/esp32/pm_esp32.c index 78ac02232c..f84ca843f5 100644 --- a/components/esp32/pm_esp32.c +++ b/components/esp32/pm_esp32.c @@ -31,9 +31,9 @@ #include "freertos/xtensa_timer.h" #include "xtensa/core-macros.h" -#include "pm_impl.h" -#include "pm_trace.h" -#include "esp_timer_impl.h" +#include "esp_private/pm_impl.h" +#include "esp_private/pm_trace.h" +#include "esp_private/esp_timer_impl.h" #include "esp32/pm.h" /* CCOMPARE update timeout, in CPU cycles. Any value above ~600 cycles will work diff --git a/components/esp32/pm_trace.c b/components/esp32/pm_trace.c index eddaec3843..b4cebf85fe 100644 --- a/components/esp32/pm_trace.c +++ b/components/esp32/pm_trace.c @@ -13,7 +13,7 @@ // limitations under the License. -#include "pm_trace.h" +#include "esp_private/pm_trace.h" #include "driver/gpio.h" #include "soc/gpio_reg.h" diff --git a/components/esp32/reset_reason.c b/components/esp32/reset_reason.c index 8870fc2a7f..f9cc0062f7 100644 --- a/components/esp32/reset_reason.c +++ b/components/esp32/reset_reason.c @@ -13,8 +13,8 @@ // limitations under the License. #include "esp_system.h" -#include "esp_system_internal.h" #include "esp32/rom/rtc.h" +#include "esp_private/system_internal.h" #include "soc/rtc_cntl_reg.h" static void esp_reset_reason_clear_hint(); diff --git a/components/esp32/sleep_modes.c b/components/esp32/sleep_modes.c index 8ee6f67fec..727b432588 100644 --- a/components/esp32/sleep_modes.c +++ b/components/esp32/sleep_modes.c @@ -17,7 +17,7 @@ #include #include "esp_attr.h" #include "esp_sleep.h" -#include "esp_timer_impl.h" +#include "esp_private/esp_timer_impl.h" #include "esp_log.h" #include "esp32/clk.h" #include "esp_newlib.h" diff --git a/components/esp32/system_api.c b/components/esp32/system_api.c index aaafb3edf4..cf6f74b41f 100644 --- a/components/esp32/system_api.c +++ b/components/esp32/system_api.c @@ -36,7 +36,7 @@ #include "freertos/task.h" #include "freertos/xtensa_api.h" #include "esp_heap_caps.h" -#include "esp_system_internal.h" +#include "esp_private/system_internal.h" #include "esp_efuse.h" #include "esp_efuse_table.h" diff --git a/components/esp32/task_wdt.c b/components/esp32/task_wdt.c index 0c302082a4..ce4d7a6ad6 100644 --- a/components/esp32/task_wdt.c +++ b/components/esp32/task_wdt.c @@ -35,7 +35,7 @@ #include "driver/timer.h" #include "driver/periph_ctrl.h" #include "esp_task_wdt.h" -#include "esp_system_internal.h" +#include "esp_private/system_internal.h" static const char *TAG = "task_wdt"; diff --git a/components/esp32/test/CMakeLists.txt b/components/esp32/test/CMakeLists.txt index b99e2888b6..bae2493d32 100644 --- a/components/esp32/test/CMakeLists.txt +++ b/components/esp32/test/CMakeLists.txt @@ -1,7 +1,7 @@ set(COMPONENT_SRCDIRS ".") set(COMPONENT_ADD_INCLUDEDIRS ". ${CMAKE_CURRENT_BINARY_DIR}") -set(COMPONENT_REQUIRES unity test_utils nvs_flash ulp) +set(COMPONENT_REQUIRES unity test_utils nvs_flash ulp esp_common) register_component() @@ -21,7 +21,7 @@ execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_cry COMMAND cut -c 1-7 OUTPUT_VARIABLE WIFI_CRYPTO_MD5 OUTPUT_STRIP_TRAILING_WHITESPACE) - + # Calculate MD5 value of header file esp_coexist_adapter.h execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_coexist_adapter.h COMMAND cut -c 1-7 @@ -34,4 +34,4 @@ add_definitions(-DCOEX_ADAPTER_MD5=\"${COEX_ADAPTER_MD5}\") add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h") -add_dependencies(${COMPONENT_TARGET} esp32_test_logo) \ No newline at end of file +add_dependencies(${COMPONENT_TARGET} esp32_test_logo) diff --git a/components/esp32/test/test_esp_timer.c b/components/esp32/test/test_esp_timer.c index 510bed4618..b46cca5608 100644 --- a/components/esp32/test/test_esp_timer.c +++ b/components/esp32/test/test_esp_timer.c @@ -10,7 +10,7 @@ #include "freertos/task.h" #include "freertos/semphr.h" #include "test_utils.h" -#include "../esp_timer_impl.h" +#include "esp_private/esp_timer_impl.h" #ifdef CONFIG_ESP_TIMER_PROFILING #define WITH_PROFILING 1 diff --git a/components/esp_common/CMakeLists.txt b/components/esp_common/CMakeLists.txt new file mode 100644 index 0000000000..1d49ff32e7 --- /dev/null +++ b/components/esp_common/CMakeLists.txt @@ -0,0 +1,19 @@ +set(COMPONENT_SRCS + "src/dbg_stubs.c" + "src/esp_err_to_name.c" + "src/esp_timer.c" + "src/ets_timer_legacy.c" + "src/pm_locks.c" + "src/stack_check.c") +set(COMPONENT_ADD_INCLUDEDIRS "include") +set(COMPONENT_PRIV_INCLUDEDIRS) +set(COMPONENT_REQUIRES) +# dbg_stubs.c needs eri.h from xtensa-debug-module +set(COMPONENT_PRIV_REQUIRES "xtensa-debug-module") +register_component() + +set_source_files_properties( + "src/stack_check.c" + PROPERTIES COMPILE_FLAGS + -fno-stack-protector) + diff --git a/components/esp_common/component.mk b/components/esp_common/component.mk new file mode 100644 index 0000000000..d01f1253f6 --- /dev/null +++ b/components/esp_common/component.mk @@ -0,0 +1,9 @@ +# +# Component Makefile +# + +COMPONENT_ADD_INCLUDEDIRS := include +COMPONENT_SRCDIRS := src + +# disable stack protection in files which are involved in initialization of that feature +stack_check.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS)) diff --git a/components/esp32/esp_timer_impl.h b/components/esp_common/include/esp_private/esp_timer_impl.h similarity index 98% rename from components/esp32/esp_timer_impl.h rename to components/esp_common/include/esp_private/esp_timer_impl.h index 5871428a5f..adc98bc42f 100644 --- a/components/esp32/esp_timer_impl.h +++ b/components/esp_common/include/esp_private/esp_timer_impl.h @@ -15,7 +15,7 @@ #pragma once /** - * @file esp_timer_impl.h + * @file esp_private/esp_timer_impl.h * * @brief Interface between common and platform-specific parts of esp_timer. * diff --git a/components/esp32/pm_impl.h b/components/esp_common/include/esp_private/pm_impl.h similarity index 99% rename from components/esp32/pm_impl.h rename to components/esp_common/include/esp_private/pm_impl.h index ddb90c02a8..134e874e5e 100644 --- a/components/esp32/pm_impl.h +++ b/components/esp_common/include/esp_private/pm_impl.h @@ -15,7 +15,7 @@ #pragma once /** - * @file pm_impl.h + * @file esp_private/pm_impl.h * * This header file defines interface between PM lock functions (pm_locks.c) * and the chip-specific power management (DFS/light sleep) implementation. diff --git a/components/esp32/pm_trace.h b/components/esp_common/include/esp_private/pm_trace.h similarity index 100% rename from components/esp32/pm_trace.h rename to components/esp_common/include/esp_private/pm_trace.h diff --git a/components/esp32/esp_system_internal.h b/components/esp_common/include/esp_private/system_internal.h similarity index 100% rename from components/esp32/esp_system_internal.h rename to components/esp_common/include/esp_private/system_internal.h diff --git a/components/esp32/dbg_stubs.c b/components/esp_common/src/dbg_stubs.c similarity index 100% rename from components/esp32/dbg_stubs.c rename to components/esp_common/src/dbg_stubs.c diff --git a/components/esp32/esp_err_to_name.c b/components/esp_common/src/esp_err_to_name.c similarity index 100% rename from components/esp32/esp_err_to_name.c rename to components/esp_common/src/esp_err_to_name.c diff --git a/components/esp32/esp_timer.c b/components/esp_common/src/esp_timer.c similarity index 99% rename from components/esp32/esp_timer.c rename to components/esp_common/src/esp_timer.c index edfa6b480f..27c3ee0aa2 100644 --- a/components/esp32/esp_timer.c +++ b/components/esp_common/src/esp_timer.c @@ -26,7 +26,7 @@ #include "freertos/xtensa_api.h" #include "sdkconfig.h" -#include "esp_timer_impl.h" +#include "esp_private/esp_timer_impl.h" #ifdef CONFIG_ESP_TIMER_PROFILING #define WITH_PROFILING 1 diff --git a/components/esp32/ets_timer_legacy.c b/components/esp_common/src/ets_timer_legacy.c similarity index 99% rename from components/esp32/ets_timer_legacy.c rename to components/esp_common/src/ets_timer_legacy.c index 44d789589b..506f2c53c1 100644 --- a/components/esp32/ets_timer_legacy.c +++ b/components/esp_common/src/ets_timer_legacy.c @@ -32,7 +32,7 @@ #include "freertos/xtensa_api.h" #include "sdkconfig.h" #include "esp_timer.h" -#include "esp_timer_impl.h" +#include "esp_private/esp_timer_impl.h" /* We abuse 'timer_arg' field of ETSTimer structure to hold a pointer to esp_timer */ #define ESP_TIMER(p_ets_timer) ((esp_timer_handle_t) (p_ets_timer)->timer_arg) diff --git a/components/esp32/pm_locks.c b/components/esp_common/src/pm_locks.c similarity index 99% rename from components/esp32/pm_locks.c rename to components/esp_common/src/pm_locks.c index e45a352b62..79d8fbefee 100644 --- a/components/esp32/pm_locks.c +++ b/components/esp_common/src/pm_locks.c @@ -19,7 +19,7 @@ #include "esp_system.h" #include "sys/queue.h" #include "freertos/FreeRTOS.h" -#include "pm_impl.h" +#include "esp_private/pm_impl.h" #include "esp_timer.h" #include "sdkconfig.h" diff --git a/components/esp32/stack_check.c b/components/esp_common/src/stack_check.c similarity index 100% rename from components/esp32/stack_check.c rename to components/esp_common/src/stack_check.c