Skip to the content.
« Previous Index Next »

Firmware Coding Standard — Debug Interfaces (FreeRTOS)

1) Purpose

Provide clear rules for implementing and controlling debug interfaces in FreeRTOS-based firmware. Ensure visibility for developers while preventing performance hits or security risks in production builds.


2) Principles


3) Debug Channels


4) Rules for Debug Code


5) Instrumentation


6) Build Configuration


7) Security Rules


8) Anti-Patterns


9) Review Checklist


10) CI/Lint Gates


11) Example Patterns

Debug macro

#if DEBUG
#define DBG_LOG(tag, fmt, ...) LOG_DEBUG(tag, fmt, ##__VA_ARGS__)
#else
#define DBG_LOG(tag, fmt, ...) ((void)0)
#endif

Instrumentation macro

#define TRACE_ISR_ENTRY(name) GPIO_SET(DBG_##name##_PIN)
#define TRACE_ISR_EXIT(name)  GPIO_CLEAR(DBG_##name##_PIN)

Task with instrumentation

void task_comms(void *arg) {
    for (;;) {
        TRACE_TASK_START(COMMS);
        comms_poll();
        TRACE_TASK_END(COMMS);
        vTaskDelayUntil(&next, pdMS_TO_TICKS(10));
    }
}

✅ With this, we’ve covered:


« Previous Index Next »