Skip to content

Conversation

@AarC10
Copy link
Member

@AarC10 AarC10 commented Oct 10, 2025

Description

Filesystems are normally not used in flight software applications for a number of reasons (non-determinism, limited resources, corruption risk, etc.). Even though LittleFS mitigates a few of these issues, having it can still be non-deterministic and files were still corrupted in sensor module from its last flight. This made it difficult to try and recover flight data. By doing raw logging, we can just dump the flash contents and identify where log files are located easier.

This new system will log data raw to the flash chip. There are several modes

  • Fixed: Once a log is written to the limit, it will no longer write
  • LinkedFixed: Same as fixed, but new log sections can be created and the metadata will point to the address of this next section. (Think of a linked list). The new section will be placed in the next free space found that meets the requested file size set by the user
  • LinkedTruncate: Same as LinkedFixed, but the new section will be placed in the next free space found regardless if the size is less than requested.

Each log file starts with a 32 byte metadata structure. This includes a

  • 16 character log name
  • 4 byte hash of the log name to validate we are reading metadata
  • 1 byte version for the file in the event we make a breaking change
  • Packet size so we know how many bytes to read per packet
  • Allocated size for the file, which is useful for skipping past the file
  • Next log address for linked modes

Note: There will definitely be improvements/changes that would need to be made to this as this gets integrated into actual flight applications and edge cases are caught for running our use cases. Still need reading capabilities as well. Planning a wrapper as well for persistently caching where logs are located.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Ran sample through native_sim testing the different modes and hexdumped the flash binary
image

image

Checklist:

  • New functionality is documented in the necessary spots (i.e new functions documented in the header)
  • Unit tests cover any new functionality or edge cases that the PR was meant to resolve (if applicable)
  • The CI checks are passing
  • I reviewed my own code in the GitHub diff and am sure that each change is intentional
  • I feel comfortable about this code flying in a rocket

@AarC10 AarC10 requested a review from a team as a code owner October 10, 2025 05:49
@AarC10 AarC10 requested a review from Copilot October 10, 2025 13:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new raw datalogger system that writes directly to flash memory without using a filesystem, addressing determinism and corruption issues previously encountered with LittleFS in flight software. The raw datalogger supports three modes: Fixed (stops when full), LinkedFixed (creates linked sections in available space), and LinkedTruncate (creates linked sections with size truncation).

Key changes:

  • Implements a new CRawDataLogger template class for direct flash logging with metadata structure and linked list capabilities
  • Renames existing filesystem-based datalogger from CDataLogger to CFsDataLogger to distinguish it from the raw implementation
  • Updates all existing usage to use the renamed CFsDataLogger class

Reviewed Changes

Copilot reviewed 21 out of 24 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
include/f_core/os/c_raw_datalogger.h New raw datalogger implementation with flash-based logging
include/f_core/os/c_fs_datalogger.h Renamed class from CDataLogger to CFsDataLogger
include/f_core/os/tenants/c_datalogger_tenant.h Updated to use renamed CFsDataLogger
app/samples/raw_datalogger/ Complete sample application demonstrating raw datalogger modes
Multiple application files Updated references from CDataLogger to CFsDataLogger
west.yml Added fatfs dependency and removed duplicate hal_st entry
lib/f_core/Kconfig Added hash function dependencies for raw datalogger
Files not reviewed (2)
  • app/backplane/sensor_module/.idea/editor.xml: Language not supported
  • app/backplane/sensor_module/.idea/vcs.xml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

#include <f_core/messaging/c_msgq_message_port.h>
#include <f_core/os/n_rtos.h>
#include <f_core/utils/n_time_utils.h>
#include <f_core/os/c_raw_datalogger.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

please make the 512 on line 17 something like 12

Copy link
Member Author

Choose a reason for hiding this comment

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

no

Copy link
Contributor

Choose a reason for hiding this comment

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

im making hw give you less ram next time so you learn

currentLogSize(logSize), currentOffset(sizeof(DataloggerMetadata)), nextLogAddress(0) {
resetBuffers();

int ret = flash_get_size(flash, &flashSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems like it will make the max size of this partition the max size of the flash itself. That kinda undoes any benefit that using the fixed partition api and 'sharing the flash' like we discussed i think you wanna take in the partition size in the constructor (and the macro)

Copy link
Contributor

Choose a reason for hiding this comment

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

re: conversation we had, flashDev arg / flash dev should be flash area and flash writes should be flash area writes

also, action item to make apple crisp in 2 weeks

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, we're going to move this feature to a branch we develop for the November Launch so it doesnt get merged in a half-baked way.
Branch created off of main: NovemberTestLaunch

@cowsed cowsed mentioned this pull request Nov 1, 2025
6 tasks
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.

3 participants