Skip to the content.
« Previous Index Next »

Firmware Coding Standard — Logging, Diagnostics & Telemetry (FreeRTOS)

1) Purpose

Define how firmware logs, reports, and exposes diagnostics in a FreeRTOS environment. Ensure visibility into system health without breaking real-time guarantees.


2) Principles


3) Logging Framework


4) Rules for Usage


5) Diagnostics & Health Monitoring


6) Telemetry


7) Crash & Fault Dumps


8) Testing & Validation


9) Anti-Patterns


10) Review Checklist (Logging)


11) CI/Lint Gates


12) Example Patterns

Logging macro

#define LOG_INFO(tag, fmt, ...) \
    log_write(LOG_LEVEL_INFO, tag, fmt, ##__VA_ARGS__)

ISR log

void DMA_IRQHandler(void) {
    BaseType_t hpw = pdFALSE;
    log_isr_event(DMA_EVT_DONE, dma_id);
    xTaskNotifyFromISR(dmaTask, EVT_DMA_DONE, eSetBits, &hpw);
    portYIELD_FROM_ISR(hpw);
}

Logging task

void log_task(void *arg) {
    for (;;) {
        log_record_t rec;
        if (xQueueReceive(logQ, &rec, portMAX_DELAY)) {
            format_and_output(&rec);
        }
    }
}

Crash dump on reboot

void system_boot(void) {
    reset_cause_t cause = get_reset_cause();
    if (cause != RESET_POWER_ON) {
        dump_last_crash();
    }
}

« Previous Index Next »