espressif: Bump IDF version to v4.4

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
diff --git a/boot/espressif/CMakeLists.txt b/boot/espressif/CMakeLists.txt
index 84e38b6..ce9c91b 100644
--- a/boot/espressif/CMakeLists.txt
+++ b/boot/espressif/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
+# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
 #
 # SPDX-License-Identifier: Apache-2.0
 
@@ -37,16 +37,6 @@
     )
 add_definitions(-DMCUBOOT_VER=\"${MCUBOOT_VER}\")
 
-execute_process(
-    COMMAND git describe --tags
-    WORKING_DIRECTORY ${IDF_PATH}
-    OUTPUT_VARIABLE IDF_VER
-    OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-if (NOT "${IDF_VER}" MATCHES "v4.3")
-    message(FATAL_ERROR "Unsupported ESP-IDF version found in IDF_PATH, please checkout to v4.3")
-endif()
-
 if (DEFINED MCUBOOT_CONFIG_FILE)
     set(mcuboot_config_file ${MCUBOOT_CONFIG_FILE})
 else()
diff --git a/boot/espressif/hal/CMakeLists.txt b/boot/espressif/hal/CMakeLists.txt
index f84abc9..56056d2 100644
--- a/boot/espressif/hal/CMakeLists.txt
+++ b/boot/espressif/hal/CMakeLists.txt
@@ -1,46 +1,59 @@
+# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
+#
+# SPDX-License-Identifier: Apache-2.0
+
 cmake_minimum_required(VERSION 3.13)
 
 project(hal)
 
 set(esp_idf_dir ${IDF_PATH})
 
-set(SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/src)
-set(INCLUDE_DIRS
+set(src_dir ${CMAKE_CURRENT_LIST_DIR}/src)
+set(include_dirs
     ${CMAKE_CURRENT_LIST_DIR}/include
     ${CMAKE_CURRENT_LIST_DIR}/include/${MCUBOOT_TARGET}
     )
 
-list(APPEND INCLUDE_DIRS
+list(APPEND include_dirs
     ${esp_idf_dir}/components/${MCUBOOT_ARCH}/include
     ${esp_idf_dir}/components/esp_common/include
     ${esp_idf_dir}/components/esp_rom/include
     ${esp_idf_dir}/components/esp_rom/include/${MCUBOOT_TARGET}
     ${esp_idf_dir}/components/spi_flash/include
-    ${esp_idf_dir}/components/spi_flash/private_include
-    ${esp_idf_dir}/components/soc/${MCUBOOT_TARGET}/include
-    ${esp_idf_dir}/components/${MCUBOOT_TARGET}/include
+    ${esp_idf_dir}/components/spi_flash/include/spi_flash
     ${esp_idf_dir}/components/soc/include
+    ${esp_idf_dir}/components/soc/${MCUBOOT_TARGET}/include
     ${esp_idf_dir}/components/esp_hw_support/include
-    ${esp_idf_dir}/components/hal/${MCUBOOT_TARGET}/include
-    ${esp_idf_dir}/components/hal/${MCUBOOT_TARGET}/include/hal
+    ${esp_idf_dir}/components/esp_hw_support/include/soc
     ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}
     ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/private_include
     ${esp_idf_dir}/components/bootloader_support/include
     ${esp_idf_dir}/components/bootloader_support/include_bootloader
     ${esp_idf_dir}/components/hal/include
+    ${esp_idf_dir}/components/hal/platform_port/include
+    ${esp_idf_dir}/components/hal/${MCUBOOT_TARGET}/include
+    ${esp_idf_dir}/components/hal/${MCUBOOT_TARGET}/include/hal
+    ${esp_idf_dir}/components/heap/include
     ${esp_idf_dir}/components/efuse/include
     ${esp_idf_dir}/components/efuse/${MCUBOOT_TARGET}/include
+    ${esp_idf_dir}/components/newlib/platform_include
     )
 
+if("${MCUBOOT_TARGET}" STREQUAL "esp32")
+    list(APPEND include_dirs
+        ${esp_idf_dir}/components/${MCUBOOT_TARGET}/include
+        )
+endif()
+
 if("${MCUBOOT_ARCH}" STREQUAL "xtensa")
-    list(APPEND INCLUDE_DIRS
+    list(APPEND include_dirs
         ${esp_idf_dir}/components/${MCUBOOT_ARCH}/${MCUBOOT_TARGET}/include
         )
 endif()
 
 set(hal_srcs
-    ${SRC_DIR}/bootloader_wdt.c
-    ${SRC_DIR}/${MCUBOOT_TARGET}/bootloader_init.c
+    ${src_dir}/bootloader_wdt.c
+    ${src_dir}/${MCUBOOT_TARGET}/bootloader_init.c
     ${esp_idf_dir}/components/hal/mpu_hal.c
     ${esp_idf_dir}/components/bootloader_support/src/bootloader_flash.c
     ${esp_idf_dir}/components/bootloader_support/src/bootloader_flash_config_${MCUBOOT_TARGET}.c
@@ -49,6 +62,7 @@
     ${esp_idf_dir}/components/bootloader_support/src/bootloader_panic.c
     ${esp_idf_dir}/components/bootloader_support/src/bootloader_mem.c
     ${esp_idf_dir}/components/spi_flash/${MCUBOOT_TARGET}/spi_flash_rom_patch.c
+    ${esp_idf_dir}/components/esp_hw_support/esp_clk.c
     ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_init.c
     ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_time.c
     ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_clk.c
@@ -56,9 +70,15 @@
     ${esp_idf_dir}/components/hal/wdt_hal_iram.c
     ${esp_idf_dir}/components/esp_hw_support/cpu_util.c
     ${esp_idf_dir}/components/esp_rom/patches/esp_rom_uart.c
-    ${esp_idf_dir}/components/${MCUBOOT_TARGET}/clk.c
+    ${esp_idf_dir}/components/esp_rom/patches/esp_rom_sys.c
     )
 
+if("${MCUBOOT_ARCH}" STREQUAL "xtensa")
+    list(APPEND hal_srcs
+        ${esp_idf_dir}/components/esp_rom/patches/esp_rom_longjmp.S
+        )
+endif()
+
 set(CFLAGS
     "-nostdlib"
     "-Wno-frame-address"
@@ -99,7 +119,7 @@
     "-lgcov"
     )
 
-if (("${MCUBOOT_TARGET}" STREQUAL "xtensa"))
+if("${MCUBOOT_ARCH}" STREQUAL "xtensa")
     list(APPEND CFLAGS
         "-mlongcalls"
         )
@@ -122,17 +142,17 @@
     -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.ld
     -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.libgcc.ld
     -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.api.ld
-    -T${esp_idf_dir}/components/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.peripherals.ld
+    -T${esp_idf_dir}/components/soc/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.peripherals.ld
     )
 
 include(${CMAKE_CURRENT_LIST_DIR}/include/${MCUBOOT_TARGET}/${MCUBOOT_TARGET}.cmake)
 
-add_library(hal STATIC ${hal_srcs} ${INCLUDE_DIRS})
+add_library(hal STATIC ${hal_srcs} ${include_dirs})
 
 target_include_directories(
     hal
     PUBLIC
-    ${INCLUDE_DIRS}
+    ${include_dirs}
     )
 
 target_compile_options(
diff --git a/boot/espressif/hal/esp-idf b/boot/espressif/hal/esp-idf
index c9646ff..e104dd7 160000
--- a/boot/espressif/hal/esp-idf
+++ b/boot/espressif/hal/esp-idf
@@ -1 +1 @@
-Subproject commit c9646ff0beffc86d2c6d1bfbad34da16e328e0e3
+Subproject commit e104dd7f27d2e73ab0e9b614dd7b9295099069bf
diff --git a/boot/espressif/hal/src/esp32/bootloader_init.c b/boot/espressif/hal/src/esp32/bootloader_init.c
index 0e77ecb..e7b1528 100644
--- a/boot/espressif/hal/src/esp32/bootloader_init.c
+++ b/boot/espressif/hal/src/esp32/bootloader_init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
+ * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
@@ -23,10 +23,9 @@
 
 #include "hal/wdt_hal.h"
 
-#include "rom/cache.h"
-#include "rom/ets_sys.h"
-#include "rom/spi_flash.h"
-#include "rom/uart.h"
+#include "esp32/rom/cache.h"
+#include "esp32/rom/spi_flash.h"
+#include "esp32/rom/uart.h"
 
 esp_image_header_t WORD_ALIGNED_ATTR bootloader_image_hdr;
 
diff --git a/boot/espressif/hal/src/esp32c3/bootloader_init.c b/boot/espressif/hal/src/esp32c3/bootloader_init.c
index 6ec064b..ec74349 100644
--- a/boot/espressif/hal/src/esp32c3/bootloader_init.c
+++ b/boot/espressif/hal/src/esp32c3/bootloader_init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
+ * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
@@ -30,11 +30,8 @@
 #include "soc/efuse_reg.h"
 #include "soc/rtc.h"
 
-#include "rom/cache.h"
-#include "rom/ets_sys.h"
-#include "rom/spi_flash.h"
-#include "rom/uart.h"
-#include "rom/efuse.h"
+#include "esp32c3/rom/cache.h"
+#include "esp32c3/rom/spi_flash.h"
 
 #include "hal/wdt_hal.h"
 
diff --git a/boot/espressif/hal/src/esp32s2/bootloader_init.c b/boot/espressif/hal/src/esp32s2/bootloader_init.c
index 8bc91ba..5e36530 100644
--- a/boot/espressif/hal/src/esp32s2/bootloader_init.c
+++ b/boot/espressif/hal/src/esp32s2/bootloader_init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
+ * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
@@ -28,10 +28,10 @@
 
 #include "hal/wdt_hal.h"
 
-#include "rom/cache.h"
-#include "rom/ets_sys.h"
-#include "rom/spi_flash.h"
-#include "rom/uart.h"
+#include "esp32s2/rom/cache.h"
+#include "esp32s2/rom/ets_sys.h"
+#include "esp32s2/rom/spi_flash.h"
+#include "esp32s2/rom/uart.h"
 
 esp_image_header_t WORD_ALIGNED_ATTR bootloader_image_hdr;