WriteFS Streaming Example
Example Description:
This example demonstrates how to perform streaming writes to multiple files on a flash filesystem. It creates two files, writes data to them in chunks, and then verifies the written data. Performance measurements are optionally included using the CONFIG_ENABLE_PERFORMANCE_TRACE flag.
Key Features:
Creates two files with specified names.
Writes data to files in chunks of ITER_SIZE bytes.
Verifies written data by reading the files back and comparing the contents.
Optionally measures performance using cycle counters.
Supports forced initialization of the filesystem.
Build and Run:
Prerequisites:
GAP SDK environment
Ninja build system (optional), otherwise will fallback to GMake
Build:
CMAKE_GENERATOR=Ninja cmake -S . -B build
cmake --build build
Run:
# Without traces
cmake --build build --target run
# With performance traces
CONFIG_ENABLE_PERFORMANCE_TRACE=1 cmake --build build --target run
Expected Output:
Starting test (type: writefs)
Number of cycles for file creation: ...
Number of cycles for 1024 bytes buffer write: ...
...
Number of cycles for file creation: ...
Number of cycles for 1024 bytes buffer write: ...
...
Example done, goodbye
Additional Notes:
The ITER_SIZE and BUFF_SIZE defines can be adjusted to modify the write behavior.
The CONFIG_ENABLE_PERFORMANCE_TRACE flag can be used to enable performance measurements.
The example assumes a pre-erased flash partition or enables automatic formatting.
Cleanup:
rm -rf build