|
| 1 | +# custom_fee |
| 2 | + |
| 3 | +`custom_fee` is a fixed-block Flash EEPROM Emulation (FEE) component for embedded |
| 4 | +systems. It targets deterministic block storage rather than a general-purpose KV |
| 5 | +database, with append-only writes, checkpoint-assisted boot recovery, and |
| 6 | +background garbage collection. |
| 7 | + |
| 8 | +## Implemented scope |
| 9 | + |
| 10 | +The current source tree already contains the main control flow and data-model |
| 11 | +building blocks for the component: |
| 12 | + |
| 13 | +- Public API entry points in [fee_api.h](./fee_api.h) |
| 14 | + and [fee_api.c](./fee_api.c) |
| 15 | +- Request submission and foreground/background arbitration in |
| 16 | + [fee_sched.c](./fee_sched.c) |
| 17 | +- Core read, write, invalidate, rollback, and record validation logic in |
| 18 | + [fee_core.c](./fee_core.c) |
| 19 | +- RAM cache maintenance and checkpoint import/export in |
| 20 | + [fee_cache.c](./fee_cache.c) and |
| 21 | + [fee_ckpt.c](./fee_ckpt.c) |
| 22 | +- Boot recovery, checkpoint restore, tail scan, and interrupted-GC handling in |
| 23 | + [fee_recovery.c](./fee_recovery.c) |
| 24 | +- Incremental garbage collection state handling in |
| 25 | + [fee_gc.c](./fee_gc.c) |
| 26 | +- On-flash header, tail, and record helpers in |
| 27 | + [fee_onflash.h](./fee_onflash.h) and |
| 28 | + [fee_onflash.c](./fee_onflash.c) |
| 29 | +- Static block and lane configuration in |
| 30 | + [fee_cfg.h](./fee_cfg.h) and |
| 31 | + [fee_cfg.c](./fee_cfg.c) |
| 32 | + |
| 33 | +## Functional characteristics |
| 34 | + |
| 35 | +At the component level, the current implementation is designed around these |
| 36 | +behaviors: |
| 37 | + |
| 38 | +- Block-oriented access by `block_id` |
| 39 | +- Synchronous reads plus queued writes, invalidates, and rollbacks |
| 40 | +- Current-copy and previous-copy tracking for rollback and tolerant recovery |
| 41 | +- RAM cache lookup after initialization instead of full media scans on every read |
| 42 | +- Checkpoint-based startup acceleration with staged initialization states |
| 43 | +- Lane-based isolation for fast, normal, and bulk traffic |
| 44 | +- Background GC and checkpoint work driven by `fee_mainfunction()` |
| 45 | +- Record-level commit markers and CRC validation for power-loss recovery |
| 46 | + |
| 47 | +## Public API |
| 48 | + |
| 49 | +The user-facing API currently exposed by |
| 50 | +[fee_api.h](./fee_api.h) is: |
| 51 | + |
| 52 | +```c |
| 53 | +fee_ret_t fee_init(void); |
| 54 | +fee_ret_t fee_read(uint16_t block_id, uint16_t offset, uint8_t *dst, uint16_t len); |
| 55 | +fee_ret_t fee_write(uint16_t block_id, const uint8_t *src, uint16_t len); |
| 56 | +fee_ret_t fee_invalidate(uint16_t block_id); |
| 57 | +fee_ret_t fee_get_status(uint16_t block_id, fee_block_status_t *status); |
| 58 | +fee_ret_t fee_rollback(uint16_t block_id); |
| 59 | +void fee_mainfunction(void); |
| 60 | + |
| 61 | +fee_status_t fee_get_memif_status(void); |
| 62 | +fee_job_result_t fee_get_job_result(void); |
| 63 | +fee_init_state_t fee_get_init_state(void); |
| 64 | +``` |
| 65 | +
|
| 66 | +## Directory layout |
| 67 | +
|
| 68 | +- [doc/README.md](./doc/README.md): documentation index |
| 69 | +- [doc/en/README.md](./doc/en/README.md): English documents |
| 70 | +- [doc/zh/README.md](./doc/zh/README.md): Chinese documents |
| 71 | +- Source files in the repository root: API, scheduler, GC, recovery, cache, |
| 72 | + checkpoint, on-flash format, and configuration modules |
| 73 | +- [Kconfig](./Kconfig) and |
| 74 | + [SConscript](./SConscript): integration hooks |
| 75 | +
|
| 76 | +## Documentation sets |
| 77 | +
|
| 78 | +Two separated documentation sets are now provided: |
| 79 | +
|
| 80 | +- English: [doc/en/README.md](./doc/en/README.md) |
| 81 | +- Chinese: [doc/zh/README.md](./doc/zh/README.md) |
| 82 | +
|
| 83 | +Recommended entry points: |
| 84 | +
|
| 85 | +- Architecture and redesign baseline: |
| 86 | + [doc/en/fee_redesign.md](./doc/en/fee_redesign.md) |
| 87 | +- Public API and usage: |
| 88 | + [doc/en/fee_API.md](./doc/en/fee_API.md) |
| 89 | +- Diagnostic test interpretation: |
| 90 | + [doc/en/fee_diag_test.md](./doc/en/fee_diag_test.md) |
| 91 | +
|
| 92 | +## Current repository status |
| 93 | +
|
| 94 | +This repository snapshot is still an integration-oriented implementation set, |
| 95 | +not a production-complete drop-in release. |
| 96 | +
|
| 97 | +- The core module logic and design documents are present. |
| 98 | +- The documentation references a `fee_port` adapter layer and test backends as |
| 99 | + part of the intended integration model. |
| 100 | +- The corresponding adapter and test source files are not included in this |
| 101 | + snapshot, so bring-up still requires project-side integration work. |
| 102 | +
|
| 103 | +## Quick integration notes |
| 104 | +
|
| 105 | +1. Configure the component in [Kconfig](./Kconfig). |
| 106 | +2. Define the block table and flash capabilities required by the target. |
| 107 | +3. Call `fee_init()` during boot. |
| 108 | +4. Drive `fee_mainfunction()` periodically. |
| 109 | +5. Treat `fee_write()`, `fee_invalidate()`, and `fee_rollback()` as queued jobs |
| 110 | + and observe completion through status/job-result APIs. |
| 111 | +
|
0 commit comments