From a9082e0882fa52f0fe77873f519d7daac2f0ffc2 Mon Sep 17 00:00:00 2001 From: Eren Terzioglu Date: Wed, 3 Jul 2024 11:43:06 +0200 Subject: [PATCH] esp32[s2]: Add nuttx toolchain support on mcuboot --- arch/xtensa/src/esp32s2/Bootloader.mk | 4 ++- tools/esp32s2/mcuboot_toolchain_esp32s2.cmake | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tools/esp32s2/mcuboot_toolchain_esp32s2.cmake diff --git a/arch/xtensa/src/esp32s2/Bootloader.mk b/arch/xtensa/src/esp32s2/Bootloader.mk index abfe536fcc..ae5709f46c 100644 --- a/arch/xtensa/src/esp32s2/Bootloader.mk +++ b/arch/xtensa/src/esp32s2/Bootloader.mk @@ -36,6 +36,7 @@ BOOTLOADER_CONFIG = $(BOOTLOADER_DIR)/bootloader.conf MCUBOOT_SRCDIR = $(BOOTLOADER_DIR)/mcuboot MCUBOOT_ESPDIR = $(MCUBOOT_SRCDIR)/boot/espressif MCUBOOT_URL = https://github.com/mcu-tools/mcuboot +MCUBOOT_TOOLCHAIN = $(TOPDIR)/tools/esp32s2/mcuboot_toolchain_esp32s2.cmake $(BOOTLOADER_DIR): $(Q) mkdir -p $(BOOTLOADER_DIR) &>/dev/null @@ -128,7 +129,8 @@ $(BOOTLOADER_BIN): chip/$(ESP_HAL_3RDPARTY_REPO) $(MCUBOOT_SRCDIR) $(BOOTLOADER_ -c esp32s2 \ -f $(BOOTLOADER_CONFIG) \ -p $(BOOTLOADER_DIR) \ - -e $(HALDIR) + -e $(HALDIR) \ + -d $(MCUBOOT_TOOLCHAIN) $(call COPYFILE, $(BOOTLOADER_DIR)/$(BOOTLOADER_OUTDIR)/mcuboot-esp32s2.bin, $(TOPDIR)) bootloader: $(BOOTLOADER_CONFIG) $(BOOTLOADER_BIN) diff --git a/tools/esp32s2/mcuboot_toolchain_esp32s2.cmake b/tools/esp32s2/mcuboot_toolchain_esp32s2.cmake new file mode 100644 index 0000000000..29e825cf73 --- /dev/null +++ b/tools/esp32s2/mcuboot_toolchain_esp32s2.cmake @@ -0,0 +1,36 @@ +# ############################################################################## +# tools/esp32s2/mcuboot_toolchain_esp32s2.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 xtensa-esp32s2-elf-gcc) +set(CMAKE_CXX_COMPILER xtensa-esp32s2-elf-g++) +set(CMAKE_ASM_COMPILER xtensa-esp32s2-elf-gcc) + +set(CMAKE_C_FLAGS + "-mlongcalls" + CACHE STRING "C Compiler Base Flags") +set(CMAKE_CXX_FLAGS + "-mlongcalls" + CACHE STRING "C++ Compiler Base Flags") + +set(CMAKE_EXE_LINKER_FLAGS + "-Wl,--gc-sections" + CACHE STRING "Linker Base Flags")