Files
frame/poc/apps/m1_hardware/main/sd_service.hh
T
Lainandlain ef5d27b6c5 feat(m1): storage info command and tf card identity record (#16)
## What

- M1 firmware: new `storage info` console command printing the mounted
TF card identity from
`sdmmc_card_t` (CID: manufacturer/OEM/product name/revision/serial/date;
CSD: capacity in
MiB, sectors, sector size). `storage: no card` when not mounted. CID/CSD
are copied out
under a new mutex that also guards mount/unmount, so the console never
dereferences a
  half-initialized or freed card. No other behavior changed.
- Lab config `_doc/lab/board-c1810c76790e.json`: `tf.tf_card` upgraded
from
`pending-visual-read` to the values read on the real board (`SD16G`,
14910 MiB,
  serial `0x00000024`, mfg 2026-05), citing the in-repo transcript.
- ADR-0003: TF record acceptance checkbox ticked with citation; blockers
list updated.

## Evidence

- `poc/evidence/tf-info-20260907/tf-cid-transcript-20260907.log`:
RTS-reset boot, two
identical `storage info` reads (L188-189, L192-193), `status --json`
sanity (L197,
  `tf":"READY`), serial non-zero.
- Board restored to PoC-A firmware after the read (`poca status`
verified).

Co-authored-by: ania-lain <[email protected]>
2026-09-07 21:03:08 +08:00

43 lines
1.0 KiB
C++

#pragma once
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/task.h"
#include "sdmmc_cmd.h"
#include "hardware_status.hh"
namespace frame::m1 {
class sd_service {
public:
explicit sd_service(hardware_status& status) : status_(status) {}
~sd_service();
sd_service(const sd_service&) = delete;
sd_service& operator=(const sd_service&) = delete;
esp_err_t start();
void request_probe();
void print_card_info() const;
private:
static void task_entry(void* context);
esp_err_t mount_and_check();
esp_err_t health_check();
esp_err_t append_status_log();
void unmount();
void run();
hardware_status& status_;
sdmmc_card_t* card_{};
// Serializes card_ mutations (sd task mount/unmount) against print_card_info copy-out
// (console task); CID/CSD are copied under the lock, printed outside it.
SemaphoreHandle_t card_lock_{};
TaskHandle_t task_{};
uint64_t log_sequence_{};
};
} // namespace frame::m1