esp32[c3|c6|h2]: Add nuttx toolchain support on mcuboot

This commit is contained in:
Eren Terzioglu 2024-07-03 10:57:04 +02:00 committed by Xiang Xiao
parent 786701c752
commit 553b1f5f5e
3 changed files with 50 additions and 3 deletions

View File

@ -34,6 +34,7 @@ BOOTLOADER_CONFIG = $(BOOTLOADER_SRCDIR)/bootloader.conf
MCUBOOT_SRCDIR = $(BOOTLOADER_SRCDIR)/mcuboot
MCUBOOT_ESPDIR = $(MCUBOOT_SRCDIR)/boot/espressif
MCUBOOT_URL = https://github.com/mcu-tools/mcuboot
MCUBOOT_TOOLCHAIN = $(TOOLSDIR)/mcuboot_toolchain_espressif.cmake
# Helpers for creating the configuration file
@ -95,7 +96,8 @@ $(BOOTLOADER_BIN): chip/$(ESP_HAL_3RDPARTY_REPO) $(MCUBOOT_SRCDIR) $(BOOTLOADER_
-c $(CHIP_SERIES) \
-f $(BOOTLOADER_CONFIG) \
-p $(BOOTLOADER_SRCDIR) \
-e $(HALDIR)
-e $(HALDIR) \
-d $(MCUBOOT_TOOLCHAIN)
$(call COPYFILE, $(BOOTLOADER_OUTDIR)/mcuboot-$(CHIP_SERIES).bin, $(TOPDIR))
bootloader: $(BOOTLOADER_CONFIG) $(BOOTLOADER_BIN)

View File

@ -11,6 +11,7 @@ usage() {
echo " -f <config> Path to file containing configuration options"
echo " -p <path> Path to execute the script"
echo " -e <hal> Path to HAL directory"
echo " -d <path> Path to toolchain file"
echo " -h Show usage and terminate"
echo ""
}
@ -22,7 +23,7 @@ build_mcuboot() {
local build_dir=".build-${target}"
local source_dir="boot/espressif"
local output_dir="${exec_path}/out"
local toolchain_file="tools/toolchain-${target}.cmake"
local toolchain_file="tools/nuttx-toolchain-${target}.cmake"
local mcuboot_config
local mcuboot_flashsize
local mcuboot_flashmode
@ -49,6 +50,12 @@ build_mcuboot() {
mcuboot_flashfreq="40m"
fi
if ! [ -z "${nuttx_toolchain}" ]; then
cp "${nuttx_toolchain}" "${mcuboot_dir}/${source_dir}/${toolchain_file}"
else
toolchain_file="tools/toolchain-${target}.cmake"
fi
pushd "${exec_path}" &>/dev/null
mkdir -p "${output_dir}" &>/dev/null
@ -84,7 +91,7 @@ build_mcuboot() {
popd &>/dev/null
}
while getopts ":hc:f:p:e:" arg; do
while getopts ":hc:f:p:e:d:" arg; do
case "${arg}" in
c)
chip=${OPTARG}
@ -98,6 +105,9 @@ while getopts ":hc:f:p:e:" arg; do
e)
esp_hal=${OPTARG}
;;
d)
nuttx_toolchain=${OPTARG}
;;
h)
usage
exit 0

View File

@ -0,0 +1,35 @@
# ##############################################################################
# tools/espressif/mcuboot_toolchain_espressif.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_C_COMPILER riscv-none-elf-gcc)
set(CMAKE_CXX_COMPILER riscv-none-elf-g++)
set(CMAKE_ASM_COMPILER riscv-none-elf-gcc)
set(CMAKE_C_FLAGS
"-march=rv32imc_zicsr_zifencei"
CACHE STRING "C Compiler Base Flags")
set(CMAKE_CXX_FLAGS
"-march=rv32imc_zicsr_zifencei"
CACHE STRING "C++ Compiler Base Flags")
set(CMAKE_EXE_LINKER_FLAGS
"-nostartfiles -march=rv32imc_zicsr_zifencei --specs=nosys.specs"
CACHE STRING "Linker Base Flags")