This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 4df395bfc cmake: add support for boot utils
4df395bfc is described below

commit 4df395bfc4fc132270a7d040b9a379ebe629f79b
Author: raiden00pl <raide...@railab.me>
AuthorDate: Thu Jul 13 11:37:39 2023 +0200

    cmake: add support for boot utils
---
 boot/CMakeLists.txt                                |   2 +
 boot/mcuboot/CMakeLists.txt                        | 111 +++++++++++++++++++++
 boot/{ => miniboot}/CMakeLists.txt                 |  10 +-
 {boot => examples/mcuboot}/CMakeLists.txt          |   6 +-
 .../mcuboot/slot_confirm}/CMakeLists.txt           |   9 +-
 .../mcuboot/swap_test}/CMakeLists.txt              |  19 +++-
 .../mcuboot/update_agent}/CMakeLists.txt           |   9 +-
 7 files changed, 156 insertions(+), 10 deletions(-)

diff --git a/boot/CMakeLists.txt b/boot/CMakeLists.txt
index ce82730ee..50b7ba7c4 100644
--- a/boot/CMakeLists.txt
+++ b/boot/CMakeLists.txt
@@ -18,4 +18,6 @@
 #
 # 
##############################################################################
 
+nuttx_add_subdirectory()
+
 nuttx_generate_kconfig(MENUDESC "Bootloader Utilities")
diff --git a/boot/mcuboot/CMakeLists.txt b/boot/mcuboot/CMakeLists.txt
new file mode 100644
index 000000000..4b0d73d1d
--- /dev/null
+++ b/boot/mcuboot/CMakeLists.txt
@@ -0,0 +1,111 @@
+# 
##############################################################################
+# apps/boot/mcuboot/CMakeLists.txt
+#
+# 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.
+#
+# 
##############################################################################
+
+if(CONFIG_BOOT_MCUBOOT)
+  nuttx_add_library(mcuboot)
+
+  if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/mcuboot)
+    FetchContent_Declare(
+      mcuboot
+      DOWNLOAD_NAME "${CONFIG_MCUBOOT_VERSION}.tar.gz"
+      DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
+      URL 
"https://github.com/mcu-tools/mcuboot/archive/${CONFIG_MCUBOOT_VERSION}.tar.gz";
+      SOURCE_DIR
+      ${CMAKE_CURRENT_LIST_DIR}/mcuboot
+      BINARY_DIR
+      ${CMAKE_BINARY_DIR}/apps/boot/mcuboot/mcuboot
+      CONFIGURE_COMMAND
+      ""
+      BUILD_COMMAND
+      ""
+      INSTALL_COMMAND
+      ""
+      TEST_COMMAND
+      ""
+      DOWNLOAD_NO_PROGRESS true
+      TIMEOUT 30)
+
+    FetchContent_GetProperties(mcuboot)
+
+    if(NOT mcuboot_POPULATED)
+      FetchContent_Populate(mcuboot)
+    endif()
+  endif()
+
+  set(SRCS
+    mcuboot/boot/bootutil/src/boot_record.c
+    mcuboot/boot/bootutil/src/bootutil_misc.c
+    mcuboot/boot/bootutil/src/bootutil_public.c
+    mcuboot/boot/bootutil/src/caps.c
+    mcuboot/boot/bootutil/src/encrypted.c
+    mcuboot/boot/bootutil/src/fault_injection_hardening.c
+    mcuboot/boot/bootutil/src/fault_injection_hardening_delay_rng_mbedtls.c
+    mcuboot/boot/bootutil/src/image_ec.c
+    mcuboot/boot/bootutil/src/image_ec256.c
+    mcuboot/boot/bootutil/src/image_ed25519.c
+    mcuboot/boot/bootutil/src/image_rsa.c
+    mcuboot/boot/bootutil/src/image_validate.c
+    mcuboot/boot/bootutil/src/loader.c
+    mcuboot/boot/bootutil/src/swap_misc.c
+    mcuboot/boot/bootutil/src/swap_move.c
+    mcuboot/boot/bootutil/src/swap_scratch.c
+    mcuboot/boot/bootutil/src/tlv.c
+  )
+
+  list(APPEND SRCS 
mcuboot/boot/nuttx/src/flash_map_backend/flash_map_backend.c)
+
+  if(CONFIG_MCUBOOT_BOOTLOADER)
+    nuttx_add_application(
+      NAME
+      mcuboot_loader
+      SRCS
+      ${CMAKE_CURRENT_LIST_DIR}/mcuboot/boot/nuttx/main.c
+      INCLUDE_DIRECTORIES
+      mcuboot/boot/bootutil/include
+      mcuboot/boot/nuttx/include
+      STACKSIZE
+      ${CONFIG_DEFAULT_TASK_STACKSIZE}
+      PRIORITY
+      SCHED_PRIORITY_DEFAULT)
+  endif()
+
+  if(CONFIG_MCUBOOT_WATCHDOG)
+    list(APPEND SRCS mcuboot/boot/nuttx/src/watchdog/watchdog.c)
+  endif()
+
+  if(CONFIG_MCUBOOT_USE_TINYCRYPT)
+    list(APPEND SRCS
+      mcuboot/ext/tinycrypt/lib/source/aes_encrypt.c
+      mcuboot/ext/tinycrypt/lib/source/aes_decrypt.c
+      mcuboot/ext/tinycrypt/lib/source/ctr_mode.c
+      mcuboot/ext/tinycrypt/lib/source/hmac.c
+      mcuboot/ext/tinycrypt/lib/source/ecc_dh.c
+      mcuboot/ext/tinycrypt/lib/source/sha256.c
+      mcuboot/ext/tinycrypt/lib/source/utils.c
+    )
+    target_include_directories(mcuboot PRIVATE 
mcuboot/ext/tinycrypt/lib/include)
+  endif()
+
+  target_include_directories(mcuboot PUBLIC mcuboot/boot/nuttx/include)
+  target_include_directories(mcuboot PUBLIC mcuboot/boot/bootutil/include)
+
+  target_compile_options(mcuboot PRIVATE -Wno-undef)
+  target_sources(mcuboot PRIVATE ${SRCS})
+endif()
diff --git a/boot/CMakeLists.txt b/boot/miniboot/CMakeLists.txt
similarity index 86%
copy from boot/CMakeLists.txt
copy to boot/miniboot/CMakeLists.txt
index ce82730ee..e23c6ddaa 100644
--- a/boot/CMakeLists.txt
+++ b/boot/miniboot/CMakeLists.txt
@@ -1,5 +1,5 @@
 # 
##############################################################################
-# apps/boot/CMakeLists.txt
+# apps/boot/miniboot/CMakeLists.txt
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
 # license agreements.  See the NOTICE file distributed with this work for
@@ -18,4 +18,10 @@
 #
 # 
##############################################################################
 
-nuttx_generate_kconfig(MENUDESC "Bootloader Utilities")
+if(CONFIG_BOOT_MINIBOOT)
+  nuttx_add_application(
+    NAME
+    miniboot
+    SRCS
+    miniboot_main.c)
+endif()
diff --git a/boot/CMakeLists.txt b/examples/mcuboot/CMakeLists.txt
similarity index 88%
copy from boot/CMakeLists.txt
copy to examples/mcuboot/CMakeLists.txt
index ce82730ee..26f891869 100644
--- a/boot/CMakeLists.txt
+++ b/examples/mcuboot/CMakeLists.txt
@@ -1,5 +1,5 @@
 # 
##############################################################################
-# apps/boot/CMakeLists.txt
+# apps/examples/mcuboot/CMakeLists.txt
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
 # license agreements.  See the NOTICE file distributed with this work for
@@ -18,4 +18,6 @@
 #
 # 
##############################################################################
 
-nuttx_generate_kconfig(MENUDESC "Bootloader Utilities")
+nuttx_add_subdirectory()
+
+nuttx_generate_kconfig(MENUDESC "MCUboot Examples")
diff --git a/boot/CMakeLists.txt b/examples/mcuboot/slot_confirm/CMakeLists.txt
similarity index 80%
copy from boot/CMakeLists.txt
copy to examples/mcuboot/slot_confirm/CMakeLists.txt
index ce82730ee..415556ffa 100644
--- a/boot/CMakeLists.txt
+++ b/examples/mcuboot/slot_confirm/CMakeLists.txt
@@ -1,5 +1,5 @@
 # 
##############################################################################
-# apps/boot/CMakeLists.txt
+# apps/examples/mcuboot/slot_confirm/CMakeLists.txt
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
 # license agreements.  See the NOTICE file distributed with this work for
@@ -18,4 +18,9 @@
 #
 # 
##############################################################################
 
-nuttx_generate_kconfig(MENUDESC "Bootloader Utilities")
+if(CONFIG_EXAMPLES_MCUBOOT_SLOT_CONFIRM)
+  nuttx_add_application(
+    NAME mcuboot_confirm2
+    SRCS ${CMAKE_CURRENT_LIST_DIR}/mcuboot_confirm_main.c
+    DEPENDS mcuboot)
+endif()
diff --git a/boot/CMakeLists.txt b/examples/mcuboot/swap_test/CMakeLists.txt
similarity index 67%
copy from boot/CMakeLists.txt
copy to examples/mcuboot/swap_test/CMakeLists.txt
index ce82730ee..2d7467dcd 100644
--- a/boot/CMakeLists.txt
+++ b/examples/mcuboot/swap_test/CMakeLists.txt
@@ -1,5 +1,5 @@
 # 
##############################################################################
-# apps/boot/CMakeLists.txt
+# apps/examples/mcuboot/swap_test/CMakeLists.txt
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
 # license agreements.  See the NOTICE file distributed with this work for
@@ -18,4 +18,19 @@
 #
 # 
##############################################################################
 
-nuttx_generate_kconfig(MENUDESC "Bootloader Utilities")
+if(CONFIG_EXAMPLES_MCUBOOT_SWAP_TEST)
+  nuttx_add_application(
+    NAME mcuboot_confirm
+    SRCS ${CMAKE_CURRENT_LIST_DIR}/confirm_main.c
+    DEPENDS mcuboot)
+
+  nuttx_add_application(
+    NAME mcuboot_set_img
+    SRCS ${CMAKE_CURRENT_LIST_DIR}/set_img_main.c
+    DEPENDS mcuboot)
+
+  nuttx_add_application(
+    NAME mcuboot_version
+    SRCS ${CMAKE_CURRENT_LIST_DIR}/version_main.c
+    DEPENDS mcuboot)
+endif()
diff --git a/boot/CMakeLists.txt b/examples/mcuboot/update_agent/CMakeLists.txt
similarity index 80%
copy from boot/CMakeLists.txt
copy to examples/mcuboot/update_agent/CMakeLists.txt
index ce82730ee..9a84d60dc 100644
--- a/boot/CMakeLists.txt
+++ b/examples/mcuboot/update_agent/CMakeLists.txt
@@ -1,5 +1,5 @@
 # 
##############################################################################
-# apps/boot/CMakeLists.txt
+# apps/examples/mcuboot/update_agent/CMakeLists.txt
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
 # license agreements.  See the NOTICE file distributed with this work for
@@ -18,4 +18,9 @@
 #
 # 
##############################################################################
 
-nuttx_generate_kconfig(MENUDESC "Bootloader Utilities")
+if(CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT)
+  nuttx_add_application(
+    NAME mcuboot_agent
+    SRCS ${CMAKE_CURRENT_LIST_DIR}/mcuboot_agent_main.c
+    DEPENDS mcuboot)
+endif()

Reply via email to