You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2024/06/27 06:50:40 UTC

(mynewt-core) branch master updated (6177f10f6 -> a09610139)

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

jerzy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


    from 6177f10f6 stm32: Fix flash write
     new 47a215ddf fs/fcb: Add support for flash with write size > 8
     new 526237ba3 fs/fcb2: Fix data access for flash with big data alignment
     new a09610139 sys/log_fcb: Relax write alignment restriction

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 fs/fcb/src/fcb.c            | 2 +-
 fs/fcb/src/fcb_append.c     | 4 ++--
 fs/fcb/src/fcb_getnext.c    | 4 ++--
 fs/fcb/src/fcb_rotate.c     | 2 +-
 fs/fcb2/src/fcb_getnext.c   | 3 ++-
 sys/log/full/src/log_fcb.c  | 4 ++--
 sys/log/full/src/log_fcb2.c | 4 ++--
 7 files changed, 12 insertions(+), 11 deletions(-)


(mynewt-core) 02/03: fs/fcb2: Fix data access for flash with big data alignment

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 526237ba31bce4accb6058b09183c4de33dc7e74
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Jun 26 12:49:43 2024 +0200

    fs/fcb2: Fix data access for flash with big data alignment
    
    In one place size of structure that was stored in flash was
    assumed to be FCB2_ENTRY_SIZE while in fact it was greater
    for flash with write alignment >= 8.
    
    Now entry locate takes into account actual space needed by
    entry.
    
    Signed-off-by: Jerzy Kasenberg <je...@codecoup.pl>
---
 fs/fcb2/src/fcb_getnext.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/fcb2/src/fcb_getnext.c b/fs/fcb2/src/fcb_getnext.c
index ea18be4f7..8a4f8f305 100644
--- a/fs/fcb2/src/fcb_getnext.c
+++ b/fs/fcb2/src/fcb_getnext.c
@@ -36,7 +36,8 @@ fcb2_getnext_in_area(struct fcb2 *fcb, struct fcb2_entry *loc)
                                                  fcb2_len_in_flash(loc->fe_range, 2);
         /* Possible entry offset for next data */
         next_entry_offset = fcb->f_active.fe_range->fsr_sector_size -
-                            (FCB2_ENTRY_SIZE * (loc->fe_entry_num + 1));
+                            (fcb2_len_in_flash(fcb->f_active.fe_range, FCB2_ENTRY_SIZE) *
+                             (loc->fe_entry_num + 1));
         loc->fe_data_len = 0;
         loc->fe_entry_num++;
         /* If there is no space for next entry just finish search */


(mynewt-core) 03/03: sys/log_fcb: Relax write alignment restriction

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit a09610139bafc095312a6e194f4137a50cc58e5f
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Jun 26 12:53:17 2024 +0200

    sys/log_fcb: Relax write alignment restriction
    
    Code was limiting usage of FCB and FCB2 to flashes
    with at most 8 bytes write alignment.
    There was no actual reason to have this limitation
    and now log can be used with STM32H7 and STM32U5 boards
    that have alignment 16 or 32 bytes.
    
    Signed-off-by: Jerzy Kasenberg <je...@codecoup.pl>
---
 sys/log/full/src/log_fcb.c  | 4 ++--
 sys/log/full/src/log_fcb2.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/log/full/src/log_fcb.c b/sys/log/full/src/log_fcb.c
index 5f4df8e31..82bd1a415 100644
--- a/sys/log/full/src/log_fcb.c
+++ b/sys/log/full/src/log_fcb.c
@@ -27,8 +27,8 @@
 #include "fcb/fcb.h"
 #include "log/log.h"
 
-/* Assume the flash alignment requirement is no stricter than 8. */
-#define LOG_FCB_MAX_ALIGN   8
+/* Assume the flash alignment requirement is no stricter than 32. */
+#define LOG_FCB_MAX_ALIGN   32
 
 static int log_fcb_rtr_erase(struct log *log);
 
diff --git a/sys/log/full/src/log_fcb2.c b/sys/log/full/src/log_fcb2.c
index c8a5d07b2..826150a12 100644
--- a/sys/log/full/src/log_fcb2.c
+++ b/sys/log/full/src/log_fcb2.c
@@ -27,8 +27,8 @@
 #include "log/log.h"
 #include "fcb/fcb2.h"
 
-/* Assume the flash alignment requirement is no stricter than 8. */
-#define LOG_FCB2_MAX_ALIGN   8
+/* Assume the flash alignment requirement is no stricter than 32. */
+#define LOG_FCB2_MAX_ALIGN   32
 
 static int log_fcb2_rtr_erase(struct log *log);
 


(mynewt-core) 01/03: fs/fcb: Add support for flash with write size > 8

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 47a215ddfb2e18715d05f87e9666238984e8b4b2
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Tue Jun 25 15:59:39 2024 +0200

    fs/fcb: Add support for flash with write size > 8
    
    Most of the code already respected flash alignment restriction.
    For write restriction greater then 8, space reserved for
    fcb_disk_area has to be adjusted when fe_elem_off is
    initialized.
    
    Signed-off-by: Jerzy Kasenberg <je...@codecoup.pl>
---
 fs/fcb/src/fcb.c         | 2 +-
 fs/fcb/src/fcb_append.c  | 4 ++--
 fs/fcb/src/fcb_getnext.c | 4 ++--
 fs/fcb/src/fcb_rotate.c  | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/fcb/src/fcb.c b/fs/fcb/src/fcb.c
index 0fe7e1f5b..4e18fb867 100644
--- a/fs/fcb/src/fcb.c
+++ b/fs/fcb/src/fcb.c
@@ -80,7 +80,7 @@ fcb_init(struct fcb *fcb)
     fcb->f_align = max_align;
     fcb->f_oldest = oldest_fap;
     fcb->f_active.fe_area = newest_fap;
-    fcb->f_active.fe_elem_off = sizeof(struct fcb_disk_area);
+    fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area));
     fcb->f_active_id = newest;
 
     /* Require alignment to be a power of two.  Some code depends on this
diff --git a/fs/fcb/src/fcb_append.c b/fs/fcb/src/fcb_append.c
index 6d1bc86a8..bc44b13ee 100644
--- a/fs/fcb/src/fcb_append.c
+++ b/fs/fcb/src/fcb_append.c
@@ -61,7 +61,7 @@ fcb_append_to_scratch(struct fcb *fcb)
         return rc;
     }
     fcb->f_active.fe_area = fa;
-    fcb->f_active.fe_elem_off = sizeof(struct fcb_disk_area);
+    fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area));
     fcb->f_active_id++;
     return FCB_OK;
 }
@@ -99,7 +99,7 @@ fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *append_loc)
             goto err;
         }
         fcb->f_active.fe_area = fa;
-        fcb->f_active.fe_elem_off = sizeof(struct fcb_disk_area);
+        fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area));
         fcb->f_active_id++;
     }
 
diff --git a/fs/fcb/src/fcb_getnext.c b/fs/fcb/src/fcb_getnext.c
index 6ca08ce85..2cf97f696 100644
--- a/fs/fcb/src/fcb_getnext.c
+++ b/fs/fcb/src/fcb_getnext.c
@@ -66,7 +66,7 @@ fcb_getnext_nolock(struct fcb *fcb, struct fcb_entry *loc)
         /*
          * If offset is zero, we serve the first entry from the area.
          */
-        loc->fe_elem_off = sizeof(struct fcb_disk_area);
+        loc->fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area));
         rc = fcb_elem_info(fcb, loc);
     } else {
         rc = fcb_getnext_in_area(fcb, loc);
@@ -94,7 +94,7 @@ next_sector:
                 return FCB_ERR_NOVAR;
             }
             loc->fe_area = fcb_getnext_area(fcb, loc->fe_area);
-            loc->fe_elem_off = sizeof(struct fcb_disk_area);
+            loc->fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area));
             rc = fcb_elem_info(fcb, loc);
             switch (rc) {
             case 0:
diff --git a/fs/fcb/src/fcb_rotate.c b/fs/fcb/src/fcb_rotate.c
index 7135fa674..6ccba8219 100644
--- a/fs/fcb/src/fcb_rotate.c
+++ b/fs/fcb/src/fcb_rotate.c
@@ -46,7 +46,7 @@ fcb_rotate(struct fcb *fcb)
             goto out;
         }
         fcb->f_active.fe_area = fap;
-        fcb->f_active.fe_elem_off = sizeof(struct fcb_disk_area);
+        fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area));
         fcb->f_active_id++;
     }
     fcb->f_oldest = fcb_getnext_area(fcb, fcb->f_oldest);