esp32: cleanup build script

This commit is contained in:
Renz Bagaporo 2021-03-19 20:03:13 +08:00 committed by Michael (XIAO Xufeng)
parent 844af01eb4
commit 7c22cccb9c
27 changed files with 75 additions and 132 deletions

View File

@ -1,3 +1,3 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES cmock)
PRIV_REQUIRES cmock driver)

View File

@ -2,7 +2,7 @@ idf_component_register(SRCS "esp_ota_ops.c"
"esp_app_desc.c"
INCLUDE_DIRS "include"
REQUIRES spi_flash partition_table bootloader_support
PRIV_REQUIRES esptool_py)
PRIV_REQUIRES esptool_py efuse)
# esp_app_desc structure is added as an undefined symbol because otherwise the
# linker will ignore this structure as it has no other files depending on it.

View File

@ -11,8 +11,6 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include "esp_err.h"
#include "esp_partition.h"

View File

@ -4,4 +4,5 @@ idf_component_register(SRCS "commands.c"
"argtable3/argtable3.c"
"linenoise/linenoise.c"
INCLUDE_DIRS "."
REQUIRES vfs)
REQUIRES vfs
PRIV_REQUIRES driver)

View File

@ -3,29 +3,20 @@ if(NOT "${target}" STREQUAL "esp32")
return()
endif()
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility
# remove in the future
set(legacy_reqs driver efuse soc)
endif()
if(BOOTLOADER_BUILD)
# For bootloader, all we need from esp32 is headers
idf_component_register(INCLUDE_DIRS include REQUIRES xtensa)
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32.peripherals.ld")
else()
# Regular app build
set(include_dirs "include")
idf_component_register(INCLUDE_DIRS include
REQUIRES xtensa "${legacy_reqs}"
REQUIRED_IDF_TARGETS esp32)
set(requires driver efuse soc xtensa) #unfortunately rom/uart uses SOC registers directly
# app_update is added here because cpu_start.c uses esp_ota_get_app_description() function.
# esp_timer is added here because cpu_start.c uses esp_timer
set(priv_requires app_trace app_update bootloader_support esp_system log mbedtls nvs_flash pthread
spi_flash vfs espcoredump esp_common perfmon esp_timer esp_ipc esp_pm)
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
REQUIRES "${requires}"
PRIV_REQUIRES "${priv_requires}"
REQUIRED_IDF_TARGETS esp32)
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32.peripherals.ld")
if(NOT BOOTLOADER_BUILD)
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
target_linker_script(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
# Process the template file through the linker script generation mechanism, and use the output for linking the
@ -34,8 +25,6 @@ else()
PROCESS "${CMAKE_CURRENT_BINARY_DIR}/ld/esp32.project.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32.peripherals.ld")
target_link_libraries(${COMPONENT_LIB} INTERFACE gcc)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u call_user_start_cpu0")
idf_build_get_property(config_dir CONFIG_DIR)
# Preprocess esp32.ld linker script to include configuration, becomes esp32_out.ld
@ -50,5 +39,4 @@ else()
add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld)
add_dependencies(${COMPONENT_LIB} esp32_linker_script)
endif()

View File

@ -1,7 +1,3 @@
# Enable dynamic esp_timer overflow value if building unit tests
ifneq ("$(filter esp32,$(TEST_COMPONENTS_LIST))","")
CPPFLAGS += -DESP_TIMER_DYNAMIC_OVERFLOW_VAL
endif
ESP32_LINKER_SCRIPT_TEMPLATE := $(COMPONENT_PATH)/ld/esp32.project.ld.in
ESP32_LINKER_SCRIPT_OUTPUT_DIR := $(realpath $(BUILD_DIR_BASE)/esp32)

View File

@ -1,34 +1,21 @@
idf_build_get_property(target IDF_TARGET)
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
if(NOT "${target}" STREQUAL "esp32c3")
return()
endif()
if(BOOTLOADER_BUILD)
# For bootloader, all we need from esp32c3 is headers
idf_component_register(INCLUDE_DIRS include REQUIRES riscv)
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32c3.peripherals.ld")
else()
# Regular app build
if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility
# remove in the future
set(legacy_reqs driver efuse soc)
endif()
set(srcs)
set(include_dirs "include")
idf_component_register(INCLUDE_DIRS include
REQUIRES riscv "${legacy_reqs}"
REQUIRED_IDF_TARGETS esp32c3)
set(requires driver efuse soc riscv) #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.
# esp_timer is added here because cpu_start.c uses esp_timer
set(priv_requires
app_trace app_update bootloader_support log mbedtls nvs_flash
pthread spi_flash vfs espcoredump esp_common esp_timer)
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
REQUIRES "${requires}"
PRIV_REQUIRES "${priv_requires}"
REQUIRED_IDF_TARGETS esp32c3)
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32c3.peripherals.ld")
if(NOT BOOTLOADER_BUILD)
target_linker_script(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/esp32c3_out.ld")
# Process the template file through the linker script generation mechanism, and use the output for linking the
@ -36,8 +23,6 @@ else()
target_linker_script(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_LIST_DIR}/ld/esp32c3.project.ld.in"
PROCESS "${CMAKE_CURRENT_BINARY_DIR}/ld/esp32c3.project.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32c3.peripherals.ld")
target_link_libraries(${COMPONENT_LIB} INTERFACE gcc)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u call_user_start_cpu0")
idf_build_get_property(config_dir CONFIG_DIR)
# Preprocess esp32c3.ld linker script to include configuration, becomes esp32c3_out.ld
@ -52,10 +37,4 @@ else()
add_custom_target(esp32c3_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32c3_out.ld)
add_dependencies(${COMPONENT_LIB} esp32c3_linker_script)
# disable stack protection in files which are involved in initialization of that feature
set_source_files_properties(
cpu_start.c
PROPERTIES COMPILE_FLAGS
-fno-stack-protector)
endif()

View File

@ -1,32 +1,22 @@
idf_build_get_property(target IDF_TARGET)
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
if(NOT "${target}" STREQUAL "esp32s2")
return()
endif()
if(BOOTLOADER_BUILD)
# For bootloader, all we need from esp32s2 is headers
idf_component_register(INCLUDE_DIRS include REQUIRES xtensa)
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32s2.peripherals.ld")
else()
# Regular app build
if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility
# remove in the future
set(legacy_reqs driver efuse soc)
endif()
set(include_dirs "include")
idf_component_register(INCLUDE_DIRS include
REQUIRES xtensa "${legacy_reqs}"
REQUIRED_IDF_TARGETS esp32s2)
set(requires driver efuse xtensa)
# app_update is added here because cpu_start.c uses esp_ota_get_app_description() function.
# esp_timer is added here because cpu_start.c uses esp_timer
set(priv_requires
app_trace app_update bootloader_support esp_system log mbedtls nvs_flash
pthread spi_flash vfs espcoredump esp_common esp_timer)
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
REQUIRES "${requires}"
PRIV_REQUIRES "${priv_requires}"
REQUIRED_IDF_TARGETS esp32s2)
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32s2.peripherals.ld")
if(NOT BOOTLOADER_BUILD)
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
target_linker_script(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/esp32s2_out.ld")
# Process the template file through the linker script generation mechanism, and use the output for linking the
@ -36,8 +26,6 @@ else()
PROCESS "${CMAKE_CURRENT_BINARY_DIR}/ld/esp32s2.project.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32s2.peripherals.ld")
target_link_libraries(${COMPONENT_LIB} INTERFACE gcc)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u call_user_start_cpu0")
idf_build_get_property(config_dir CONFIG_DIR)
# Preprocess esp32s2.ld linker script to include configuration, becomes esp32s2_out.ld

View File

@ -1,32 +1,22 @@
idf_build_get_property(target IDF_TARGET)
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
if(NOT "${target}" STREQUAL "esp32s3")
return()
endif()
if(BOOTLOADER_BUILD)
# For bootloader, all we need from esp32s3 is headers
idf_component_register(INCLUDE_DIRS include REQUIRES xtensa)
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32s3.peripherals.ld")
else()
# Regular app build
set(include_dirs "include")
if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility
# remove in the future
set(legacy_reqs driver efuse soc)
endif()
set(requires driver efuse soc xtensa) #unfortunately rom/uart uses SOC registers directly
idf_component_register(INCLUDE_DIRS include
REQUIRES xtensa "${legacy_reqs}"
REQUIRED_IDF_TARGETS esp32s3)
# 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.
# esp_timer is added here because cpu_start.c uses esp_timer
set(priv_requires app_trace app_update bootloader_support log mbedtls nvs_flash pthread
spi_flash vfs espcoredump esp_common perfmon esp_timer esp_ipc)
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
REQUIRES "${requires}"
PRIV_REQUIRES "${priv_requires}"
REQUIRED_IDF_TARGETS esp32s3)
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32s3.peripherals.ld")
if(NOT BOOTLOADER_BUILD)
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
target_linker_script(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/esp32s3_out.ld")
# Process the template file through the linker script generation mechanism, and use the output for linking the
@ -35,8 +25,6 @@ else()
PROCESS "${CMAKE_CURRENT_BINARY_DIR}/ld/esp32s3.project.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32s3.peripherals.ld")
target_link_libraries(${COMPONENT_LIB} INTERFACE gcc)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u call_user_start_cpu0")
idf_build_get_property(config_dir CONFIG_DIR)
# Preprocess esp32s3.ld linker script to include configuration, becomes esp32s3_out.ld
@ -51,10 +39,4 @@ else()
add_custom_target(esp32s3_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32s3_out.ld)
add_dependencies(${COMPONENT_LIB} esp32s3_linker_script)
# disable stack protection in files which are involved in initialization of that feature
set_source_files_properties(
cpu_start.c
PROPERTIES COMPILE_FLAGS
-fno-stack-protector)
endif()

View File

@ -2,6 +2,7 @@ idf_build_get_property(target IDF_TARGET)
set(priv_requires efuse)
set(requires soc)
set(priv_requires efuse bootloader_support spi_flash)
if(${target} STREQUAL "esp32")
list(APPEND requires efuse)
endif()
@ -28,7 +29,7 @@ idf_component_register(SRCS ${srcs}
INCLUDE_DIRS include include/soc include/soc/${target}
PRIV_INCLUDE_DIRS port/include
REQUIRES ${requires}
PRIV_REQUIRES ${priv_requires}
PRIV_REQUIRES "${priv_requires}"
LDFRAGMENTS linker.lf)
idf_build_get_property(target IDF_TARGET)

View File

@ -1,3 +1,3 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "${include_dirs}"
PRIV_REQUIRES cmock test_utils esp_hw_support)
PRIV_REQUIRES cmock test_utils esp_hw_support driver efuse)

View File

@ -1,3 +1,4 @@
idf_component_register(SRCS "pm_locks.c" "pm_trace.c" "pm_impl.c"
INCLUDE_DIRS include
PRIV_REQUIRES esp_system driver
LDFRAGMENTS linker.lf)

View File

@ -1,3 +1,3 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES cmock test_utils)
PRIV_REQUIRES cmock test_utils esp_ringbuf driver)

View File

@ -38,7 +38,7 @@ else()
# should be removable once using component init functions
# link-time registration is used.
esp_pm app_update nvs_flash pthread app_trace esp_gdbstub
espcoredump esp_phy
espcoredump esp_phy efuse
LDFRAGMENTS "linker.lf" "app.lf")
add_subdirectory(port)

View File

@ -1,3 +1,3 @@
idf_component_register(SRC_DIRS .
PRIV_INCLUDE_DIRS .
PRIV_REQUIRES unity test_utils)
PRIV_REQUIRES unity test_utils driver)

View File

@ -69,7 +69,7 @@ idf_component_register(SRCS "${srcs}"
PRIV_INCLUDE_DIRS ${private_include_dirs}
LDFRAGMENTS linker.lf
REQUIRES ${required_components}
PRIV_REQUIRES soc)
PRIV_REQUIRES soc esp_pm)
idf_component_get_property(COMPONENT_DIR freertos COMPONENT_DIR)
idf_component_set_property(freertos ORIG_INCLUDE_PATH "${COMPONENT_DIR}/include/freertos/")

View File

@ -1,4 +1,3 @@
idf_component_register(SRC_DIRS .
PRIV_INCLUDE_DIRS .
PRIV_REQUIRES cmock test_utils esp_ipc
)
PRIV_REQUIRES cmock test_utils esp_ipc driver)

View File

@ -118,6 +118,7 @@ idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes}
PRIV_INCLUDE_DIRS ${priv_include}
REQUIRES soc
PRIV_REQUIRES ${target}
LDFRAGMENTS linker.lf)
if(CONFIG_HAL_DEFAULT_ASSERTION_LEVEL EQUAL 1)

View File

@ -1,10 +1,16 @@
idf_build_get_property(idf_target IDF_TARGET)
idf_build_get_property(python PYTHON)
set(priv_requires soc esp_hw_support)
if(NOT BOOTLOADER_BUILD)
list(APPEND priv_requires esp_pm)
endif()
idf_component_register(SRCS "esp_crt_bundle/esp_crt_bundle.c"
INCLUDE_DIRS "port/include" "mbedtls/include" "esp_crt_bundle/include"
REQUIRES lwip
PRIV_REQUIRES esp_pm soc
PRIV_REQUIRES "${priv_requires}"
)
if(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE)
@ -183,6 +189,8 @@ if(CONFIG_MBEDTLS_HARDWARE_MPI)
endif()
set_property(TARGET mbedcrypto APPEND PROPERTY LINK_INTERFACE_LIBRARIES mbedtls)
set_property(TARGET mbedcrypto APPEND PROPERTY LINK_LIBRARIES idf::driver idf::${target})
set_property(TARGET mbedcrypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES idf::driver idf::${target})
# Link mbedtls libraries to component library
target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_targets})

View File

@ -1,3 +1,3 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES cmock test_utils)
PRIV_REQUIRES cmock test_utils driver)

View File

@ -105,7 +105,7 @@ else()
"spi_flash_os_func_noos.c")
list(APPEND srcs ${cache_srcs})
set(priv_requires bootloader_support app_update soc esp_ipc)
set(priv_requires bootloader_support app_update soc esp_ipc driver)
endif()
idf_component_register(SRCS "${srcs}"

View File

@ -5,4 +5,4 @@ endif()
idf_component_register(SRC_DIRS "."
EXCLUDE_SRCS "${exclude_srcs}"
PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES cmock test_utils spi_flash bootloader_support app_update)
PRIV_REQUIRES cmock test_utils spi_flash bootloader_support app_update driver)

View File

@ -3,7 +3,7 @@ if(IDF_TARGET STREQUAL "esp32s3")
endif()
idf_component_register(SRC_DIRS ${IDF_TARGET}
PRIV_INCLUDE_DIRS .
PRIV_REQUIRES cmock ulp soc esp_common)
PRIV_REQUIRES cmock ulp soc esp_common driver)
if(IDF_TARGET STREQUAL "esp32")
set(ulp_sources "ulp/test_jumps_esp32.S")

View File

@ -7,4 +7,5 @@ endif()
idf_component_register(SRCS "hcd.c"
INCLUDE_DIRS ""
PRIV_INCLUDE_DIRS "private_include")
PRIV_INCLUDE_DIRS "private_include"
PRIV_REQUIRES hal driver)

View File

@ -2,7 +2,8 @@ idf_component_register(SRCS "vfs.c"
"vfs_eventfd.c"
"vfs_uart.c"
"vfs_semihost.c"
INCLUDE_DIRS include)
INCLUDE_DIRS include
PRIV_REQUIRES driver)
if(CONFIG_ESP_CONSOLE_USB_CDC)
target_sources(${COMPONENT_LIB} PRIVATE "vfs_cdcacm.c")

View File

@ -354,7 +354,6 @@ IDF_VER := $(shell echo "$(IDF_VER_T)" | cut -c 1-31)
# Set default LDFLAGS
EXTRA_LDFLAGS ?=
LDFLAGS ?= -nostdlib \
-u call_user_start_cpu0 \
$(EXTRA_LDFLAGS) \
-Wl,--gc-sections \
-Wl,-static \

View File

@ -20,4 +20,4 @@ idf_component_register(SRCS ${srcs}
INCLUDE_DIRS include
PRIV_INCLUDE_DIRS private_include
REQUIRES spi_flash idf_test cmock
PRIV_REQUIRES perfmon esp_ipc)
PRIV_REQUIRES perfmon esp_ipc driver)