Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flashfs rolling erase #211

Closed
wants to merge 4 commits into from

Conversation

gongtao0607
Copy link
Contributor

@gongtao0607 gongtao0607 commented Dec 26, 2024

This PR is based off PR #209. It implements rolling erase.

Background: #126 (comment) bullet 3

set blackbox_rolling_erase = ON to turn it on (default is off).

The feature is tested on Matek G474Heli and Flydragon, both have w25n01g flash chip whose sector erase is ~2ms.

If the sector erase is slower, there will be buffer drops and log gaps, which is generally fine (tested). However, the exact behavior on other flash chips is untested and there may be room for improvements (e.g., erase suspend, larger buffer).

@gongtao0607 gongtao0607 changed the title Flashfs Loop background erase Flashfs background erase Dec 26, 2024
@gongtao0607 gongtao0607 force-pushed the background_erase branch 2 times, most recently from 253b426 to 4217b7e Compare January 3, 2025 00:24
When using loop mode, we will identify the "start of the data stream"
(by empty region followed by filled region). Also the usable size is
reduced to `full size - page size - buffer size`. (The - buffer size is
for code simplicity).
The original FLASHFS_FREE_BLOCK_SIZE is changed to page size to avoid
misalignment.

A new option blackbox_initial_erase is added to maintain a certain amount
of free space upon record start.

This also add (change) some cli cmds for diagnoses:
flash_fill
flash_verify
flash_erase_sector
flashfs_initial_erase
@gongtao0607 gongtao0607 changed the title Flashfs background erase Flashfs rolling erase Jan 6, 2025
@gongtao0607
Copy link
Contributor Author

This is rolling erase performed on a flywing F405 with highest blackbox write bandwidth (all sensors enabled and 2000Hz record speed), ~ 86KiB / S.

Screenshot 2025-01-13 233558

The record gap is unfortunately quite large: ~250ms gap per 128k write. But please note this is the highest record setting.

@gongtao0607 gongtao0607 marked this pull request as ready for review January 15, 2025 19:21
Change `initialEraseFreeSpace` to `....KiB` and update unit tests.
A new option `blackbox_rolling_erase` is added to enable
automatic rolling erase when flashfs volume is full.
@@ -1753,7 +1754,7 @@ const clivalue_t valueTable[] = {
{ "sbus_out_source_range_low", VAR_INT16 | MASTER_VALUE | MODE_ARRAY, .config.array.length = SBUS_OUT_CHANNELS, PG_DRIVER_SBUS_OUT_CONFIG, offsetof(sbusOutConfig_t, sourceRangeLow) },
{ "sbus_out_source_range_high", VAR_INT16 | MASTER_VALUE | MODE_ARRAY, .config.array.length = SBUS_OUT_CHANNELS, PG_DRIVER_SBUS_OUT_CONFIG, offsetof(sbusOutConfig_t, sourceRangeHigh) },
{ "sbus_out_frame_rate", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = {25, 250}, PG_DRIVER_SBUS_OUT_CONFIG, offsetof(sbusOutConfig_t, frameRate) },
{ "sbus_out_pinswap", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON}, PG_DRIVER_SBUS_OUT_CONFIG, offsetof(sbusOutConfig_t, pinSwap) },
{ "sbus_out_pinswap", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_DRIVER_SBUS_OUT_CONFIG, offsetof(sbusOutConfig_t, pinSwap) },
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't make changes to unrelated things.

rotorflight pushed a commit that referenced this pull request Jan 18, 2025
A new option `blackbox_rolling_erase` is added to enable
automatic rolling erase when flashfs volume is full.
@rotorflight
Copy link
Owner

Conflict resolved and merged.

gongtao0607 added a commit to gongtao0607/rotorflight-firmware that referenced this pull request Jan 18, 2025
A new option `blackbox_rolling_erase` is added to enable
automatic rolling erase when flashfs volume is full.
@gongtao0607 gongtao0607 deleted the background_erase branch January 18, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants