Commit 523ef3fc authored by Gustavo Henrique Nihei's avatar Gustavo Henrique Nihei Committed by Gustavo Henrique Nihei
Browse files

espressif: Add support for hardware Secure Boot

parent ce3668fd
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
# Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0

@@ -23,3 +23,14 @@ CONFIG_ESP_SCRATCH_SIZE=0x40000
# It is strongly recommended to generate a new signing key
# using imgtool instead of use the existent sample
# CONFIG_ESP_SIGN_KEY_FILE=root-ec-p256.pem

# Hardware Secure Boot related options
# CONFIG_SECURE_SIGNED_ON_BOOT=1
# CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME=1
# CONFIG_SECURE_BOOT=1
# CONFIG_SECURE_BOOT_V2_ENABLED=1
# CONFIG_SECURE_BOOT_SUPPORTS_RSA=1

# Options for enabling eFuse emulation in Flash
# CONFIG_EFUSE_VIRTUAL=1
# CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH=1
+33 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ list(APPEND include_dirs
    ${esp_idf_dir}/components/heap/include
    ${esp_idf_dir}/components/efuse/include
    ${esp_idf_dir}/components/efuse/${MCUBOOT_TARGET}/include
    ${esp_idf_dir}/components/efuse/private_include
    ${esp_idf_dir}/components/efuse/${MCUBOOT_TARGET}/private_include
    ${esp_idf_dir}/components/newlib/platform_include
    )

@@ -53,14 +55,23 @@ endif()

set(hal_srcs
    ${src_dir}/bootloader_wdt.c
    ${src_dir}/secure_boot.c
    ${src_dir}/${MCUBOOT_TARGET}/bootloader_init.c
    ${esp_idf_dir}/components/hal/mpu_hal.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_common_loader.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_console_loader.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_flash.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_flash_config_${MCUBOOT_TARGET}.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_clock_init.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_efuse_${MCUBOOT_TARGET}.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_panic.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_mem.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_random.c
    ${esp_idf_dir}/components/bootloader_support/src/bootloader_utility.c
    ${esp_idf_dir}/components/bootloader_support/src/esp_image_format.c
    ${esp_idf_dir}/components/bootloader_support/src/secure_boot_v2/secure_boot_signatures_bootloader.c
    ${esp_idf_dir}/components/bootloader_support/src/${MCUBOOT_TARGET}/bootloader_sha.c
    ${esp_idf_dir}/components/bootloader_support/src/${MCUBOOT_TARGET}/secure_boot_secure_features.c
    ${esp_idf_dir}/components/spi_flash/${MCUBOOT_TARGET}/spi_flash_rom_patch.c
    ${esp_idf_dir}/components/esp_hw_support/esp_clk.c
    ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_init.c
@@ -71,8 +82,24 @@ set(hal_srcs
    ${esp_idf_dir}/components/esp_hw_support/cpu_util.c
    ${esp_idf_dir}/components/esp_rom/patches/esp_rom_uart.c
    ${esp_idf_dir}/components/esp_rom/patches/esp_rom_sys.c
    ${esp_idf_dir}/components/efuse/${MCUBOOT_TARGET}/esp_efuse_table.c
    ${esp_idf_dir}/components/efuse/src/esp_efuse_fields.c
    ${esp_idf_dir}/components/efuse/${MCUBOOT_TARGET}/esp_efuse_fields.c
    ${esp_idf_dir}/components/efuse/src/esp_efuse_api.c
    ${esp_idf_dir}/components/efuse/src/esp_efuse_utility.c
    ${esp_idf_dir}/components/efuse/${MCUBOOT_TARGET}/esp_efuse_utility.c
    )

if("${MCUBOOT_TARGET}" STREQUAL "esp32")
    list(APPEND hal_srcs
        ${esp_idf_dir}/components/efuse/src/esp_efuse_api_key_esp32.c
        )
else()
    list(APPEND hal_srcs
        ${esp_idf_dir}/components/efuse/src/esp_efuse_api_key_esp32xx.c
        )
endif()

if("${MCUBOOT_ARCH}" STREQUAL "xtensa")
    list(APPEND hal_srcs
        ${esp_idf_dir}/components/esp_rom/patches/esp_rom_longjmp.S
@@ -145,6 +172,12 @@ set(LINKER_SCRIPTS
    -T${esp_idf_dir}/components/soc/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.peripherals.ld
    )

if("${MCUBOOT_TARGET}" STREQUAL "esp32" OR "${MCUBOOT_TARGET}" STREQUAL "esp32c3")
    list(APPEND LINKER_SCRIPTS
        -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.eco3.ld
        )
endif()

include(${CMAKE_CURRENT_LIST_DIR}/include/${MCUBOOT_TARGET}/${MCUBOOT_TARGET}.cmake)

add_library(hal STATIC ${hal_srcs} ${include_dirs})
+8 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
 * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#define BOOTLOADER_BUILD 1
#define CONFIG_IDF_FIRMWARE_CHIP_ID 0x0000
#define CONFIG_IDF_TARGET_ESP32 1
#define CONFIG_ESP32_REV_MIN_3 1
#define CONFIG_ESP32_REV_MIN 3
#define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1
#define CONFIG_ESP32_XTAL_FREQ 40
#define CONFIG_MCUBOOT 1
@@ -13,3 +16,7 @@
#define CONFIG_BOOTLOADER_WDT_TIME_MS 9000
#define CONFIG_ESP_CONSOLE_UART_BAUDRATE 115200
#define CONFIG_BOOTLOADER_OFFSET_IN_FLASH 0x1000
#define CONFIG_PARTITION_TABLE_OFFSET 0xE000
#define CONFIG_EFUSE_VIRTUAL_OFFSET 0xE000
#define CONFIG_EFUSE_VIRTUAL_SIZE 0x2000
#define CONFIG_EFUSE_MAX_BLK_LEN 192
+12 −1
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#define BOOTLOADER_BUILD 1
#define CONFIG_IDF_FIRMWARE_CHIP_ID 0x0005
#define CONFIG_IDF_TARGET_ESP32C3 1
#define CONFIG_IDF_TARGET_ARCH_RISCV 1
#define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1
@@ -6,4 +14,7 @@
#define CONFIG_BOOTLOADER_WDT_TIME_MS 9000
#define CONFIG_ESP_CONSOLE_UART_BAUDRATE 115200
#define CONFIG_BOOTLOADER_OFFSET_IN_FLASH 0x0000
#define BOOTLOADER_BUILD 1
#define CONFIG_PARTITION_TABLE_OFFSET 0xE000
#define CONFIG_EFUSE_VIRTUAL_OFFSET 0xE000
#define CONFIG_EFUSE_VIRTUAL_SIZE 0x2000
#define CONFIG_EFUSE_MAX_BLK_LEN 256
+6 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
 * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#define BOOTLOADER_BUILD 1
#define CONFIG_IDF_FIRMWARE_CHIP_ID 0x0002
#define CONFIG_IDF_TARGET_ESP32S2 1
#define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1
#define CONFIG_ESP32S2_XTAL_FREQ 40
@@ -13,3 +14,7 @@
#define CONFIG_BOOTLOADER_WDT_TIME_MS 9000
#define CONFIG_ESP_CONSOLE_UART_BAUDRATE 115200
#define CONFIG_BOOTLOADER_OFFSET_IN_FLASH 0x1000
#define CONFIG_PARTITION_TABLE_OFFSET 0xE000
#define CONFIG_EFUSE_VIRTUAL_OFFSET 0xE000
#define CONFIG_EFUSE_VIRTUAL_SIZE 0x2000
#define CONFIG_EFUSE_MAX_BLK_LEN 256
Loading