diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index 790d13f8dc..c66f3958c9 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -20,7 +20,6 @@ else() "crosscore_int.c" "dport_access.c" "dport_panic_highint_hdl.S" - "esp_adapter.c" "esp_timer_esp32.c" "esp_himem.c" "hw_random.c" @@ -37,12 +36,12 @@ else() "task_wdt.c") set(include_dirs "include") - set(requires driver esp_event efuse soc) #unfortunately rom/uart uses SOC registers directly + set(requires driver efuse soc) #unfortunately rom/uart uses SOC registers directly # driver is a public requirement because esp_sleep.h uses gpio_num_t & touch_pad_t # app_update is added here because cpu_start.c uses esp_ota_get_app_description() function. set(priv_requires app_trace app_update bootloader_support log mbedtls nvs_flash pthread - spi_flash vfs wpa_supplicant espcoredump esp_common esp_wifi perfmon) + spi_flash vfs espcoredump esp_common perfmon) set(fragments linker.lf ld/esp32_fragments.lf) idf_component_register(SRCS "${srcs}" diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index ee5e38eeed..e42c5fd537 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -45,7 +45,6 @@ #include "esp_spi_flash.h" #include "esp_flash_internal.h" #include "nvs_flash.h" -#include "esp_event.h" #include "esp_spi_flash.h" #include "esp_private/crosscore_int.h" #include "esp_log.h" diff --git a/components/esp32/dport_access.c b/components/esp32/dport_access.c index ca89028014..aa5b4913ff 100644 --- a/components/esp32/dport_access.c +++ b/components/esp32/dport_access.c @@ -144,15 +144,6 @@ void IRAM_ATTR esp_dport_access_stall_other_cpu_end(void) #endif /* CONFIG_FREERTOS_UNICORE */ } -void IRAM_ATTR esp_dport_access_stall_other_cpu_start_wrap(void) -{ - DPORT_STALL_OTHER_CPU_START(); -} - -void IRAM_ATTR esp_dport_access_stall_other_cpu_end_wrap(void) -{ - DPORT_STALL_OTHER_CPU_END(); -} #ifndef CONFIG_FREERTOS_UNICORE static void dport_access_init_core(void *arg) diff --git a/components/esp32s2beta/CMakeLists.txt b/components/esp32s2beta/CMakeLists.txt index 6e181e7a7a..d32575be89 100644 --- a/components/esp32s2beta/CMakeLists.txt +++ b/components/esp32s2beta/CMakeLists.txt @@ -18,7 +18,6 @@ else() "crosscore_int.c" "dport_access.c" "dport_panic_highint_hdl.S" - "esp_adapter.c" "esp_timer_esp32s2beta.c" "hw_random.c" "int_wdt.c" @@ -34,13 +33,13 @@ else() "task_wdt.c") set(include_dirs "include") - set(requires driver esp_event efuse soc) #unfortunately rom/uart uses SOC registers directly + set(requires driver efuse soc) #unfortunately rom/uart uses SOC registers directly # driver is a public requirement because esp_sleep.h uses gpio_num_t & touch_pad_t # app_update is added here because cpu_start.c uses esp_ota_get_app_description() function. set(priv_requires app_trace app_update bootloader_support log mbedtls nvs_flash - pthread spi_flash vfs wpa_supplicant espcoredump esp_common esp_wifi) + pthread spi_flash vfs espcoredump esp_common) set(fragments linker.lf ld/esp32s2beta_fragments.lf) diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index 7338c480c7..dc855d93a9 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -8,6 +8,13 @@ else() set(ldfragments "linker.lf") endif() +if(IDF_TARGET_ESP32) + # dport workaround headers are in esp32 component + set(extra_priv_requires esp32) +else() + set(extra_priv_requires) +endif() + idf_component_register(SRCS "src/coexist.c" "src/lib_printf.c" "src/mesh_event.c" @@ -17,8 +24,10 @@ idf_component_register(SRCS "src/coexist.c" "src/wifi_init.c" "src/wifi_default.c" "src/wifi_netif.c" + "${idf_target}/esp_adapter.c" INCLUDE_DIRS "include" "${idf_target}/include" - PRIV_REQUIRES wpa_supplicant nvs_flash esp_netif + REQUIRES esp_event + PRIV_REQUIRES wpa_supplicant nvs_flash esp_netif ${extra_priv_requires} LDFRAGMENTS "${ldfragments}") idf_build_get_property(build_dir BUILD_DIR) diff --git a/components/esp_wifi/component.mk b/components/esp_wifi/component.mk index 578041750f..846b9130c2 100644 --- a/components/esp_wifi/component.mk +++ b/components/esp_wifi/component.mk @@ -3,7 +3,7 @@ # COMPONENT_ADD_INCLUDEDIRS := include $(IDF_TARGET)/include -COMPONENT_SRCDIRS := src +COMPONENT_SRCDIRS := src $(IDF_TARGET) ifndef CONFIG_ESP32_NO_BLOBS LIBS := core rtc net80211 pp smartconfig coexist espnow phy mesh diff --git a/components/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c similarity index 97% rename from components/esp32/esp_adapter.c rename to components/esp_wifi/esp32/esp_adapter.c index 410a73025b..99ccd14345 100644 --- a/components/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -44,13 +44,20 @@ #include "esp_smartconfig.h" #include "esp_coexist_internal.h" #include "esp_coexist_adapter.h" - - -extern void esp_dport_access_stall_other_cpu_start_wrap(void); -extern void esp_dport_access_stall_other_cpu_end_wrap(void); +#include "esp32/dport_access.h" #define TAG "esp_adapter" +static void IRAM_ATTR s_esp_dport_access_stall_other_cpu_start(void) +{ + DPORT_STALL_OTHER_CPU_START(); +} + +static void IRAM_ATTR s_esp_dport_access_stall_other_cpu_end(void) +{ + DPORT_STALL_OTHER_CPU_END(); +} + /* If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly. If failed, try to allocate it in internal memory then. @@ -557,8 +564,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._event_post = esp_event_post_wrapper, ._get_free_heap_size = esp_get_free_heap_size, ._rand = esp_random, - ._dport_access_stall_other_cpu_start_wrap = esp_dport_access_stall_other_cpu_start_wrap, - ._dport_access_stall_other_cpu_end_wrap = esp_dport_access_stall_other_cpu_end_wrap, + ._dport_access_stall_other_cpu_start_wrap = s_esp_dport_access_stall_other_cpu_start, + ._dport_access_stall_other_cpu_end_wrap = s_esp_dport_access_stall_other_cpu_end, ._phy_rf_deinit = esp_phy_rf_deinit, ._phy_load_cal_and_init = esp_phy_load_cal_and_init, ._phy_common_clock_enable = esp_phy_common_clock_enable, diff --git a/components/esp32s2beta/esp_adapter.c b/components/esp_wifi/esp32s2beta/esp_adapter.c similarity index 100% rename from components/esp32s2beta/esp_adapter.c rename to components/esp_wifi/esp32s2beta/esp_adapter.c diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index a46a6b6f04..08e6f1ee06 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -44,4 +44,5 @@ endforeach() set_property(TARGET mbedcrypto APPEND PROPERTY LINK_INTERFACE_LIBRARIES mbedtls) # Link mbedtls libraries to component library -target_link_libraries(${COMPONENT_LIB} INTERFACE ${mbedtls_targets}) \ No newline at end of file +target_link_libraries(${COMPONENT_LIB} INTERFACE ${mbedtls_targets}) + diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index fd825e9a0e..f22446d75d 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -267,7 +267,6 @@ function run_tests() mv main/Kconfig.projbuild_bak main/Kconfig.projbuild assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} - print_status "can build with phy_init_data" idf.py clean > /dev/null idf.py fullclean > /dev/null @@ -293,49 +292,42 @@ function run_tests() rm sdkconfig rm sdkconfig.defaults - # Next two tests will use this fake 'esp31b' target - export fake_target=esp31b - mkdir -p components/$fake_target - mkdir -p ${IDF_PATH}/components/xtensa/$fake_target/include - touch components/$fake_target/CMakeLists.txt - cp ${IDF_PATH}/tools/cmake/toolchain-esp32.cmake components/$fake_target/toolchain-$fake_target.cmake - ${SED} -i.bak '/cmake_minimum_required/ a\ - set(COMPONENTS esptool_py)' CMakeLists.txt + # the next four tests use the esp32s2beta target + export other_target=esp32s2beta print_status "Can override IDF_TARGET from environment" clean_build_dir rm sdkconfig - export IDF_TARGET=$fake_target + export IDF_TARGET=$other_target (cd build && cmake -G Ninja .. ) || failure "Failed to configure with IDF_TARGET set in environment" - grep "CONFIG_IDF_TARGET=\"${fake_target}\"" sdkconfig || failure "Project not configured for IDF_TARGET correctly" - grep "IDF_TARGET:STRING=${fake_target}" build/CMakeCache.txt || failure "IDF_TARGET not set in CMakeCache.txt" + grep "CONFIG_IDF_TARGET=\"${other_target}\"" sdkconfig || failure "Project not configured for IDF_TARGET correctly" + grep "IDF_TARGET:STRING=${other_target}" build/CMakeCache.txt || failure "IDF_TARGET not set in CMakeCache.txt" unset IDF_TARGET print_status "Can set target using idf.py -D" clean_build_dir rm sdkconfig - idf.py -DIDF_TARGET=$fake_target reconfigure || failure "Failed to set target via idf.py" - grep "CONFIG_IDF_TARGET=\"${fake_target}\"" sdkconfig || failure "Project not configured correctly using idf.py -D" - grep "IDF_TARGET:STRING=${fake_target}" build/CMakeCache.txt || failure "IDF_TARGET not set in CMakeCache.txt using idf.py -D" + idf.py -DIDF_TARGET=$other_target reconfigure || failure "Failed to set target via idf.py" + grep "CONFIG_IDF_TARGET=\"${other_target}\"" sdkconfig || failure "Project not configured correctly using idf.py -D" + grep "IDF_TARGET:STRING=${other_target}" build/CMakeCache.txt || failure "IDF_TARGET not set in CMakeCache.txt using idf.py -D" print_status "Can set target using -D as subcommand parameter for idf.py" clean_build_dir rm sdkconfig - idf.py reconfigure -DIDF_TARGET=$fake_target || failure "Failed to set target via idf.py subcommand -D parameter" - grep "CONFIG_IDF_TARGET=\"${fake_target}\"" sdkconfig || failure "Project not configured correctly using idf.py reconfigure -D" - grep "IDF_TARGET:STRING=${fake_target}" build/CMakeCache.txt || failure "IDF_TARGET not set in CMakeCache.txt using idf.py reconfigure -D" + idf.py reconfigure -DIDF_TARGET=$other_target || failure "Failed to set target via idf.py subcommand -D parameter" + grep "CONFIG_IDF_TARGET=\"${other_target}\"" sdkconfig || failure "Project not configured correctly using idf.py reconfigure -D" + grep "IDF_TARGET:STRING=${other_target}" build/CMakeCache.txt || failure "IDF_TARGET not set in CMakeCache.txt using idf.py reconfigure -D" - real_target=esp32s2beta print_status "Can set target using idf.py set-target" clean_build_dir rm sdkconfig - idf.py set-target ${real_target} || failure "Failed to set target via idf.py set-target" - grep "CONFIG_IDF_TARGET=\"${real_target}\"" sdkconfig || failure "Project not configured correctly using idf.py set-target" - grep "IDF_TARGET:STRING=${real_target}" build/CMakeCache.txt || failure "IDF_TARGET not set in CMakeCache.txt using idf.py set-target" + idf.py set-target ${other_target} || failure "Failed to set target via idf.py set-target" + grep "CONFIG_IDF_TARGET=\"${other_target}\"" sdkconfig || failure "Project not configured correctly using idf.py set-target" + grep "IDF_TARGET:STRING=${other_target}" build/CMakeCache.txt || failure "IDF_TARGET not set in CMakeCache.txt using idf.py set-target" - # Clean up modifications for the fake target - mv CMakeLists.txt.bak CMakeLists.txt - rm -rf components sdkconfig build + unset other_target # done changing target from the default + clean_build_dir + rm sdkconfig print_status "Can build with auto generated CMakeLists.txt" clean_build_dir diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index 517fdf8aa5..e010a4401a 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -152,7 +152,9 @@ function(__build_init idf_path) endforeach() # Set components required by all other components in the build - set(requires_common cxx newlib freertos heap log soc esp_rom esp_common xtensa) + # + # - lwip is here so that #include works without any special provisions + set(requires_common cxx newlib freertos heap log lwip soc esp_rom esp_common xtensa) idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${requires_common}") __build_get_idf_git_revision() @@ -490,4 +492,4 @@ function(idf_build_get_config var config) get_property(val TARGET __idf_build_target PROPERTY ${config}) endif() set(${var} ${val} PARENT_SCOPE) -endfunction() \ No newline at end of file +endfunction()