soc: esp32c3: prepare kconfigs and cmake to support mcuboot
This modifies esp32c3 SOC configuration to support MCUBoot. CmakeLists is moved from board to soc specific. It also includes MCUBoot changes. Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
This commit is contained in:
parent
245b8264e7
commit
f1e26219d0
6 changed files with 95 additions and 76 deletions
|
@ -1,66 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CONFIG_BOOTLOADER_ESP_IDF)
|
||||
include(ExternalProject)
|
||||
|
||||
## we use hello-world project, but I think any can be used.
|
||||
set(espidf_components_dir ${ESP_IDF_PATH}/components)
|
||||
set(espidf_prefix ${CMAKE_BINARY_DIR}/esp-idf)
|
||||
set(espidf_build_dir ${espidf_prefix}/build)
|
||||
|
||||
ExternalProject_Add(
|
||||
EspIdfBootloader
|
||||
PREFIX ${espidf_prefix}
|
||||
SOURCE_DIR ${espidf_components_dir}/bootloader/subproject
|
||||
BINARY_DIR ${espidf_build_dir}/bootloader
|
||||
CONFIGURE_COMMAND
|
||||
${CMAKE_COMMAND} -G${CMAKE_GENERATOR}
|
||||
-S ${espidf_components_dir}/bootloader/subproject
|
||||
-B ${espidf_build_dir}/bootloader -DSDKCONFIG=${espidf_build_dir}/sdkconfig
|
||||
-DIDF_PATH=${ESP_IDF_PATH} -DIDF_TARGET=${CONFIG_SOC}
|
||||
-DSDKCONFIG_DEFAULTS=${ESP_IDF_PATH}/zephyr/esp32c3/sdkconfig.defaults
|
||||
-DPYTHON_DEPS_CHECKED=1
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
|
||||
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
||||
-DPYTHON=${PYTHON_EXECUTABLE}
|
||||
BUILD_COMMAND
|
||||
${CMAKE_COMMAND} --build .
|
||||
INSTALL_COMMAND "" # This particular build system has no install command
|
||||
)
|
||||
|
||||
ExternalProject_Add(
|
||||
EspPartitionTable
|
||||
SOURCE_DIR ${espidf_components_dir}/partition_table
|
||||
BINARY_DIR ${espidf_build_dir}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND
|
||||
${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
|
||||
--offset 0x8000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
if(CONFIG_BUILD_OUTPUT_BIN)
|
||||
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
|
||||
ARGS --chip esp32c3 elf2image --flash_mode dio --flash_freq 40m
|
||||
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
|
||||
${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)
|
||||
endif()
|
||||
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag_inline_source)
|
||||
|
||||
add_dependencies(app EspIdfBootloader EspPartitionTable)
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-flash-bootloader=${espidf_build_dir}/bootloader/bootloader.bin")
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-flash-partition_table=${espidf_build_dir}/partitions_singleapp.bin")
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-boot-address=0x0000")
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-partition-table-address=0x8000")
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-app-address=0x10000")
|
||||
|
||||
endif()
|
|
@ -4,7 +4,7 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config BOARD
|
||||
default "esp32c3"
|
||||
default "esp32c3_devkitm"
|
||||
depends on BOARD_ESP32C3_DEVKITM
|
||||
|
||||
config ENTROPY_ESP32_RNG
|
||||
|
|
|
@ -8,7 +8,6 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
|
|||
CONFIG_CONSOLE=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
CONFIG_XIP=n
|
||||
CONFIG_PINMUX=y
|
||||
CONFIG_PINMUX_ESP32=y
|
||||
CONFIG_GPIO=y
|
||||
|
|
|
@ -6,4 +6,79 @@ zephyr_sources(
|
|||
soc_irq.S
|
||||
soc_irq.c
|
||||
soc.c
|
||||
loader.c
|
||||
)
|
||||
|
||||
if(CONFIG_BOOTLOADER_ESP_IDF)
|
||||
include(ExternalProject)
|
||||
|
||||
## we use hello-world project, but I think any can be used.
|
||||
set(espidf_components_dir ${ESP_IDF_PATH}/components)
|
||||
set(espidf_prefix ${CMAKE_BINARY_DIR}/esp-idf)
|
||||
set(espidf_build_dir ${espidf_prefix}/build)
|
||||
|
||||
ExternalProject_Add(
|
||||
EspIdfBootloader
|
||||
PREFIX ${espidf_prefix}
|
||||
SOURCE_DIR ${espidf_components_dir}/bootloader/subproject
|
||||
BINARY_DIR ${espidf_build_dir}/bootloader
|
||||
CONFIGURE_COMMAND
|
||||
${CMAKE_COMMAND} -G${CMAKE_GENERATOR}
|
||||
-S ${espidf_components_dir}/bootloader/subproject
|
||||
-B ${espidf_build_dir}/bootloader -DSDKCONFIG=${espidf_build_dir}/sdkconfig
|
||||
-DIDF_PATH=${ESP_IDF_PATH} -DIDF_TARGET=${CONFIG_SOC}
|
||||
-DPYTHON_DEPS_CHECKED=1
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
|
||||
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
||||
-DPYTHON=${PYTHON_EXECUTABLE}
|
||||
BUILD_COMMAND
|
||||
${CMAKE_COMMAND} --build .
|
||||
INSTALL_COMMAND "" # This particular build system has no install command
|
||||
)
|
||||
|
||||
ExternalProject_Add(
|
||||
EspPartitionTable
|
||||
SOURCE_DIR ${espidf_components_dir}/partition_table
|
||||
BINARY_DIR ${espidf_build_dir}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND
|
||||
${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
|
||||
--offset 0x8000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
if(CONFIG_BUILD_OUTPUT_BIN)
|
||||
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
|
||||
ARGS --chip esp32c3 elf2image --flash_mode dio --flash_freq 40m
|
||||
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
|
||||
${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)
|
||||
endif()
|
||||
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag_inline_source)
|
||||
|
||||
add_dependencies(app EspIdfBootloader EspPartitionTable)
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-flash-bootloader=${espidf_build_dir}/bootloader/bootloader.bin")
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-flash-partition_table=${espidf_build_dir}/partitions_singleapp.bin")
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-boot-address=0x0000")
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-partition-table-address=0x8000")
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-app-address=0x10000")
|
||||
|
||||
endif()
|
||||
|
||||
if(CONFIG_BOOTLOADER_MCUBOOT)
|
||||
|
||||
# get code-partition slot0 address
|
||||
dt_nodelabel(dts_partition_path NODELABEL "slot0_partition")
|
||||
dt_reg_addr(img_0_off PATH ${dts_partition_path})
|
||||
|
||||
board_finalize_runner_args(esp32 "--esp-app-address=${img_0_off}")
|
||||
|
||||
endif()
|
||||
|
|
|
@ -5,6 +5,25 @@
|
|||
|
||||
if SOC_ESP32C3
|
||||
|
||||
if BOOTLOADER_MCUBOOT
|
||||
|
||||
config HAS_FLASH_LOAD_OFFSET
|
||||
default y
|
||||
|
||||
config XIP
|
||||
default y
|
||||
|
||||
config MCUBOOT_GENERATE_UNSIGNED_IMAGE
|
||||
default y
|
||||
|
||||
config MCUBOOT_GENERATE_CONFIRMED_IMAGE
|
||||
default y
|
||||
|
||||
config ROM_START_OFFSET
|
||||
default 0x20
|
||||
|
||||
endif
|
||||
|
||||
config SOC
|
||||
default "esp32c3"
|
||||
|
||||
|
@ -23,9 +42,6 @@ config GEN_IRQ_VECTOR_TABLE
|
|||
config DYNAMIC_INTERRUPTS
|
||||
default y
|
||||
|
||||
config XIP
|
||||
default n
|
||||
|
||||
config ISR_STACK_SIZE
|
||||
default 2048
|
||||
|
||||
|
|
|
@ -18,8 +18,3 @@ config ESPTOOLPY_FLASHFREQ_80M
|
|||
bool
|
||||
default y
|
||||
depends on SOC_ESP32C3
|
||||
|
||||
config BOOTLOADER_ESP_IDF
|
||||
bool "Use esp-idf 2nd stage bootloader"
|
||||
default y
|
||||
depends on SOC_ESP32C3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue