Storage and files#
Everything the board records stays on the board. On the ESP32-S3 that is a FAT-formatted SD card. The ESP-Mosaico writes its drive logs to a 128 MB NAND and keeps its state files in a FAT volume on the flash. The file formats are in Configuration and file formats.
Files on the SD card#
The board writes everything under /sdcard/obd/.
File |
What it is |
|---|---|
|
one row per OBD poll cycle, 88 columns (see below) |
|
one line per model run (see below) |
|
one row per closed 10 s pattern window |
|
raw hex of supported PIDs the firmware has no decoder for |
|
session metadata: adapter, VIN, supported PIDs, trouble codes, counters |
|
the k-means pattern model, kept across drives |
|
Wi-Fi networks to import (you create it) |
|
settings to import (you create it) |
|
up to 8 custom PIDs (you create it) |
|
the time at the last save, so the clock can resume after a power cut |
A new session starts at every power cycle. Everything is flushed to the card at least every 10 seconds (SDLOG_SYNC_PERIOD_S). The newest save line on page 3 shows live whether you can cut the power (main/power_state.c): green “Safe to turn off” once no car data has arrived for 5 seconds, the last of it is on the card and no upload is running, and red “Not safe: logging”, “Not safe: saving” or “Not safe: upload” until then. The AI model runs once per row of car data, so it has stopped by the time the line turns green.
ESP-Mosaico: storage that survives resets#
ESP-IDF writes each 4 KB flash sector as an erase followed by a write, so a reset between the two leaves an erased sector, and FatFs then copied a torn first FAT over the good second one. That lost the whole volume twice on the bench. Now:
Before every software reset the logger flushes and holds the file system’s lock.
The two FAT copies are compared before mounting, and a torn copy is rewritten from the good one.
Lost clusters are freed and torn directory entries are marked deleted.
A volume that holds data but does not mount is never formatted on its own. Settings has Format storage for that, and it works right after boot too.
Entering download mode through the USB port waits until the storage has finished starting.
Bench test |
Before the fix |
After |
|---|---|---|
Random software resets (restart, abort, ROM reset), volume lost |
8 of 90 |
0 of 200 |
Screen frozen until the stall guard resets the board, volume lost |
2 of 40 |
0 of 60 |
Entering download mode during storage start-up, sectors torn |
3 of 12 |
0 of 24 |
The reset test (CONFIG_OCM_STORAGE_RESET_TEST) is off in the release and never in a car build.
ESP-Mosaico: the 128 MB NAND#
The drive logs (sNNNNNN.csv, .json, .pat, .ml.csv, .sum.json and drives.csv) are written to the board’s 128 MB SPI NAND, mounted at /nand. The flash FAT keeps the state files. NAND writes go over their own SPI bus and never turn the flash cache off, so a log write no longer stalls the screen or the other tasks the way a NOR flash write does.
The NAND runs on SPI3 at 20 MHz with the Dhara flash translation layer (
espressif/spi_nand_flash1.4.4) and a FAT16 volume with two FAT copies.A blank NAND is formatted at the first boot. A NAND that holds data but will not mount is never formatted on its own.
Drives logged before the update are moved from the flash to the NAND once: each file is copied, synced, read back and compared (size and CRC) before the flash copy is removed. A reset in the middle of the move leaves either the old copy or two identical copies, never none.
The desktop app lists and imports drives from both stores while the move runs. A drive on both is shown once.
Format storage formats the NAND (about 15 seconds) and removes the drive logs still on the flash. The state files are not touched.
Without a working NAND the board logs to the flash FAT as before.
The NAND’s speed, its power draw and a reset-injection run on it are part of the board check for this release and are not in this guide yet. The store rules, the move and the volume repair are covered by host tests (652 checks, the repair at 19 reset points).