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

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


The following commit(s) were added to refs/heads/master by this push:
     new 28ee22e  fs/fcb2; use fcb2 prefix in public API
28ee22e is described below

commit 28ee22e1a4dafcf439438f7bd911452db78f3a5f
Author: Marko Kiiskila <ma...@apache.org>
AuthorDate: Tue Sep 17 01:15:33 2019 +0300

    fs/fcb2; use fcb2 prefix in public API
---
 fs/fcb2/include/fcb/fcb.h                          | 199 -------------
 fs/fcb2/include/fcb/fcb2.h                         | 316 +++++++++++++++++++++
 fs/fcb2/selftest/src/fcb_test.c                    |  18 +-
 fs/fcb2/selftest/src/fcb_test.h                    |  10 +-
 fs/fcb2/selftest/src/testcases/fcb_test_append.c   |  12 +-
 .../selftest/src/testcases/fcb_test_append_fill.c  |  21 +-
 .../src/testcases/fcb_test_append_too_big.c        |  20 +-
 .../selftest/src/testcases/fcb_test_area_info.c    |  36 ++-
 .../selftest/src/testcases/fcb_test_empty_walk.c   |   4 +-
 fs/fcb2/selftest/src/testcases/fcb_test_getprev.c  |  56 ++--
 fs/fcb2/selftest/src/testcases/fcb_test_init.c     |  19 +-
 .../selftest/src/testcases/fcb_test_last_of_n.c    |  24 +-
 .../src/testcases/fcb_test_multiple_scratch.c      |  30 +-
 fs/fcb2/selftest/src/testcases/fcb_test_reset.c    |  42 +--
 fs/fcb2/selftest/src/testcases/fcb_test_rotate.c   |  28 +-
 fs/fcb2/src/fcb.c                                  |  98 +++----
 fs/fcb2/src/fcb_append.c                           | 115 ++++----
 fs/fcb2/src/fcb_area_info.c                        |  16 +-
 fs/fcb2/src/fcb_elem_info.c                        |  45 +--
 fs/fcb2/src/fcb_getnext.c                          |  46 +--
 fs/fcb2/src/fcb_getprev.c                          |  24 +-
 fs/fcb2/src/fcb_priv.h                             |  58 ++--
 fs/fcb2/src/fcb_rotate.c                           |  20 +-
 fs/fcb2/src/fcb_walk.c                             |  20 +-
 sys/config/include/config/config_fcb.h             |   2 +
 sys/config/include/config/config_fcb2.h            |   4 +-
 sys/config/include/config/config_generic_kv.h      |  20 +-
 sys/config/selftest-fcb2/src/conf_test_fcb2.c      |   2 +-
 sys/config/selftest-fcb2/src/conf_test_fcb2.h      |   2 +-
 .../src/testcases/config_test_compress_reset.c     |   6 +-
 sys/config/src/config_fcb2.c                       |  64 ++---
 sys/config/src/config_init.c                       |   3 +-
 sys/log/full/include/log/log_fcb.h                 |  32 ++-
 .../src/log_test_fcb_bookmarks_util.c              |   4 +-
 .../src/log_test_fcb_watermarks_util.c             |   2 +-
 .../util/include/log_test_util/log_test_util.h     |   8 +
 sys/log/full/selftest/util/src/log_test_util.c     |   7 +-
 sys/log/full/src/log_fcb2.c                        | 116 ++++----
 sys/log/full/src/log_fcb_bmark.c                   |   6 +
 sys/reboot/src/log_reboot.c                        |  26 +-
 40 files changed, 883 insertions(+), 698 deletions(-)

diff --git a/fs/fcb2/include/fcb/fcb.h b/fs/fcb2/include/fcb/fcb.h
deleted file mode 100644
index a0c3772..0000000
--- a/fs/fcb2/include/fcb/fcb.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-#ifndef __SYS_FCB_H_
-#define __SYS_FCB_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \defgroup FCB Flash circular buffer.
- * @{
- */
-
-#include <inttypes.h>
-#include <limits.h>
-#include <assert.h>
-
-#include <syscfg/syscfg.h>
-#include <os/os_mutex.h>
-#include <flash_map/flash_map.h>
-
-#define FCB_MAX_LEN    (CHAR_MAX | CHAR_MAX << 7) /* Max length of element */
-
-#define FCB_SECTOR_OLDEST UINT16_MAX
-
-struct fcb;
-
-/**
- * Entry location point to sector, and offset
- * within that sector.
- */
-struct fcb_entry {
-    struct flash_sector_range *fe_range;  /* ptr to area within fcb->f_ranges 
*/
-    uint16_t fe_sector;     /* sector number in fcb flash */
-    uint16_t fe_data_len;   /* size of data area */
-    uint32_t fe_data_off;   /* start of data in sector */
-    uint16_t fe_entry_num;  /* entry number in sector */
-};
-
-/* Number of bytes needed for fcb_sector_entry on flash */
-#define FCB_ENTRY_SIZE          6
-#define FCB_CRC_LEN             2
-
-struct fcb {
-    /* Caller of fcb_init fills this in */
-    uint32_t f_magic;       /* As placed on the disk */
-    uint8_t f_version;      /* Current version number of the data */
-    uint8_t f_scratch_cnt;  /* How many sectors should be kept empty */
-    uint8_t f_range_cnt;    /* Number of elements in range array */
-    uint16_t f_sector_cnt;  /* Number of sectors used by fcb */
-    uint16_t f_oldest_sec;  /* Index of oldest sector */
-    struct flash_sector_range *f_ranges;
-
-    /* Flash circular buffer internal state */
-    struct os_mutex f_mtx;     /* Locking for accessing the FCB data */
-    struct fcb_entry f_active;
-    uint16_t f_active_id;
-};
-
-/**
- * Error codes.
- */
-#define FCB_OK           0
-#define FCB_ERR_ARGS    -1
-#define FCB_ERR_FLASH   -2
-#define FCB_ERR_NOVAR   -3
-#define FCB_ERR_NOSPACE -4
-#define FCB_ERR_NOMEM   -5
-#define FCB_ERR_CRC     -6
-#define FCB_ERR_MAGIC   -7
-#define FCB_ERR_VERSION -8
-
-int fcb_init(struct fcb *fcb);
-
-/*
- * Initialize fcb for specific flash area
- *
- * Function initializes FCB structure with data taken from specified flash
- * area.
- * If FCB was not initialized before in this area, area will be erased.
- *
- * @param fcb            Fcb to initialize
- * @param flash_area_id  flash area for this fcb
- * @param magic          User defined magic value that is stored in each
- *                       flash sector used by fcb
- * @param version        version of fcb
- *
- */
-int fcb_init_flash_area(struct fcb *fcb, int flash_area_id, uint32_t magic,
-    uint8_t version);
-
-/**
- * fcb_append() appends an entry to circular buffer. When writing the
- * contents for the entry, fcb_write() with fcb_entry filled by.
- * fcb_append(). When you're finished, call fcb_append_finish() with
- * loc as argument.
- */
-int fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *loc);
-int fcb_write(struct fcb_entry *loc, uint16_t off, const void *buf,
-              uint16_t len);
-int fcb_append_finish(struct fcb_entry *append_loc);
-
-/**
- * Walk over all log entries in FCB, or entries in a given flash_area.
- * cb gets called for every entry. If cb wants to stop the walk, it should
- * return non-zero value.
- *
- * Entry data can be read using fcb_read().
- */
-typedef int (*fcb_walk_cb)(struct fcb_entry *loc, void *arg);
-int fcb_walk(struct fcb *, int sector, fcb_walk_cb cb, void *cb_arg);
-int fcb_getnext(struct fcb *fcb, struct fcb_entry *loc);
-int fcb_getprev(struct fcb *fcb, struct fcb_entry *loc);
-int fcb_read(struct fcb_entry *loc, uint16_t off, void *buf, uint16_t len);
-
-/**
- * Erases the data from oldest sector.
- */
-int fcb_rotate(struct fcb *fcb);
-
-/**
- * Start using the scratch block.
- */
-int fcb_append_to_scratch(struct fcb *fcb);
-
-/**
- * How many sectors are unused.
- */
-int fcb_free_sector_cnt(struct fcb *fcb);
-
-/**
- * Whether FCB has any data.
- */
-int fcb_is_empty(struct fcb *fcb);
-
-/**
- * Element at offset *entries* from last position (backwards).
- */
-int
-fcb_offset_last_n(struct fcb *fcb, uint8_t entries,
-                  struct fcb_entry *last_n_entry);
-
-/**
- * Erase sector in FCB
- *
- * @param fcb     FCB to use
- * @param sector  sector number to erase 0..f_sector_cnt
- *
- * return 0 on success, error code on failure
- */
-int fcb_sector_erase(const struct fcb *fcb, int sector);
-
-/**
- * Get total size of FCB
- *
- * @param fcb     FCB to use
- *
- * return FCB's size in bytes
- */
-int fcb_get_total_size(const struct fcb *fcb);
-
-/**
- * Clears FCB passed to it
- */
-int fcb_clear(struct fcb *fcb);
-
-/**
- * Usage report for a given FCB sector. Returns number of elements and the
- * number of bytes stored in them.
- */
-int fcb_area_info(struct fcb *fcb, int sector, int *elemsp, int *bytesp);
-
-#ifdef __cplusplus
-}
-
-/**
- * @} FCB
- */
-
-#endif
-
-#endif /* __SYS_FLASHVAR_H_ */
diff --git a/fs/fcb2/include/fcb/fcb2.h b/fs/fcb2/include/fcb/fcb2.h
new file mode 100644
index 0000000..da824a4
--- /dev/null
+++ b/fs/fcb2/include/fcb/fcb2.h
@@ -0,0 +1,316 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#ifndef __SYS_FCB2_H_
+#define __SYS_FCB2_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \defgroup FCB2 Flash circular buffer.
+ * @{
+ */
+
+#include <inttypes.h>
+#include <limits.h>
+#include <assert.h>
+
+#include <syscfg/syscfg.h>
+#include <os/os_mutex.h>
+#include <flash_map/flash_map.h>
+
+#define FCB2_MAX_LEN   (CHAR_MAX | CHAR_MAX << 7) /* Max length of element */
+
+#define FCB2_SECTOR_OLDEST UINT16_MAX
+
+struct fcb2;
+
+/**
+ * Entry location point to sector, and offset  within that sector.
+ */
+struct fcb2_entry {
+    struct flash_sector_range *fe_range;  /* ptr to area within fcb->f_ranges 
*/
+    uint16_t fe_sector;     /* sector number in fcb flash */
+    uint16_t fe_data_len;   /* size of data area */
+    uint32_t fe_data_off;   /* start of data in sector */
+    uint16_t fe_entry_num;  /* entry number in sector */
+};
+
+/* Number of bytes needed for fcb_sector_entry on flash */
+#define FCB2_ENTRY_SIZE          6
+#define FCB2_CRC_LEN             2
+
+/**
+ * State structure for flash circular buffer version2.
+ */
+struct fcb2 {
+    /* Caller of fcb2_init() fills this in */
+    uint32_t f_magic;       /* As placed on the disk */
+    uint8_t f_version;      /* Current version number of the data */
+    uint8_t f_scratch_cnt;  /* How many sectors should be kept empty */
+    uint8_t f_range_cnt;    /* Number of elements in range array */
+    uint16_t f_sector_cnt;  /* Number of sectors used by fcb */
+    uint16_t f_oldest_sec;  /* Index of oldest sector */
+    struct flash_sector_range *f_ranges;
+
+    /* Flash circular buffer internal state */
+    struct os_mutex f_mtx;     /* Locking for accessing the FCB data */
+    struct fcb2_entry f_active;
+    uint16_t f_active_id;
+};
+
+/**
+ * Error codes.
+ */
+#define FCB2_OK           0
+#define FCB2_ERR_ARGS    -1
+#define FCB2_ERR_FLASH   -2
+#define FCB2_ERR_NOVAR   -3
+#define FCB2_ERR_NOSPACE -4
+#define FCB2_ERR_NOMEM   -5
+#define FCB2_ERR_CRC     -6
+#define FCB2_ERR_MAGIC   -7
+#define FCB2_ERR_VERSION -8
+
+
+/**
+ *
+ * Initialize FCB for use.
+ *
+ * @param fcb            Fcb to initialize. User specific fields of structure
+ *                       must be set before calling this.
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_init(struct fcb2 *fcb);
+
+/**
+ * Initialize fcb for specific flash area
+ *
+ * Function initializes FCB structure with data taken from specified flash
+ * area.
+ * If FCB was not initialized before in this area, area will be erased.
+ *
+ * @param fcb            Fcb to initialize
+ * @param flash_area_id  flash area for this fcb
+ * @param magic          User defined magic value that is stored in each
+ *                       flash sector used by fcb
+ * @param version        version of fcb
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_init_flash_area(struct fcb2 *fcb, int flash_area_id, uint32_t magic,
+                         uint8_t version);
+
+/**
+ * fcb2_append() reserves space for an entry within FCB. When writing the
+ * contents for the entry, fcb2_write() with fcb_entry filled by.
+ * fcb2_append(). When you're finished, call fcb2_append_finish() with
+ * loc as argument.
+ *
+ * @param fcb            FCB this entry is being appended to.
+ * @param len            Size of the entry being added
+ * @param loc            Will be filled with fcb2_entry where data will be
+ *                       written to
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_append(struct fcb2 *fcb, uint16_t len, struct fcb2_entry *loc);
+
+/**
+ * Write entry data to location indicated by loc. User must've called
+ * fcb2_append() before adding data to entry to populate loc. Should not
+ * be called after fcb2_append_finish() for this entry has been called.
+ *
+ * @param loc            Where this entry will be written
+ * @param off            Offset within entry area where to write the data
+ * @param buf            Pointer to data being written
+ * @param len            Number of bytes to write
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_write(struct fcb2_entry *loc, uint16_t off, const void *buf,
+               uint16_t len);
+
+/**
+ * Finalize writing data for entry.
+ *
+ * @param append_loc     Location of the entry
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_append_finish(struct fcb2_entry *append_loc);
+
+/**
+ * Callback routine getting called when walking through FCB entries.
+ * Entry data can be read by using fcb2_read().
+ *
+ * @param loc            Location of the entry
+ * @param arg            void * which was passed as arg when calling 
fcb2_walk()
+ *
+ * @return 0 if walk should continue, non-zero if walk should stop
+ */
+typedef int (*fcb2_walk_cb)(struct fcb2_entry *loc, void *arg);
+
+/**
+ * Iterate over all entries within FCB. Caller passes callback function to
+ * call for every valid entry. Entries are walked from oldest to newest.
+ *
+ * @param fcb            FCB to iterate
+ * @param sector         Sector ID where walk should start.
+ *                       Use FCB2_SECTOR_OLDEST to start from beginning.
+ * @param cb             Callback to call for the entries.
+ * @param cb_arg         void * to pass to callback.
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_walk(struct fcb2 *fcb, int sector, fcb2_walk_cb cb, void *cb_arg);
+
+/**
+ * Walk through entries within FCB from oldest to newest.
+ * fcb_getnext() finds the next valid entry forward from loc, and fills in
+ * the location of that entry.
+ *
+ * @param fcb            FCB to walk
+ * @param loc            FCB entry location. To get the oldest entry
+ *                       set loc->fe_range to NULL, and fe_entry_num to 0.
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_getnext(struct fcb2 *fcb, struct fcb2_entry *loc);
+
+/**
+ * Walk through entries within FCB from newest to oldest.
+ * fcb_getprev() finds the previous valid entry backwards from loc, and fills 
in
+ * the location of that entry.
+ *
+ * @param fcb            FCB to walk
+ * @param loc            FCB entry location. To get the newest entry
+ *                       set loc->fe_range to NULL.
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_getprev(struct fcb2 *fcb, struct fcb2_entry *loc);
+
+/**
+ * Read entry data belonging pointed by loc.
+ *
+ * @param loc            FCB entry to read
+ * @param off            Offset within entry area
+ * @param buf            Pointer to area where to populate the data
+ * @param len            Number of bytes to read.
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_read(struct fcb2_entry *loc, uint16_t off, void *buf, uint16_t len);
+
+/**
+ * Erases the data from oldest sector.
+ *
+ * @param fcb            FCB where to erase the sector
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_rotate(struct fcb2 *fcb);
+
+/**
+ * Start using the scratch block.
+ *
+ * @param fcb
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_append_to_scratch(struct fcb2 *fcb);
+
+/**
+ * How many sectors are unused.
+ */
+int fcb2_free_sector_cnt(struct fcb2 *fcb);
+
+/**
+ * Whether FCB has any data.
+ *
+ * @param fcb            FCB to inspect
+ *
+ * @return 1 if area is empty, 0 if not
+ */
+int fcb2_is_empty(struct fcb2 *fcb);
+
+/**
+ * Element at offset *entries* from last position (backwards).
+ *
+ * @param fcb            FCB to inspect
+ * @param entries        How many entries to look backwards
+ * @param last_n_entry   location of entry being returned
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_offset_last_n(struct fcb2 *fcb, uint8_t entries,
+                       struct fcb2_entry *last_n_entry);
+
+/**
+ * Erase sector in FCB
+ *
+ * @param fcb            FCB to use
+ * @param sector         sector number to erase 0..f_sector_cnt
+ *
+ * return 0 on success, error code on failure
+ */
+int fcb2_sector_erase(const struct fcb2 *fcb, int sector);
+
+/**
+ * Get total size of FCB
+ *
+ * @param fcb            FCB to inspect
+ *
+ * @return FCB's size in bytes
+ */
+int fcb2_get_total_size(const struct fcb2 *fcb);
+
+/**
+ * Empty the FCB
+ *
+ * @param fcb            FCB to clear
+ *
+ * @return 0 on success. Otherwise one of FCB2_XXX error codes.
+ */
+int fcb2_clear(struct fcb2 *fcb);
+
+/**
+ * Usage report for a given FCB sector. Returns number of elements and the
+ * number of bytes stored in them.
+ *
+ * @param fcb            FCB to inspect
+ * @param sector         Sector to inspect within FCB
+ * @param elemsp         Pointer where number of elements should be stored
+ * @param bytesp         Pointer where number of bytes used should be stored
+ */
+int fcb2_area_info(struct fcb2 *fcb, int sector, int *elemsp, int *bytesp);
+
+#ifdef __cplusplus
+}
+
+/**
+ * @} FCB2
+ */
+
+#endif
+
+#endif /* __SYS_FLASHVAR_H_ */
diff --git a/fs/fcb2/selftest/src/fcb_test.c b/fs/fcb2/selftest/src/fcb_test.c
index 0a29f55..c384e82 100644
--- a/fs/fcb2/selftest/src/fcb_test.c
+++ b/fs/fcb2/selftest/src/fcb_test.c
@@ -23,14 +23,14 @@
 #include "os/mynewt.h"
 #include "testutil/testutil.h"
 
-#include "fcb/fcb.h"
-#include "fcb/../../src/fcb_priv.h"
+#include "fcb/fcb2.h"
+#include "fcb_priv.h"
 
 #include "fcb_test.h"
 
 #include "flash_map/flash_map.h"
 
-struct fcb test_fcb;
+struct fcb2 test_fcb;
 
 struct flash_sector_range test_fcb_ranges[] = {
     [0] = {
@@ -62,7 +62,7 @@ fcb_test_wipe(void)
 }
 
 int
-fcb_test_empty_walk_cb(struct fcb_entry *loc, void *arg)
+fcb_test_empty_walk_cb(struct fcb2_entry *loc, void *arg)
 {
     TEST_ASSERT(0);
     return 0;
@@ -75,7 +75,7 @@ fcb_test_append_data(int msg_len, int off)
 }
 
 int
-fcb_test_data_walk_cb(struct fcb_entry *loc, void *arg)
+fcb_test_data_walk_cb(struct fcb2_entry *loc, void *arg)
 {
     uint16_t len;
     uint8_t test_data[128];
@@ -87,7 +87,7 @@ fcb_test_data_walk_cb(struct fcb_entry *loc, void *arg)
 
     TEST_ASSERT(len == *var_cnt);
 
-    rc = fcb_read(loc, 0, test_data, len);
+    rc = fcb2_read(loc, 0, test_data, len);
     TEST_ASSERT(rc == 0);
 
     for (i = 0; i < len; i++) {
@@ -98,7 +98,7 @@ fcb_test_data_walk_cb(struct fcb_entry *loc, void *arg)
 }
 
 int
-fcb_test_cnt_elems_cb(struct fcb_entry *loc, void *arg)
+fcb_test_cnt_elems_cb(struct fcb2_entry *loc, void *arg)
 {
     struct append_arg *aa = (struct append_arg *)arg;
     int idx;
@@ -111,7 +111,7 @@ fcb_test_cnt_elems_cb(struct fcb_entry *loc, void *arg)
 void
 fcb_tc_pretest(uint8_t sector_count)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int rc = 0;
 
     fcb_test_wipe();
@@ -124,7 +124,7 @@ fcb_tc_pretest(uint8_t sector_count)
     test_fcb_ranges[0].fsr_flash_area.fa_size =
         test_fcb_ranges[0].fsr_sector_size * sector_count;
 
-    rc = fcb_init(fcb);
+    rc = fcb2_init(fcb);
     if (rc != 0) {
         printf("fcb_tc_pretest rc == %x, %d\n", rc, rc);
         TEST_ASSERT(rc == 0);
diff --git a/fs/fcb2/selftest/src/fcb_test.h b/fs/fcb2/selftest/src/fcb_test.h
index 670e8bd..acc8242 100644
--- a/fs/fcb2/selftest/src/fcb_test.h
+++ b/fs/fcb2/selftest/src/fcb_test.h
@@ -25,14 +25,14 @@
 #include "os/mynewt.h"
 #include "testutil/testutil.h"
 
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 #include "fcb_priv.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-extern struct fcb test_fcb;
+extern struct fcb2 test_fcb;
 
 extern struct flash_sector_range test_fcb_ranges[];
 
@@ -41,10 +41,10 @@ struct append_arg {
 };
 
 void fcb_test_wipe(void);
-int fcb_test_empty_walk_cb(struct fcb_entry *loc, void *arg);
+int fcb_test_empty_walk_cb(struct fcb2_entry *loc, void *arg);
 uint8_t fcb_test_append_data(int msg_len, int off);
-int fcb_test_data_walk_cb(struct fcb_entry *loc, void *arg);
-int fcb_test_cnt_elems_cb(struct fcb_entry *loc, void *arg);
+int fcb_test_data_walk_cb(struct fcb2_entry *loc, void *arg);
+int fcb_test_cnt_elems_cb(struct fcb2_entry *loc, void *arg);
 void fcb_tc_pretest(uint8_t sector_count);
 
 #ifdef __cplusplus
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_append.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_append.c
index 0e283e6..a1131f6 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_append.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_append.c
@@ -21,8 +21,8 @@
 TEST_CASE_SELF(fcb_test_append)
 {
     int rc;
-    struct fcb *fcb;
-    struct fcb_entry loc;
+    struct fcb2 *fcb;
+    struct fcb2_entry loc;
     uint8_t test_data[128];
     int i;
     int j;
@@ -36,16 +36,16 @@ TEST_CASE_SELF(fcb_test_append)
         for (j = 0; j < i; j++) {
             test_data[j] = fcb_test_append_data(i, j);
         }
-        rc = fcb_append(fcb, i, &loc);
+        rc = fcb2_append(fcb, i, &loc);
         TEST_ASSERT_FATAL(rc == 0);
-        rc = fcb_write(&loc, 0, test_data, i);
+        rc = fcb2_write(&loc, 0, test_data, i);
         TEST_ASSERT(rc == 0);
-        rc = fcb_append_finish(&loc);
+        rc = fcb2_append_finish(&loc);
         TEST_ASSERT(rc == 0);
     }
 
     var_cnt = 1;
-    rc = fcb_walk(fcb, 0, fcb_test_data_walk_cb, &var_cnt);
+    rc = fcb2_walk(fcb, 0, fcb_test_data_walk_cb, &var_cnt);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(var_cnt == sizeof(test_data));
 }
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_append_fill.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_append_fill.c
index e0cad99..7ca56cd 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_append_fill.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_append_fill.c
@@ -20,10 +20,10 @@
 
 TEST_CASE_SELF(fcb_test_append_fill)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int rc;
     int i;
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
     uint8_t test_data[128];
     int elem_cnts[2] = {0, 0};
     int aa_together_cnts[2];
@@ -44,8 +44,8 @@ TEST_CASE_SELF(fcb_test_append_fill)
     }
 
     while (1) {
-        rc = fcb_append(fcb, sizeof(test_data), &loc);
-        if (rc == FCB_ERR_NOSPACE) {
+        rc = fcb2_append(fcb, sizeof(test_data), &loc);
+        if (rc == FCB2_ERR_NOSPACE) {
             break;
         }
         if (loc.fe_sector == 0) {
@@ -56,29 +56,26 @@ TEST_CASE_SELF(fcb_test_append_fill)
             TEST_ASSERT(0);
         }
 
-        rc = fcb_write(&loc, 0, test_data, sizeof(test_data));
+        rc = fcb2_write(&loc, 0, test_data, sizeof(test_data));
         TEST_ASSERT(rc == 0);
 
-        rc = fcb_append_finish(&loc);
+        rc = fcb2_append_finish(&loc);
         TEST_ASSERT(rc == 0);
     }
     TEST_ASSERT(elem_cnts[0] > 0);
     TEST_ASSERT(elem_cnts[0] == elem_cnts[1]);
 
     memset(&aa_together_cnts, 0, sizeof(aa_together_cnts));
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_cnt_elems_cb, &aa_together);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_cnt_elems_cb, 
&aa_together);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(aa_together.elem_cnts[0] == elem_cnts[0]);
     TEST_ASSERT(aa_together.elem_cnts[1] == elem_cnts[1]);
 
     memset(&aa_separate_cnts, 0, sizeof(aa_separate_cnts));
-    rc = fcb_walk(fcb, 0, fcb_test_cnt_elems_cb,
-      &aa_separate);
+    rc = fcb2_walk(fcb, 0, fcb_test_cnt_elems_cb, &aa_separate);
     TEST_ASSERT(rc == 0);
-    rc = fcb_walk(fcb, 1, fcb_test_cnt_elems_cb,
-      &aa_separate);
+    rc = fcb2_walk(fcb, 1, fcb_test_cnt_elems_cb, &aa_separate);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(aa_separate.elem_cnts[0] == elem_cnts[0]);
     TEST_ASSERT(aa_separate.elem_cnts[1] == elem_cnts[1]);
-
 }
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_append_too_big.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_append_too_big.c
index 6556601..860d62d 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_append_too_big.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_append_too_big.c
@@ -20,10 +20,10 @@
 
 TEST_CASE_SELF(fcb_test_append_too_big)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int rc;
     int len;
-    struct fcb_entry elem_loc;
+    struct fcb2_entry elem_loc;
 
     fcb_tc_pretest(2);
 
@@ -35,26 +35,26 @@ TEST_CASE_SELF(fcb_test_append_too_big)
      */
     len = fcb->f_active.fe_range->fsr_sector_size;
 
-    rc = fcb_append(fcb, len, &elem_loc);
+    rc = fcb2_append(fcb, len, &elem_loc);
     TEST_ASSERT(rc != 0);
 
     len--;
-    rc = fcb_append(fcb, len, &elem_loc);
+    rc = fcb2_append(fcb, len, &elem_loc);
     TEST_ASSERT(rc != 0);
 
-    len -= sizeof(struct fcb_disk_area);
-    rc = fcb_append(fcb, len, &elem_loc);
+    len -= sizeof(struct fcb2_disk_area);
+    rc = fcb2_append(fcb, len, &elem_loc);
     TEST_ASSERT(rc != 0);
 
     len = fcb->f_active.fe_range->fsr_sector_size -
-      (sizeof(struct fcb_disk_area) + 2 + 6);
-    rc = fcb_append(fcb, len, &elem_loc);
+      (sizeof(struct fcb2_disk_area) + 2 + 6);
+    rc = fcb2_append(fcb, len, &elem_loc);
     TEST_ASSERT(rc == 0);
 
-    rc = fcb_append_finish(&elem_loc);
+    rc = fcb2_append_finish(&elem_loc);
     TEST_ASSERT(rc == 0);
 
-    rc = fcb_elem_info(&elem_loc);
+    rc = fcb2_elem_info(&elem_loc);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(elem_loc.fe_data_len == len);
 }
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_area_info.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_area_info.c
index 9bfee02..5ed6036 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_area_info.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_area_info.c
@@ -20,10 +20,10 @@
 
 TEST_CASE_SELF(fcb_test_area_info)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int rc;
     int i;
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
     uint8_t test_data[128];
     int elem_cnts[2] = {0, 0};
     int area_elems[2];
@@ -34,21 +34,20 @@ TEST_CASE_SELF(fcb_test_area_info)
     fcb = &test_fcb;
 
     /* check that sector outside of range fails */
-    rc = fcb_area_info(fcb, fcb->f_sector_cnt, area_elems, area_bytes);
-    TEST_ASSERT(rc == FCB_ERR_ARGS);
-    rc = fcb_area_info(fcb, fcb->f_sector_cnt + 1, area_elems, area_bytes);
-    TEST_ASSERT(rc == FCB_ERR_ARGS);
+    rc = fcb2_area_info(fcb, fcb->f_sector_cnt, area_elems, area_bytes);
+    TEST_ASSERT(rc == FCB2_ERR_ARGS);
+    rc = fcb2_area_info(fcb, fcb->f_sector_cnt + 1, area_elems, area_bytes);
+    TEST_ASSERT(rc == FCB2_ERR_ARGS);
 
     /* output arguments are optional */
-    rc = fcb_area_info(fcb, 0, NULL, NULL);
+    rc = fcb2_area_info(fcb, 0, NULL, NULL);
     TEST_ASSERT(rc == 0);
 
     /*
      * Should be empty, with elem count and byte count zero.
      */
     for (i = 0; i < 2; i++) {
-        rc = fcb_area_info(fcb, 0, &area_elems[i],
-                           &area_bytes[i]);
+        rc = fcb2_area_info(fcb, 0, &area_elems[i], &area_bytes[i]);
         TEST_ASSERT(rc == 0);
         TEST_ASSERT(area_elems[i] == 0);
         TEST_ASSERT(area_bytes[i] == 0);
@@ -58,8 +57,8 @@ TEST_CASE_SELF(fcb_test_area_info)
      * Fill up the areas, make sure that reporting is ok.
      */
     while (1) {
-        rc = fcb_append(fcb, sizeof(test_data), &loc);
-        if (rc == FCB_ERR_NOSPACE) {
+        rc = fcb2_append(fcb, sizeof(test_data), &loc);
+        if (rc == FCB2_ERR_NOSPACE) {
             break;
         }
         if (loc.fe_sector == 0) {
@@ -70,15 +69,14 @@ TEST_CASE_SELF(fcb_test_area_info)
             TEST_ASSERT(0);
         }
 
-        rc = fcb_write(&loc, 0, test_data, sizeof(test_data));
+        rc = fcb2_write(&loc, 0, test_data, sizeof(test_data));
         TEST_ASSERT(rc == 0);
 
-        rc = fcb_append_finish(&loc);
+        rc = fcb2_append_finish(&loc);
         TEST_ASSERT(rc == 0);
 
         for (i = 0; i < 2; i++) {
-            rc = fcb_area_info(fcb, i, &area_elems[i],
-                               &area_bytes[i]);
+            rc = fcb2_area_info(fcb, i, &area_elems[i], &area_bytes[i]);
             TEST_ASSERT(rc == 0);
             TEST_ASSERT(area_elems[i] == elem_cnts[i]);
             TEST_ASSERT(area_bytes[i] == elem_cnts[i] * sizeof(test_data));
@@ -88,12 +86,12 @@ TEST_CASE_SELF(fcb_test_area_info)
     /*
      * Wipe out the oldest, should report zeroes for that area now.
      */
-    rc = fcb_rotate(fcb);
+    rc = fcb2_rotate(fcb);
     TEST_ASSERT(rc == 0);
 
-    rc = fcb_area_info(fcb, 0, &area_elems[0], &area_bytes[0]);
+    rc = fcb2_area_info(fcb, 0, &area_elems[0], &area_bytes[0]);
     TEST_ASSERT(rc == 0);
-    rc = fcb_area_info(fcb, 1, &area_elems[1], &area_bytes[1]);
+    rc = fcb2_area_info(fcb, 1, &area_elems[1], &area_bytes[1]);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(area_elems[0] == 0);
     TEST_ASSERT(area_bytes[0] == 0);
@@ -103,7 +101,7 @@ TEST_CASE_SELF(fcb_test_area_info)
     /*
      * Test oldest sector should be sector area 1.
      */
-    rc = fcb_area_info(fcb, FCB_SECTOR_OLDEST, &area_elems[0], &area_bytes[0]);
+    rc = fcb2_area_info(fcb, FCB2_SECTOR_OLDEST, &area_elems[0], 
&area_bytes[0]);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(area_elems[0] == elem_cnts[1]);
     TEST_ASSERT(area_bytes[0] == elem_cnts[1] * sizeof(test_data));
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_empty_walk.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_empty_walk.c
index a48d6c6..7d5b4b1 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_empty_walk.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_empty_walk.c
@@ -21,12 +21,12 @@
 TEST_CASE_SELF(fcb_test_empty_walk)
 {
     int rc;
-    struct fcb *fcb;
+    struct fcb2 *fcb;
 
     fcb_tc_pretest(2);
 
     fcb = &test_fcb;
 
-    rc = fcb_walk(fcb, 0, fcb_test_empty_walk_cb, NULL);
+    rc = fcb2_walk(fcb, 0, fcb_test_empty_walk_cb, NULL);
     TEST_ASSERT(rc == 0);
 }
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_getprev.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_getprev.c
index ec1a255..9daa80c 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_getprev.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_getprev.c
@@ -20,9 +20,9 @@
 
 TEST_CASE_SELF(fcb_test_getprev)
 {
-    struct fcb *fcb = &test_fcb;
-    struct fcb_entry loc;
-    struct fcb_entry prev;
+    struct fcb2 *fcb = &test_fcb;
+    struct fcb2_entry loc;
+    struct fcb2_entry prev;
     int rc;
     int i, j;
 
@@ -33,33 +33,33 @@ TEST_CASE_SELF(fcb_test_getprev)
     /*
      * Empty FCB returns error.
      */
-    rc = fcb_getprev(fcb, &prev);
-    TEST_ASSERT_FATAL(rc == FCB_ERR_NOVAR);
+    rc = fcb2_getprev(fcb, &prev);
+    TEST_ASSERT_FATAL(rc == FCB2_ERR_NOVAR);
 
     /*
      * Add one entry. getprev should find that guy, and then error.
      */
-    rc = fcb_append(fcb, 8, &loc);
+    rc = fcb2_append(fcb, 8, &loc);
     TEST_ASSERT(rc == 0);
-    rc = fcb_append_finish(&loc);
+    rc = fcb2_append_finish(&loc);
     TEST_ASSERT(rc == 0);
 
     prev.fe_range = NULL;
-    rc = fcb_getprev(fcb, &prev);
+    rc = fcb2_getprev(fcb, &prev);
     TEST_ASSERT_FATAL(rc == 0);
     TEST_ASSERT(!memcmp(&loc, &prev, sizeof(loc)));
 
-    rc = fcb_getprev(fcb, &prev);
-    TEST_ASSERT(rc == FCB_ERR_NOVAR);
+    rc = fcb2_getprev(fcb, &prev);
+    TEST_ASSERT(rc == FCB2_ERR_NOVAR);
 
     /*
      * Add enough entries to go to 2 sectors, should find them all.
      */
     fcb_tc_pretest(3);
     for (i = 0; ; i++) {
-        rc = fcb_append(fcb, i + 1, &loc);
+        rc = fcb2_append(fcb, i + 1, &loc);
         TEST_ASSERT(rc == 0);
-        rc = fcb_append_finish(&loc);
+        rc = fcb2_append_finish(&loc);
         TEST_ASSERT(rc == 0);
 
         if (loc.fe_sector == prev.fe_sector + 2) {
@@ -69,12 +69,12 @@ TEST_CASE_SELF(fcb_test_getprev)
 
     prev.fe_range = NULL;
     for (j = i; j >= 0; j--) {
-        rc = fcb_getprev(fcb, &prev);
+        rc = fcb2_getprev(fcb, &prev);
         TEST_ASSERT(rc == 0);
         TEST_ASSERT(prev.fe_data_len == j + 1);
     }
-    rc = fcb_getprev(fcb, &prev);
-    TEST_ASSERT(rc == FCB_ERR_NOVAR);
+    rc = fcb2_getprev(fcb, &prev);
+    TEST_ASSERT(rc == FCB2_ERR_NOVAR);
 
     /*
      * Clean the area. Fill 2 whole sectors with corrupt entries. And one
@@ -83,23 +83,23 @@ TEST_CASE_SELF(fcb_test_getprev)
     fcb_tc_pretest(3);
 
     for (i = 0; ; i++) {
-        rc = fcb_append(fcb, i + 1, &loc);
+        rc = fcb2_append(fcb, i + 1, &loc);
         TEST_ASSERT(rc == 0);
 
         if (loc.fe_sector == prev.fe_sector + 2) {
-            rc = fcb_append_finish(&loc);
+            rc = fcb2_append_finish(&loc);
             TEST_ASSERT(rc == 0);
             break;
         }
     }
 
     prev.fe_range = NULL;
-    rc = fcb_getprev(fcb, &prev);
+    rc = fcb2_getprev(fcb, &prev);
     TEST_ASSERT_FATAL(rc == 0);
     TEST_ASSERT(!memcmp(&loc, &prev, sizeof(loc)));
 
-    rc = fcb_getprev(fcb, &prev);
-    TEST_ASSERT(rc == FCB_ERR_NOVAR);
+    rc = fcb2_getprev(fcb, &prev);
+    TEST_ASSERT(rc == FCB2_ERR_NOVAR);
 
     /*
      * Create new. Rotate one sector, should be able to follow
@@ -109,28 +109,28 @@ TEST_CASE_SELF(fcb_test_getprev)
     fcb_tc_pretest(3);
 
     for (i = 0; ; i++) {
-        rc = fcb_append(fcb, i + 8, &loc);
-        if (rc == FCB_ERR_NOSPACE) {
+        rc = fcb2_append(fcb, i + 8, &loc);
+        if (rc == FCB2_ERR_NOSPACE) {
             break;
         }
         TEST_ASSERT(rc == 0);
-        rc = fcb_append_finish(&loc);
+        rc = fcb2_append_finish(&loc);
         TEST_ASSERT(rc == 0);
     }
 
     /*
      * Full. Rotate, add one more, and then walk backwards.
      */
-    fcb_rotate(fcb);
+    fcb2_rotate(fcb);
 
-    rc = fcb_append(fcb, i + 8, &loc);
+    rc = fcb2_append(fcb, i + 8, &loc);
     TEST_ASSERT(rc == 0);
-    rc = fcb_append_finish(&loc);
+    rc = fcb2_append_finish(&loc);
     TEST_ASSERT(rc == 0);
 
     for (j = i; j >= 0; j--) {
-        rc = fcb_getprev(fcb, &prev);
-        if (rc == FCB_ERR_NOVAR) {
+        rc = fcb2_getprev(fcb, &prev);
+        if (rc == FCB2_ERR_NOVAR) {
             TEST_ASSERT(i > 0);
             break;
         }
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_init.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_init.c
index dcea7ba..aa1a5e0 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_init.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_init.c
@@ -21,29 +21,30 @@
 TEST_CASE_SELF(fcb_test_init)
 {
     int rc;
-    struct fcb *fcb;
+    struct fcb2 *fcb;
 
     fcb_tc_pretest(2);
 
     fcb = &test_fcb;
     memset(fcb, 0, sizeof(*fcb));
 
-    rc = fcb_init(fcb);
-    TEST_ASSERT(rc == FCB_ERR_ARGS);
+    rc = fcb2_init(fcb);
+    TEST_ASSERT(rc == FCB2_ERR_ARGS);
 
     fcb->f_ranges = test_fcb_ranges;
 
-    rc = fcb_init(fcb);
-    TEST_ASSERT(rc == FCB_ERR_ARGS);
+    rc = fcb2_init(fcb);
+    TEST_ASSERT(rc == FCB2_ERR_ARGS);
 
     fcb->f_sector_cnt = 2;
     fcb->f_magic = 0x12345678;
     fcb->f_range_cnt = 1;
-    fcb->f_ranges[0].fsr_flash_area.fa_size = 2 * 
fcb->f_ranges[0].fsr_sector_size;
-    rc = fcb_init(fcb);
-    TEST_ASSERT(rc == FCB_ERR_MAGIC);
+    fcb->f_ranges[0].fsr_flash_area.fa_size =
+              2 * fcb->f_ranges[0].fsr_sector_size;
+    rc = fcb2_init(fcb);
+    TEST_ASSERT(rc == FCB2_ERR_MAGIC);
 
     fcb->f_magic = 0;
-    rc = fcb_init(fcb);
+    rc = fcb2_init(fcb);
     TEST_ASSERT(rc == 0);
 }
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_last_of_n.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_last_of_n.c
index 2a6c3cd..7f0aef1 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_last_of_n.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_last_of_n.c
@@ -21,10 +21,10 @@
 TEST_CASE_SELF(fcb_test_last_of_n)
 {
     const uint8_t ENTRIES = 5;
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int rc;
-    struct fcb_entry loc;
-    struct fcb_entry areas[ENTRIES];
+    struct fcb2_entry loc;
+    struct fcb2_entry areas[ENTRIES];
     uint8_t test_data[128];
     uint8_t i;
 
@@ -34,50 +34,50 @@ TEST_CASE_SELF(fcb_test_last_of_n)
     fcb->f_scratch_cnt = 1;
 
     /* No fcbs available */
-    rc = fcb_offset_last_n(fcb, 1, &loc);
+    rc = fcb2_offset_last_n(fcb, 1, &loc);
     TEST_ASSERT(rc != 0);
 
     /*
      * Add some fcbs.
      */
     for (i = 0; i < ENTRIES; i++) {
-        rc = fcb_append(fcb, sizeof(test_data), &loc);
-        if (rc == FCB_ERR_NOSPACE) {
+        rc = fcb2_append(fcb, sizeof(test_data), &loc);
+        if (rc == FCB2_ERR_NOSPACE) {
             break;
         }
 
-        rc = fcb_write(&loc, 0, test_data, sizeof(test_data));
+        rc = fcb2_write(&loc, 0, test_data, sizeof(test_data));
         TEST_ASSERT(rc == 0);
 
-        rc = fcb_append_finish(&loc);
+        rc = fcb2_append_finish(&loc);
         TEST_ASSERT(rc == 0);
 
         areas[i] = loc;
     }
 
     /* last entry */
-    rc = fcb_offset_last_n(fcb, 1, &loc);
+    rc = fcb2_offset_last_n(fcb, 1, &loc);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(areas[4].fe_sector == loc.fe_sector);
     TEST_ASSERT(areas[4].fe_data_off == loc.fe_data_off);
     TEST_ASSERT(areas[4].fe_data_len == loc.fe_data_len);
 
     /* somewhere in the middle */
-    rc = fcb_offset_last_n(fcb, 3, &loc);
+    rc = fcb2_offset_last_n(fcb, 3, &loc);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(areas[2].fe_sector == loc.fe_sector);
     TEST_ASSERT(areas[2].fe_data_off == loc.fe_data_off);
     TEST_ASSERT(areas[2].fe_data_len == loc.fe_data_len);
 
     /* first entry */
-    rc = fcb_offset_last_n(fcb, 5, &loc);
+    rc = fcb2_offset_last_n(fcb, 5, &loc);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(areas[0].fe_sector == loc.fe_sector);
     TEST_ASSERT(areas[0].fe_data_off == loc.fe_data_off);
     TEST_ASSERT(areas[0].fe_data_len == loc.fe_data_len);
 
     /* after last valid entry, returns the first one like for 5 */
-    rc = fcb_offset_last_n(fcb, 6, &loc);
+    rc = fcb2_offset_last_n(fcb, 6, &loc);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(areas[0].fe_sector == loc.fe_sector);
     TEST_ASSERT(areas[0].fe_data_off == loc.fe_data_off);
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_multiple_scratch.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_multiple_scratch.c
index 3b2cf95..3b855f6 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_multiple_scratch.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_multiple_scratch.c
@@ -20,9 +20,9 @@
 
 TEST_CASE_SELF(fcb_test_multiple_scratch)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int rc;
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
     uint8_t test_data[128];
     int elem_cnts[4];
     int idx;
@@ -42,17 +42,17 @@ TEST_CASE_SELF(fcb_test_multiple_scratch)
      */
     memset(elem_cnts, 0, sizeof(elem_cnts));
     while (1) {
-        rc = fcb_append(fcb, sizeof(test_data), &loc);
-        if (rc == FCB_ERR_NOSPACE) {
+        rc = fcb2_append(fcb, sizeof(test_data), &loc);
+        if (rc == FCB2_ERR_NOSPACE) {
             break;
         }
         idx = loc.fe_sector;
         elem_cnts[idx]++;
 
-        rc = fcb_write(&loc, 0, test_data, sizeof(test_data));
+        rc = fcb2_write(&loc, 0, test_data, sizeof(test_data));
         TEST_ASSERT(rc == 0);
 
-        rc = fcb_append_finish(&loc);
+        rc = fcb2_append_finish(&loc);
         TEST_ASSERT(rc == 0);
     }
 
@@ -63,21 +63,21 @@ TEST_CASE_SELF(fcb_test_multiple_scratch)
     /*
      * Ask to use scratch block, then fill it up.
      */
-    rc = fcb_append_to_scratch(fcb);
+    rc = fcb2_append_to_scratch(fcb);
     TEST_ASSERT(rc == 0);
 
     while (1) {
-        rc = fcb_append(fcb, sizeof(test_data), &loc);
-        if (rc == FCB_ERR_NOSPACE) {
+        rc = fcb2_append(fcb, sizeof(test_data), &loc);
+        if (rc == FCB2_ERR_NOSPACE) {
             break;
         }
         idx = loc.fe_sector;
         elem_cnts[idx]++;
 
-        rc = fcb_write(&loc, 0, test_data, sizeof(test_data));
+        rc = fcb2_write(&loc, 0, test_data, sizeof(test_data));
         TEST_ASSERT(rc == 0);
 
-        rc = fcb_append_finish(&loc);
+        rc = fcb2_append_finish(&loc);
         TEST_ASSERT(rc == 0);
     }
     TEST_ASSERT(elem_cnts[3] == elem_cnts[0]);
@@ -85,19 +85,19 @@ TEST_CASE_SELF(fcb_test_multiple_scratch)
     /*
      * Rotate
      */
-    rc = fcb_rotate(fcb);
+    rc = fcb2_rotate(fcb);
     TEST_ASSERT(rc == 0);
 
     memset(&cnts, 0, sizeof(cnts));
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_cnt_elems_cb, &aa_arg);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_cnt_elems_cb, &aa_arg);
     TEST_ASSERT(rc == 0);
 
     TEST_ASSERT(cnts[0] == 0);
     TEST_ASSERT(cnts[1] > 0);
     TEST_ASSERT(cnts[1] == cnts[2] && cnts[1] == cnts[3]);
 
-    rc = fcb_append_to_scratch(fcb);
+    rc = fcb2_append_to_scratch(fcb);
     TEST_ASSERT(rc == 0);
-    rc = fcb_append_to_scratch(fcb);
+    rc = fcb2_append_to_scratch(fcb);
     TEST_ASSERT(rc != 0);
 }
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_reset.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_reset.c
index 17c0202..b073065 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_reset.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_reset.c
@@ -20,10 +20,10 @@
 
 TEST_CASE_SELF(fcb_test_reset)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int rc;
     int i;
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
     uint8_t test_data[128];
     int var_cnt;
 
@@ -32,35 +32,35 @@ TEST_CASE_SELF(fcb_test_reset)
     fcb = &test_fcb;
 
     var_cnt = 0;
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(var_cnt == 0);
 
-    rc = fcb_append(fcb, 32, &loc);
+    rc = fcb2_append(fcb, 32, &loc);
     TEST_ASSERT(rc == 0);
 
     /*
      * No ready ones yet. CRC should not match.
      */
     var_cnt = 0;
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(var_cnt == 0);
 
     for (i = 0; i < sizeof(test_data); i++) {
         test_data[i] = fcb_test_append_data(32, i);
     }
-    rc = fcb_write(&loc, 0, test_data, 32);
+    rc = fcb2_write(&loc, 0, test_data, 32);
     TEST_ASSERT(rc == 0);
 
-    rc = fcb_append_finish(&loc);
+    rc = fcb2_append_finish(&loc);
     TEST_ASSERT(rc == 0);
 
     /*
      * one entry
      */
     var_cnt = 32;
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(var_cnt == 33);
 
@@ -72,35 +72,35 @@ TEST_CASE_SELF(fcb_test_reset)
     fcb->f_sector_cnt = 2;
     fcb->f_ranges = test_fcb_ranges;
 
-    rc = fcb_init(fcb);
+    rc = fcb2_init(fcb);
     TEST_ASSERT(rc == 0);
 
     var_cnt = 32;
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(var_cnt == 33);
 
-    rc = fcb_append(fcb, 33, &loc);
+    rc = fcb2_append(fcb, 33, &loc);
     TEST_ASSERT(rc == 0);
 
     for (i = 0; i < sizeof(test_data); i++) {
         test_data[i] = fcb_test_append_data(33, i);
     }
-    rc = fcb_write(&loc, 0, test_data, 33);
+    rc = fcb2_write(&loc, 0, test_data, 33);
     TEST_ASSERT(rc == 0);
 
-    rc = fcb_append_finish(&loc);
+    rc = fcb2_append_finish(&loc);
     TEST_ASSERT(rc == 0);
 
     var_cnt = 32;
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(var_cnt == 34);
 
     /*
      * Add partial one, make sure that we survive reset then.
      */
-    rc = fcb_append(fcb, 34, &loc);
+    rc = fcb2_append(fcb, 34, &loc);
     TEST_ASSERT(rc == 0);
 
     memset(fcb, 0, sizeof(*fcb));
@@ -108,35 +108,35 @@ TEST_CASE_SELF(fcb_test_reset)
     fcb->f_sector_cnt = 2;
     fcb->f_ranges = test_fcb_ranges;
 
-    rc = fcb_init(fcb);
+    rc = fcb2_init(fcb);
     TEST_ASSERT(rc == 0);
 
     /*
      * Walk should skip that.
      */
     var_cnt = 32;
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(var_cnt == 34);
 
     /* Add a 3rd one, should go behind corrupt entry */
-    rc = fcb_append(fcb, 34, &loc);
+    rc = fcb2_append(fcb, 34, &loc);
     TEST_ASSERT(rc == 0);
 
     for (i = 0; i < sizeof(test_data); i++) {
         test_data[i] = fcb_test_append_data(34, i);
     }
-    rc = fcb_write(&loc, 0, test_data, 34);
+    rc = fcb2_write(&loc, 0, test_data, 34);
     TEST_ASSERT(rc == 0);
 
-    rc = fcb_append_finish(&loc);
+    rc = fcb2_append_finish(&loc);
     TEST_ASSERT(rc == 0);
 
     /*
      * Walk should skip corrupt entry, but report the next one.
      */
     var_cnt = 32;
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_data_walk_cb, &var_cnt);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(var_cnt == 35);
 }
diff --git a/fs/fcb2/selftest/src/testcases/fcb_test_rotate.c 
b/fs/fcb2/selftest/src/testcases/fcb_test_rotate.c
index 34ce9d7..4b7d9d6 100644
--- a/fs/fcb2/selftest/src/testcases/fcb_test_rotate.c
+++ b/fs/fcb2/selftest/src/testcases/fcb_test_rotate.c
@@ -20,10 +20,10 @@
 
 TEST_CASE_SELF(fcb_test_rotate)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int rc;
     int old_id;
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
     uint8_t test_data[128];
     int elem_cnts[2] = {0, 0};
     int cnts[2];
@@ -36,7 +36,7 @@ TEST_CASE_SELF(fcb_test_rotate)
     fcb = &test_fcb;
 
     old_id = fcb->f_active_id;
-    rc = fcb_rotate(fcb);
+    rc = fcb2_rotate(fcb);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(fcb->f_active_id == old_id + 1);
 
@@ -44,8 +44,8 @@ TEST_CASE_SELF(fcb_test_rotate)
      * Now fill up the
      */
     while (1) {
-        rc = fcb_append(fcb, sizeof(test_data), &loc);
-        if (rc == FCB_ERR_NOSPACE) {
+        rc = fcb2_append(fcb, sizeof(test_data), &loc);
+        if (rc == FCB2_ERR_NOSPACE) {
             break;
         }
         if (loc.fe_sector == 0) {
@@ -56,21 +56,21 @@ TEST_CASE_SELF(fcb_test_rotate)
             TEST_ASSERT(0);
         }
 
-        rc = fcb_write(&loc, 0, test_data, sizeof(test_data));
+        rc = fcb2_write(&loc, 0, test_data, sizeof(test_data));
         TEST_ASSERT(rc == 0);
 
-        rc = fcb_append_finish(&loc);
+        rc = fcb2_append_finish(&loc);
         TEST_ASSERT(rc == 0);
     }
     TEST_ASSERT(elem_cnts[0] > 0 && elem_cnts[0] == elem_cnts[1]);
 
     old_id = fcb->f_active_id;
-    rc = fcb_rotate(fcb);
+    rc = fcb2_rotate(fcb);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(fcb->f_active_id == old_id); /* no new area created */
 
     memset(cnts, 0, sizeof(cnts));
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_cnt_elems_cb, &aa_arg);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_cnt_elems_cb, &aa_arg);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(aa_arg.elem_cnts[0] == elem_cnts[0] ||
       aa_arg.elem_cnts[1] == elem_cnts[1]);
@@ -79,23 +79,23 @@ TEST_CASE_SELF(fcb_test_rotate)
     /*
      * One sector is full. The other one should have one entry in it.
      */
-    rc = fcb_append(fcb, sizeof(test_data), &loc);
+    rc = fcb2_append(fcb, sizeof(test_data), &loc);
     TEST_ASSERT(rc == 0);
 
-    rc = fcb_write(&loc, 0, test_data,
+    rc = fcb2_write(&loc, 0, test_data,
       sizeof(test_data));
     TEST_ASSERT(rc == 0);
 
-    rc = fcb_append_finish(&loc);
+    rc = fcb2_append_finish(&loc);
     TEST_ASSERT(rc == 0);
 
     old_id = fcb->f_active_id;
-    rc = fcb_rotate(fcb);
+    rc = fcb2_rotate(fcb);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(fcb->f_active_id == old_id);
 
     memset(cnts, 0, sizeof(cnts));
-    rc = fcb_walk(fcb, FCB_SECTOR_OLDEST, fcb_test_cnt_elems_cb, &aa_arg);
+    rc = fcb2_walk(fcb, FCB2_SECTOR_OLDEST, fcb_test_cnt_elems_cb, &aa_arg);
     TEST_ASSERT(rc == 0);
     TEST_ASSERT(aa_arg.elem_cnts[0] == 1 || aa_arg.elem_cnts[1] == 1);
     TEST_ASSERT(aa_arg.elem_cnts[0] == 0 || aa_arg.elem_cnts[1] == 0);
diff --git a/fs/fcb2/src/fcb.c b/fs/fcb2/src/fcb.c
index 80451d6..e8a65ff 100644
--- a/fs/fcb2/src/fcb.c
+++ b/fs/fcb2/src/fcb.c
@@ -19,12 +19,12 @@
 #include <limits.h>
 #include <stdlib.h>
 
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 #include "fcb_priv.h"
 #include "string.h"
 
 int
-fcb_init(struct fcb *fcb)
+fcb2_init(struct fcb2 *fcb)
 {
     struct flash_sector_range *range;
     struct flash_sector_range *newest_srp = NULL;
@@ -32,20 +32,20 @@ fcb_init(struct fcb *fcb)
     int i;
     int oldest = -1, newest = -1;
     int oldest_sec = -1, newest_sec = -1;
-    struct fcb_disk_area fda;
+    struct fcb2_disk_area fda;
 
     if (!fcb->f_ranges || fcb->f_sector_cnt - fcb->f_scratch_cnt < 1) {
-        return FCB_ERR_ARGS;
+        return FCB2_ERR_ARGS;
     }
 
     /* Fill last used, first used */
     for (i = 0; i < fcb->f_sector_cnt; i++) {
-        range = fcb_get_sector_range(fcb, i);
+        range = fcb2_get_sector_range(fcb, i);
         /* Require alignment to be a power of two.  Some code depends on this
          * assumption.
          */
         assert((range->fsr_align & (range->fsr_align - 1)) == 0);
-        rc = fcb_sector_hdr_read(fcb, range, i, &fda);
+        rc = fcb2_sector_hdr_read(fcb, range, i, &fda);
         if (rc < 0) {
             return rc;
         }
@@ -58,11 +58,11 @@ fcb_init(struct fcb *fcb)
             newest_srp = range;
             continue;
         }
-        if (FCB_ID_GT(fda.fd_id, newest)) {
+        if (FCB2_ID_GT(fda.fd_id, newest)) {
             newest = fda.fd_id;
             newest_sec = i;
             newest_srp = range;
-        } else if (FCB_ID_GT(oldest, fda.fd_id)) {
+        } else if (FCB2_ID_GT(oldest, fda.fd_id)) {
             oldest = fda.fd_id;
             oldest_sec = i;
         }
@@ -73,7 +73,7 @@ fcb_init(struct fcb *fcb)
          */
         oldest_sec = newest_sec = 0;
         newest_srp = fcb->f_ranges;
-        rc = fcb_sector_hdr_init(fcb, newest_sec, 0);
+        rc = fcb2_sector_hdr_init(fcb, newest_sec, 0);
         if (rc) {
             return rc;
         }
@@ -83,14 +83,14 @@ fcb_init(struct fcb *fcb)
     fcb->f_active.fe_range = newest_srp;
     fcb->f_active.fe_sector = newest_sec;
     fcb->f_active.fe_data_off =
-        fcb_len_in_flash(newest_srp, sizeof(struct fcb_disk_area));
+        fcb2_len_in_flash(newest_srp, sizeof(struct fcb2_disk_area));
     fcb->f_active.fe_entry_num = 0;
     fcb->f_active_id = newest;
 
     while (1) {
-        rc = fcb_getnext_in_area(fcb, &fcb->f_active);
-        if (rc == FCB_ERR_NOVAR) {
-            rc = FCB_OK;
+        rc = fcb2_getnext_in_area(fcb, &fcb->f_active);
+        if (rc == FCB2_ERR_NOVAR) {
+            rc = FCB2_OK;
             break;
         }
         if (rc != 0) {
@@ -102,14 +102,14 @@ fcb_init(struct fcb *fcb)
 }
 
 int
-fcb_free_sector_cnt(struct fcb *fcb)
+fcb2_free_sector_cnt(struct fcb2 *fcb)
 {
     int i;
     int sector;
 
     sector = fcb->f_active.fe_sector;
     for (i = 0; i < fcb->f_sector_cnt; i++) {
-        sector = fcb_getnext_sector(fcb, sector);
+        sector = fcb2_getnext_sector(fcb, sector);
         if (sector == fcb->f_oldest_sec) {
             break;
         }
@@ -118,21 +118,21 @@ fcb_free_sector_cnt(struct fcb *fcb)
 }
 
 int
-fcb_is_empty(struct fcb *fcb)
+fcb2_is_empty(struct fcb2 *fcb)
 {
     return (fcb->f_active.fe_sector == fcb->f_oldest_sec &&
         fcb->f_active.fe_data_off ==
-            fcb_len_in_flash(fcb->f_active.fe_range,
-                             sizeof(struct fcb_disk_area)));
+            fcb2_len_in_flash(fcb->f_active.fe_range,
+                              sizeof(struct fcb2_disk_area)));
 }
 
 struct flash_sector_range *
-fcb_get_sector_range(const struct fcb *fcb, int sector)
+fcb2_get_sector_range(const struct fcb2 *fcb, int sector)
 {
     int i;
     struct flash_sector_range *srp = fcb->f_ranges;
 
-    if (FCB_SECTOR_OLDEST == sector) {
+    if (FCB2_SECTOR_OLDEST == sector) {
         sector = fcb->f_oldest_sec;
     }
     for (i = 0; i < fcb->f_range_cnt; ++i, ++srp) {
@@ -149,15 +149,15 @@ fcb_get_sector_range(const struct fcb *fcb, int sector)
  * Initialize erased sector for use.
  */
 int
-fcb_sector_hdr_init(struct fcb *fcb, int sector, uint16_t id)
+fcb2_sector_hdr_init(struct fcb2 *fcb, int sector, uint16_t id)
 {
-    struct fcb_disk_area fda;
-    struct fcb_sector_info info;
+    struct fcb2_disk_area fda;
+    struct fcb2_sector_info info;
     struct flash_sector_range *range;
     int sector_in_range;
     int rc;
 
-    rc = fcb_get_sector_info(fcb, sector, &info);
+    rc = fcb2_get_sector_info(fcb, sector, &info);
     if (rc) {
         return rc;
     }
@@ -173,7 +173,7 @@ fcb_sector_hdr_init(struct fcb *fcb, int sector, uint16_t 
id)
     rc = flash_area_write(&range->fsr_flash_area,
         sector_in_range * range->fsr_sector_size, &fda, sizeof(fda));
     if (rc) {
-        return FCB_ERR_FLASH;
+        return FCB2_ERR_FLASH;
     }
     return 0;
 }
@@ -185,10 +185,10 @@ fcb_sector_hdr_init(struct fcb *fcb, int sector, uint16_t 
id)
  * Returns 1 if sector has data.
  */
 int
-fcb_sector_hdr_read(struct fcb *fcb, struct flash_sector_range *srp,
-    uint16_t sec, struct fcb_disk_area *fdap)
+fcb2_sector_hdr_read(struct fcb2 *fcb, struct flash_sector_range *srp,
+                     uint16_t sec, struct fcb2_disk_area *fdap)
 {
-    struct fcb_disk_area fda;
+    struct fcb2_disk_area fda;
     int rc;
     uint32_t off = (sec - srp->fsr_first_sector) * srp->fsr_sector_size;
 
@@ -197,15 +197,15 @@ fcb_sector_hdr_read(struct fcb *fcb, struct 
flash_sector_range *srp,
     }
     rc = flash_area_read_is_empty(&srp->fsr_flash_area, off, fdap, 
sizeof(*fdap));
     if (rc < 0) {
-        return FCB_ERR_FLASH;
+        return FCB2_ERR_FLASH;
     } else if (rc == 1) {
         return 0;
     }
     if (fdap->fd_magic != fcb->f_magic) {
-        return FCB_ERR_MAGIC;
+        return FCB2_ERR_MAGIC;
     }
     if (fdap->fd_ver != fcb->f_version) {
-        return FCB_ERR_VERSION;
+        return FCB2_ERR_VERSION;
     }
     return 1;
 }
@@ -218,7 +218,7 @@ fcb_sector_hdr_read(struct fcb *fcb, struct 
flash_sector_range *srp,
  * @return 0 on there are any fcbs aviable; OS_ENOENT otherwise
  */
 int
-fcb_offset_last_n(struct fcb *fcb, uint8_t entries, struct fcb_entry *loc)
+fcb2_offset_last_n(struct fcb2 *fcb, uint8_t entries, struct fcb2_entry *loc)
 {
     int i;
 
@@ -229,7 +229,7 @@ fcb_offset_last_n(struct fcb *fcb, uint8_t entries, struct 
fcb_entry *loc)
 
     i = 0;
     memset(loc, 0, sizeof(*loc));
-    while (!fcb_getprev(fcb, loc)) {
+    while (!fcb2_getprev(fcb, loc)) {
         --entries;
         i++;
         if (entries == 0) {
@@ -237,7 +237,7 @@ fcb_offset_last_n(struct fcb *fcb, uint8_t entries, struct 
fcb_entry *loc)
         }
     }
 
-    return (i == 0) ? FCB_ERR_NOVAR : 0;
+    return (i == 0) ? FCB2_ERR_NOVAR : 0;
 }
 
 /**
@@ -246,13 +246,13 @@ fcb_offset_last_n(struct fcb *fcb, uint8_t entries, 
struct fcb_entry *loc)
  * @return 0 on success; non-zero on failure
  */
 int
-fcb_clear(struct fcb *fcb)
+fcb2_clear(struct fcb2 *fcb)
 {
     int rc;
 
     rc = 0;
-    while (!fcb_is_empty(fcb)) {
-        rc = fcb_rotate(fcb);
+    while (!fcb2_is_empty(fcb)) {
+        rc = fcb2_rotate(fcb);
         if (rc) {
             break;
         }
@@ -261,8 +261,8 @@ fcb_clear(struct fcb *fcb)
 }
 
 int
-fcb_init_flash_area(struct fcb *fcb, int flash_area_id, uint32_t magic,
-    uint8_t version)
+fcb2_init_flash_area(struct fcb2 *fcb, int flash_area_id, uint32_t magic,
+                     uint8_t version)
 {
     const struct flash_area *fa;
     struct flash_sector_range *sector_ranges;
@@ -297,14 +297,14 @@ fcb_init_flash_area(struct fcb *fcb, int flash_area_id, 
uint32_t magic,
      * should be in dedicated flash area and nothing should prevent us from
      * creating log there.
      */
-    rc = fcb_init(fcb);
+    rc = fcb2_init(fcb);
     if (rc) {
         /* Need to erase full area here */
         rc = flash_area_open(flash_area_id, &fa);
         assert(rc == 0);
 
         flash_area_erase(fa, 0, fa->fa_size);
-        rc = fcb_init(fcb);
+        rc = fcb2_init(fcb);
         assert(rc == 0);
     }
 
@@ -312,13 +312,13 @@ fcb_init_flash_area(struct fcb *fcb, int flash_area_id, 
uint32_t magic,
 }
 
 int
-fcb_get_sector_info(const struct fcb *fcb, int sector,
-    struct fcb_sector_info *info)
+fcb2_get_sector_info(const struct fcb2 *fcb, int sector,
+                     struct fcb2_sector_info *info)
 {
     struct flash_sector_range *srp = fcb->f_ranges;
     int i;
 
-    if (sector == FCB_SECTOR_OLDEST) {
+    if (sector == FCB2_SECTOR_OLDEST) {
         sector = fcb->f_oldest_sec;
     }
 
@@ -333,11 +333,11 @@ fcb_get_sector_info(const struct fcb *fcb, int sector,
             sector * srp->fsr_sector_size;
         return 0;
     }
-    return FCB_ERR_ARGS;
+    return FCB2_ERR_ARGS;
 }
 
 int
-fcb_get_total_size(const struct fcb *fcb)
+fcb2_get_total_size(const struct fcb2 *fcb)
 {
     struct flash_sector_range *srp = fcb->f_ranges;
     int size = 0;
@@ -350,12 +350,12 @@ fcb_get_total_size(const struct fcb *fcb)
 }
 
 int
-fcb_sector_erase(const struct fcb *fcb, int sector)
+fcb2_sector_erase(const struct fcb2 *fcb, int sector)
 {
-    struct fcb_sector_info info;
+    struct fcb2_sector_info info;
     int rc;
 
-    rc = fcb_get_sector_info(fcb, sector, &info);
+    rc = fcb2_get_sector_info(fcb, sector, &info);
     if (rc) {
         goto end;
     }
diff --git a/fs/fcb2/src/fcb_append.c b/fs/fcb2/src/fcb_append.c
index a039ece..156bb15 100644
--- a/fs/fcb2/src/fcb_append.c
+++ b/fs/fcb2/src/fcb_append.c
@@ -18,18 +18,19 @@
  */
 #include <stddef.h>
 
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 #include "fcb_priv.h"
 #include "crc/crc8.h"
 
 int
-fcb_new_sector(struct fcb *fcb, int cnt)
+fcb2_new_sector(struct fcb2 *fcb, int cnt)
 {
 
     int new_sector = -1;
     int sector = fcb->f_active.fe_sector;
+
     do {
-        sector = fcb_getnext_sector(fcb, sector);
+        sector = fcb2_getnext_sector(fcb, sector);
         if (new_sector < 0) {
             new_sector = sector;
         }
@@ -46,39 +47,39 @@ fcb_new_sector(struct fcb *fcb, int cnt)
  * Take one of the scratch blocks into use, if at all possible.
  */
 int
-fcb_append_to_scratch(struct fcb *fcb)
+fcb2_append_to_scratch(struct fcb2 *fcb)
 {
     int sector;
     int rc;
     struct flash_sector_range *range;
 
-    sector = fcb_new_sector(fcb, 0);
+    sector = fcb2_new_sector(fcb, 0);
     if (sector < 0) {
-        return FCB_ERR_NOSPACE;
+        return FCB2_ERR_NOSPACE;
     }
-    rc = fcb_sector_hdr_init(fcb, sector, fcb->f_active_id + 1);
+    rc = fcb2_sector_hdr_init(fcb, sector, fcb->f_active_id + 1);
     if (rc) {
         return rc;
     }
-    range = fcb_get_sector_range(fcb, sector);
+    range = fcb2_get_sector_range(fcb, sector);
     fcb->f_active.fe_range = range;
     fcb->f_active.fe_sector = sector;
     fcb->f_active.fe_data_off =
-        fcb_len_in_flash(range, sizeof(struct fcb_disk_area));
+        fcb2_len_in_flash(range, sizeof(struct fcb2_disk_area));
     fcb->f_active.fe_entry_num = 1;
     fcb->f_active_id++;
-    return FCB_OK;
+    return FCB2_OK;
 }
 
 static inline int
-fcb_sector_flash_offset(const struct fcb_entry *loc)
+fcb2_sector_flash_offset(const struct fcb2_entry *loc)
 {
     return (loc->fe_sector - loc->fe_range->fsr_first_sector) *
         loc->fe_range->fsr_sector_size;
 }
 
 int
-fcb_write_to_sector(struct fcb_entry *loc, int off, const void *buf, int len)
+fcb2_write_to_sector(struct fcb2_entry *loc, int off, const void *buf, int len)
 {
     /* For negative offsets write from the end of sector */
     if (off < 0) {
@@ -89,11 +90,11 @@ fcb_write_to_sector(struct fcb_entry *loc, int off, const 
void *buf, int len)
         len = loc->fe_range->fsr_sector_size - off;
     }
     return flash_area_write(&loc->fe_range->fsr_flash_area,
-        fcb_sector_flash_offset(loc) + off, buf, len);
+        fcb2_sector_flash_offset(loc) + off, buf, len);
 }
 
 int
-fcb_read_from_sector(struct fcb_entry *loc, int off, void *buf, int len)
+fcb2_read_from_sector(struct fcb2_entry *loc, int off, void *buf, int len)
 {
     /* For negative offsets read from the end of sector */
     if (off < 0) {
@@ -104,90 +105,92 @@ fcb_read_from_sector(struct fcb_entry *loc, int off, void 
*buf, int len)
         len = loc->fe_range->fsr_sector_size - off;
     }
     return flash_area_read(&loc->fe_range->fsr_flash_area,
-        fcb_sector_flash_offset(loc) + off, buf, len);
+        fcb2_sector_flash_offset(loc) + off, buf, len);
 }
 
 int
-fcb_entry_location_in_range(const struct fcb_entry *loc)
+fcb2_entry_location_in_range(const struct fcb2_entry *loc)
 {
     const struct flash_sector_range *range = loc->fe_range;
 
     return range->fsr_sector_size *
         (1 + loc->fe_sector - range->fsr_first_sector) -
-        (loc->fe_entry_num * fcb_len_in_flash(loc->fe_range, FCB_ENTRY_SIZE));
+        (loc->fe_entry_num * fcb2_len_in_flash(loc->fe_range, 
FCB2_ENTRY_SIZE));
 }
 
 int
-fcb_active_sector_free_space(const struct fcb *fcb)
+fcb2_active_sector_free_space(const struct fcb2 *fcb)
 {
-    const struct fcb_entry *active = &fcb->f_active;
+    const struct fcb2_entry *active = &fcb->f_active;
     const struct flash_sector_range *range = active->fe_range;
 
     return range->fsr_sector_size - active->fe_data_off -
-        (active->fe_entry_num * fcb_len_in_flash(range, FCB_ENTRY_SIZE));
+        (active->fe_entry_num * fcb2_len_in_flash(range, FCB2_ENTRY_SIZE));
 }
 
 int
-fcb_write(struct fcb_entry *loc, uint16_t off, const void *buf, uint16_t len)
+fcb2_write(struct fcb2_entry *loc, uint16_t off, const void *buf, uint16_t len)
 {
     int pos = loc->fe_data_off + off;
-    /* Make sure tha write does not exceed lenght declared in fcb_append */
+
+    /* Make sure tha write does not exceed lenght declared in fcb2_append */
     if (off + len > loc->fe_data_len) {
         len = loc->fe_data_len - off;
     }
-    return fcb_write_to_sector(loc, pos, buf, len);
+    return fcb2_write_to_sector(loc, pos, buf, len);
 }
 
 int
-fcb_read(struct fcb_entry *loc, uint16_t off, void *buf, uint16_t len)
+fcb2_read(struct fcb2_entry *loc, uint16_t off, void *buf, uint16_t len)
 {
     int pos = loc->fe_data_off + off;
+
     /* Make sure that read is only from entry data */
     if (off + len > loc->fe_data_len) {
         len = loc->fe_data_len - off;
     }
-    return fcb_read_from_sector(loc, pos, buf, len);
+    return fcb2_read_from_sector(loc, pos, buf, len);
 }
 
 int
-fcb_element_length_in_flash(const struct fcb_entry *loc, int len)
+fcb2_element_length_in_flash(const struct fcb2_entry *loc, int len)
 {
-    return fcb_len_in_flash(loc->fe_range, len) +
-        fcb_len_in_flash(loc->fe_range, FCB_CRC_LEN);
+    return fcb2_len_in_flash(loc->fe_range, len) +
+        fcb2_len_in_flash(loc->fe_range, FCB2_CRC_LEN);
 }
 
 int
-fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *append_loc)
+fcb2_append(struct fcb2 *fcb, uint16_t len, struct fcb2_entry *append_loc)
 {
-    struct fcb_entry *active;
+    struct fcb2_entry *active;
     struct flash_sector_range *range;
-    uint8_t flash_entry[FCB_ENTRY_SIZE];
+    uint8_t flash_entry[FCB2_ENTRY_SIZE];
     int sector;
     int rc;
 
-    if (len == 0 || len >= FCB_MAX_LEN) {
-        return FCB_ERR_ARGS;
+    if (len == 0 || len >= FCB2_MAX_LEN) {
+        return FCB2_ERR_ARGS;
     }
 
     rc = os_mutex_pend(&fcb->f_mtx, OS_WAIT_FOREVER);
     if (rc && rc != OS_NOT_STARTED) {
-        return FCB_ERR_ARGS;
+        return FCB2_ERR_ARGS;
     }
     active = &fcb->f_active;
-    if (fcb_active_sector_free_space(fcb) < fcb_element_length_in_flash(active,
-                                                                        len)) {
-        sector = fcb_new_sector(fcb, fcb->f_scratch_cnt);
+    if (fcb2_active_sector_free_space(fcb) < 
fcb2_element_length_in_flash(active,
+                                                                          
len)) {
+        sector = fcb2_new_sector(fcb, fcb->f_scratch_cnt);
         if (sector >= 0) {
-            range = fcb_get_sector_range(fcb, sector);
+            range = fcb2_get_sector_range(fcb, sector);
         }
         if (sector < 0 || (range->fsr_sector_size <
-            fcb_len_in_flash(range, sizeof(struct fcb_disk_area)) +
-            fcb_len_in_flash(range, len) +
-            fcb_len_in_flash(range, FCB_CRC_LEN))) {
-            rc = FCB_ERR_NOSPACE;
+            fcb2_len_in_flash(range, sizeof(struct fcb2_disk_area)) +
+            fcb2_len_in_flash(range, len) +
+            fcb2_len_in_flash(range, FCB2_CRC_LEN))) {
+            rc = FCB2_ERR_NOSPACE;
             goto err;
         }
-        rc = fcb_sector_hdr_init(fcb, sector, fcb->f_active_id + 1);
+        rc = fcb2_sector_hdr_init(fcb, sector, fcb->f_active_id + 1);
         if (rc) {
             goto err;
         }
@@ -195,7 +198,7 @@ fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry 
*append_loc)
         fcb->f_active.fe_sector = sector;
         /* Start with offset just after sector header */
         fcb->f_active.fe_data_off =
-            fcb_len_in_flash(range, sizeof(struct fcb_disk_area));
+            fcb2_len_in_flash(range, sizeof(struct fcb2_disk_area));
         /* No entries as yet */
         fcb->f_active.fe_entry_num = 1;
         fcb->f_active.fe_data_len = 0;
@@ -210,13 +213,13 @@ fcb_append(struct fcb *fcb, uint16_t len, struct 
fcb_entry *append_loc)
     flash_entry[2] = (uint8_t)(fcb->f_active.fe_data_off >> 0);
     flash_entry[3] = (uint8_t)(len >> 8);
     flash_entry[4] = (uint8_t)(len >> 0);
-    flash_entry[5] = crc8_calc(crc8_init(), flash_entry, FCB_ENTRY_SIZE - 1);
+    flash_entry[5] = crc8_calc(crc8_init(), flash_entry, FCB2_ENTRY_SIZE - 1);
 
-    rc = fcb_write_to_sector(active,
-        active->fe_entry_num * -fcb_len_in_flash(range, FCB_ENTRY_SIZE),
-        flash_entry, FCB_ENTRY_SIZE);
+    rc = fcb2_write_to_sector(active,
+        active->fe_entry_num * -fcb2_len_in_flash(range, FCB2_ENTRY_SIZE),
+        flash_entry, FCB2_ENTRY_SIZE);
     if (rc) {
-        rc = FCB_ERR_FLASH;
+        rc = FCB2_ERR_FLASH;
         goto err;
     }
     *append_loc = *active;
@@ -224,35 +227,35 @@ fcb_append(struct fcb *fcb, uint16_t len, struct 
fcb_entry *append_loc)
     append_loc->fe_data_len = len;
 
     /* Prepare active element num and offset for new append */
-    active->fe_data_off += fcb_element_length_in_flash(active, len);
+    active->fe_data_off += fcb2_element_length_in_flash(active, len);
     active->fe_entry_num++;
 
     os_mutex_release(&fcb->f_mtx);
 
-    return FCB_OK;
+    return FCB2_OK;
 err:
     os_mutex_release(&fcb->f_mtx);
     return rc;
 }
 
 int
-fcb_append_finish(struct fcb_entry *loc)
+fcb2_append_finish(struct fcb2_entry *loc)
 {
     int rc;
     uint16_t crc;
     uint8_t fl_crc[2];
     uint32_t off;
 
-    rc = fcb_elem_crc16(loc, &crc);
+    rc = fcb2_elem_crc16(loc, &crc);
     if (rc) {
         return rc;
     }
     put_be16(fl_crc, crc);
-    off = loc->fe_data_off + fcb_len_in_flash(loc->fe_range, loc->fe_data_len);
+    off = loc->fe_data_off + fcb2_len_in_flash(loc->fe_range, 
loc->fe_data_len);
 
-    rc = fcb_write_to_sector(loc, off, fl_crc, sizeof(fl_crc));
+    rc = fcb2_write_to_sector(loc, off, fl_crc, sizeof(fl_crc));
     if (rc) {
-        return FCB_ERR_FLASH;
+        return FCB2_ERR_FLASH;
     }
     return 0;
 }
diff --git a/fs/fcb2/src/fcb_area_info.c b/fs/fcb2/src/fcb_area_info.c
index 80c41c4..85a5b53 100644
--- a/fs/fcb2/src/fcb_area_info.c
+++ b/fs/fcb2/src/fcb_area_info.c
@@ -17,19 +17,19 @@
  * under the License.
  */
 
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 #include "fcb_priv.h"
 
 int
-fcb_area_info(struct fcb *fcb, int sector, int *elemsp, int *bytesp)
+fcb2_area_info(struct fcb2 *fcb, int sector, int *elemsp, int *bytesp)
 {
-    struct fcb_entry loc;
-    struct fcb_sector_info info;
+    struct fcb2_entry loc;
+    struct fcb2_sector_info info;
     int rc;
     int elems = 0;
     int bytes = 0;
 
-    rc = fcb_get_sector_info(fcb, sector, &info);
+    rc = fcb2_get_sector_info(fcb, sector, &info);
     if (rc) {
         return rc;
     }
@@ -37,12 +37,12 @@ fcb_area_info(struct fcb *fcb, int sector, int *elemsp, int 
*bytesp)
     loc.fe_sector = info.si_sector_in_range + loc.fe_range->fsr_first_sector;
     loc.fe_entry_num = 0;
     /* In case caller passed oldest, get real sector number */
-    if (sector == FCB_SECTOR_OLDEST) {
-        sector =  loc.fe_sector;
+    if (sector == FCB2_SECTOR_OLDEST) {
+        sector = loc.fe_sector;
     }
 
     while (1) {
-        rc = fcb_getnext(fcb, &loc);
+        rc = fcb2_getnext(fcb, &loc);
         if (rc) {
             break;
         }
diff --git a/fs/fcb2/src/fcb_elem_info.c b/fs/fcb2/src/fcb_elem_info.c
index a222f36..ea1d9b8 100644
--- a/fs/fcb2/src/fcb_elem_info.c
+++ b/fs/fcb2/src/fcb_elem_info.c
@@ -20,16 +20,16 @@
 #include <crc/crc8.h>
 #include <crc/crc16.h>
 
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 #include "fcb_priv.h"
 
 /*
  * Given offset in flash area, compute crc16 over the data.
  */
 int
-fcb_elem_crc16(struct fcb_entry *loc, uint16_t *c16p)
+fcb2_elem_crc16(struct fcb2_entry *loc, uint16_t *c16p)
 {
-    uint8_t tmp_str[FCB_TMP_BUF_SZ];
+    uint8_t tmp_str[FCB2_TMP_BUF_SZ];
     int blk_sz;
     uint16_t crc16;
     uint32_t off;
@@ -46,9 +46,9 @@ fcb_elem_crc16(struct fcb_entry *loc, uint16_t *c16p)
             blk_sz = sizeof(tmp_str);
         }
 
-        rc = fcb_read_from_sector(loc, off, tmp_str, blk_sz);
+        rc = fcb2_read_from_sector(loc, off, tmp_str, blk_sz);
         if (rc) {
-            return FCB_ERR_FLASH;
+            return FCB2_ERR_FLASH;
         }
         crc16 = crc16_ccitt(crc16, tmp_str, blk_sz);
     }
@@ -58,9 +58,9 @@ fcb_elem_crc16(struct fcb_entry *loc, uint16_t *c16p)
 }
 
 static int
-fcb_read_entry(struct fcb_entry *loc)
+fcb2_read_entry(struct fcb2_entry *loc)
 {
-    uint8_t buf[FCB_ENTRY_SIZE];
+    uint8_t buf[FCB2_ENTRY_SIZE];
     uint8_t entry_crc;
     uint32_t entry_offset;
     uint32_t offset;
@@ -68,30 +68,31 @@ fcb_read_entry(struct fcb_entry *loc)
     int rc;
 
     assert(loc != NULL);
-    entry_offset = fcb_entry_location_in_range(loc);
+    entry_offset = fcb2_entry_location_in_range(loc);
     rc = flash_area_read_is_empty(&loc->fe_range->fsr_flash_area,
         entry_offset, buf, sizeof(buf));
     if (rc < 0) {
         /* Error reading from flash */
-        return FCB_ERR_FLASH;
+        return FCB2_ERR_FLASH;
     } else if (rc == 1) {
         /* Entry not filled on flash */
-        return FCB_ERR_NOVAR;
+        return FCB2_ERR_NOVAR;
     }
     /* Check entry CRC first */
-    entry_crc = crc8_calc(crc8_init(), buf, FCB_ENTRY_SIZE - 1);
-    if (entry_crc != buf[FCB_ENTRY_SIZE - 1]) {
-        return FCB_ERR_CRC;
+    entry_crc = crc8_calc(crc8_init(), buf, FCB2_ENTRY_SIZE - 1);
+    if (entry_crc != buf[FCB2_ENTRY_SIZE - 1]) {
+        return FCB2_ERR_CRC;
     }
     offset = (buf[0] << 16) | (buf[1] << 8) | (buf[2] << 0);
     len = (buf[3] << 8) | (buf[4] << 0);
     /* Sanity check for entry */
-    if (offset < fcb_len_in_flash(loc->fe_range, sizeof(struct fcb_disk_area)) 
||
-        len > FCB_MAX_LEN ||
+    if (offset < fcb2_len_in_flash(loc->fe_range,
+                                   sizeof(struct fcb2_disk_area)) ||
+        len > FCB2_MAX_LEN ||
         offset + len > entry_offset) {
         /* Entry was found but data stored does not make any sense
          * report as CRC error so it can be skipped */
-        return FCB_ERR_CRC;
+        return FCB2_ERR_CRC;
     }
 
     /* Entry looks decent, pass to the caller */
@@ -102,30 +103,30 @@ fcb_read_entry(struct fcb_entry *loc)
 }
 
 int
-fcb_elem_info(struct fcb_entry *loc)
+fcb2_elem_info(struct fcb2_entry *loc)
 {
     int rc;
     uint16_t crc16;
     uint8_t fl_crc16[2];
 
     /* Read entry from the end of the sector */
-    rc = fcb_read_entry(loc);
+    rc = fcb2_read_entry(loc);
     if (rc != 0) {
         return rc;
     }
 
     /* Read actual data and calculate CRC */
-    rc = fcb_elem_crc16(loc, &crc16);
+    rc = fcb2_elem_crc16(loc, &crc16);
     if (rc) {
         return rc;
     }
 
     /* Read CRC from flash */
-    rc = fcb_read_from_sector(loc,
-        loc->fe_data_off + fcb_len_in_flash(loc->fe_range, loc->fe_data_len),
+    rc = fcb2_read_from_sector(loc,
+        loc->fe_data_off + fcb2_len_in_flash(loc->fe_range, loc->fe_data_len),
         &fl_crc16, 2);
     if (rc || get_be16(fl_crc16) != crc16) {
-        return FCB_ERR_CRC;
+        return FCB2_ERR_CRC;
     }
 
     return 0;
diff --git a/fs/fcb2/src/fcb_getnext.c b/fs/fcb2/src/fcb_getnext.c
index f90e26d..4a61dfb 100644
--- a/fs/fcb2/src/fcb_getnext.c
+++ b/fs/fcb2/src/fcb_getnext.c
@@ -18,32 +18,32 @@
  */
 #include <stddef.h>
 
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 #include "fcb_priv.h"
 
 int
-fcb_getnext_in_area(struct fcb *fcb, struct fcb_entry *loc)
+fcb2_getnext_in_area(struct fcb2 *fcb, struct fcb2_entry *loc)
 {
-    int rc = FCB_ERR_CRC;
+    int rc = FCB2_ERR_CRC;
     int off;
     int len;
 
-    while (rc == FCB_ERR_CRC) {
+    while (rc == FCB2_ERR_CRC) {
         len = loc->fe_data_len;
         off = loc->fe_data_off;
         loc->fe_data_len = 0;
         loc->fe_entry_num++;
-        rc = fcb_elem_info(loc);
+        rc = fcb2_elem_info(loc);
         if (len) {
-            loc->fe_data_off = off + fcb_len_in_flash(loc->fe_range, len) +
-                fcb_len_in_flash(loc->fe_range, 2);
+            loc->fe_data_off = off + fcb2_len_in_flash(loc->fe_range, len) +
+                fcb2_len_in_flash(loc->fe_range, 2);
         }
     }
     return rc;
 }
 
 int
-fcb_getnext_nolock(struct fcb *fcb, struct fcb_entry *loc)
+fcb2_getnext_nolock(struct fcb2 *fcb, struct fcb2_entry *loc)
 {
     int rc;
 
@@ -52,47 +52,47 @@ fcb_getnext_nolock(struct fcb *fcb, struct fcb_entry *loc)
          * Find the first one we have in flash.
          */
         loc->fe_sector = fcb->f_oldest_sec;
-        loc->fe_range = fcb_get_sector_range(fcb, loc->fe_sector);
+        loc->fe_range = fcb2_get_sector_range(fcb, loc->fe_sector);
     }
     if (loc->fe_entry_num == 0) {
         /*
          * If offset is zero, we serve the first entry from the area.
          */
         loc->fe_entry_num = 1;
-        rc = fcb_elem_info(loc);
+        rc = fcb2_elem_info(loc);
     } else {
-        rc = fcb_getnext_in_area(fcb, loc);
+        rc = fcb2_getnext_in_area(fcb, loc);
     }
     switch (rc) {
     case 0:
         return 0;
-    case FCB_ERR_CRC:
+    case FCB2_ERR_CRC:
         break;
     default:
         goto next_sector;
     }
-    while (rc == FCB_ERR_CRC) {
-        rc = fcb_getnext_in_area(fcb, loc);
+    while (rc == FCB2_ERR_CRC) {
+        rc = fcb2_getnext_in_area(fcb, loc);
         if (rc == 0) {
             return 0;
         }
 
-        if (rc != FCB_ERR_CRC) {
+        if (rc != FCB2_ERR_CRC) {
             /*
              * Moving to next sector.
              */
 next_sector:
             if (loc->fe_sector == fcb->f_active.fe_sector) {
-                return FCB_ERR_NOVAR;
+                return FCB2_ERR_NOVAR;
             }
-            loc->fe_sector = fcb_getnext_sector(fcb, loc->fe_sector);
-            loc->fe_range = fcb_get_sector_range(fcb, loc->fe_sector);
+            loc->fe_sector = fcb2_getnext_sector(fcb, loc->fe_sector);
+            loc->fe_range = fcb2_get_sector_range(fcb, loc->fe_sector);
             loc->fe_entry_num = 1;
-            rc = fcb_elem_info(loc);
+            rc = fcb2_elem_info(loc);
             switch (rc) {
             case 0:
                 return 0;
-            case FCB_ERR_CRC:
+            case FCB2_ERR_CRC:
                 break;
             default:
                 goto next_sector;
@@ -104,15 +104,15 @@ next_sector:
 }
 
 int
-fcb_getnext(struct fcb *fcb, struct fcb_entry *loc)
+fcb2_getnext(struct fcb2 *fcb, struct fcb2_entry *loc)
 {
     int rc;
 
     rc = os_mutex_pend(&fcb->f_mtx, OS_WAIT_FOREVER);
     if (rc && rc != OS_NOT_STARTED) {
-        return FCB_ERR_ARGS;
+        return FCB2_ERR_ARGS;
     }
-    rc = fcb_getnext_nolock(fcb, loc);
+    rc = fcb2_getnext_nolock(fcb, loc);
     os_mutex_release(&fcb->f_mtx);
 
     return rc;
diff --git a/fs/fcb2/src/fcb_getprev.c b/fs/fcb2/src/fcb_getprev.c
index e98c86c..2305655 100644
--- a/fs/fcb2/src/fcb_getprev.c
+++ b/fs/fcb2/src/fcb_getprev.c
@@ -18,11 +18,11 @@
  */
 #include <stddef.h>
 
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 #include "fcb_priv.h"
 
 static int
-fcb_sector_find_last(struct fcb *fcb, struct fcb_entry *loc)
+fcb2_sector_find_last(struct fcb2 *fcb, struct fcb2_entry *loc)
 {
     int rc;
     int last_valid = 0;
@@ -30,11 +30,11 @@ fcb_sector_find_last(struct fcb *fcb, struct fcb_entry *loc)
     loc->fe_entry_num = 1;
 
     do {
-        rc = fcb_elem_info(loc);
+        rc = fcb2_elem_info(loc);
         if (rc == 0) {
             last_valid = loc->fe_entry_num;
         }
-        if (rc == FCB_ERR_NOVAR) {
+        if (rc == FCB2_ERR_NOVAR) {
             /*
              * Out entries in this sector
              */
@@ -43,10 +43,10 @@ fcb_sector_find_last(struct fcb *fcb, struct fcb_entry *loc)
                 /*
                  * No valid entries in this sector.
                  */
-                return FCB_ERR_NOVAR;
+                return FCB2_ERR_NOVAR;
             } else {
                 loc->fe_entry_num = last_valid;
-                rc = fcb_elem_info(loc);
+                rc = fcb2_elem_info(loc);
                 assert(rc == 0); /* must be; just succeeded a bit earlier */
                 return rc;
             }
@@ -57,13 +57,13 @@ fcb_sector_find_last(struct fcb *fcb, struct fcb_entry *loc)
 }
 
 int
-fcb_getprev(struct fcb *fcb, struct fcb_entry *loc)
+fcb2_getprev(struct fcb2 *fcb, struct fcb2_entry *loc)
 {
     int rc;
 
     rc = os_mutex_pend(&fcb->f_mtx, OS_WAIT_FOREVER);
     if (rc && rc != OS_NOT_STARTED) {
-        return FCB_ERR_ARGS;
+        return FCB2_ERR_ARGS;
     }
     if (loc->fe_range == NULL) {
         /*
@@ -78,20 +78,20 @@ fcb_getprev(struct fcb *fcb, struct fcb_entry *loc)
              * Need to get from previous sector.
              */
             if (loc->fe_sector == fcb->f_oldest_sec) {
-                return FCB_ERR_NOVAR;
+                return FCB2_ERR_NOVAR;
             }
             if (loc->fe_sector == 0) {
                 loc->fe_sector = fcb->f_sector_cnt - 1;
             } else {
                 loc->fe_sector--;
             }
-            loc->fe_range = fcb_get_sector_range(fcb, loc->fe_sector);
-            rc = fcb_sector_find_last(fcb, loc);
+            loc->fe_range = fcb2_get_sector_range(fcb, loc->fe_sector);
+            rc = fcb2_sector_find_last(fcb, loc);
             if (rc == 0) {
                 break;
             }
         } else {
-            rc = fcb_elem_info(loc);
+            rc = fcb2_elem_info(loc);
             if (rc == 0) {
                 break;
             }
diff --git a/fs/fcb2/src/fcb_priv.h b/fs/fcb2/src/fcb_priv.h
index a1ec9d5..d02784f 100644
--- a/fs/fcb2/src/fcb_priv.h
+++ b/fs/fcb2/src/fcb_priv.h
@@ -16,32 +16,32 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#ifndef __SYS_FCB_PRIV_H_
-#define __SYS_FCB_PRIV_H_
+#ifndef __SYS_FCB2_PRIV_H_
+#define __SYS_FCB2_PRIV_H_
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define FCB_TMP_BUF_SZ  32
+#define FCB2_TMP_BUF_SZ  32
 
-#define FCB_ID_GT(a, b) (((int16_t)(a) - (int16_t)(b)) > 0)
+#define FCB2_ID_GT(a, b) (((int16_t)(a) - (int16_t)(b)) > 0)
 
-struct fcb_disk_area {
+struct fcb2_disk_area {
     uint32_t fd_magic;
     uint8_t  fd_ver;
     uint8_t  _pad;
     uint16_t fd_id;
 };
 
-struct fcb_sector_info {
+struct fcb2_sector_info {
     struct flash_sector_range *si_range;  /* Sector range */
     uint32_t si_sector_offset;            /* Sector offset in fcb */
     uint16_t si_sector_in_range;          /* Sector number relative to 
si_range */
 };
 
 static inline int
-fcb_len_in_flash(const struct flash_sector_range *range, uint16_t len)
+fcb2_len_in_flash(const struct flash_sector_range *range, uint16_t len)
 {
     if (range->fsr_align <= 1) {
         return len;
@@ -49,10 +49,10 @@ fcb_len_in_flash(const struct flash_sector_range *range, 
uint16_t len)
     return (len + (range->fsr_align - 1)) & ~(range->fsr_align - 1);
 }
 
-int fcb_getnext_in_area(struct fcb *fcb, struct fcb_entry *loc);
+int fcb2_getnext_in_area(struct fcb2 *fcb, struct fcb2_entry *loc);
 
 static inline int
-fcb_getnext_sector(struct fcb *fcb, int sector)
+fcb2_getnext_sector(struct fcb2 *fcb, int sector)
 {
     if (++sector >= fcb->f_sector_cnt) {
         sector = 0;
@@ -60,63 +60,63 @@ fcb_getnext_sector(struct fcb *fcb, int sector)
     return sector;
 }
 
-int fcb_getnext_nolock(struct fcb *fcb, struct fcb_entry *loc);
+int fcb2_getnext_nolock(struct fcb2 *fcb, struct fcb2_entry *loc);
 
-int fcb_elem_info(struct fcb_entry *loc);
-int fcb_elem_crc16(struct fcb_entry *loc, uint16_t *c16p);
-int fcb_sector_hdr_init(struct fcb *fcb, int sector, uint16_t id);
-int fcb_entry_location_in_range(const struct fcb_entry *loc);
+int fcb2_elem_info(struct fcb2_entry *loc);
+int fcb2_elem_crc16(struct fcb2_entry *loc, uint16_t *c16p);
+int fcb2_sector_hdr_init(struct fcb2 *fcb, int sector, uint16_t id);
+int fcb2_entry_location_in_range(const struct fcb2_entry *loc);
 
-struct flash_sector_range *fcb_get_sector_range(const struct fcb *fcb,
-    int sector);
+struct flash_sector_range *fcb2_get_sector_range(const struct fcb2 *fcb,
+                                                 int sector);
 
-int fcb_sector_hdr_read(struct fcb *, struct flash_sector_range *srp,
-    uint16_t sec, struct fcb_disk_area *fdap);
+int fcb2_sector_hdr_read(struct fcb2 *, struct flash_sector_range *srp,
+                         uint16_t sec, struct fcb2_disk_area *fdap);
 
 /**
  * Finds sector range for given fcb sector.
  */
-struct flash_sector_range *fcb_get_sector_range(const struct fcb *fcb,
-    int sector);
+struct flash_sector_range *fcb2_get_sector_range(const struct fcb2 *fcb,
+                                                 int sector);
 
 /**
  * @brief Get information about sector from fcb.
  *
  * @param fcb     fcb to check sector
  * @param sector  fcb sector number
- *                sector can be specified as FCB_SECTOR_OLDEST.
+ *                sector can be specified as FCB2_SECTOR_OLDEST.
  * @param info    pointer to structure that will receive sector information
  *
  * @return 0 if sector information was extracted correctly
- *        FCB_ERR_ARGS if sector number was outside fcb range.
+ *        FCB2_ERR_ARGS if sector number was outside fcb range.
  */
-int fcb_get_sector_info(const struct fcb *fcb, int sector,
-    struct fcb_sector_info *info);
+int fcb2_get_sector_info(const struct fcb2 *fcb, int sector,
+                         struct fcb2_sector_info *info);
 
 /**
  * @brief Write data to fcb sector.
  *
- * @param loc     location of the sector from fcb_get_sector_loc().
+ * @param loc     location of the sector from fcb2_get_sector_loc().
  * @param off     offset from the beginning of the sector to start write
  * @param buf     pointer to data to be written
  * @param len     number of bytes to write to the fcb sector
  *
  * @return 0 if write was successful non zero otherwise.
  */
-int fcb_write_to_sector(struct fcb_entry *loc, int off,
-    const void *buf, int len);
+int fcb2_write_to_sector(struct fcb2_entry *loc, int off,
+                         const void *buf, int len);
 
 /**
  * @brief Read data from fcb sector.
  *
- * @param loc     location of the sector from fcb_get_sector_loc().
+ * @param loc     location of the sector from fcb2_get_sector_loc().
  * @param off     offset from the beginning of the sector to start read
  * @param buf     pointer to output buffer
  * @param len     number of bytes to read from the fcb sector
  *
  * @return 0 if read was successful non zero otherwise.
  */
-int fcb_read_from_sector(struct fcb_entry *loc, int off, void *buf, int len);
+int fcb2_read_from_sector(struct fcb2_entry *loc, int off, void *buf, int len);
 
 #ifdef __cplusplus
 }
diff --git a/fs/fcb2/src/fcb_rotate.c b/fs/fcb2/src/fcb_rotate.c
index 53364e5..53bb13e 100644
--- a/fs/fcb2/src/fcb_rotate.c
+++ b/fs/fcb2/src/fcb_rotate.c
@@ -17,11 +17,11 @@
  * under the License.
  */
 
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 #include "fcb_priv.h"
 
 int
-fcb_rotate(struct fcb *fcb)
+fcb2_rotate(struct fcb2 *fcb)
 {
     int sector;
     int rc = 0;
@@ -29,34 +29,34 @@ fcb_rotate(struct fcb *fcb)
 
     rc = os_mutex_pend(&fcb->f_mtx, OS_WAIT_FOREVER);
     if (rc && rc != OS_NOT_STARTED) {
-        return FCB_ERR_ARGS;
+        return FCB2_ERR_ARGS;
     }
 
-    rc = fcb_sector_erase(fcb, fcb->f_oldest_sec);
+    rc = fcb2_sector_erase(fcb, fcb->f_oldest_sec);
     if (rc) {
-        rc = FCB_ERR_FLASH;
+        rc = FCB2_ERR_FLASH;
         goto out;
     }
     if (fcb->f_oldest_sec == fcb->f_active.fe_sector) {
         /*
          * Need to create a new active sector, as we're wiping the current.
          */
-        sector = fcb_getnext_sector(fcb, fcb->f_oldest_sec);
+        sector = fcb2_getnext_sector(fcb, fcb->f_oldest_sec);
 
-        rc = fcb_sector_hdr_init(fcb, sector, fcb->f_active_id + 1);
+        rc = fcb2_sector_hdr_init(fcb, sector, fcb->f_active_id + 1);
         if (rc) {
             goto out;
         }
-        range = fcb_get_sector_range(fcb, sector);
+        range = fcb2_get_sector_range(fcb, sector);
         fcb->f_active.fe_sector = sector;
         fcb->f_active.fe_range = range;
         fcb->f_active.fe_data_off =
-            fcb_len_in_flash(range, sizeof(struct fcb_disk_area));
+            fcb2_len_in_flash(range, sizeof(struct fcb2_disk_area));
         fcb->f_active.fe_entry_num = 1;
         fcb->f_active.fe_data_len = 0;
         fcb->f_active_id++;
     }
-    fcb->f_oldest_sec = fcb_getnext_sector(fcb, fcb->f_oldest_sec);
+    fcb->f_oldest_sec = fcb2_getnext_sector(fcb, fcb->f_oldest_sec);
 out:
     os_mutex_release(&fcb->f_mtx);
     return rc;
diff --git a/fs/fcb2/src/fcb_walk.c b/fs/fcb2/src/fcb_walk.c
index e6e1084..7e2d972 100644
--- a/fs/fcb2/src/fcb_walk.c
+++ b/fs/fcb2/src/fcb_walk.c
@@ -17,16 +17,16 @@
  * under the License.
  */
 
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 #include "fcb_priv.h"
 
 int
-fcb_get_sector_loc(const struct fcb *fcb, int sector, struct fcb_entry *entry)
+fcb2_get_sector_loc(const struct fcb2 *fcb, int sector, struct fcb2_entry 
*entry)
 {
-    struct fcb_sector_info info;
+    struct fcb2_sector_info info;
     int rc = 0;
 
-    rc = fcb_get_sector_info(fcb, sector, &info);
+    rc = fcb2_get_sector_info(fcb, sector, &info);
     if (rc == 0) {
         entry->fe_range = info.si_range;
         entry->fe_sector = info.si_sector_in_range +
@@ -41,22 +41,22 @@ fcb_get_sector_loc(const struct fcb *fcb, int sector, 
struct fcb_entry *entry)
  * only elements with that flash_area are reported.
  */
 int
-fcb_walk(struct fcb *fcb, int sector, fcb_walk_cb cb, void *cb_arg)
+fcb2_walk(struct fcb2 *fcb, int sector, fcb2_walk_cb cb, void *cb_arg)
 {
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
     int rc;
 
-    fcb_get_sector_loc(fcb, sector, &loc);
+    fcb2_get_sector_loc(fcb, sector, &loc);
     loc.fe_data_off = 0;
     loc.fe_entry_num = 0;
 
     rc = os_mutex_pend(&fcb->f_mtx, OS_WAIT_FOREVER);
     if (rc && rc != OS_NOT_STARTED) {
-        return FCB_ERR_ARGS;
+        return FCB2_ERR_ARGS;
     }
-    while ((rc = fcb_getnext_nolock(fcb, &loc)) != FCB_ERR_NOVAR) {
+    while ((rc = fcb2_getnext_nolock(fcb, &loc)) != FCB2_ERR_NOVAR) {
         os_mutex_release(&fcb->f_mtx);
-        if (sector != FCB_SECTOR_OLDEST && loc.fe_sector != sector) {
+        if (sector != FCB2_SECTOR_OLDEST && loc.fe_sector != sector) {
             return 0;
         }
         rc = cb(&loc, cb_arg);
diff --git a/sys/config/include/config/config_fcb.h 
b/sys/config/include/config/config_fcb.h
index 9c75fc9..ccc4c7d 100644
--- a/sys/config/include/config/config_fcb.h
+++ b/sys/config/include/config/config_fcb.h
@@ -19,6 +19,8 @@
 #ifndef __SYS_CONFIG_FCB_H_
 #define __SYS_CONFIG_FCB_H_
 
+#include <fcb/fcb.h>
+
 #include "config/config.h"
 #include "config/config_store.h"
 
diff --git a/sys/config/include/config/config_fcb2.h 
b/sys/config/include/config/config_fcb2.h
index 7072521..114a909 100644
--- a/sys/config/include/config/config_fcb2.h
+++ b/sys/config/include/config/config_fcb2.h
@@ -19,6 +19,8 @@
 #ifndef __SYS_CONFIG_FCB2_H_
 #define __SYS_CONFIG_FCB2_H_
 
+#include <fcb/fcb2.h>
+
 #include "config/config.h"
 #include "config/config_store.h"
 
@@ -28,7 +30,7 @@ extern "C" {
 
 struct conf_fcb2 {
     struct conf_store cf2_store;
-    struct fcb cf2_fcb;
+    struct fcb2 cf2_fcb;
 };
 
 /**
diff --git a/sys/config/include/config/config_generic_kv.h 
b/sys/config/include/config/config_generic_kv.h
index d9997c3..6d7b3c9 100644
--- a/sys/config/include/config/config_generic_kv.h
+++ b/sys/config/include/config/config_generic_kv.h
@@ -20,8 +20,14 @@
 #define __SYS_CONFIG_GENERIC_KV_H_
 
 #include <stddef.h>
+
 #include "config/config.h"
+#if MYNEWT_VAL(CONFIG_FCB)
 #include "fcb/fcb.h"
+#endif
+#if MYNEWT_VAL(CONFIG_FCB2)
+#include "fcb/fcb2.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -45,7 +51,12 @@ extern "C" {
  *
  * @return OS_OK on success, error code otherwise
  */
-int conf_fcb_kv_load(struct fcb *fcb, const char *name, char *value, size_t 
len);
+#if MYNEWT_VAL(CONFIG_FCB)
+int conf_fcb_kv_load(struct fcb *, const char *name, char *value, size_t len);
+#endif
+#if MYNEWT_VAL(CONFIG_FCB2)
+int conf_fcb2_kv_load(struct fcb2 *, const char *name, char *value, size_t 
len);
+#endif
 
 /**
  * Store value for given key to FCB key-value storage area
@@ -59,7 +70,12 @@ int conf_fcb_kv_load(struct fcb *fcb, const char *name, char 
*value, size_t len)
  *
  * @return OS_OK on success, error code otherwise
  */
-int conf_fcb_kv_save(struct fcb *fcb, const char *name, const char *value);
+#if MYNEWT_VAL(CONFIG_FCB)
+int conf_fcb_kv_save(struct fcb *, const char *name, const char *value);
+#endif
+#if MYNEWT_VAL(CONFIG_FCB2)
+int conf_fcb2_kv_save(struct fcb2 *, const char *name, const char *value);
+#endif
 
 #ifdef __cplusplus
 }
diff --git a/sys/config/selftest-fcb2/src/conf_test_fcb2.c 
b/sys/config/selftest-fcb2/src/conf_test_fcb2.c
index 8f097fd..4210179 100644
--- a/sys/config/selftest-fcb2/src/conf_test_fcb2.c
+++ b/sys/config/selftest-fcb2/src/conf_test_fcb2.c
@@ -23,7 +23,7 @@
 #include <os/mynewt.h>
 #include <flash_map/flash_map.h>
 #include <testutil/testutil.h>
-#include <fcb/fcb.h>
+#include <fcb/fcb2.h>
 #include <config/config.h>
 #include <config/config_fcb2.h>
 #include <config_priv.h>
diff --git a/sys/config/selftest-fcb2/src/conf_test_fcb2.h 
b/sys/config/selftest-fcb2/src/conf_test_fcb2.h
index 3b2b63f..c5e81e8 100644
--- a/sys/config/selftest-fcb2/src/conf_test_fcb2.h
+++ b/sys/config/selftest-fcb2/src/conf_test_fcb2.h
@@ -24,7 +24,7 @@
 #include <os/mynewt.h>
 #include <flash_map/flash_map.h>
 #include <testutil/testutil.h>
-#include <fcb/fcb.h>
+#include <fcb/fcb2.h>
 #include <config/config.h>
 #include <config/config_fcb2.h>
 #include <config_priv.h>
diff --git 
a/sys/config/selftest-fcb2/src/testcases/config_test_compress_reset.c 
b/sys/config/selftest-fcb2/src/testcases/config_test_compress_reset.c
index f74c8da..cc8eb1f 100644
--- a/sys/config/selftest-fcb2/src/testcases/config_test_compress_reset.c
+++ b/sys/config/selftest-fcb2/src/testcases/config_test_compress_reset.c
@@ -65,9 +65,9 @@ TEST_CASE_SELF(config_test_compress_reset)
     }
 
     fa = cf.cf2_fcb.f_active_id;
-    rc = fcb_append_to_scratch(&cf.cf2_fcb);
+    rc = fcb2_append_to_scratch(&cf.cf2_fcb);
     TEST_ASSERT(rc == 0);
-    TEST_ASSERT(fcb_free_sector_cnt(&cf.cf2_fcb) == 0);
+    TEST_ASSERT(fcb2_free_sector_cnt(&cf.cf2_fcb) == 0);
     TEST_ASSERT(fa != cf.cf2_fcb.f_active_id);
 
     config_wipe_srcs();
@@ -85,7 +85,7 @@ TEST_CASE_SELF(config_test_compress_reset)
     rc = conf_fcb2_dst(&cf);
     TEST_ASSERT(rc == 0);
 
-    TEST_ASSERT(fcb_free_sector_cnt(&cf.cf2_fcb) == 1);
+    TEST_ASSERT(fcb2_free_sector_cnt(&cf.cf2_fcb) == 1);
     TEST_ASSERT(fa == cf.cf2_fcb.f_active_id);
 
     c2_var_count = 0;
diff --git a/sys/config/src/config_fcb2.c b/sys/config/src/config_fcb2.c
index f3627ae..0874685 100644
--- a/sys/config/src/config_fcb2.c
+++ b/sys/config/src/config_fcb2.c
@@ -21,7 +21,7 @@
 
 #if MYNEWT_VAL(CONFIG_FCB2)
 
-#include <fcb/fcb.h>
+#include <fcb/fcb2.h>
 #include <string.h>
 
 #include "config/config.h"
@@ -65,7 +65,7 @@ conf_fcb2_src(struct conf_fcb2 *cf)
         cf->cf2_fcb.f_scratch_cnt = 0;
     }
     while (1) {
-        rc = fcb_init(&cf->cf2_fcb);
+        rc = fcb2_init(&cf->cf2_fcb);
         if (rc) {
             return OS_INVALID_PARM;
         }
@@ -75,8 +75,8 @@ conf_fcb2_src(struct conf_fcb2 *cf)
          * situation is recognized by checking if the scratch block is missing.
          */
         if (cf->cf2_fcb.f_scratch_cnt &&
-            fcb_free_sector_cnt(&cf->cf2_fcb) < 1) {
-            fcb_sector_erase(&cf->cf2_fcb, cf->cf2_fcb.f_active.fe_sector);
+            fcb2_free_sector_cnt(&cf->cf2_fcb) < 1) {
+            fcb2_sector_erase(&cf->cf2_fcb, cf->cf2_fcb.f_active.fe_sector);
         } else {
             break;
         }
@@ -98,7 +98,7 @@ conf_fcb2_dst(struct conf_fcb2 *cf)
 }
 
 static int
-conf_fcb2_load_cb(struct fcb_entry *loc, void *arg)
+conf_fcb2_load_cb(struct fcb2_entry *loc, void *arg)
 {
     struct conf_fcb2_load_cb_arg *argp;
     char buf[CONF_MAX_NAME_LEN + CONF_MAX_VAL_LEN + 32];
@@ -114,7 +114,7 @@ conf_fcb2_load_cb(struct fcb_entry *loc, void *arg)
         len = sizeof(buf) - 1;
     }
 
-    rc = fcb_read(loc, 0, buf, len);
+    rc = fcb2_read(loc, 0, buf, len);
     if (rc) {
         return 0;
     }
@@ -137,7 +137,7 @@ conf_fcb2_load(struct conf_store *cs, conf_store_load_cb 
cb, void *cb_arg)
 
     arg.cb = cb;
     arg.cb_arg = cb_arg;
-    rc = fcb_walk(&cf->cf2_fcb, FCB_SECTOR_OLDEST, conf_fcb2_load_cb, &arg);
+    rc = fcb2_walk(&cf->cf2_fcb, FCB2_SECTOR_OLDEST, conf_fcb2_load_cb, &arg);
     if (rc) {
         return OS_EINVAL;
     }
@@ -145,11 +145,11 @@ conf_fcb2_load(struct conf_store *cs, conf_store_load_cb 
cb, void *cb_arg)
 }
 
 static int
-conf_fcb2_var_read(struct fcb_entry *loc, char *buf, char **name, char **val)
+conf_fcb2_var_read(struct fcb2_entry *loc, char *buf, char **name, char **val)
 {
     int rc;
 
-    rc = fcb_read(loc, 0, buf, loc->fe_data_len);
+    rc = fcb2_read(loc, 0, buf, loc->fe_data_len);
     if (rc) {
         return rc;
     }
@@ -159,7 +159,7 @@ conf_fcb2_var_read(struct fcb_entry *loc, char *buf, char 
**name, char **val)
 }
 
 static void
-conf_fcb2_compress_internal(struct fcb *fcb,
+conf_fcb2_compress_internal(struct fcb2 *fcb,
                             int (*copy_or_not)(const char *name, const char 
*val,
                                                void *cn_arg),
                             void *cn_arg)
@@ -167,20 +167,20 @@ conf_fcb2_compress_internal(struct fcb *fcb,
     int rc;
     char buf1[CONF_MAX_NAME_LEN + CONF_MAX_VAL_LEN + 32];
     char buf2[CONF_MAX_NAME_LEN + CONF_MAX_VAL_LEN + 32];
-    struct fcb_entry loc1;
-    struct fcb_entry loc2;
+    struct fcb2_entry loc1;
+    struct fcb2_entry loc2;
     char *name1, *val1;
     char *name2, *val2;
     int copy;
 
-    rc = fcb_append_to_scratch(fcb);
+    rc = fcb2_append_to_scratch(fcb);
     if (rc) {
         return; /* XXX */
     }
 
     loc1.fe_range = NULL;
     loc1.fe_entry_num = 0;
-    while (fcb_getnext(fcb, &loc1) == 0) {
+    while (fcb2_getnext(fcb, &loc1) == 0) {
         if (loc1.fe_sector != fcb->f_oldest_sec) {
             break;
         }
@@ -193,7 +193,7 @@ conf_fcb2_compress_internal(struct fcb *fcb,
         }
         loc2 = loc1;
         copy = 1;
-        while (fcb_getnext(fcb, &loc2) == 0) {
+        while (fcb2_getnext(fcb, &loc2) == 0) {
             rc = conf_fcb2_var_read(&loc2, buf2, &name2, &val2);
             if (rc) {
                 continue;
@@ -216,21 +216,21 @@ conf_fcb2_compress_internal(struct fcb *fcb,
         /*
          * Can't find one. Must copy.
          */
-        rc = fcb_read(&loc1, 0, buf1, loc1.fe_data_len);
+        rc = fcb2_read(&loc1, 0, buf1, loc1.fe_data_len);
         if (rc) {
             continue;
         }
-        rc = fcb_append(fcb, loc1.fe_data_len, &loc2);
+        rc = fcb2_append(fcb, loc1.fe_data_len, &loc2);
         if (rc) {
             continue;
         }
-        rc = fcb_write(&loc2, 0, buf1, loc1.fe_data_len);
+        rc = fcb2_write(&loc2, 0, buf1, loc1.fe_data_len);
         if (rc) {
             continue;
         }
-        fcb_append_finish(&loc2);
+        fcb2_append_finish(&loc2);
     }
-    rc = fcb_rotate(fcb);
+    rc = fcb2_rotate(fcb);
     if (rc) {
         /* XXXX */
         ;
@@ -238,15 +238,15 @@ conf_fcb2_compress_internal(struct fcb *fcb,
 }
 
 static int
-conf_fcb2_append(struct fcb *fcb, char *buf, int len)
+conf_fcb2_append(struct fcb2 *fcb, char *buf, int len)
 {
     int rc;
     int i;
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
 
     for (i = 0; i < 10; i++) {
-        rc = fcb_append(fcb, len, &loc);
-        if (rc != FCB_ERR_NOSPACE) {
+        rc = fcb2_append(fcb, len, &loc);
+        if (rc != FCB2_ERR_NOSPACE) {
             break;
         }
         if (fcb->f_scratch_cnt == 0) {
@@ -257,11 +257,11 @@ conf_fcb2_append(struct fcb *fcb, char *buf, int len)
     if (rc) {
         return OS_EINVAL;
     }
-    rc = fcb_write(&loc, 0, buf, len);
+    rc = fcb2_write(&loc, 0, buf, len);
     if (rc) {
         return OS_EINVAL;
     }
-    fcb_append_finish(&loc);
+    fcb2_append_finish(&loc);
     return OS_OK;
 }
 
@@ -270,7 +270,7 @@ conf_fcb2_save(struct conf_store *cs, const char *name, 
const char *value)
 {
     struct conf_fcb2 *cf = (struct conf_fcb2 *)cs;
 
-    return conf_fcb_kv_save(&cf->cf2_fcb, name, value);
+    return conf_fcb2_kv_save(&cf->cf2_fcb, name, value);
 }
 
 void
@@ -283,7 +283,7 @@ conf_fcb2_compress(struct conf_fcb2 *cf,
 }
 
 static int
-conf_kv_load_cb(struct fcb_entry *loc, void *arg)
+conf_kv_load_cb(struct fcb2_entry *loc, void *arg)
 {
     struct conf_kv_load_cb_arg *cb_arg = arg;
     char buf[CONF_MAX_NAME_LEN + CONF_MAX_VAL_LEN + 32];
@@ -297,7 +297,7 @@ conf_kv_load_cb(struct fcb_entry *loc, void *arg)
         len = sizeof(buf) - 1;
     }
 
-    rc = fcb_read(loc, 0, buf, len);
+    rc = fcb2_read(loc, 0, buf, len);
     if (rc) {
         return 0;
     }
@@ -319,7 +319,7 @@ conf_kv_load_cb(struct fcb_entry *loc, void *arg)
 }
 
 int
-conf_fcb_kv_load(struct fcb *fcb, const char *name, char *value, size_t len)
+conf_fcb2_kv_load(struct fcb2 *fcb, const char *name, char *value, size_t len)
 {
     struct conf_kv_load_cb_arg arg;
     int rc;
@@ -328,7 +328,7 @@ conf_fcb_kv_load(struct fcb *fcb, const char *name, char 
*value, size_t len)
     arg.value = value;
     arg.len = len;
 
-    rc = fcb_walk(fcb, 0, conf_kv_load_cb, &arg);
+    rc = fcb2_walk(fcb, 0, conf_kv_load_cb, &arg);
     if (rc) {
         return OS_EINVAL;
     }
@@ -337,7 +337,7 @@ conf_fcb_kv_load(struct fcb *fcb, const char *name, char 
*value, size_t len)
 }
 
 int
-conf_fcb_kv_save(struct fcb *fcb, const char *name, const char *value)
+conf_fcb2_kv_save(struct fcb2 *fcb, const char *name, const char *value)
 {
     char buf[CONF_MAX_NAME_LEN + CONF_MAX_VAL_LEN + 32];
     int len;
diff --git a/sys/config/src/config_init.c b/sys/config/src/config_init.c
index ca5cccc..7a8b021 100644
--- a/sys/config/src/config_init.c
+++ b/sys/config/src/config_init.c
@@ -47,7 +47,7 @@ config_init_fs(void)
 }
 
 #elif MYNEWT_VAL(CONFIG_FCB)
-#include "fcb/fcb.h"
+
 #include "config/config_fcb.h"
 
 static struct flash_area conf_fcb_area[MYNEWT_VAL(CONFIG_FCB_NUM_AREAS) + 1];
@@ -90,7 +90,6 @@ config_init_fcb(void)
 
 #elif MYNEWT_VAL(CONFIG_FCB2)
 
-#include "fcb/fcb.h"
 #include "config/config_fcb2.h"
 
 static struct flash_sector_range config_init_fcb2_sector_range;
diff --git a/sys/log/full/include/log/log_fcb.h 
b/sys/log/full/include/log/log_fcb.h
index 05e52f0..c87937f 100644
--- a/sys/log/full/include/log/log_fcb.h
+++ b/sys/log/full/include/log/log_fcb.h
@@ -23,13 +23,20 @@
 extern "C" {
 #endif
 
+#if MYNEWT_VAL(LOG_FCB)
 #include <fcb/fcb.h>
+#elif MYNEWT_VAL(LOG_FCB2)
+#include <fcb/fcb2.h>
+#endif
 
 /** An individual fcb log bookmark. */
 struct log_fcb_bmark {
     /* FCB entry that the bookmark points to. */
+#if MYNEWT_VAL(LOG_FCB)
     struct fcb_entry lfb_entry;
-
+#elif MYNEWT_VAL(LOG_FCB2)
+    struct fcb2_entry lfb_entry;
+#endif
     /* The index of the log entry that the FCB entry contains. */
     uint32_t lfb_index;
 };
@@ -52,24 +59,36 @@ struct log_fcb_bset {
 /**
  * fcb_log is needed as the number of entries in a log
  */
+#if MYNEWT_VAL(LOG_FCB)
+
 struct fcb_log {
     struct fcb fl_fcb;
     uint8_t fl_entries;
 
 #if MYNEWT_VAL(LOG_STORAGE_WATERMARK)
-#if MYNEWT_VAL(LOG_FCB)
     /* Internal - tracking storage use */
     uint32_t fl_watermark_off;
 #endif
-#if MYNEWT_VAL(LOG_FCB2)
+#if MYNEWT_VAL(LOG_FCB_BOOKMARKS)
+    struct log_fcb_bset fl_bset;
+#endif
+};
+
+#elif MYNEWT_VAL(LOG_FCB2)
+
+struct fcb_log {
+    struct fcb2 fl_fcb;
+    uint8_t fl_entries;
+
+#if MYNEWT_VAL(LOG_STORAGE_WATERMARK)
     uint16_t fl_watermark_sec;
     uint32_t fl_watermark_off;
 #endif
-#endif
 #if MYNEWT_VAL(LOG_FCB_BOOKMARKS)
     struct log_fcb_bset fl_bset;
 #endif
 };
+#endif
 
 #if MYNEWT_VAL(LOG_FCB_BOOKMARKS)
 
@@ -125,8 +144,13 @@ log_fcb_closest_bmark(const struct fcb_log *fcb_log, 
uint32_t index);
  * @param entry                 The entry the bookmark should point to.
  * @param index                 The log entry index of the bookmark.
  */
+#if MYNEWT_VAL(LOG_FCB)
 void log_fcb_add_bmark(struct fcb_log *fcb_log, const struct fcb_entry *entry,
                        uint32_t index);
+#elif MYNEWT_VAL(LOG_FCB2)
+void log_fcb_add_bmark(struct fcb_log *fcb_log, const struct fcb2_entry *entry,
+                       uint32_t index);
+#endif
 #endif
 
 #ifdef __cplusplus
diff --git 
a/sys/log/full/selftest/fcb2_bookmarks/src/log_test_fcb_bookmarks_util.c 
b/sys/log/full/selftest/fcb2_bookmarks/src/log_test_fcb_bookmarks_util.c
index 25d7018..d422121 100644
--- a/sys/log/full/selftest/fcb2_bookmarks/src/log_test_fcb_bookmarks_util.c
+++ b/sys/log/full/selftest/fcb2_bookmarks/src/log_test_fcb_bookmarks_util.c
@@ -58,7 +58,7 @@ ltfbu_max_entries(void)
 
     /* "+ 2" for CRC. */
     entry_size = LOG_BASE_ENTRY_HDR_SIZE + ltfbu_cfg.body_len +
-                 FCB_ENTRY_SIZE + 2;
+                 FCB2_ENTRY_SIZE + 2;
     entry_space = LTFBU_SECTOR_SIZE - 8;
 
     return entry_space / entry_size;
@@ -216,7 +216,7 @@ ltfbu_init(const struct ltfbu_cfg *cfg)
                      ltfbu_fcb_range.fsr_flash_area.fa_size);
     TEST_ASSERT_FATAL(rc == 0);
 
-    rc = fcb_init(&ltfbu_fcb_log.fl_fcb);
+    rc = fcb2_init(&ltfbu_fcb_log.fl_fcb);
     TEST_ASSERT_FATAL(rc == 0);
 
     if (cfg->bmark_count > 0) {
diff --git 
a/sys/log/full/selftest/fcb2_watermarks/src/log_test_fcb_watermarks_util.c 
b/sys/log/full/selftest/fcb2_watermarks/src/log_test_fcb_watermarks_util.c
index 4d74b0c..a079ee2 100644
--- a/sys/log/full/selftest/fcb2_watermarks/src/log_test_fcb_watermarks_util.c
+++ b/sys/log/full/selftest/fcb2_watermarks/src/log_test_fcb_watermarks_util.c
@@ -169,7 +169,7 @@ ltfwu_init(const struct ltfwu_cfg *cfg)
                           ltfwu_fcb_range.fsr_flash_area.fa_size);
     TEST_ASSERT_FATAL(rc == 0);
 
-    rc = fcb_init(&ltfwu_fcb_log.fl_fcb);
+    rc = fcb2_init(&ltfwu_fcb_log.fl_fcb);
     TEST_ASSERT_FATAL(rc == 0);
 
     log_register("log", &ltfwu_log, &log_fcb_handler, &ltfwu_fcb_log,
diff --git a/sys/log/full/selftest/util/include/log_test_util/log_test_util.h 
b/sys/log/full/selftest/util/include/log_test_util/log_test_util.h
index 9786190..c6c78f5 100644
--- a/sys/log/full/selftest/util/include/log_test_util/log_test_util.h
+++ b/sys/log/full/selftest/util/include/log_test_util/log_test_util.h
@@ -22,7 +22,11 @@
 
 #include "os/mynewt.h"
 #include "testutil/testutil.h"
+#if MYNEWT_VAL(LOG_FCB)
 #include "fcb/fcb.h"
+#elif MYNEWT_VAL(LOG_FCB2)
+#include "fcb/fcb2.h"
+#endif
 #include "log/log.h"
 #include "log_test_util.h"
 
@@ -30,7 +34,11 @@
 extern "C" {
 #endif
 
+#if MYNEWT_VAL(LOG_FCB)
 extern struct fcb log_fcb;
+#elif MYNEWT_VAL(LOG_FCB2)
+extern struct fcb2 log_fcb;
+#endif
 extern struct log my_log;
 extern char *ltu_str_logs[];
 
diff --git a/sys/log/full/selftest/util/src/log_test_util.c 
b/sys/log/full/selftest/util/src/log_test_util.c
index 1682e04..4eaf2aa 100644
--- a/sys/log/full/selftest/util/src/log_test_util.c
+++ b/sys/log/full/selftest/util/src/log_test_util.c
@@ -121,6 +121,8 @@ ltu_setup_fcb(struct fcb_log *fcb_log, struct log *log)
         rc = flash_area_erase(&fcb_areas[i], 0, fcb_areas[i].fa_size);
         TEST_ASSERT(rc == 0);
     }
+    rc = fcb_init(&fcb_log->fl_fcb);
+    TEST_ASSERT(rc == 0);
 #endif
 #if MYNEWT_VAL(LOG_FCB2)
     (void)i;
@@ -129,10 +131,9 @@ ltu_setup_fcb(struct fcb_log *fcb_log, struct log *log)
     fcb_log->fl_fcb.f_ranges = &fcb_range;
     rc = flash_area_erase(&fcb_range.fsr_flash_area, 0,
                           fcb_range.fsr_flash_area.fa_size);
-#endif
-
-    rc = fcb_init(&fcb_log->fl_fcb);
+    rc = fcb2_init(&fcb_log->fl_fcb);
     TEST_ASSERT(rc == 0);
+#endif
 
     log_register("log", log, &log_fcb_handler, fcb_log, LOG_SYSLEVEL);
 }
diff --git a/sys/log/full/src/log_fcb2.c b/sys/log/full/src/log_fcb2.c
index 6528202..2d5ee76 100644
--- a/sys/log/full/src/log_fcb2.c
+++ b/sys/log/full/src/log_fcb2.c
@@ -25,7 +25,7 @@
 
 #include "flash_map/flash_map.h"
 #include "log/log.h"
-#include "fcb/fcb.h"
+#include "fcb/fcb2.h"
 
 /* Assume the flash alignment requirement is no stricter than 8. */
 #define LOG_FCB2_MAX_ALIGN   8
@@ -54,14 +54,14 @@ static int log_fcb2_rtr_erase(struct log *log);
  */
 static int
 log_fcb2_find_gte(struct log *log, struct log_offset *log_offset,
-                  struct fcb_entry *out_entry)
+                  struct fcb2_entry *out_entry)
 {
 #if MYNEWT_VAL(LOG_FCB_BOOKMARKS)
     const struct log_fcb_bmark *bmark;
 #endif
     struct log_entry_hdr hdr;
     struct fcb_log *fcb_log;
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int rc;
 
     fcb_log = log->l_arg;
@@ -69,8 +69,8 @@ log_fcb2_find_gte(struct log *log, struct log_offset 
*log_offset,
 
     /* Attempt to read the last entry.  If this fails, the FCB is empty. */
     memset(out_entry, 0, sizeof(*out_entry));
-    rc = fcb_getprev(fcb, out_entry);
-    if (rc == FCB_ERR_NOVAR) {
+    rc = fcb2_getprev(fcb, out_entry);
+    if (rc == FCB2_ERR_NOVAR) {
         return SYS_ENOENT;
     } else if (rc != 0) {
         return SYS_EUNKNOWN;
@@ -98,7 +98,7 @@ log_fcb2_find_gte(struct log *log, struct log_offset 
*log_offset,
      * Start from beginning.
      */
     memset(out_entry, 0, sizeof(*out_entry));
-    rc = fcb_getnext(fcb, out_entry);
+    rc = fcb2_getnext(fcb, out_entry);
     if (rc != 0) {
         return SYS_EUNKNOWN;
     }
@@ -119,15 +119,15 @@ log_fcb2_find_gte(struct log *log, struct log_offset 
*log_offset,
         if (hdr.ue_index >= log_offset->lo_index) {
             return 0;
         }
-    } while (fcb_getnext(fcb, out_entry) == 0);
+    } while (fcb2_getnext(fcb, out_entry) == 0);
 
     return SYS_ENOENT;
 }
 
 static int
-log_fcb2_start_append(struct log *log, int len, struct fcb_entry *loc)
+log_fcb2_start_append(struct log *log, int len, struct fcb2_entry *loc)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     struct fcb_log *fcb_log;
 #if MYNEWT_VAL(LOG_STORAGE_WATERMARK)
     int old_sec;
@@ -141,12 +141,12 @@ log_fcb2_start_append(struct log *log, int len, struct 
fcb_entry *loc)
     fcb = &fcb_log->fl_fcb;
 
     while (1) {
-        rc = fcb_append(fcb, len, loc);
+        rc = fcb2_append(fcb, len, loc);
         if (rc == 0) {
             break;
         }
 
-        if (rc != FCB_ERR_NOSPACE) {
+        if (rc != FCB2_ERR_NOSPACE) {
             goto err;
         }
 
@@ -163,7 +163,7 @@ log_fcb2_start_append(struct log *log, int len, struct 
fcb_entry *loc)
 #endif
 
 #if MYNEWT_VAL(LOG_STATS)
-        rc = fcb_area_info(fcb, FCB_SECTOR_OLDEST, &cnt, NULL);
+        rc = fcb2_area_info(fcb, FCB2_SECTOR_OLDEST, &cnt, NULL);
         if (rc == 0) {
             LOG_STATS_INCN(log, lost, cnt);
         }
@@ -174,7 +174,7 @@ log_fcb2_start_append(struct log *log, int len, struct 
fcb_entry *loc)
         log_fcb_clear_bmarks(fcb_log);
 #endif
 
-        rc = fcb_rotate(fcb);
+        rc = fcb2_rotate(fcb);
         if (rc) {
             goto err;
         }
@@ -223,7 +223,7 @@ log_fcb2_append_body(struct log *log, const struct 
log_entry_hdr *hdr,
 {
     uint8_t buf[LOG_BASE_ENTRY_HDR_SIZE + LOG_IMG_HASHLEN +
                 LOG_FCB2_MAX_ALIGN - 1];
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
     const uint8_t *u8p;
     int hdr_alignment;
     int chunk_sz;
@@ -262,7 +262,7 @@ log_fcb2_append_body(struct log *log, const struct 
log_entry_hdr *hdr,
     }
     memcpy(buf + hdr_len, u8p, hdr_alignment);
 
-    rc = fcb_write(&loc, 0, buf, chunk_sz);
+    rc = fcb2_write(&loc, 0, buf, chunk_sz);
     if (rc != 0) {
         return rc;
     }
@@ -273,13 +273,13 @@ log_fcb2_append_body(struct log *log, const struct 
log_entry_hdr *hdr,
     body_len -= hdr_alignment;
 
     if (body_len > 0) {
-        rc = fcb_write(&loc, chunk_sz, u8p, body_len);
+        rc = fcb2_write(&loc, chunk_sz, u8p, body_len);
         if (rc != 0) {
             return rc;
         }
     }
 
-    rc = fcb_append_finish(&loc);
+    rc = fcb2_append_finish(&loc);
     if (rc != 0) {
         return rc;
     }
@@ -299,12 +299,12 @@ log_fcb2_append(struct log *log, void *buf, int len)
 }
 
 static int
-log_fcb2_write_mbuf(struct fcb_entry *loc, struct os_mbuf *om, int off)
+log_fcb2_write_mbuf(struct fcb2_entry *loc, struct os_mbuf *om, int off)
 {
     int rc;
 
     while (om) {
-        rc = fcb_write(loc, off, om->om_data, om->om_len);
+        rc = fcb2_write(loc, off, om->om_data, om->om_len);
         if (rc != 0) {
             return SYS_EIO;
         }
@@ -320,7 +320,7 @@ static int
 log_fcb2_append_mbuf_body(struct log *log, const struct log_entry_hdr *hdr,
                           struct os_mbuf *om)
 {
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
     int len;
     int rc;
 
@@ -342,7 +342,7 @@ log_fcb2_append_mbuf_body(struct log *log, const struct 
log_entry_hdr *hdr,
         return rc;
     }
 
-    rc = fcb_write(&loc, 0, hdr, LOG_BASE_ENTRY_HDR_SIZE);
+    rc = fcb2_write(&loc, 0, hdr, LOG_BASE_ENTRY_HDR_SIZE);
     if (rc != 0) {
         return rc;
     }
@@ -350,7 +350,7 @@ log_fcb2_append_mbuf_body(struct log *log, const struct 
log_entry_hdr *hdr,
 
     if (hdr->ue_flags & LOG_FLAGS_IMG_HASH) {
         /* Write LOG_IMG_HASHLEN bytes of image hash */
-        rc = fcb_write(&loc, len, hdr->ue_imghash, LOG_IMG_HASHLEN);
+        rc = fcb2_write(&loc, len, hdr->ue_imghash, LOG_IMG_HASHLEN);
         if (rc != 0) {
             return rc;
         }
@@ -362,7 +362,7 @@ log_fcb2_append_mbuf_body(struct log *log, const struct 
log_entry_hdr *hdr,
         return rc;
     }
 
-    rc = fcb_append_finish(&loc);
+    rc = fcb2_append_finish(&loc);
     if (rc != 0) {
         return rc;
     }
@@ -415,15 +415,15 @@ log_fcb2_append_mbuf(struct log *log, struct os_mbuf *om)
 static int
 log_fcb2_read(struct log *log, void *dptr, void *buf, uint16_t off, uint16_t 
len)
 {
-    struct fcb_entry *loc;
+    struct fcb2_entry *loc;
     int rc;
 
-    loc = (struct fcb_entry *)dptr;
+    loc = (struct fcb2_entry *)dptr;
 
     if (off + len > loc->fe_data_len) {
         len = loc->fe_data_len - off;
     }
-    rc = fcb_read(loc, off, buf, len);
+    rc = fcb2_read(loc, off, buf, len);
     if (rc == 0) {
         return len;
     } else {
@@ -435,13 +435,13 @@ static int
 log_fcb2_read_mbuf(struct log *log, void *dptr, struct os_mbuf *om,
                    uint16_t off, uint16_t len)
 {
-    struct fcb_entry *loc;
+    struct fcb2_entry *loc;
     uint8_t data[128];
     uint16_t read_len;
     uint16_t rem_len;
     int rc;
 
-    loc = (struct fcb_entry *)dptr;
+    loc = (struct fcb2_entry *)dptr;
 
     if (off + len > loc->fe_data_len) {
         len = loc->fe_data_len - off;
@@ -451,7 +451,7 @@ log_fcb2_read_mbuf(struct log *log, void *dptr, struct 
os_mbuf *om,
 
     while (rem_len > 0) {
         read_len = min(rem_len, sizeof(data));
-        rc = fcb_read(loc, off, data, read_len);
+        rc = fcb2_read(loc, off, data, read_len);
         if (rc) {
             goto done;
         }
@@ -473,9 +473,9 @@ static int
 log_fcb2_walk(struct log *log, log_walk_func_t walk_func,
               struct log_offset *log_off)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     struct fcb_log *fcb_log;
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
     int rc;
 
     fcb_log = log->l_arg;
@@ -512,7 +512,7 @@ log_fcb2_walk(struct log *log, log_walk_func_t walk_func,
                 return 0;
             }
         }
-    } while (fcb_getnext(fcb, &loc) == 0);
+    } while (fcb2_getnext(fcb, &loc) == 0);
 
     return 0;
 }
@@ -521,7 +521,7 @@ static int
 log_fcb2_flush(struct log *log)
 {
     struct fcb_log *fcb_log;
-    struct fcb *fcb;
+    struct fcb2 *fcb;
 
     fcb_log = (struct fcb_log *)log->l_arg;
     fcb = &fcb_log->fl_fcb;
@@ -530,18 +530,18 @@ log_fcb2_flush(struct log *log)
     log_fcb_clear_bmarks(fcb_log);
 #endif
 
-    return fcb_clear(fcb);
+    return fcb2_clear(fcb);
 }
 
 static int
 log_fcb2_registered(struct log *log)
 {
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int i;
     struct fcb_log *fl;
 #if MYNEWT_VAL(LOG_STORAGE_WATERMARK)
 #if MYNEWT_VAL(LOG_PERSIST_WATERMARK)
-    struct fcb_entry loc;
+    struct fcb2_entry loc;
 #endif
 #endif
 
@@ -559,7 +559,7 @@ log_fcb2_registered(struct log *log)
     /* Set watermark to first element */
     memset(&loc, 0, sizeof(loc));
 
-    if (fcb_getnext(fcb, &loc)) {
+    if (fcb2_getnext(fcb, &loc)) {
         fl->fl_watermark_sec = loc.fe_sector;
         fl->fl_watermark_off = loc.fe_data_off;
     } else {
@@ -568,7 +568,7 @@ log_fcb2_registered(struct log *log)
     }
 #else
     /* Initialize watermark to designated unknown value*/
-    fl->fl_watermark_sec = FCB_SECTOR_OLDEST;
+    fl->fl_watermark_sec = FCB2_SECTOR_OLDEST;
     fl->fl_watermark_off = 0xffffffff;
 #endif
 #endif
@@ -580,7 +580,7 @@ static int
 log_fcb2_storage_info(struct log *log, struct log_storage_info *info)
 {
     struct fcb_log *fl;
-    struct fcb *fcb;
+    struct fcb2 *fcb;
     int i;
     int j;
     int sec;
@@ -593,7 +593,7 @@ log_fcb2_storage_info(struct log *log, struct 
log_storage_info *info)
 
     rc = os_mutex_pend(&fcb->f_mtx, OS_WAIT_FOREVER);
     if (rc && rc != OS_NOT_STARTED) {
-        return FCB_ERR_ARGS;
+        return FCB2_ERR_ARGS;
     }
 
     el_min_sec = fcb->f_oldest_sec;
@@ -650,7 +650,7 @@ log_fcb2_storage_info(struct log *log, struct 
log_storage_info *info)
         }
     }
 #if MYNEWT_VAL(LOG_STORAGE_WATERMARK)
-    if (fl->fl_watermark_sec == FCB_SECTOR_OLDEST) {
+    if (fl->fl_watermark_sec == FCB2_SECTOR_OLDEST) {
         info->used_unread = 0xffffffff;
     }
 #endif
@@ -666,12 +666,12 @@ static int
 log_fcb2_new_watermark_index(struct log *log, struct log_offset *log_off,
                              void *dptr, uint16_t len)
 {
-    struct fcb_entry *loc;
+    struct fcb2_entry *loc;
     struct fcb_log *fl;
     struct log_entry_hdr ueh;
     int rc;
 
-    loc = (struct fcb_entry *)dptr;
+    loc = (struct fcb2_entry *)dptr;
     fl = (struct fcb_log *)log->l_arg;
 
     rc = log_fcb2_read(log, loc, &ueh, 0, sizeof(ueh));
@@ -696,7 +696,7 @@ log_fcb2_set_watermark(struct log *log, uint32_t index)
     int rc;
     struct log_offset log_offset;
     struct fcb_log *fl;
-    struct fcb *fcb;
+    struct fcb2 *fcb;
 
     fl = (struct fcb_log *)log->l_arg;
     fcb = &fl->fl_fcb;
@@ -734,8 +734,8 @@ done:
  * @return 0 on success; non-zero on error
  */
 static int
-log_fcb2_copy_entry(struct log *log, struct fcb_entry *entry,
-                    struct fcb *dst_fcb)
+log_fcb2_copy_entry(struct log *log, struct fcb2_entry *entry,
+                    struct fcb2 *dst_fcb)
 {
     struct log_entry_hdr ueh;
     char data[LOG_PRINTF_MAX_ENTRY_LEN + LOG_BASE_ENTRY_HDR_SIZE +
@@ -743,7 +743,7 @@ log_fcb2_copy_entry(struct log *log, struct fcb_entry 
*entry,
     uint16_t hdr_len;
     int dlen;
     int rc;
-    struct fcb *fcb_tmp;
+    struct fcb2 *fcb_tmp;
 
     rc = log_fcb2_read(log, entry, &ueh, 0, LOG_BASE_ENTRY_HDR_SIZE);
     if (rc != LOG_BASE_ENTRY_HDR_SIZE) {
@@ -785,10 +785,10 @@ err:
  * @return 0 on success; non-zero on error
  */
 static int
-log_fcb2_copy(struct log *log, struct fcb *src_fcb, struct fcb *dst_fcb,
-              struct fcb_entry *from)
+log_fcb2_copy(struct log *log, struct fcb2 *src_fcb, struct fcb2 *dst_fcb,
+              struct fcb2_entry *from)
 {
-    struct fcb_entry entry;
+    struct fcb2_entry entry;
     int rc;
 
     rc = 0;
@@ -799,8 +799,8 @@ log_fcb2_copy(struct log *log, struct fcb *src_fcb, struct 
fcb *dst_fcb,
         if (rc) {
             break;
         }
-        rc = fcb_getnext(src_fcb, &entry);
-        if (rc == FCB_ERR_NOVAR) {
+        rc = fcb2_getnext(src_fcb, &entry);
+        if (rc == FCB2_ERR_NOVAR) {
             rc = 0;
             break;
         }
@@ -821,9 +821,9 @@ static int
 log_fcb2_rtr_erase(struct log *log)
 {
     struct fcb_log *fcb_log;
-    struct fcb fcb_scratch;
-    struct fcb *fcb;
-    struct fcb_entry entry;
+    struct fcb2 fcb_scratch;
+    struct fcb2 *fcb;
+    struct fcb2_entry entry;
     int rc;
     struct flash_sector_range range;
     int range_cnt;
@@ -851,13 +851,13 @@ log_fcb2_rtr_erase(struct log *log)
     fcb_scratch.f_version = g_log_info.li_version;
 
     flash_area_erase(&range.fsr_flash_area, 0, range.fsr_flash_area.fa_size);
-    rc = fcb_init(&fcb_scratch);
+    rc = fcb2_init(&fcb_scratch);
     if (rc) {
         goto err;
     }
 
     /* Calculate offset of n-th last entry */
-    rc = fcb_offset_last_n(fcb, fcb_log->fl_entries, &entry);
+    rc = fcb2_offset_last_n(fcb, fcb_log->fl_entries, &entry);
     if (rc) {
         goto err;
     }
@@ -875,7 +875,7 @@ log_fcb2_rtr_erase(struct log *log)
     }
 
     memset(&entry, 0, sizeof(entry));
-    rc = fcb_getnext(&fcb_scratch, &entry);
+    rc = fcb2_getnext(&fcb_scratch, &entry);
     if (rc) {
         goto err;
     }
diff --git a/sys/log/full/src/log_fcb_bmark.c b/sys/log/full/src/log_fcb_bmark.c
index 92e4791..365464e 100644
--- a/sys/log/full/src/log_fcb_bmark.c
+++ b/sys/log/full/src/log_fcb_bmark.c
@@ -68,9 +68,15 @@ log_fcb_closest_bmark(const struct fcb_log *fcb_log, 
uint32_t index)
     return closest;
 }
 
+#if MYNEWT_VAL(LOG_FCB)
 void
 log_fcb_add_bmark(struct fcb_log *fcb_log, const struct fcb_entry *entry,
                   uint32_t index)
+#elif MYNEWT_VAL(LOG_FCB2)
+void
+log_fcb_add_bmark(struct fcb_log *fcb_log, const struct fcb2_entry *entry,
+                  uint32_t index)
+#endif
 {
     struct log_fcb_bset *bset;
 
diff --git a/sys/reboot/src/log_reboot.c b/sys/reboot/src/log_reboot.c
index 24e335f..868295d 100644
--- a/sys/reboot/src/log_reboot.c
+++ b/sys/reboot/src/log_reboot.c
@@ -30,10 +30,6 @@
 #include "bsp/bsp.h"
 #include "flash_map/flash_map.h"
 
-#if MYNEWT_VAL(REBOOT_LOG_FCB)
-#include "fcb/fcb.h"
-#endif
-
 uint16_t reboot_cnt;
 static char reboot_cnt_str[12];
 static char log_reboot_written_str[12];
@@ -86,12 +82,18 @@ static int
 log_reboot_init_fcb(void)
 {
     const struct flash_area *ptr;
+#if MYNEWT_VAL(LOG_FCB)
     struct fcb *fcbp;
+#elif MYNEWT_VAL(LOG_FCB2)
+    struct fcb2 *fcbp;
+#endif
     int rc;
 
     if (flash_area_open(MYNEWT_VAL(REBOOT_LOG_FLASH_AREA), &ptr)) {
         return SYS_EUNKNOWN;
     }
+
+    reboot_log_fcb.fl_entries = MYNEWT_VAL(REBOOT_LOG_ENTRY_COUNT);
     fcbp = &reboot_log_fcb.fl_fcb;
 #if MYNEWT_VAL(LOG_FCB)
     reboot_sector = *ptr;
@@ -99,6 +101,15 @@ log_reboot_init_fcb(void)
     fcbp->f_version = g_log_info.li_version;
     fcbp->f_sector_cnt = 1;
     fcbp->f_sectors = &reboot_sector;
+
+    rc = fcb_init(fcbp);
+    if (rc) {
+        flash_area_erase(ptr, 0, ptr->fa_size);
+        rc = fcb_init(fcbp);
+        if (rc) {
+            return rc;
+        }
+    }
 #endif
 #if MYNEWT_VAL(LOG_FCB2)
     fcbp->f_magic = 0x8EADBAE0;
@@ -110,17 +121,16 @@ log_reboot_init_fcb(void)
     reboot_sector.fsr_sector_count = 1;
     reboot_sector.fsr_sector_size = ptr->fa_size;
     reboot_sector.fsr_align = flash_area_align(ptr);
-#endif
-    reboot_log_fcb.fl_entries = MYNEWT_VAL(REBOOT_LOG_ENTRY_COUNT);
 
-    rc = fcb_init(fcbp);
+    rc = fcb2_init(fcbp);
     if (rc) {
         flash_area_erase(ptr, 0, ptr->fa_size);
-        rc = fcb_init(fcbp);
+        rc = fcb2_init(fcbp);
         if (rc) {
             return rc;
         }
     }
+#endif
 
     rc = log_register("reboot_log", &reboot_log, &log_fcb_handler,
                       &reboot_log_fcb, LOG_SYSLEVEL);

Reply via email to