2019-06-13 05:55:51 -04:00
|
|
|
idf_build_get_property(target IDF_TARGET)
|
|
|
|
|
2021-06-02 23:59:00 -04:00
|
|
|
set(include_dirs "include" "include/${target}")
|
|
|
|
|
|
|
|
set(private_required_comp "")
|
|
|
|
|
|
|
|
set(sources "")
|
|
|
|
|
|
|
|
if(target STREQUAL "linux")
|
|
|
|
list(APPEND sources "${target}/esp_rom_sys.c"
|
|
|
|
"${target}/esp_rom_crc.c"
|
|
|
|
"${target}/esp_rom_md5.c"
|
|
|
|
"${target}/esp_rom_efuse.c")
|
|
|
|
else()
|
|
|
|
list(APPEND include_dirs "${target}")
|
|
|
|
list(APPEND sources "patches/esp_rom_crc.c"
|
|
|
|
"patches/esp_rom_sys.c"
|
2021-08-27 03:28:48 -04:00
|
|
|
"patches/esp_rom_uart.c"
|
|
|
|
"patches/esp_rom_tjpgd.c")
|
2021-06-02 23:59:00 -04:00
|
|
|
list(APPEND private_required_comp soc hal)
|
|
|
|
endif()
|
2021-04-08 00:16:17 -04:00
|
|
|
|
2021-06-10 23:56:58 -04:00
|
|
|
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
|
2021-04-08 00:16:17 -04:00
|
|
|
list(APPEND sources "patches/esp_rom_longjmp.S")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
idf_component_register(SRCS ${sources}
|
2021-06-02 23:59:00 -04:00
|
|
|
INCLUDE_DIRS ${include_dirs}
|
|
|
|
PRIV_REQUIRES ${private_required_comp})
|
2019-11-28 08:10:31 -05:00
|
|
|
|
2020-11-17 18:28:10 -05:00
|
|
|
# Append a target linker script at the target-specific path,
|
|
|
|
# only the 'name' part is different for each script
|
|
|
|
function(rom_linker_script name)
|
|
|
|
target_linker_script(${COMPONENT_LIB} INTERFACE "${target}/ld/${target}.rom.${name}.ld")
|
|
|
|
endfunction()
|
|
|
|
|
2021-06-02 23:59:00 -04:00
|
|
|
if(target STREQUAL "linux")
|
|
|
|
# We need to disable some warnings due to the ROM code's printf implementation
|
|
|
|
if(${CMAKE_CXX_COMPILER_VERSION} GREATER "7.0.0") # TODO: clang compatibility
|
|
|
|
target_compile_options(${COMPONENT_LIB} PUBLIC -Wimplicit-fallthrough=0 -Wno-shift-count-overflow)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
target_linker_script(${COMPONENT_LIB} INTERFACE "${target}/ld/${target}.rom.ld")
|
|
|
|
rom_linker_script("api")
|
|
|
|
rom_linker_script("libgcc")
|
|
|
|
endif()
|
2020-11-17 18:28:10 -05:00
|
|
|
|
2019-03-14 05:29:32 -04:00
|
|
|
if(BOOTLOADER_BUILD)
|
2020-11-17 18:28:10 -05:00
|
|
|
if(target STREQUAL "esp32")
|
|
|
|
rom_linker_script("newlib-funcs")
|
2021-09-01 15:12:49 -04:00
|
|
|
if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)
|
|
|
|
rom_linker_script("spiflash")
|
|
|
|
endif()
|
2020-11-17 18:28:10 -05:00
|
|
|
if(CONFIG_ESP32_REV_MIN_3)
|
|
|
|
rom_linker_script("eco3")
|
|
|
|
endif()
|
2020-11-25 23:47:32 -05:00
|
|
|
|
2020-11-17 18:28:10 -05:00
|
|
|
elseif(target STREQUAL "esp32s2")
|
|
|
|
rom_linker_script("newlib-funcs")
|
|
|
|
rom_linker_script("spiflash")
|
2019-08-07 23:44:24 -04:00
|
|
|
|
2020-11-17 18:28:10 -05:00
|
|
|
elseif(target STREQUAL "esp32s3")
|
2021-03-17 06:48:05 -04:00
|
|
|
rom_linker_script("newlib")
|
2020-06-10 07:07:48 -04:00
|
|
|
|
2020-11-17 18:28:10 -05:00
|
|
|
elseif(target STREQUAL "esp32c3")
|
2020-12-22 02:24:39 -05:00
|
|
|
rom_linker_script("newlib")
|
2021-06-10 00:53:34 -04:00
|
|
|
|
|
|
|
elseif(target STREQUAL "esp32h2")
|
|
|
|
rom_linker_script("newlib")
|
2021-11-06 05:21:57 -04:00
|
|
|
|
|
|
|
elseif(target STREQUAL "esp8684")
|
|
|
|
rom_linker_script("newlib")
|
|
|
|
rom_linker_script("mbedtls")
|
2020-11-25 23:47:32 -05:00
|
|
|
endif()
|
2019-06-13 05:55:51 -04:00
|
|
|
|
2020-11-17 18:28:10 -05:00
|
|
|
else() # Regular app build
|
2019-11-28 08:10:31 -05:00
|
|
|
if(target STREQUAL "esp32")
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("newlib-data")
|
|
|
|
rom_linker_script("syscalls")
|
2019-03-14 05:29:32 -04:00
|
|
|
|
2019-05-27 02:29:43 -04:00
|
|
|
if(NOT CONFIG_SPIRAM_CACHE_WORKAROUND)
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("newlib-funcs")
|
2020-01-09 23:58:54 -05:00
|
|
|
if(NOT CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS)
|
|
|
|
# If SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS option is defined
|
|
|
|
# then all time functions from the ROM memory will not be linked.
|
|
|
|
# Instead, those functions can be used from the toolchain by ESP-IDF.
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("newlib-time")
|
2020-01-09 23:58:54 -05:00
|
|
|
endif()
|
2019-03-14 05:29:32 -04:00
|
|
|
|
2020-02-07 05:35:37 -05:00
|
|
|
# Include in newlib nano from ROM only if SPIRAM cache workaround is disabled
|
|
|
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("newlib-nano")
|
2020-02-07 05:35:37 -05:00
|
|
|
endif()
|
|
|
|
|
2019-05-27 02:29:43 -04:00
|
|
|
endif()
|
2019-03-14 05:29:32 -04:00
|
|
|
|
2019-05-27 02:29:43 -04:00
|
|
|
if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("spiflash")
|
2019-05-27 02:29:43 -04:00
|
|
|
endif()
|
2019-03-29 00:37:51 -04:00
|
|
|
|
2020-02-24 14:51:41 -05:00
|
|
|
if(CONFIG_ESP32_REV_MIN_3)
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("eco3")
|
2020-02-24 14:51:41 -05:00
|
|
|
endif()
|
|
|
|
|
2020-01-16 22:47:08 -05:00
|
|
|
elseif(target STREQUAL "esp32s2")
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("newlib-funcs")
|
|
|
|
rom_linker_script("newlib-data")
|
|
|
|
rom_linker_script("spiflash")
|
2020-01-23 12:02:29 -05:00
|
|
|
|
|
|
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("newlib-nano")
|
2020-01-23 12:02:29 -05:00
|
|
|
endif()
|
2020-06-10 07:07:48 -04:00
|
|
|
|
2020-11-17 18:28:10 -05:00
|
|
|
# descirptors used by ROM code
|
|
|
|
target_sources(${COMPONENT_LIB} PRIVATE "esp32s2/usb_descriptors.c")
|
|
|
|
|
2020-06-10 07:07:48 -04:00
|
|
|
elseif(target STREQUAL "esp32s3")
|
2021-03-17 06:48:05 -04:00
|
|
|
rom_linker_script("newlib")
|
|
|
|
rom_linker_script("version")
|
2020-06-10 07:07:48 -04:00
|
|
|
|
|
|
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("newlib-nano")
|
2020-06-10 07:07:48 -04:00
|
|
|
endif()
|
|
|
|
|
2020-11-25 23:47:32 -05:00
|
|
|
elseif(target STREQUAL "esp32c3")
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("newlib")
|
|
|
|
rom_linker_script("version")
|
2020-11-25 23:47:32 -05:00
|
|
|
|
|
|
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
2020-11-17 18:28:10 -05:00
|
|
|
rom_linker_script("newlib-nano")
|
2020-11-25 23:47:32 -05:00
|
|
|
endif()
|
2021-03-02 22:57:58 -05:00
|
|
|
|
|
|
|
if(CONFIG_ESP32C3_REV_MIN_3)
|
|
|
|
rom_linker_script("eco3")
|
|
|
|
endif()
|
2021-06-10 00:53:34 -04:00
|
|
|
|
|
|
|
elseif(target STREQUAL "esp32h2")
|
|
|
|
rom_linker_script("newlib")
|
|
|
|
rom_linker_script("version")
|
|
|
|
|
2021-11-06 05:21:57 -04:00
|
|
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
|
|
|
rom_linker_script("newlib-nano")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
elseif(target STREQUAL "esp8684")
|
|
|
|
rom_linker_script("newlib")
|
|
|
|
rom_linker_script("version")
|
|
|
|
rom_linker_script("mbedtls")
|
|
|
|
|
2021-06-10 00:53:34 -04:00
|
|
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
|
|
|
rom_linker_script("newlib-nano")
|
|
|
|
endif()
|
2019-03-14 05:29:32 -04:00
|
|
|
endif()
|
2019-05-27 02:29:43 -04:00
|
|
|
|
2021-06-10 23:56:58 -04:00
|
|
|
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
|
2021-04-08 00:16:17 -04:00
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=longjmp")
|
|
|
|
endif()
|
2019-03-14 05:29:32 -04:00
|
|
|
endif()
|
2020-04-30 09:19:56 -04:00
|
|
|
|
|
|
|
if(target STREQUAL "esp32s2")
|
|
|
|
target_sources(${COMPONENT_LIB} PRIVATE "esp32s2/usb_descriptors.c")
|
|
|
|
endif()
|