2019-08-08 14:00:45 +10:00
|
|
|
idf_build_get_property(target IDF_TARGET)
|
2020-01-17 11:47:08 +08:00
|
|
|
if(NOT "${target}" STREQUAL "esp32s2")
|
2019-08-08 14:00:45 +10:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2021-03-19 20:03:13 +08:00
|
|
|
if(NOT BOOTLOADER_BUILD)
|
|
|
|
# [refactor-todo] propagate these requirements for compatibility
|
|
|
|
# remove in the future
|
|
|
|
set(legacy_reqs driver efuse soc)
|
|
|
|
endif()
|
2019-05-10 11:34:06 +08:00
|
|
|
|
2021-03-19 20:03:13 +08:00
|
|
|
idf_component_register(INCLUDE_DIRS include
|
|
|
|
REQUIRES xtensa "${legacy_reqs}"
|
|
|
|
REQUIRED_IDF_TARGETS esp32s2)
|
2019-05-10 11:34:06 +08:00
|
|
|
|
2021-03-19 20:03:13 +08:00
|
|
|
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32s2.peripherals.ld")
|
2019-05-10 11:34:06 +08:00
|
|
|
|
2021-03-19 20:03:13 +08:00
|
|
|
if(NOT BOOTLOADER_BUILD)
|
|
|
|
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
|
2020-01-17 11:47:08 +08:00
|
|
|
target_linker_script(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/esp32s2_out.ld")
|
2019-05-10 11:34:06 +08:00
|
|
|
|
|
|
|
# Process the template file through the linker script generation mechanism, and use the output for linking the
|
|
|
|
# final binary
|
2020-11-10 17:51:08 +11:00
|
|
|
target_linker_script(${COMPONENT_LIB} INTERFACE
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/ld/esp32s2.project.ld.in"
|
|
|
|
PROCESS "${CMAKE_CURRENT_BINARY_DIR}/ld/esp32s2.project.ld")
|
2019-05-10 11:34:06 +08:00
|
|
|
|
2020-01-17 11:47:08 +08:00
|
|
|
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32s2.peripherals.ld")
|
2019-05-10 11:34:06 +08:00
|
|
|
|
2020-02-07 13:08:34 +01:00
|
|
|
idf_build_get_property(config_dir CONFIG_DIR)
|
2020-01-17 11:47:08 +08:00
|
|
|
# Preprocess esp32s2.ld linker script to include configuration, becomes esp32s2_out.ld
|
2019-05-10 11:34:06 +08:00
|
|
|
set(LD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ld)
|
|
|
|
add_custom_command(
|
2020-01-17 11:47:08 +08:00
|
|
|
OUTPUT esp32s2_out.ld
|
|
|
|
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32s2_out.ld -I ${config_dir} ${LD_DIR}/esp32s2.ld
|
2021-03-01 12:30:50 +08:00
|
|
|
MAIN_DEPENDENCY ${LD_DIR}/esp32s2.ld
|
|
|
|
DEPENDS ${sdkconfig_header}
|
2019-05-10 11:34:06 +08:00
|
|
|
COMMENT "Generating linker script..."
|
|
|
|
VERBATIM)
|
|
|
|
|
2020-01-17 11:47:08 +08:00
|
|
|
add_custom_target(esp32s2_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32s2_out.ld)
|
|
|
|
add_dependencies(${COMPONENT_LIB} esp32s2_linker_script)
|
2019-05-10 11:34:06 +08:00
|
|
|
endif()
|