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 <[email protected]> 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 <[email protected]> --- 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);
