components: update with build system changes

This commit is contained in:
Renz Christian Bagaporo 2019-05-10 10:53:08 +08:00
parent ee92352bf8
commit ffec9d4947
49 changed files with 329 additions and 307 deletions

View file

@ -30,6 +30,5 @@ register_component()
# disable --coverage for this component, as it is used as transport
# for gcov
component_compile_options("-fno-profile-arcs" "-fno-test-coverage")
target_link_libraries(${COMPONENT_TARGET} gcov)
target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-profile-arcs" "-fno-test-coverage")
target_link_libraries(${COMPONENT_LIB} gcov ${LIBC} ${LIBM})

View file

@ -8,35 +8,40 @@ register_component()
# 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.
target_link_libraries(${COMPONENT_TARGET} "-u esp_app_desc")
target_link_libraries(${COMPONENT_LIB} "-u esp_app_desc")
# cut PROJECT_VER and PROJECT_NAME to required 32 characters.
string(SUBSTRING "${PROJECT_VER}" 0 31 PROJECT_VER_CUT)
string(SUBSTRING "${PROJECT_NAME}" 0 31 PROJECT_NAME_CUT)
idf_build_get_property(project_ver PROJECT_VER)
idf_build_get_property(project_name PROJECT_NAME)
string(SUBSTRING "${project_ver}" 0 31 PROJECT_VER_CUT)
string(SUBSTRING "${project_name}" 0 31 PROJECT_NAME_CUT)
set_source_files_properties(
SOURCE "esp_app_desc.c"
PROPERTIES COMPILE_DEFINITIONS
"PROJECT_VER=\"${PROJECT_VER_CUT}\"; PROJECT_NAME=\"${PROJECT_NAME_CUT}\"")
if (NOT BOOTLOADER_BUILD AND IDF_BUILD_ARTIFACTS)
if(NOT BOOTLOADER_BUILD)
partition_table_get_partition_info(otadata_offset "--partition-type data --partition-subtype ota" "offset")
partition_table_get_partition_info(otadata_size "--partition-type data --partition-subtype ota" "size")
set(blank_otadata_file ${IDF_BUILD_ARTIFACTS_DIR}/ota_data_initial.bin)
# Add custom target for generating empty otadata partition for flashing
if(otadata_size AND otadata_offset)
idf_build_get_property(build_dir BUILD_DIR)
set(blank_otadata_file ${build_dir}/ota_data_initial.bin)
idf_build_get_property(idf_path IDF_PATH)
idf_build_get_property(python PYTHON)
add_custom_command(OUTPUT ${blank_otadata_file}
COMMAND ${PYTHON} ${IDF_PATH}/components/partition_table/parttool.py
COMMAND ${python} ${idf_path}/components/partition_table/parttool.py
--partition-type data --partition-subtype ota -q
--partition-table-file ${PARTITION_CSV_PATH} generate_blank_partition_file
--output ${blank_otadata_file})
add_custom_target(blank_ota_data ALL DEPENDS ${blank_otadata_file})
add_dependencies(flash blank_ota_data)
add_dependencies(app blank_ota_data)
set(otatool_py ${PYTHON} ${COMPONENT_PATH}/otatool.py)
set(otatool_py ${python} ${COMPONENT_DIR}/otatool.py)
add_custom_target(read_otadata DEPENDS "${PARTITION_CSV_PATH}"
COMMAND ${otatool_py} --partition-table-file ${PARTITION_CSV_PATH} read_otadata)

View file

@ -1,5 +1,7 @@
register_component()
# Do not generate flash file when building bootloader or is in early expansion of the build
if(CMAKE_BUILD_EARLY_EXPANSION OR BOOTLOADER_BUILD)
if(BOOTLOADER_BUILD)
return()
endif()

View file

@ -1,8 +1,15 @@
# Do not generate flash file when building bootloader or is in early expansion of the build
if(BOOTLOADER_BUILD)
return()
endif()
idf_build_get_property(project_dir PROJECT_DIR)
# This is for tracking the top level project path
if(BOOTLOADER_BUILD)
set(main_project_path "${CMAKE_BINARY_DIR}/../..")
else()
set(main_project_path "${IDF_PROJECT_PATH}")
set(main_project_path "${project_dir}")
endif()
get_filename_component(secure_boot_signing_key
@ -19,15 +26,13 @@ else()
add_custom_target(gen_secure_boot_signing_key)
endif()
if(BOOTLOADER_BUILD OR NOT IDF_BUILD_ARTIFACTS)
return() # don't keep recursing, generate on project builds
endif()
# Glue to build the bootloader subproject binary as an external
# cmake project under this one
#
#
set(BOOTLOADER_BUILD_DIR "${IDF_BUILD_ARTIFACTS_DIR}/bootloader")
idf_build_get_property(build_dir BUILD_DIR)
set(BOOTLOADER_BUILD_DIR "${build_dir}/bootloader")
set(bootloader_binary_files
"${BOOTLOADER_BUILD_DIR}/bootloader.elf"
"${BOOTLOADER_BUILD_DIR}/bootloader.bin"
@ -47,12 +52,16 @@ endif()
if((NOT CONFIG_SECURE_BOOT_ENABLED) OR
CONFIG_SECURE_BOOTLOADER_REFLASHABLE OR
CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH)
idf_build_get_property(idf_path IDF_PATH)
idf_build_get_property(sdkconfig SDKCONFIG)
idf_build_get_property(idf_target IDF_TARGET)
externalproject_add(bootloader
# TODO: support overriding the bootloader in COMPONENT_PATHS
SOURCE_DIR "${IDF_PATH}/components/bootloader/subproject"
SOURCE_DIR "${idf_path}/components/bootloader/subproject"
BINARY_DIR "${BOOTLOADER_BUILD_DIR}"
CMAKE_ARGS -DSDKCONFIG=${SDKCONFIG} -DIDF_PATH=${IDF_PATH} -DIDF_TARGET=${IDF_TARGET}
CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target}
-DSECURE_BOOT_SIGNING_KEY=${secure_boot_signing_key}
-DPYTHON_DEPS_CHECKED=1
INSTALL_COMMAND ""
BUILD_ALWAYS 1 # no easy way around this...
BUILD_BYPRODUCTS ${bootloader_binary_files}

View file

@ -17,33 +17,17 @@ endif()
set(COMPONENTS bootloader esptool_py partition_table soc bootloader_support log spi_flash micro-ecc main efuse)
set(BOOTLOADER_BUILD 1)
add_definitions(-DBOOTLOADER_BUILD=1)
set(COMPONENT_REQUIRES_COMMON log esp_rom esp_common xtensa)
if (CONFIG_LEGACY_INCLUDE_COMMON_HEADERS)
list(APPEND COMPONENT_REQUIRES_COMMON "soc")
endif()
include("${IDF_PATH}/tools/cmake/project.cmake")
set(common_req log esp_rom esp_common xtensa)
if (CONFIG_LEGACY_INCLUDE_COMMON_HEADERS)
list(APPEND common_req soc)
endif()
idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${common_req}")
idf_build_set_property(__OUTPUT_SDKCONFIG 0)
project(bootloader)
target_linker_script(bootloader.elf
"main/${IDF_TARGET}.bootloader.ld"
"main/${IDF_TARGET}.bootloader.rom.ld"
)
# as cmake won't attach linker args to a header-only library, attach
# linker args directly to the bootloader.elf
# esp32.rom.newlib-funcs.ld is included to use memset/memcpy.
set(BOOTLOADER_LINKER_SCRIPTS
"${IDF_PATH}/components/esp_rom/${IDF_TARGET}/ld/${IDF_TARGET}.rom.ld"
"${IDF_PATH}/components/esp_rom/${IDF_TARGET}/ld/${IDF_TARGET}.rom.newlib-funcs.ld"
"${IDF_PATH}/components/${IDF_TARGET}/ld/${IDF_TARGET}.peripherals.ld")
target_linker_script(bootloader.elf ${BOOTLOADER_LINKER_SCRIPTS})
target_link_libraries(bootloader.elf gcc)
idf_build_set_property(COMPILE_DEFINITIONS "-DBOOTLOADER_BUILD=1" APPEND)
idf_build_set_property(COMPILE_OPTIONS "-fno-stack-protector" APPEND)
set(secure_boot_signing_key ${SECURE_BOOT_SIGNING_KEY})

View file

@ -1,8 +1,4 @@
# only compile the "micro-ecc/uECC.c" source file
set(COMPONENT_SRCS "micro-ecc/uECC.c")
set(COMPONENT_ADD_INCLUDEDIRS micro-ecc)
set(COMPONENT_REQUIRES)
register_component()

View file

@ -1,4 +1,10 @@
set(COMPONENT_SRCS "bootloader_start.c")
set(COMPONENT_ADD_INCLUDEDIRS "")
set(COMPONENT_REQUIRES "bootloader bootloader_support")
set(COMPONENT_REQUIRES bootloader bootloader_support)
register_component()
idf_build_get_property(target IDF_TARGET)
set(scripts "${target}.bootloader.ld"
"${target}.bootloader.rom.ld")
target_linker_script(${COMPONENT_LIB} "${scripts}")

View file

@ -7,7 +7,7 @@ set(COMPONENT_SRCS "src/bootloader_clock.c"
"src/flash_partitions.c"
"src/flash_qio_mode.c")
if(${BOOTLOADER_BUILD})
if(BOOTLOADER_BUILD)
set(COMPONENT_ADD_INCLUDEDIRS "include include_bootloader")
set(COMPONENT_REQUIRES soc) #unfortunately the header directly uses SOC registers
set(COMPONENT_PRIV_REQUIRES spi_flash micro-ecc efuse)

View file

@ -280,9 +280,9 @@ register_component()
if(CONFIG_BT_ENABLED)
if(GCC_NOT_5_2_0)
component_compile_options(-Wno-implicit-fallthrough -Wno-unused-const-variable)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
endif()
target_link_libraries(${COMPONENT_TARGET} "-L${CMAKE_CURRENT_LIST_DIR}/lib")
target_link_libraries(${COMPONENT_TARGET} btdm_app)
target_link_libraries(${COMPONENT_LIB} "-L${CMAKE_CURRENT_LIST_DIR}/lib")
target_link_libraries(${COMPONENT_LIB} btdm_app)
endif()

View file

@ -26,3 +26,9 @@ register_component()
# Silence format truncation warning, until it is fixed upstream
set_source_files_properties(libcoap/src/coap_debug.c PROPERTIES COMPILE_FLAGS -Wno-format-truncation)
# Needed for coap headers in public builds, also.
#
# TODO: find a way to move this to a port header
target_compile_definitions(${COMPONENT_LIB} PUBLIC WITH_POSIX)

View file

@ -3,8 +3,5 @@ set(COMPONENT_SRCS "commands.c"
"split_argv.c"
"argtable3/argtable3.c"
"linenoise/linenoise.c")
set(COMPONENT_REQUIRES)
register_component()

View file

@ -1,12 +1,10 @@
set(COMPONENT_SRCS "cxx_exception_stubs.cpp"
"cxx_guards.cpp")
set(COMPONENT_REQUIRES)
register_component()
target_link_libraries(${COMPONENT_TARGET} stdc++)
target_link_libraries(${COMPONENT_TARGET} "-u __cxa_guard_dummy")
target_link_libraries(${COMPONENT_LIB} stdc++)
target_link_libraries(${COMPONENT_LIB} "-u __cxa_guard_dummy")
if(NOT CONFIG_CXX_EXCEPTIONS)
target_link_libraries(${COMPONENT_TARGET} "-u __cxx_fatal_exception")
target_link_libraries(${COMPONENT_LIB} "-u __cxx_fatal_exception")
endif()

View file

@ -1,43 +1,44 @@
set(SOC_NAME ${IDF_TARGET})
idf_build_get_property(soc_name IDF_TARGET)
if(EXISTS "${COMPONENT_PATH}/${SOC_NAME}")
include(${COMPONENT_PATH}/${SOC_NAME}/sources.cmake)
if(EXISTS "${COMPONENT_DIR}/${soc_name}")
include(${COMPONENT_DIR}/${soc_name}/sources.cmake)
spaces2list(EFUSE_SOC_SRCS)
add_prefix(COMPONENT_SRCS "${SOC_NAME}/" ${EFUSE_SOC_SRCS})
set(COMPONENT_ADD_INCLUDEDIRS include
${SOC_NAME}/include)
add_prefix(COMPONENT_SRCS "${soc_name}/" ${EFUSE_SOC_SRCS})
set(COMPONENT_ADD_INCLUDEDIRS include ${soc_name}/include)
endif()
list(APPEND COMPONENT_SRCS "src/esp_efuse_api.c"
"src/esp_efuse_fields.c"
"src/esp_efuse_utility.c")
set(COMPONENT_REQUIRES)
set(COMPONENT_PRIV_REQUIRES bootloader_support soc)
register_component()
set(GEN_EFUSE_TABLE_ARG --max_blk_len ${CONFIG_EFUSE_MAX_BLK_LEN})
idf_build_get_property(python PYTHON)
###################
# Make common files esp_efuse_table.c and include/esp_efuse_table.h files.
set(EFUSE_COMMON_TABLE_CSV_PATH "${COMPONENT_PATH}/${SOC_NAME}/esp_efuse_table.csv")
set(EFUSE_COMMON_TABLE_CSV_PATH "${COMPONENT_DIR}/${soc_name}/esp_efuse_table.csv")
add_custom_target(efuse_common_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
add_custom_target(efuse_common_table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
###################
# Make custom files project/main/esp_efuse_custom_table.c and project/main/include/esp_efuse_custom_table.h files.
# Path to CSV file is relative to project path for custom CSV files.
if(${CONFIG_EFUSE_CUSTOM_TABLE})
# Custom filename expands any path relative to the project
get_filename_component(EFUSE_CUSTOM_TABLE_CSV_PATH "${CONFIG_EFUSE_CUSTOM_TABLE_FILENAME}" ABSOLUTE BASE_DIR "${IDF_PROJECT_PATH}")
add_custom_target(efuse_custom_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
idf_build_get_property(project_dir PROJECT_DIR)
get_filename_component(EFUSE_CUSTOM_TABLE_CSV_PATH "${CONFIG_EFUSE_CUSTOM_TABLE_FILENAME}" ABSOLUTE BASE_DIR "${project_dir}")
add_custom_target(efuse_custom_table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
else()
add_custom_target(efuse_custom_table COMMAND)
endif()#if(${CONFIG_EFUSE_CUSTOM_TABLE})
add_custom_target(show_efuse_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG} "--info")
add_custom_target(show_efuse_table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG} "--info")
###################
# Generates files for unit test. This command is run manually.
set(EFUSE_TEST_TABLE_CSV_PATH "${COMPONENT_PATH}/test/esp_efuse_test_table.csv")
add_custom_target(efuse_test_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_TEST_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
set(EFUSE_TEST_TABLE_CSV_PATH "${COMPONENT_DIR}/test/esp_efuse_test_table.csv")
add_custom_target(efuse_test_table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_TEST_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})

View file

@ -3,9 +3,8 @@ require_idf_targets(esp32)
if(BOOTLOADER_BUILD)
# For bootloader, all we need from esp32 is headers
set(COMPONENT_ADD_INCLUDEDIRS include)
set(COMPONENT_REQUIRES ${IDF_COMPONENTS} soc) #unfortunately rom/uart uses SOC registers directly
set(COMPONENT_SRCS )
register_component()
target_linker_script(${COMPONENT_LIB} "ld/esp32.peripherals.ld")
else()
# Regular app build
@ -47,52 +46,42 @@ else()
register_component()
target_linker_script(${COMPONENT_TARGET} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
target_linker_script(${COMPONENT_LIB} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
# Rely on user code to define app_main
target_link_libraries(${COMPONENT_LIB} "-u app_main")
if(CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY)
# This has to be linked before esp32.project.ld
target_linker_script(${COMPONENT_TARGET} "ld/esp32.extram.bss.ld")
target_linker_script(${COMPONENT_LIB} "ld/esp32.extram.bss.ld")
endif()
if(IDF_PROJECT_EXECUTABLE)
# Process the template file through the linker script generation mechanism, and use the output for linking the
# final binary
set(esp32_project_script "${CMAKE_CURRENT_BINARY_DIR}/esp32.project.ld")
set(esp32_project_template "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.project.ld.in")
target_linker_script(${COMPONENT_LIB} "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.project.ld.in" PROCESS)
ldgen_process_template(${esp32_project_template} ${esp32_project_script})
target_link_libraries(${COMPONENT_TARGET} "-T ${esp32_project_script}")
set_property(TARGET ${IDF_PROJECT_EXECUTABLE} APPEND PROPERTY LINK_DEPENDS ${esp32_project_script})
endif()
target_linker_script(${COMPONENT_TARGET} "ld/esp32.peripherals.ld")
target_link_libraries(${COMPONENT_TARGET} gcc)
target_link_libraries(${COMPONENT_TARGET} "-u call_user_start_cpu0")
target_linker_script(${COMPONENT_LIB} "ld/esp32.peripherals.ld")
target_link_libraries(${COMPONENT_LIB} gcc)
target_link_libraries(${COMPONENT_LIB} "-u call_user_start_cpu0")
#ld_include_panic_highint_hdl is added as an undefined symbol because otherwise the
#linker will ignore panic_highint_hdl.S as it has no other files depending on any
#symbols in it.
target_link_libraries(${COMPONENT_TARGET} "-u ld_include_panic_highint_hdl")
target_link_libraries(${COMPONENT_LIB} "-u ld_include_panic_highint_hdl")
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
get_filename_component(config_dir ${sdkconfig_header} DIRECTORY)
# Preprocess esp32.ld linker script to include configuration, becomes esp32_out.ld
set(LD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ld)
add_custom_command(
OUTPUT esp32_out.ld
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${CONFIG_DIR} ${LD_DIR}/esp32.ld
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${config_dir} ${LD_DIR}/esp32.ld
MAIN_DEPENDENCY ${LD_DIR}/esp32.ld ${SDKCONFIG_H}
COMMENT "Generating linker script..."
VERBATIM)
add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld)
add_dependencies(${COMPONENT_TARGET} esp32_linker_script)
# Enable dynamic esp_timer overflow value if building unit tests
if(esp32_test IN_LIST BUILD_TEST_COMPONENTS)
add_definitions(-DESP_TIMER_DYNAMIC_OVERFLOW_VAL)
endif()
add_dependencies(${COMPONENT_LIB} esp32_linker_script)
# disable stack protection in files which are involved in initialization of that feature
set_source_files_properties(

View file

@ -3,6 +3,19 @@ if(CONFIG_SPIRAM_CACHE_WORKAROUND)
# are not part of the ESP-IDF build system (for cases where a generic
# non-IDF CMakeLists.txt file is imported into a component) don't depend
# on the esp32 component so don't get the extra flag. This handles that case.
add_compile_options(-mfix-esp32-psram-cache-issue)
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-issue" APPEND)
endif()
# Check toolchain is configured properly in cmake
if(NOT ( ${CMAKE_SYSTEM_NAME} STREQUAL "Generic" AND ${CMAKE_C_COMPILER} MATCHES xtensa))
message(FATAL_ERROR "Internal error, toolchain has not been set correctly by project "
"(or an invalid CMakeCache.txt file has been generated somehow)")
endif()
#
# Warn if the toolchain version doesn't match
#
# TODO: make these platform-specific for diff toolchains
get_expected_ctng_version(expected_toolchain expected_gcc)
gcc_version_check("${expected_gcc}")
crosstool_version_check("${expected_toolchain}")

View file

@ -7,9 +7,11 @@ register_component()
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
COMMAND xxd -i "logo.jpg" "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
WORKING_DIRECTORY ${COMPONENT_PATH}
WORKING_DIRECTORY ${COMPONENT_DIR}
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg")
add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h")
add_dependencies(${COMPONENT_TARGET} esp32_test_logo)
add_dependencies(${COMPONENT_LIB} esp32_test_logo)
idf_build_set_property(COMPILE_DEFINITIONS "-DESP_TIMER_DYNAMIC_OVERFLOW_VAL" APPEND)

View file

@ -4,6 +4,12 @@ if(BOOTLOADER_BUILD)
set(COMPONENT_REQUIRES ${IDF_COMPONENTS})
set(COMPONENT_SRCS)
register_component()
set(scripts
"esp32/ld/esp32.rom.ld"
"esp32/ld/esp32.rom.newlib-funcs.ld"
"esp32/ld/esp32.rom.libgcc.ld"
)
target_linker_script(${COMPONENT_LIB} "${scripts}")
else()
# Regular app build
set(COMPONENT_SRCS "esp_rom.c")
@ -11,27 +17,32 @@ else()
register_component()
target_linker_script(${COMPONENT_TARGET}
set(scripts
"esp32/ld/esp32.rom.ld"
"esp32/ld/esp32.rom.libgcc.ld"
"esp32/ld/esp32.rom.syscalls.ld"
"esp32/ld/esp32.rom.newlib-data.ld")
"esp32/ld/esp32.rom.newlib-data.ld"
)
target_linker_script(${COMPONENT_LIB} "${scripts}")
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
target_compile_options(${COMPONENT_TARGET} PUBLIC -mfix-esp32-psram-cache-issue)
# Note: Adding as a PUBLIC compile option here causes this option to propagate to all components that depend on esp32.
#
# To handle some corner cases, the same flag is set in project_include.cmake
target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-issue)
else()
target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-funcs.ld")
target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.newlib-funcs.ld")
endif()
if(CONFIG_NEWLIB_NANO_FORMAT)
target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-nano.ld")
target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.newlib-nano.ld")
endif()
if(NOT GCC_NOT_5_2_0)
target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-locale.ld")
target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.newlib-locale.ld")
endif()
if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)
target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.spiflash.ld")
target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.spiflash.ld")
endif()
endif()

View file

@ -16,29 +16,31 @@ if(NOT CONFIG_NO_BLOBS)
endif()
register_component()
target_link_libraries(${COMPONENT_LIB} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}")
if(NOT CONFIG_NO_BLOBS)
target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}")
target_link_libraries(${COMPONENT_TARGET} coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps)
target_link_libraries(${COMPONENT_LIB} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}")
target_link_libraries(${COMPONENT_LIB} coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps)
endif()
if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION AND IDF_BUILD_ARTIFACTS)
if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION)
idf_build_get_property(build_dir BUILD_DIR)
partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset")
set(phy_init_data_bin "${IDF_BUILD_ARTIFACTS_DIR}/phy_init_data.bin")
set(phy_init_data_bin "${build_dir}/phy_init_data.bin")
# To get the phy_init_data.bin file, compile phy_init_data.h as a C file and then objcopy
# the object file to a raw binary
add_custom_command(
OUTPUT ${phy_init_data_bin}
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/include/phy_init_data.h
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
COMMAND ${CMAKE_C_COMPILER} -x c -c
-I ${CMAKE_CURRENT_LIST_DIR} -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${IDF_BUILD_ARTIFACTS_DIR}
-I ${CMAKE_CURRENT_LIST_DIR} -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${build_dir}
-o phy_init_data.obj
${CMAKE_CURRENT_LIST_DIR}/include/phy_init_data.h
${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
COMMAND ${CMAKE_OBJCOPY} -O binary phy_init_data.obj ${phy_init_data_bin}
)
add_custom_target(phy_init_data ALL DEPENDS ${phy_init_data_bin})
add_dependencies(flash phy_init_data)
add_dependencies(app phy_init_data)
esptool_py_flash_project_args(phy ${phy_partition_offset} ${phy_init_data_bin} FLASH_IN_PROJECT)
endif()

View file

@ -5,20 +5,21 @@ set(COMPONENT_REQUIRES unity test_utils nvs_flash ulp esp_common)
register_component()
idf_build_get_property(idf_path IDF_PATH)
# Calculate MD5 value of header file esp_wifi_os_adapter.h
execute_process(COMMAND md5sum ${IDF_PATH}/components/esp_wifi/include/esp_private/wifi_os_adapter.h
execute_process(COMMAND md5sum ${idf_path}/components/esp_wifi/include/esp_wifi_os_adapter.h
COMMAND cut -c 1-7
OUTPUT_VARIABLE WIFI_OS_ADAPTER_MD5
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Calculate MD5 value of header file esp_wifi_crypto_types.h
execute_process(COMMAND md5sum ${IDF_PATH}/components/esp_wifi/include/esp_wifi_crypto_types.h
execute_process(COMMAND md5sum ${idf_path}/components/esp_wifi/include/esp_wifi_crypto_types.h
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/esp_wifi/include/esp_coexist_adapter.h
execute_process(COMMAND md5sum ${idf_path}/components/esp_wifi/include/esp_coexist_adapter.h
COMMAND cut -c 1-7
OUTPUT_VARIABLE COEX_ADAPTER_MD5
OUTPUT_STRIP_TRAILING_WHITESPACE)

View file

@ -1,6 +1,5 @@
set(COMPONENT_PRIV_INCLUDEDIRS "include_core_dump")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES)
set(COMPONENT_PRIV_REQUIRES spi_flash soc)
set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
set(COMPONENT_SRCS "src/core_dump_common.c"

View file

@ -1,6 +1,5 @@
register_config_only_component()
if(IDF_BUILD_ARTIFACTS)
string(REPLACE ";" " " ESPTOOLPY_FLASH_PROJECT_OPTIONS "${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS}")
set(ESPTOOLPY_FLASH_PROJECT_OPTIONS
"${ESPTOOLPY_FLASH_PROJECT_OPTIONS}"
@ -13,15 +12,27 @@ endif()
# Generate the flash project args and the flasher args json file using the accumulated values
# from esptool_py_flash_project_args calls. The file is first configured using configure_file() for all variable values,
# and then generated using file(GENERATE... for generator expressions.
configure_file(${COMPONENT_PATH}/flash_project_args.in
configure_file(${COMPONENT_DIR}/flash_project_args.in
${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in)
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/flash_project_args
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in2
INPUT ${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in)
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/flash_project_args
INPUT ${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in2)
configure_file(${COMPONENT_PATH}/flasher_args.json.in
configure_file(${COMPONENT_DIR}/flasher_args.json.in
${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in)
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/flasher_args.json
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in2
INPUT ${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in)
endif()
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/flasher_args.json
INPUT ${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in2)
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in"
"${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in2"
"${CMAKE_BINARY_DIR}/flash_project_args"
"${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in2"
"${CMAKE_BINARY_DIR}/flasher_args.json")

View file

@ -1,13 +1,10 @@
if(NOT IDF_BUILD_ARTIFACTS)
return()
endif()
# Set some global esptool.py variables
#
# Many of these are read when generating flash_app_args & flash_project_args
set(ESPTOOLPY ${PYTHON} "${CMAKE_CURRENT_LIST_DIR}/esptool/esptool.py" --chip esp32)
set(ESPSECUREPY ${PYTHON} "${CMAKE_CURRENT_LIST_DIR}/esptool/espsecure.py")
set(ESPEFUSEPY ${PYTHON} "${CMAKE_CURRENT_LIST_DIR}/esptool/espefuse.py")
idf_build_get_property(python PYTHON)
set(ESPTOOLPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/esptool.py" --chip esp32)
set(ESPSECUREPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/espsecure.py")
set(ESPEFUSEPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/espefuse.py")
set(ESPFLASHMODE ${CONFIG_ESPTOOLPY_FLASHMODE})
set(ESPFLASHFREQ ${CONFIG_ESPTOOLPY_FLASHFREQ})
@ -62,44 +59,51 @@ if(CONFIG_ESPTOOLPY_FLASHSIZE_DETECT)
set(ESPFLASHSIZE detect)
endif()
get_filename_component(IDF_PROJECT_NAME ${IDF_PROJECT_EXECUTABLE} NAME_WE)
idf_build_get_property(build_dir BUILD_DIR)
idf_build_get_property(elf_name EXECUTABLE_NAME GENERATOR_EXPRESSION)
idf_build_get_property(elf EXECUTABLE GENERATOR_EXPRESSION)
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES AND NOT BOOTLOADER_BUILD)
set(unsigned_project_binary "${IDF_PROJECT_NAME}-unsigned.bin")
set(unsigned_project_binary "${elf_name}-unsigned.bin")
else()
set(unsigned_project_binary "${IDF_PROJECT_NAME}.bin")
set(unsigned_project_binary "${elf_name}.bin")
endif()
set(PROJECT_BIN "${elf_name}.bin")
#
# Add 'app.bin' target - generates with elf2image
#
add_custom_command(OUTPUT "${IDF_BUILD_ARTIFACTS_DIR}/${unsigned_project_binary}"
add_custom_command(OUTPUT "${build_dir}/.app_hash"
COMMAND ${ESPTOOLPY} elf2image ${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS} ${ESPTOOLPY_ELF2IMAGE_OPTIONS}
-o "${IDF_BUILD_ARTIFACTS_DIR}/${unsigned_project_binary}" "${IDF_PROJECT_EXECUTABLE}"
DEPENDS ${IDF_PROJECT_EXECUTABLE}
-o "${build_dir}/${unsigned_project_binary}" "${elf}"
COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${unsigned_project_binary}" > "${build_dir}/.app_hash"
DEPENDS ${elf}
VERBATIM
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${build_dir}
)
get_filename_component(IDF_PROJECT_BIN ${IDF_PROJECT_EXECUTABLE} NAME_WE)
set(IDF_PROJECT_BIN ${IDF_PROJECT_BIN}.bin)
add_custom_target(gen_project_binary DEPENDS "${build_dir}/.app_hash")
if(NOT BOOTLOADER_BUILD AND
CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
# for locally signed secure boot image, add a signing step to get from unsigned app to signed app
add_custom_target(gen_unsigned_project_binary ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/${unsigned_project_binary}")
add_custom_command(OUTPUT "${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}"
add_custom_command(OUTPUT "${build_dir}/.signed_app_hash"
COMMAND ${ESPSECUREPY} sign_data --keyfile ${secure_boot_signing_key}
-o "${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}" "${IDF_BUILD_ARTIFACTS_DIR}/${unsigned_project_binary}"
DEPENDS gen_unsigned_project_binary
-o "${build_dir}/${PROJECT_BIN}" "${build_dir}/${unsigned_project_binary}"
COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${PROJECT_BIN}" > "${build_dir}/.signed_app_hash"
DEPENDS "${build_dir}/.app_hash"
VERBATIM
)
add_custom_target(gen_signed_project_binary DEPENDS "${build_dir}/.signed_app_hash")
add_dependencies(gen_project_binary gen_signed_project_binary)
endif()
if(NOT BOOTLOADER_BUILD)
add_custom_target(app ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}")
add_custom_target(app ALL DEPENDS gen_project_binary)
else()
add_custom_target(bootloader ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}")
add_custom_target(bootloader ALL DEPENDS gen_project_binary)
endif()
if(NOT BOOTLOADER_BUILD AND
@ -109,7 +113,7 @@ if(NOT BOOTLOADER_BUILD AND
COMMAND ${CMAKE_COMMAND} -E echo
"App built but not signed. Sign app before flashing"
COMMAND ${CMAKE_COMMAND} -E echo
"\t${ESPSECUREPY} sign_data --keyfile KEYFILE ${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}"
"\t${ESPSECUREPY} sign_data --keyfile KEYFILE ${build_dir}/${elf_bin}"
VERBATIM)
endif()
@ -117,12 +121,13 @@ endif()
# Add 'flash' target - not all build systems can run this directly
#
function(esptool_py_custom_target target_name flasher_filename dependencies)
idf_build_get_property(idf_path IDF_PATH)
add_custom_target(${target_name} DEPENDS ${dependencies}
COMMAND ${CMAKE_COMMAND}
-D IDF_PATH="${IDF_PATH}"
-D IDF_PATH="${idf_path}"
-D ESPTOOLPY="${ESPTOOLPY}"
-D ESPTOOL_ARGS="write_flash;@flash_${flasher_filename}_args"
-D ESPTOOL_WORKING_DIR="${IDF_BUILD_ARTIFACTS_DIR}"
-D ESPTOOL_WORKING_DIR="${build_dir}"
-P run_esptool.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
USES_TERMINAL
@ -142,8 +147,9 @@ function(esptool_py_flash_project_args entry offset image)
set(options FLASH_IN_PROJECT) # flash the image when flashing the project
set(single_value FLASH_FILE_TEMPLATE) # template file to use to be able to
# flash the image individually using esptool
cmake_parse_arguments(flash_entry "${options}" "${single_value}" "" "${ARGN}")
cmake_parse_arguments(_ "${options}" "${single_value}" "" "${ARGN}")
idf_build_get_property(build_dir BUILD_DIR)
get_property(flash_project_entries TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ENTRIES)
if(${entry} IN_LIST flash_project_entries)
@ -156,14 +162,16 @@ function(esptool_py_flash_project_args entry offset image)
file(RELATIVE_PATH image ${CMAKE_BINARY_DIR} ${image})
# Generate the standalone flash file to flash the image individually using esptool
set(entry_flash_args ${IDF_BUILD_ARTIFACTS_DIR}/flash_${entry}_args)
if(NOT flash_entry_FLASH_FILE_TEMPLATE)
set(entry_flash_args ${build_dir}/flash_${entry}_args)
if(NOT __FLASH_FILE_TEMPLATE)
file(GENERATE OUTPUT ${entry_flash_args} CONTENT "${offset} ${image}")
else()
configure_file(${flash_entry_FLASH_FILE_TEMPLATE} ${entry_flash_args})
get_filename_component(template "${__FLASH_FILE_TEMPLATE}" ABSOLUTE)
file(GENERATE OUTPUT ${entry_flash_args} INPUT ${template})
endif()
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${entry_flash_args})
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${entry_flash_args})
# Generate standalone entries in the flasher args json file
get_property(flash_project_args_entry_json TARGET
@ -174,7 +182,7 @@ function(esptool_py_flash_project_args entry offset image)
PROPERTY FLASH_PROJECT_ARGS_ENTRY_JSON "${flash_project_args_entry_json}")
# Generate entries in the flasher args json file
if(flash_entry_FLASH_IN_PROJECT)
if(__FLASH_IN_PROJECT)
get_property(flash_project_args TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS)
list(APPEND flash_project_args "${offset} ${image}")
set_property(TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS "${flash_project_args}")

View file

@ -5,15 +5,12 @@ set(COMPONENT_SRCS "expat/expat/lib/loadlibrary.c"
"expat/expat/lib/xmltok.c"
"expat/expat/lib/xmltok_impl.c"
"expat/expat/lib/xmltok_ns.c")
set(COMPONENT_REQUIRES)
register_component()
component_compile_definitions(HAVE_EXPAT_CONFIG_H)
component_compile_definitions(HAVE_GETRANDOM)
target_compile_definitions(${COMPONENT_LIB} PRIVATE HAVE_EXPAT_CONFIG_H)
target_compile_definitions(${COMPONENT_LIB} PRIVATE HAVE_GETRANDOM)
# Temporary suppress "fallthrough" warnings until they are fixed in expat repo
if(GCC_NOT_5_2_0)
component_compile_options(-Wno-implicit-fallthrough)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough)
endif()

View file

@ -1,7 +1,5 @@
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(COMPONENT_SRCS "common/esp_modbus_master.c"
"common/esp_modbus_slave.c"
"modbus/mb.c"

View file

@ -25,7 +25,7 @@ set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
register_component()
target_link_libraries(${COMPONENT_TARGET} "-Wl,--undefined=uxTopUsedPriority")
target_link_libraries(${COMPONENT_LIB} "-Wl,--undefined=uxTopUsedPriority")
set_source_files_properties(
tasks.c

View file

@ -16,9 +16,7 @@ endif()
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
set(COMPONENT_REQUIRES "")
set(COMPONENT_PRIV_REQUIRES soc)
register_component()
if(CONFIG_HEAP_TRACING)
@ -34,7 +32,7 @@ if(CONFIG_HEAP_TRACING)
heap_caps_realloc_default)
foreach(wrap ${WRAP_FUNCTIONS})
target_link_libraries(${COMPONENT_TARGET} "-Wl,--wrap=${wrap}")
target_link_libraries(${COMPONENT_LIB} "-Wl,--wrap=${wrap}")
endforeach()
endif()

View file

@ -1,3 +1,2 @@
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES)
register_component()

View file

@ -1,6 +1,3 @@
set(COMPONENT_SRCS "src/jsmn.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES "")
register_component()

View file

@ -2,7 +2,4 @@ set(COMPONENT_SRCS "cJSON/cJSON.c"
"cJSON/cJSON_Utils.c"
"cJSON/test.c")
set(COMPONENT_ADD_INCLUDEDIRS cJSON)
set(COMPONENT_REQUIRES "")
register_component()

View file

@ -1,7 +1,4 @@
set(SRC libsodium/src/libsodium)
set(COMPONENT_REQUIRES "mbedtls")
# Derived from libsodium/src/libsodium/Makefile.am
# (ignoring the !MINIMAL set)
set(COMPONENT_SRCS "${SRC}/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c"
@ -129,9 +126,10 @@ endif()
set(COMPONENT_ADD_INCLUDEDIRS ${SRC}/include port_include)
set(COMPONENT_PRIV_INCLUDEDIRS ${SRC}/include/sodium port_include/sodium port)
set(COMPONENT_REQUIRES mbedtls vfs)
register_component()
component_compile_definitions(
target_compile_definitions(${COMPONENT_LIB} PRIVATE
CONFIGURED
NATIVE_LITTLE_ENDIAN
HAVE_WEAK_SYMBOLS

View file

@ -1,5 +1,4 @@
set(COMPONENT_SRCS "log.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES)
set(COMPONENT_PRIV_REQUIRES soc)
register_component()

View file

@ -130,7 +130,7 @@ set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
register_component()
# lots of LWIP source files evaluate macros that check address of stack variables
component_compile_options(-Wno-address)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-address)
if(GCC_NOT_5_2_0)
set_source_files_properties(

View file

@ -18,7 +18,7 @@ function(project)
endfunction()
# Needed to for include_next includes to work from within mbedtls
include_directories("${COMPONENT_PATH}/port/include")
include_directories("${COMPONENT_DIR}/port/include")
# Workaround issue with creating symbolic links due to issues with native
# path conversion (TO_NATIVE_PATH). The following summarizes what CMake invocations
@ -46,13 +46,14 @@ if(CMAKE_HOST_WIN32)
"mbedtls/scripts")
foreach(target_link ${target_links})
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${target_link} link)
file(TO_NATIVE_PATH ${COMPONENT_PATH}/${target_link} target)
file(TO_NATIVE_PATH ${COMPONENT_DIR}/${target_link} target)
idf_build_get_property(python PYTHON)
if(NOT EXISTS ${link})
if(IS_DIRECTORY ${target})
set(command ${PYTHON} ${COMPONENT_PATH}/mklink.py /j ${link} ${target})
set(command ${python} ${COMPONENT_DIR}/mklink.py /j ${link} ${target})
else()
set(command ${PYTHON} ${COMPONENT_PATH}/mklink.py /h ${link} ${target})
set(command ${python} ${COMPONENT_DIR}/mklink.py /h ${link} ${target})
endif()
execute_process(COMMAND ${command}
@ -78,35 +79,24 @@ set_property(TARGET mbedtls PROPERTY SOURCES ${src_tls})
set(mbedtls_targets mbedtls mbedcrypto mbedx509)
# Add port files to mbedtls targets
target_sources(mbedtls PRIVATE "${COMPONENT_PATH}/port/esp_bignum.c"
"${COMPONENT_PATH}/port/esp_hardware.c"
"${COMPONENT_PATH}/port/esp_mem.c"
target_sources(mbedtls PRIVATE "${COMPONENT_DIR}/port/esp_bignum.c"
"${COMPONENT_DIR}/port/esp_hardware.c"
"${COMPONENT_PATH}/port/esp_sha.c"
"${COMPONENT_PATH}/port/esp_sha1.c"
"${COMPONENT_PATH}/port/esp_sha256.c"
"${COMPONENT_PATH}/port/esp_sha512.c"
"${COMPONENT_PATH}/port/mbedtls_debug.c"
"${COMPONENT_PATH}/port/net_sockets.c"
"${COMPONENT_PATH}/port/esp32/aes.c"
"${COMPONENT_PATH}/port/esp32/sha.c")
"${COMPONENT_DIR}/port/esp_sha1.c"
"${COMPONENT_DIR}/port/esp_sha256.c"
"${COMPONENT_DIR}/port/esp_sha512.c"
"${COMPONENT_DIR}/port/mbedtls_debug.c"
"${COMPONENT_DIR}/port/net_sockets.c"
"${COMPONENT_DIR}/port/esp32/aes.c"
"${COMPONENT_DIR}/port/esp32/sha.c")
target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/esp_mem.c")
foreach(target ${mbedtls_targets})
# Propagate compile options to mbedtls library targets
target_include_directories(${target} PRIVATE "${IDF_INCLUDE_DIRECTORIES}")
target_compile_options(${target} PRIVATE "${IDF_COMPILE_OPTIONS};${IDF_C_COMPILE_OPTIONS}")
target_compile_definitions(${target} PRIVATE "${IDF_COMPILE_DEFINITIONS}")
target_compile_definitions(${target} PUBLIC -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h")
# The mbedtls targets also depends on core components
foreach(common ${MBEDTLS_PRIV_REQUIRES})
component_get_target(common_target ${common})
set_property(TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${common_target})
set_property(TARGET ${target} APPEND PROPERTY LINK_LIBRARIES ${common_target})
endforeach()
endforeach()
# Link mbedtls libraries to component library
target_link_libraries(${COMPONENT_TARGET} ${mbedtls_targets})
target_link_libraries(${COMPONENT_LIB} ${mbedtls_targets})
# Catch usage of deprecated mbedTLS functions when building tests
if(mbedtls_test IN_LIST BUILD_TEST_COMPONENTS)

View file

@ -63,12 +63,21 @@ list(APPEND COMPONENT_ADD_LDFRAGMENTS newlib.lf)
register_component()
if (LIB_PATH)
target_link_libraries(${COMPONENT_TARGET} "-L ${LIB_PATH}")
target_link_libraries(${COMPONENT_LIB} "-L ${LIB_PATH}")
endif()
if(GCC_NOT_5_2_0)
# Toolchain libraries require code defined in this component
add_library(extra INTERFACE)
idf_component_get_property(newlib newlib COMPONENT_LIB)
target_link_libraries(extra INTERFACE ${LIBC} ${LIBM} "$<TARGET_FILE:${newlib}>")
target_link_libraries(${COMPONENT_LIB} extra)
else()
target_link_libraries(${COMPONENT_LIB} ${LIBC} ${LIBM})
endif()
target_link_libraries(${COMPONENT_TARGET} ${LIBC} ${LIBM})
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
if(EXTRA_LINK_FLAGS)
target_link_libraries(${COMPONENT_TARGET} "${EXTRA_LINK_FLAGS}")
target_link_libraries(${COMPONENT_LIB} "${EXTRA_LINK_FLAGS}")
endif()

View file

@ -1,6 +1,8 @@
register_config_only_component()
if(NOT BOOTLOADER_BUILD AND IDF_BUILD_ARTIFACTS)
if(BOOTLOADER_BUILD)
return()
endif()
set(partition_csv "${PARTITION_CSV_PATH}")
@ -28,28 +30,31 @@ else()
set(partition_secure_opt "")
endif()
add_custom_command(OUTPUT "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}"
COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py"
idf_build_get_property(build_dir BUILD_DIR)
idf_build_get_property(python PYTHON)
add_custom_command(OUTPUT "${build_dir}/partition_table/${unsigned_partition_bin}"
COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py"
-q --offset ${PARTITION_TABLE_OFFSET} ${md5_opt} ${flashsize_opt}
${partition_secure_opt} ${partition_csv} ${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}
${partition_secure_opt} ${partition_csv} ${build_dir}/partition_table/${unsigned_partition_bin}
DEPENDS ${partition_csv} "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py"
VERBATIM)
# Add signing steps
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
add_custom_target(gen_unsigned_partition_bin ALL DEPENDS
"${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}")
"${build_dir}/partition_table/${unsigned_partition_bin}")
add_custom_command(OUTPUT "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin}"
add_custom_command(OUTPUT "${build_dir}/partition_table/${final_partition_bin}"
COMMAND ${ESPSECUREPY} sign_data --keyfile "${secure_boot_signing_key}"
-o "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin}"
"${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}"
DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}"
-o "${build_dir}/partition_table/${final_partition_bin}"
"${build_dir}/partition_table/${unsigned_partition_bin}"
DEPENDS "${build_dir}/partition_table/${unsigned_partition_bin}"
VERBATIM)
endif()
if(EXISTS ${partition_csv})
add_custom_target(partition_table ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin}")
add_custom_target(partition_table ALL DEPENDS "${build_dir}/partition_table/${final_partition_bin}")
else()
# If the partition input CSV is not found, create a phony partition_table target that
# fails the build. fail_at_build_time also touches CMakeCache.txt to cause a cmake run next time
@ -86,15 +91,12 @@ add_dependencies(app partition_table)
# the list of esptool write arguments for flashing
set_property(GLOBAL APPEND_STRING PROPERTY
ESPTOOL_WRITE_FLASH_ARGS
"${PARTITION_TABLE_OFFSET} ${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin} ")
"${PARTITION_TABLE_OFFSET} ${build_dir}/partition_table/${final_partition_bin} ")
esptool_py_flash_project_args(partition_table ${PARTITION_TABLE_OFFSET}
${IDF_BUILD_ARTIFACTS_DIR}/partition_table/partition-table.bin FLASH_IN_PROJECT)
${build_dir}/partition_table/partition-table.bin FLASH_IN_PROJECT)
if (NOT BOOTLOADER_BUILD)
partition_table_get_partition_info(app_partition_offset "--partition-boot-default" "offset")
esptool_py_flash_project_args(app ${app_partition_offset} ${CMAKE_BINARY_DIR}/${IDF_PROJECT_BIN} FLASH_IN_PROJECT)
endif()
esptool_py_flash_project_args(app ${app_partition_offset} ${build_dir}/${PROJECT_BIN} FLASH_IN_PROJECT)
endif()

View file

@ -4,9 +4,10 @@ set(PARTITION_TABLE_OFFSET ${CONFIG_PARTITION_TABLE_OFFSET})
# Set PARTITION_CSV_PATH to the configured partition CSV file
# absolute path
if(CONFIG_PARTITION_TABLE_CUSTOM)
idf_build_get_property(project_dir PROJECT_DIR)
# Custom filename expands any path relative to the project
get_filename_component(PARTITION_CSV_PATH "${CONFIG_PARTITION_TABLE_FILENAME}"
ABSOLUTE BASE_DIR "${IDF_PROJECT_PATH}")
ABSOLUTE BASE_DIR "${project_dir}")
if(NOT EXISTS "${PARTITION_CSV_PATH}")
message(WARNING "Partition table CSV file ${PARTITION_CSV_PATH} not found. "
@ -16,7 +17,7 @@ if(CONFIG_PARTITION_TABLE_CUSTOM)
endif()
else()
# Other .csv files are always in the component directory
get_filename_component(PARTITION_CSV_PATH "${COMPONENT_PATH}/${CONFIG_PARTITION_TABLE_FILENAME}" ABSOLUTE)
get_filename_component(PARTITION_CSV_PATH "${COMPONENT_DIR}/${CONFIG_PARTITION_TABLE_FILENAME}" ABSOLUTE)
if(NOT EXISTS "${PARTITION_CSV_PATH}")
message(FATAL_ERROR "Internal error, built-in ${PARTITION_CSV_PATH} not found.")
@ -25,14 +26,17 @@ endif()
# need to re-run CMake if the partition CSV changes, as the offsets/sizes of partitions may change
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PARTITION_CSV_PATH})
endif()
# partition_table_get_partition_info
#
# Get information about a partition from the partition table
function(partition_table_get_partition_info result get_part_info_args part_info)
idf_build_get_property(python PYTHON)
idf_build_get_property(idf_path IDF_PATH)
separate_arguments(get_part_info_args)
execute_process(COMMAND ${PYTHON}
${IDF_PATH}/components/partition_table/parttool.py -q
execute_process(COMMAND ${python}
${idf_path}/components/partition_table/parttool.py -q
--partition-table-offset ${PARTITION_TABLE_OFFSET}
--partition-table-file ${PARTITION_CSV_PATH}
${get_part_info_args} get_partition_info --info ${part_info}
@ -45,5 +49,3 @@ function(partition_table_get_partition_info result get_part_info_args part_info)
endif()
set(${result} ${info} PARENT_SCOPE)
endfunction()
endif()

View file

@ -2,9 +2,8 @@ set(COMPONENT_SRCS "pthread.c"
"pthread_cond_var.c"
"pthread_local_storage.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES)
register_component()
if(CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK)
target_link_libraries(${COMPONENT_TARGET} "-Wl,--wrap=vPortCleanUpTCB")
target_link_libraries(${COMPONENT_LIB} "-Wl,--wrap=vPortCleanUpTCB")
endif()

View file

@ -1,11 +1,11 @@
set(SOC_NAME ${IDF_TARGET})
idf_build_get_property(soc_name IDF_TARGET)
if(EXISTS "${COMPONENT_PATH}/${SOC_NAME}")
include(${COMPONENT_PATH}/${SOC_NAME}/sources.cmake)
if(EXISTS "${COMPONENT_DIR}/${soc_name}")
include(${COMPONENT_DIR}/${soc_name}/sources.cmake)
spaces2list(SOC_SRCS)
add_prefix(COMPONENT_SRCS "${SOC_NAME}/" ${SOC_SRCS})
set(COMPONENT_ADD_INCLUDEDIRS ${SOC_NAME}/include)
add_prefix(COMPONENT_SRCS "${soc_name}/" ${SOC_SRCS})
set(COMPONENT_ADD_INCLUDEDIRS ${soc_name}/include)
endif()
list(APPEND COMPONENT_ADD_INCLUDEDIRS include)

View file

@ -1,8 +1,8 @@
set(SOC_NAME ${IDF_TARGET})
set(SOC_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../${SOC_NAME}/test)
if(EXISTS "${SOC_TEST_DIR}")
set(COMPONENT_SRCDIRS "${SOC_TEST_DIR}")
set(COMPONENT_ADD_INCLUDEDIRS "${SOC_TEST_DIR}")
idf_build_get_property(soc_name IDF_TARGET)
get_filename_component(soc_test "${CMAKE_CURRENT_SOURCE_DIR}/../${soc_name}/test" ABSOLUTE)
if(EXISTS "${soc_test}")
set(COMPONENT_SRCS "${soc_test}")
set(COMPONENT_ADD_INCLUDEDIRS "${soc_test}")
endif()
set(COMPONENT_REQUIRES unity test_utils)

View file

@ -13,8 +13,6 @@ else()
endif()
set(COMPONENT_ADD_INCLUDEDIRS include)
set(COMPONENT_REQUIRES)
set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
register_component()

View file

@ -6,7 +6,8 @@ function(spiffs_create_partition_image partition base_dir)
set(options FLASH_IN_PROJECT)
cmake_parse_arguments(arg "${options}" "" "" "${ARGN}")
set(spiffsgen_py ${PYTHON} ${IDF_PATH}/components/spiffs/spiffsgen.py)
idf_build_get_property(idf_path IDF_PATH)
set(spiffsgen_py ${PYTHON} ${idf_path}/components/spiffs/spiffsgen.py)
get_filename_component(base_dir_full_path ${base_dir} ABSOLUTE)

View file

@ -1,7 +1,4 @@
set(COMPONENT_SRCS "ulp.c"
"ulp_macro.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES)
register_component()

View file

@ -38,7 +38,7 @@ foreach(include ${COMPONENT_INCLUDES})
endforeach()
list(APPEND ULP_PREPROCESSOR_ARGS ${component_includes})
list(APPEND ULP_PREPROCESSOR_ARGS -I${COMPONENT_PATH})
list(APPEND ULP_PREPROCESSOR_ARGS -I${COMPONENT_DIR})
list(APPEND ULP_PREPROCESSOR_ARGS -I${sdkconfig_dir})
include_directories(${component_includes})

View file

@ -25,19 +25,23 @@ if(NOT CMAKE_BUILD_EARLY_EXPANSION)
# the external ULP project. This is a workaround to the bug https://public.kitware.com/Bug/view.php?id=16137.
string(REPLACE ";" "|" ulp_s_sources "${ulp_s_sources}")
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
idf_build_get_property(idf_path IDF_PATH)
idf_build_get_property(python PYTHON)
externalproject_add(${ULP_APP_NAME}
SOURCE_DIR ${IDF_PATH}/components/ulp/cmake
SOURCE_DIR ${idf_path}/components/ulp/cmake
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}
INSTALL_COMMAND ""
CMAKE_ARGS -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
-DCMAKE_TOOLCHAIN_FILE=${IDF_PATH}/components/ulp/cmake/toolchain-ulp.cmake
-DCMAKE_TOOLCHAIN_FILE=${idf_path}/components/ulp/cmake/toolchain-ulp.cmake
-DULP_S_SOURCES=${ulp_s_sources} -DULP_APP_NAME=${ULP_APP_NAME}
-DCOMPONENT_PATH=${COMPONENT_PATH}
-DCOMPONENT_DIR=${COMPONENT_DIR}
# Even though this resolves to a ';' separated list, this is fine. This must be special behavior
# for generator expressions.
-DCOMPONENT_INCLUDES=$<TARGET_PROPERTY:${COMPONENT_TARGET},INTERFACE_INCLUDE_DIRECTORIES>
-DIDF_PATH=${IDF_PATH}
-DSDKCONFIG=${SDKCONFIG_HEADER}
-DCOMPONENT_INCLUDES=$<TARGET_PROPERTY:${COMPONENT_LIB},INTERFACE_INCLUDE_DIRECTORIES>
-DIDF_PATH=${idf_path}
-DSDKCONFIG=${sdkconfig_header}
-DPYTHON=${python}
BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME} --target build
BUILD_BYPRODUCTS ${ulp_artifacts} ${ulp_artifacts_extras} ${ulp_ps_sources}
${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}
@ -52,8 +56,8 @@ if(NOT CMAKE_BUILD_EARLY_EXPANSION)
add_custom_target(${ULP_APP_NAME}_artifacts DEPENDS ${ULP_APP_NAME})
add_dependencies(${COMPONENT_TARGET} ${ULP_APP_NAME}_artifacts)
add_dependencies(${COMPONENT_LIB} ${ULP_APP_NAME}_artifacts)
target_linker_script(${COMPONENT_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}.ld)
target_add_binary_data(${COMPONENT_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}.bin BINARY)
target_linker_script(${COMPONENT_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}.ld)
target_add_binary_data(${COMPONENT_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}.bin BINARY)
endif()

View file

@ -8,4 +8,5 @@ register_component()
set(ULP_APP_NAME ulp_test_app)
set(ULP_S_SOURCES "ulp/test_jumps.S")
set(ULP_EXP_DEP_SRCS "test_ulp_as.c")
include(${IDF_PATH}/components/ulp/component_ulp_common.cmake)
idf_build_get_property(idf_path IDF_PATH)
include(${idf_path}/components/ulp/component_ulp_common.cmake)

View file

@ -14,10 +14,10 @@ endif()
register_component()
target_compile_definitions(${COMPONENT_TARGET} PUBLIC
target_compile_definitions(${COMPONENT_LIB} PUBLIC
-DUNITY_INCLUDE_CONFIG_H
)
if(GCC_NOT_5_2_0)
component_compile_options(-Wno-unused-const-variable)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-const-variable)
endif()

View file

@ -2,7 +2,4 @@ set(COMPONENT_SRCS "vfs.c"
"vfs_uart.c"
"vfs_semihost.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES)
register_component()

View file

@ -79,8 +79,8 @@ set(COMPONENT_PRIV_REQUIRES mbedtls)
register_component()
component_compile_options(-Wno-strict-aliasing)
component_compile_definitions(
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-strict-aliasing)
target_compile_definitions(${COMPONENT_LIB} PRIVATE
__ets__
EMBEDDED_SUPP
IEEE8021X_EAPOL

View file

@ -7,4 +7,4 @@ set(COMPONENT_PRIV_REQUIRES soc)
register_component()
target_link_libraries(${COMPONENT_TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/${IDF_TARGET}/libhal.a")
target_link_libraries(${COMPONENT_LIB} "${CMAKE_CURRENT_SOURCE_DIR}/${IDF_TARGET}/libhal.a")