You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/11/05 17:37:51 UTC

(nuttx-apps) branch master updated: nxboot: fix incorrect confirm state for directly flashed image

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d5afd062 nxboot: fix incorrect confirm state for directly flashed image
2d5afd062 is described below

commit 2d5afd0625d8e3bbd6c907731224323ab2bc4317
Author: Michal Lenc <mi...@seznam.cz>
AuthorDate: Tue Nov 5 14:17:06 2024 +0100

    nxboot: fix incorrect confirm state for directly flashed image
    
    API function nxboot_get_confirm was returning incorrect value if
    primary image was flashed directly into the embedded flash (this
    image does not have a tail, but is automatically considered as valid
    and stable based on the header magic value).
    
    Signed-off-by: Michal Lenc <mi...@seznam.cz>
---
 boot/nxboot/loader/boot.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/boot/nxboot/loader/boot.c b/boot/nxboot/loader/boot.c
index d2c0d2688..6bd9a2dcb 100644
--- a/boot/nxboot/loader/boot.c
+++ b/boot/nxboot/loader/boot.c
@@ -577,6 +577,7 @@ int nxboot_get_state(struct nxboot_state *state)
 int nxboot_get_confirm(void)
 {
   int primary;
+  struct nxboot_img_header primary_header;
 
   primary = flash_partition_open(CONFIG_NXBOOT_PRIMARY_SLOT_PATH);
   if (primary < 0)
@@ -584,7 +585,9 @@ int nxboot_get_confirm(void)
       return ERROR;
     }
 
-  if (get_image_flag(primary, NXBOOT_CONFIRMED_PAGE_INDEX))
+  get_image_header(primary, &primary_header);
+  if (get_image_flag(primary, NXBOOT_CONFIRMED_PAGE_INDEX) ||
+      primary_header.magic == NXBOOT_HEADER_MAGIC_INV)
     {
       return 1;
     }