Infineon: Switch to 1.9.0 code base, add xmc7000 family support, refactor memory layer
diff --git a/boot/nuttx/include/flash_map_backend/flash_map_backend.h b/boot/nuttx/include/flash_map_backend/flash_map_backend.h
index 7d17a8b..50dbc57 100644
--- a/boot/nuttx/include/flash_map_backend/flash_map_backend.h
+++ b/boot/nuttx/include/flash_map_backend/flash_map_backend.h
@@ -191,11 +191,11 @@
* Retrieve flash area from the flash map for a given partition.
*
* Input Parameters:
- * fa_id - ID of the flash partition.
+ * id - ID of the flash partition.
*
* Output Parameters:
- * fa - Pointer which will contain the reference to flash_area.
- * If ID is unknown, it will be NULL on output.
+ * fa - Pointer which will contain the reference to flash_area.
+ * If ID is unknown, it will be NULL on output.
*
* Returned Value:
* Zero on success, or negative value in case of error.
@@ -306,7 +306,7 @@
*
****************************************************************************/
-uint8_t flash_area_align(const struct flash_area *fa);
+uint32_t flash_area_align(const struct flash_area *fa);
/****************************************************************************
* Name: flash_area_erased_val
@@ -392,15 +392,15 @@
*
* Input Parameters:
* image_index - Index of the image.
- * fa_id - Image slot, which may be 0 (primary) or 1 (secondary).
- *
+ * area_id - Unique identifier that is represented by fa_id in the
+ * flash_area struct.
* Returned Value:
* Image slot index (0 or 1), or negative value in case ID doesn't
* correspond to an image slot.
*
****************************************************************************/
-int flash_area_id_to_multi_image_slot(int image_index, int fa_id);
+int flash_area_id_to_multi_image_slot(int image_index, int area_id);
/****************************************************************************
* Name: flash_area_id_from_image_offset
@@ -412,7 +412,7 @@
* offset - Image offset.
*
* Returned Value:
- * Flash area ID (0 or 1), or negative value in case the requested slot
+ * Flash area ID (0 or 1), or negative value in case the requested offset
* is invalid.
*
****************************************************************************/
diff --git a/boot/nuttx/include/mcuboot_config/mcuboot_config.h b/boot/nuttx/include/mcuboot_config/mcuboot_config.h
index ae945f6..6a8eb22 100644
--- a/boot/nuttx/include/mcuboot_config/mcuboot_config.h
+++ b/boot/nuttx/include/mcuboot_config/mcuboot_config.h
@@ -27,7 +27,7 @@
#include <nuttx/config.h>
#ifdef CONFIG_MCUBOOT_WATCHDOG
-#include "watchdog/watchdog.h"
+# include "watchdog/watchdog.h"
#endif
/****************************************************************************
@@ -58,27 +58,43 @@
* the default upgrade mode.
*/
-/* Uncomment to enable the overwrite-only code path. */
+/* Enable the overwrite-only code path. */
-/* #define MCUBOOT_OVERWRITE_ONLY */
+#ifdef CONFIG_MCUBOOT_OVERWRITE_ONLY
+# define MCUBOOT_OVERWRITE_ONLY
+#endif
-#ifdef MCUBOOT_OVERWRITE_ONLY
-
-/* Uncomment to only erase and overwrite those primary slot sectors needed
+/* Only erase and overwrite those primary slot sectors needed
* to install the new image, rather than the entire image slot.
*/
-/* #define MCUBOOT_OVERWRITE_ONLY_FAST */
-
+#ifdef CONFIG_MCUBOOT_OVERWRITE_ONLY_FAST
+# define MCUBOOT_OVERWRITE_ONLY_FAST
#endif
-/* Uncomment to enable the direct-xip code path. */
+/* Enable the direct-xip code path. */
-/* #define MCUBOOT_DIRECT_XIP */
+#ifdef CONFIG_MCUBOOT_DIRECT_XIP
+# define MCUBOOT_DIRECT_XIP
+#endif
-/* Uncomment to enable the ram-load code path. */
+/* Enable the revert mechanism in direct-xip mode. */
-/* #define MCUBOOT_RAM_LOAD */
+#ifdef CONFIG_MCUBOOT_DIRECT_XIP_REVERT
+# define MCUBOOT_DIRECT_XIP_REVERT
+#endif
+
+/* Enable the ram-load code path. */
+
+#ifdef CONFIG_MCUBOOT_RAM_LOAD
+# define MCUBOOT_RAM_LOAD
+#endif
+
+/* Enable bootstrapping the erased primary slot from the secondary slot */
+
+#ifdef CONFIG_MCUBOOT_BOOTSTRAP
+# define MCUBOOT_BOOTSTRAP
+#endif
/* Cryptographic settings
*
@@ -88,11 +104,11 @@
*/
#ifdef CONFIG_MCUBOOT_USE_MBED_TLS
-#define MCUBOOT_USE_MBED_TLS
+# define MCUBOOT_USE_MBED_TLS
#endif
#ifdef CONFIG_MCUBOOT_USE_TINYCRYPT
-#define MCUBOOT_USE_TINYCRYPT
+# define MCUBOOT_USE_TINYCRYPT
#endif
/* Always check the signature of the image in the primary slot before
diff --git a/boot/nuttx/include/mcuboot_config/mcuboot_logging.h b/boot/nuttx/include/mcuboot_config/mcuboot_logging.h
index 6853fff..a2ccce0 100644
--- a/boot/nuttx/include/mcuboot_config/mcuboot_logging.h
+++ b/boot/nuttx/include/mcuboot_config/mcuboot_logging.h
@@ -30,6 +30,9 @@
* Pre-processor Definitions
****************************************************************************/
+#define MCUBOOT_LOG_MODULE_DECLARE(...)
+#define MCUBOOT_LOG_MODULE_REGISTER(...)
+
#define MCUBOOT_LOG_ERR(format, ...) \
syslog(LOG_ERR, "%s: " format "\n", __FUNCTION__, ##__VA_ARGS__)
diff --git a/boot/nuttx/main.c b/boot/nuttx/main.c
index 728df13..7c19c86 100644
--- a/boot/nuttx/main.c
+++ b/boot/nuttx/main.c
@@ -23,7 +23,7 @@
#include <nuttx/config.h>
-#include <stdio.h>
+#include <syslog.h>
#include <sys/boardctl.h>
@@ -52,7 +52,7 @@
ret = flash_area_open(area_id, &flash_area);
assert(ret == OK);
- printf("Booting from %s...\n", flash_area->fa_mtd_path);
+ syslog(LOG_INFO, "Booting from %s...\n", flash_area->fa_mtd_path);
info.path = flash_area->fa_mtd_path;
info.header_size = rsp->br_hdr->ih_hdr_size;
@@ -61,7 +61,7 @@
if (boardctl(BOARDIOC_BOOT_IMAGE, (uintptr_t)&info) != OK)
{
- fprintf(stderr, "Failed to load application image!\n");
+ syslog(LOG_ERR, "Failed to load application image!\n");
FIH_PANIC;
}
}
@@ -79,13 +79,13 @@
struct boot_rsp rsp;
fih_int fih_rc = FIH_FAILURE;
- printf("*** Booting MCUboot build %s ***\n", CONFIG_MCUBOOT_VERSION);
+ syslog(LOG_INFO, "*** Booting MCUboot build %s ***\n", CONFIG_MCUBOOT_VERSION);
FIH_CALL(boot_go, fih_rc, &rsp);
if (fih_not_eq(fih_rc, FIH_SUCCESS))
{
- fprintf(stderr, "Unable to find bootable image\n");
+ syslog(LOG_ERR, "Unable to find bootable image\n");
FIH_PANIC;
}
diff --git a/boot/nuttx/src/flash_map_backend/flash_map_backend.c b/boot/nuttx/src/flash_map_backend/flash_map_backend.c
index 3aa53fb..fcf6bab 100644
--- a/boot/nuttx/src/flash_map_backend/flash_map_backend.c
+++ b/boot/nuttx/src/flash_map_backend/flash_map_backend.c
@@ -64,9 +64,9 @@
struct partition_info_s partinfo;
- int fd; /* File descriptor for an open flash area */
- int32_t refs; /* Reference counter */
- uint8_t erase_state; /* Byte value of the flash erased state */
+ int fd; /* File descriptor for an open flash area */
+ uint32_t refs; /* Reference counter */
+ uint8_t erase_state; /* Byte value of the flash erased state */
};
/****************************************************************************
@@ -232,11 +232,11 @@
* Retrieve flash area from the flash map for a given ID.
*
* Input Parameters:
- * fa_id - ID of the flash area.
+ * id - ID of the flash area.
*
* Output Parameters:
- * fa - Pointer which will contain the reference to flash_area.
- * If ID is unknown, it will be NULL on output.
+ * fa - Pointer which will contain the reference to flash_area.
+ * If ID is unknown, it will be NULL on output.
*
* Returned Value:
* Zero on success, or negative value in case of error.
@@ -254,7 +254,7 @@
dev = lookup_flash_device_by_id(id);
if (dev == NULL)
{
- BOOT_LOG_ERR("Undefined flash area: %d", id);
+ BOOT_LOG_ERR("Undefined flash area: %" PRIu8, id);
return ERROR;
}
@@ -263,7 +263,7 @@
if (dev->refs++ > 0)
{
- BOOT_LOG_INF("Flash area ID %d already open, count: %d (+)",
+ BOOT_LOG_INF("Flash area ID %" PRIu8 " already open, count: %" PRIu32 " (+)",
id, dev->refs);
return OK;
@@ -319,7 +319,7 @@
dev->fd = fd;
- BOOT_LOG_INF("Flash area %d open, count: %d (+)", id, dev->refs);
+ BOOT_LOG_INF("Flash area %" PRIu8 " open, count: %" PRIu32 " (+)", id, dev->refs);
return OK;
@@ -363,7 +363,7 @@
return;
}
- BOOT_LOG_INF("Close request for flash area %" PRIu8 ", count: %d (-)",
+ BOOT_LOG_INF("Close request for flash area %" PRIu8 ", count: %" PRIu32 " (-)",
fa->fa_id, dev->refs);
if (--dev->refs == 0)
@@ -552,7 +552,7 @@
return ERROR;
}
- memset(buffer, erase_val, sizeof(buffer));
+ memset(buffer, erase_val, sector_size);
i = 0;
@@ -568,7 +568,7 @@
if (ret == OK)
{
- BOOT_LOG_DBG("Erasing %zu bytes at offset %" PRIu32,
+ BOOT_LOG_DBG("Erasing %" PRIu32 " bytes at offset %" PRIu32,
len - i, off + i);
ret = flash_area_write(fa, off + i, buffer, len - i);
@@ -595,13 +595,13 @@
*
****************************************************************************/
-uint8_t flash_area_align(const struct flash_area *fa)
+uint32_t flash_area_align(const struct flash_area *fa)
{
/* MTD access alignment is handled by the character and block device
* drivers.
*/
- const uint8_t minimum_write_length = 1;
+ const uint32_t minimum_write_length = 1;
BOOT_LOG_INF("ID:%" PRIu8 " align:%" PRIu8,
fa->fa_id, minimum_write_length);
@@ -752,30 +752,30 @@
*
* Input Parameters:
* image_index - Index of the image.
- * fa_id - Image slot, which may be 0 (primary) or 1 (secondary).
- *
+ * area_id - Unique identifier that is represented by fa_id in the
+ * flash_area struct.
* Returned Value:
* Image slot index (0 or 1), or negative value in case ID doesn't
* correspond to an image slot.
*
****************************************************************************/
-int flash_area_id_to_multi_image_slot(int image_index, int fa_id)
+int flash_area_id_to_multi_image_slot(int image_index, int area_id)
{
- BOOT_LOG_INF("image_index:%d fa_id:%d", image_index, fa_id);
+ BOOT_LOG_INF("image_index:%d area_id:%d", image_index, area_id);
- if (fa_id == FLASH_AREA_IMAGE_PRIMARY(image_index))
+ if (area_id == FLASH_AREA_IMAGE_PRIMARY(image_index))
{
return 0;
}
- if (fa_id == FLASH_AREA_IMAGE_SECONDARY(image_index))
+ if (area_id == FLASH_AREA_IMAGE_SECONDARY(image_index))
{
return 1;
}
- BOOT_LOG_ERR("Unexpected Request: image_index:%d, fa_id:%d",
- image_index, fa_id);
+ BOOT_LOG_ERR("Unexpected Request: image_index:%d, area_id:%d",
+ image_index, area_id);
return ERROR; /* flash_area_open will fail on that */
}
@@ -790,7 +790,7 @@
* offset - Image offset.
*
* Returned Value:
- * Flash area ID (0 or 1), or negative value in case the requested slot
+ * Flash area ID (0 or 1), or negative value in case the requested offset
* is invalid.
*
****************************************************************************/
@@ -801,5 +801,12 @@
BOOT_LOG_INF("offset:%" PRIu32, offset);
- return dev->fa_cfg->fa_id;
+ if (dev != NULL)
+ {
+ return dev->fa_cfg->fa_id;
+ }
+
+ BOOT_LOG_ERR("Unexpected Request: offset:%" PRIu32, offset);
+
+ return ERROR; /* flash_area_open will fail on that */
}