2019-08-18 01:31:09 -04:00
|
|
|
set(srcs
|
2019-06-21 02:29:32 -04:00
|
|
|
"src/bootloader_clock.c"
|
|
|
|
"src/bootloader_common.c"
|
|
|
|
"src/bootloader_flash.c"
|
|
|
|
"src/bootloader_random.c"
|
|
|
|
"src/bootloader_utility.c"
|
|
|
|
"src/esp_image_format.c"
|
|
|
|
"src/flash_partitions.c"
|
2019-08-07 23:44:24 -04:00
|
|
|
"src/flash_qio_mode.c"
|
2019-08-09 01:26:49 -04:00
|
|
|
"src/bootloader_flash_config_${IDF_TARGET}.c"
|
2019-10-02 13:19:26 -04:00
|
|
|
"src/bootloader_efuse_${IDF_TARGET}.c"
|
2019-08-07 23:44:24 -04:00
|
|
|
)
|
2018-01-11 21:49:13 -05:00
|
|
|
|
2019-08-18 01:31:09 -04:00
|
|
|
if(IDF_TARGET STREQUAL "esp32")
|
2019-08-08 00:00:45 -04:00
|
|
|
# Not supported on ESP32S2Beta yet
|
|
|
|
list(APPEND srcs "src/flash_encrypt.c")
|
|
|
|
endif()
|
2018-01-11 21:49:13 -05:00
|
|
|
|
2019-05-09 22:53:08 -04:00
|
|
|
if(BOOTLOADER_BUILD)
|
2019-04-28 03:38:23 -04:00
|
|
|
set(include_dirs "include" "include_bootloader")
|
2019-08-08 01:33:45 -04:00
|
|
|
# freertos is included just for the CONFIG_FREERTOS_UNICORE macro
|
|
|
|
set(priv_requires micro-ecc spi_flash efuse freertos)
|
2019-08-07 23:44:24 -04:00
|
|
|
list(APPEND srcs
|
2019-06-21 02:29:32 -04:00
|
|
|
"src/bootloader_init.c"
|
|
|
|
"src/${IDF_TARGET}/bootloader_sha.c"
|
|
|
|
"src/${IDF_TARGET}/flash_encrypt.c"
|
|
|
|
"src/${IDF_TARGET}/secure_boot_signatures.c"
|
2019-08-07 23:44:24 -04:00
|
|
|
"src/${IDF_TARGET}/secure_boot.c"
|
|
|
|
"src/${IDF_TARGET}/bootloader_${IDF_TARGET}.c"
|
|
|
|
)
|
2018-01-11 21:49:13 -05:00
|
|
|
else()
|
2019-08-07 23:44:24 -04:00
|
|
|
list(APPEND srcs
|
2019-06-21 02:29:32 -04:00
|
|
|
"src/idf/bootloader_sha.c"
|
|
|
|
"src/idf/secure_boot_signatures.c")
|
2019-04-28 03:38:23 -04:00
|
|
|
set(include_dirs "include")
|
|
|
|
set(priv_include_dirs "include_bootloader")
|
|
|
|
set(priv_requires spi_flash mbedtls efuse)
|
2018-01-11 21:49:13 -05:00
|
|
|
endif()
|
|
|
|
|
2019-08-07 23:44:24 -04:00
|
|
|
set(requires soc) #unfortunately the header directly uses SOC registers
|
2018-10-19 15:02:55 -04:00
|
|
|
|
2019-04-28 03:38:23 -04:00
|
|
|
idf_component_register(SRCS "${srcs}"
|
|
|
|
INCLUDE_DIRS "${include_dirs}"
|
|
|
|
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
|
|
|
REQUIRES "${requires}"
|
2019-05-08 22:25:08 -04:00
|
|
|
PRIV_REQUIRES "${priv_requires}")
|
|
|
|
|
|
|
|
if(BOOTLOADER_BUILD AND CONFIG_SECURE_SIGNED_APPS)
|
2019-05-10 03:25:25 -04:00
|
|
|
# Whether CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES or not, we need verification key to embed
|
|
|
|
# in the library.
|
2019-05-08 22:25:08 -04:00
|
|
|
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
|
2019-05-10 03:25:25 -04:00
|
|
|
# We generate the key from the signing key. The signing key is passed from the main project.
|
|
|
|
get_filename_component(secure_boot_signing_key
|
|
|
|
"${SECURE_BOOT_SIGNING_KEY}"
|
|
|
|
ABSOLUTE BASE_DIR "${project_dir}")
|
2018-10-19 15:02:55 -04:00
|
|
|
get_filename_component(secure_boot_verification_key
|
|
|
|
"signature_verification_key.bin"
|
2019-05-10 03:25:25 -04:00
|
|
|
ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
2019-05-08 22:25:08 -04:00
|
|
|
add_custom_command(OUTPUT "${secure_boot_verification_key}"
|
|
|
|
COMMAND ${ESPSECUREPY}
|
|
|
|
extract_public_key --keyfile "${secure_boot_signing_key}"
|
|
|
|
"${secure_boot_verification_key}"
|
|
|
|
VERBATIM)
|
|
|
|
else()
|
2019-05-10 03:25:25 -04:00
|
|
|
# We expect to 'inherit' the verification key passed from main project.
|
|
|
|
get_filename_component(secure_boot_verification_key
|
|
|
|
${SECURE_BOOT_VERIFICATION_KEY}
|
|
|
|
ABSOLUTE BASE_DIR "${project_dir}")
|
2018-10-19 15:02:55 -04:00
|
|
|
endif()
|
2018-01-11 21:49:13 -05:00
|
|
|
|
2019-05-08 22:25:08 -04:00
|
|
|
target_add_binary_data(${COMPONENT_LIB} "${secure_boot_verification_key}" "BINARY")
|
|
|
|
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
|
|
|
|
"${secure_boot_verification_key}")
|
|
|
|
endif()
|