espressif:esp32: Add multi image support

Changes on configuration and flash area organization for supporting
multi image and implementation for booting on different processors
on esp32

Signed-off-by: Almir Okato <almir.okato@espressif.com>
diff --git a/boot/espressif/hal/include/app_cpu_start.h b/boot/espressif/hal/include/app_cpu_start.h
new file mode 100644
index 0000000..03c5c77
--- /dev/null
+++ b/boot/espressif/hal/include/app_cpu_start.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+void appcpu_start(uint32_t entry_addr);
diff --git a/boot/espressif/hal/include/esp32/esp32.cmake b/boot/espressif/hal/include/esp32/esp32.cmake
index e26b6c3..7d3776e 100644
--- a/boot/espressif/hal/include/esp32/esp32.cmake
+++ b/boot/espressif/hal/include/esp32/esp32.cmake
@@ -10,6 +10,12 @@
     ${esp_idf_dir}/components/efuse/src/esp_efuse_api_key_esp32.c
     )
 
+if (DEFINED CONFIG_ESP_MULTI_PROCESSOR_BOOT)
+    list(APPEND hal_srcs
+        ${src_dir}/${MCUBOOT_TARGET}/app_cpu_start.c
+        )
+endif()
+
 list(APPEND LINKER_SCRIPTS
     -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.newlib-funcs.ld
     -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.eco3.ld
diff --git a/boot/espressif/hal/include/mcuboot_config/mcuboot_config.h b/boot/espressif/hal/include/mcuboot_config/mcuboot_config.h
index abbbd97..8f309de 100644
--- a/boot/espressif/hal/include/mcuboot_config/mcuboot_config.h
+++ b/boot/espressif/hal/include/mcuboot_config/mcuboot_config.h
@@ -98,7 +98,11 @@
 
 /* Default number of separately updateable images; change in case of
  * multiple images. */
+#if defined(CONFIG_ESP_IMAGE_NUMBER)
+#define MCUBOOT_IMAGE_NUMBER CONFIG_ESP_IMAGE_NUMBER
+#else
 #define MCUBOOT_IMAGE_NUMBER 1
+#endif
 
 /*
  * Logging