Skip to content

Firmware & FreeRTOS

1 Topics 1 Posts

C programming, FreeRTOS tasks, queues, mutexes, state machines, watchdog

This category can be followed from the open social web via the handle firmware-freertos@forum.grapesiot.com

  • 🔧 Firmware bugs? Post like this

    firmware freertos help
    1
    0 Votes
    1 Posts
    128 Views
    A
    Half of firmware debugging is how you ask. A good report gets you an answer in an hour; "it doesn't work" gets you silence. Use this format every time: What I'm trying to do: one sentence — the goal, not the method. What I tried: the steps, in order. "Changed the baud rate, added a delay, swapped cables." What happened: exact text, not paraphrase. Paste the panic dump, the serial output, the wrong value. My setup: board (ESP32 DevKitC? which revision), IDE + version, relevant library versions. Minimal code: the smallest snippet that reproduces it — 20 lines beats 500. Use code blocks, never screenshots of code. Serial output: pasted as text, from boot to failure. Decode your own crash first A Guru Meditation Error print is a gift — it tells you the exception cause, the guilty program counter, and a backtrace. The fastest path: rebuild the exact same binary with symbols, feed the addresses to the decoder, and read the function names. Nine times out of ten it lands on one of these: Stack overflow — a task with a 1 KB stack calling deep library functions, or a large array declared inside a function. Symptom: crash inside random-looking code, corrupted backtrace. Fix: grow the stack, move big buffers to static/global. Watchdog bite — a task that never blocks. Any loop without a delay or blocking call starves the idle task and the watchdog resets the chip. Fix: yield every iteration. Null / wild pointer — dereferencing a queue handle or object that was never created, or used after deletion. Symptom: LoadProhibited on an address near zero. Fix: check every create call's return before use. Shared state without protection — a variable touched from a task and an ISR (or two tasks) with no guard. Symptom: works for hours, then corrupts once. Fix: qualifier or guard, depending on who shares it. The five gotchas that solve most posts here ADC reads garbage with WiFi on → use ADC1 pins, never ADC2 under WiFi. Board resets randomly on USB → weak cable or port; measure the rail under load, try a shorter cable and a powered hub. Serial shows garbage → monitor baud must match Serial.begin() exactly. "Worked yesterday" → something changed: code, wiring, power source, library update. Figure out what, then bisect it. Timing drift under WiFi → never use blocking delays for cadence; sample on a stable timebase. Post with the format above and tag with firmware, freertos or esp32.