espressif: update secure boot and flash encryption

Adjust secure boot and flash encryption after IDF v5.x updates.
It also allows to enable secure boot on ESP32-C2.

Signed-off-by: Almir Okato <almir.okato@espressif.com>
diff --git a/boot/espressif/hal/CMakeLists.txt b/boot/espressif/hal/CMakeLists.txt
index 7f3d1bb..d248c26 100644
--- a/boot/espressif/hal/CMakeLists.txt
+++ b/boot/espressif/hal/CMakeLists.txt
@@ -71,11 +71,8 @@
     ${esp_hal_dir}/components/bootloader_support/src/bootloader_random_${MCUBOOT_TARGET}.c
     ${esp_hal_dir}/components/bootloader_support/src/bootloader_utility.c
     ${esp_hal_dir}/components/bootloader_support/src/esp_image_format.c
-    ${esp_hal_dir}/components/bootloader_support/src/secure_boot_v2/secure_boot_signatures_bootloader.c
     ${esp_hal_dir}/components/bootloader_support/src/${MCUBOOT_TARGET}/bootloader_soc.c
     ${esp_hal_dir}/components/bootloader_support/src/${MCUBOOT_TARGET}/bootloader_sha.c
-    ${esp_hal_dir}/components/bootloader_support/src/${MCUBOOT_TARGET}/secure_boot_secure_features.c
-    ${esp_hal_dir}/components/bootloader_support/src/${MCUBOOT_TARGET}/flash_encryption_secure_features.c
     ${esp_hal_dir}/components/hal/mpu_hal.c
     ${esp_hal_dir}/components/hal/efuse_hal.c
     ${esp_hal_dir}/components/hal/mmu_hal.c
@@ -103,12 +100,23 @@
 if(DEFINED CONFIG_SECURE_BOOT_V2_ENABLED)
     list(APPEND hal_srcs
         ${src_dir}/secure_boot.c
+        ${esp_hal_dir}/components/bootloader_support/src/secure_boot_v2/secure_boot_signatures_bootloader.c
+        ${esp_hal_dir}/components/bootloader_support/src/${MCUBOOT_TARGET}/secure_boot_secure_features.c
+        )
+    list(APPEND include_dirs
+        ${esp_hal_dir}/components/bootloader_support/src/secure_boot_v2
         )
 endif()
 
 if(DEFINED CONFIG_SECURE_FLASH_ENC_ENABLED)
     list(APPEND hal_srcs
         ${src_dir}/flash_encrypt.c
+        ${esp_hal_dir}/components/bootloader_support/src/${MCUBOOT_TARGET}/flash_encryption_secure_features.c
+        )
+    set_source_files_properties(
+        ${src_dir}/flash_encrypt.c
+        PROPERTIES COMPILE_FLAGS
+        "-Wno-unused-variable"
         )
 endif()