boot/espressif: Add CMakeLists.txt and mcuboot_config.h
Add sources and headers required for build
Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
diff --git a/boot/espressif/include/flash_map_backend/flash_map_backend.h b/boot/espressif/include/flash_map_backend/flash_map_backend.h
new file mode 100644
index 0000000..fcbdc9f
--- /dev/null
+++ b/boot/espressif/include/flash_map_backend/flash_map_backend.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include <inttypes.h>
+
+struct flash_area {
+ uint8_t fa_id; /** The slot/scratch identification */
+ uint8_t fa_device_id; /** The device id (usually there's only one) */
+ uint16_t pad16;
+ uint32_t fa_off; /** The flash offset from the beginning */
+ uint32_t fa_size; /** The size of this sector */
+};
+
+//! Structure describing a sector within a flash area.
+struct flash_sector {
+ //! Offset of this sector, from the start of its flash area (not device).
+ uint32_t fs_off;
+
+ //! Size of this sector, in bytes.
+ uint32_t fs_size;
+};
+
+static inline uint8_t flash_area_get_device_id(const struct flash_area *fa)
+{
+ return (uint8_t)fa->fa_device_id;
+}
+static inline uint32_t flash_area_get_off(const struct flash_area *fa)
+{
+ return (uint32_t)fa->fa_off;
+}
+
+static inline uint32_t flash_area_get_size(const struct flash_area *fa)
+{
+ return (uint32_t)fa->fa_size;
+}
+
+static inline uint8_t flash_area_get_id(const struct flash_area *fa)
+{
+ return fa->fa_id;
+}
+
+static inline uint32_t flash_sector_get_off(const struct flash_sector *fs)
+{
+ return fs->fs_off;
+}
+
+static inline uint32_t flash_sector_get_size(const struct flash_sector *fs)
+{
+ return fs->fs_size;
+}
+
+//! Opens the area for use. id is one of the `fa_id`s */
+int flash_area_open(uint8_t id, const struct flash_area **area_outp);
+void flash_area_close(const struct flash_area *fa);
+
+//! Reads `len` bytes of flash memory at `off` to the buffer at `dst`
+int flash_area_read(const struct flash_area *fa, uint32_t off,
+ void *dst, uint32_t len);
+//! Writes `len` bytes of flash memory at `off` from the buffer at `src`
+int flash_area_write(const struct flash_area *fa, uint32_t off,
+ const void *src, uint32_t len);
+//! Erases `len` bytes of flash memory at `off`
+int flash_area_erase(const struct flash_area *fa,
+ uint32_t off, uint32_t len);
+
+//! Returns this `flash_area`s alignment
+size_t flash_area_align(const struct flash_area *area);
+//! Returns the value read from an erased flash area byte
+uint8_t flash_area_erased_val(const struct flash_area *area);
+
+//! Given flash area ID, return info about sectors within the area
+int flash_area_get_sectors(int fa_id, uint32_t *count,
+ struct flash_sector *sectors);
+
+//! Returns the `fa_id` for slot, where slot is 0 (primary) or 1 (secondary).
+//!
+//! `image_index` (0 or 1) is the index of the image. Image index is
+//! relevant only when multi-image support support is enabled
+int flash_area_id_from_multi_image_slot(int image_index, int slot);
+int flash_area_id_from_image_slot(int slot);
+int flash_area_to_sectors(int idx, int *cnt, struct flash_area *fa);
diff --git a/boot/espressif/include/os/os_malloc.h b/boot/espressif/include/os/os_malloc.h
new file mode 100644
index 0000000..1a6a6dc
--- /dev/null
+++ b/boot/espressif/include/os/os_malloc.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include <stdlib.h>
diff --git a/boot/espressif/include/sysflash/sysflash.h b/boot/espressif/include/sysflash/sysflash.h
new file mode 100644
index 0000000..7f0fb28
--- /dev/null
+++ b/boot/espressif/include/sysflash/sysflash.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+//! A user-defined identifier for different storage mediums
+//! (i.e internal flash, external NOR flash, eMMC, etc)
+#define FLASH_DEVICE_INTERNAL_FLASH 0
+
+//! An arbitrarily high slot ID we will use to indicate that
+//! there is not slot
+#define FLASH_SLOT_DOES_NOT_EXIST 255
+
+//! NB: MCUboot expects this define to exist but it's only used
+//! if MCUBOOT_SWAP_USING_SCRATCH=1 is set
+#define FLASH_AREA_IMAGE_SCRATCH FLASH_SLOT_DOES_NOT_EXIST
+
+//! The slot we will use to track the bootloader allocation
+#define FLASH_AREA_BOOTLOADER 0
+
+//! A mapping to primary and secondary/upgrade slot
+//! given an image_index. We'll plan to use
+#define FLASH_AREA_IMAGE_PRIMARY(i) ((i == 0) ? 1 : 255)
+#define FLASH_AREA_IMAGE_SECONDARY(i) ((i == 0) ? 2 : 255)