Embedded file system for onboard flash

I'm working on my first embedded project, targeting the Raspberry Pi Pico and using the Embassy framework. I would like to use the onboard flash that's attached to the RP2040 chip to store log files that my application generates. My intended use case is like this:

  • When the program starts a new log file is created.
  • For the duration of the program I want to append a line to the log file at most a few times per second.
  • At a later time, the user can retrieve the stored log files via usb serial (or wifi, if I decide to upgrade to a Pico W).

I think an embedded file system would fit this use case but I'm not sure which one and I could use some guidance on how to best approach this. I searched online and found several crates that could be useful but none seem to perfectly fit my needs.

I found embedded-sdmmc and an async fork maintained by the embassy project but these can only be used on SD cards formatted with a FAT file system.

embedded-fatfs looks like it could work but the FAT file system is not power-fail safe so I don't think it's suitable here.

I don't need a lot of file system features so in the embassy Matrix chat I got the suggestion to look into key-value stores tickv or ekv. If I were to use a kv store, I think every log line should be its own database entry. As far as I can see these crates don't offer an API to iterate over the records in the database so I don't see a way to recover the log lines that belong to a given log "file". Is there a solution to this?

Are there other options that I overlooked?

This was crossposted on reddit. That is ok, but you should note in both places that you did this and link to the other one so people don't waste time if it has been answered in the other place already.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.