IoT and Smart Systems Engineer · Focus area 1: Embedded programming and firmware
IO4: Reliable firmware: interrupts, RTOS tasks, watchdogs and safe state
Goal: respond to events on time with interrupts, split work into RTOS tasks safely, recover from hangs with a watchdog, keep state safe through resets and power cuts, and diagnose faults on devices you can't reach.
You'll need: IO2, IO3, Module 2 (Operating Systems), Module 24 (Asynchronous Programming), Module 96 (Reliability Engineering), and
the JalSetu practice kit (firmware/state.py, sim/flash.py, sim/harness.py).
Where this is used: any device that must keep working for months unattended: meters, alarms, medical monitors, factory controllers and vehicle electronics. Many run FreeRTOS or Zephyr; all need to recover from faults by themselves.
How it differs: a crashed web server is restarted by the platform and its logs are in the cloud. A crashed device must restart itself, keep its data safe, and leave enough clues for someone far away to understand what happened.
Time: reading about 3 hours · practice (the Try it tasks) about 3 hours · assignment about 4 hours.
Lessons
- 1Interrupts: reacting on timeReading 15–25 minutes, plus practice✓
- 2RTOS tasks, queues and prioritiesReading 15–25 minutes, plus practice✓
- 3Watchdogs and recovering by yourselfReading 15–25 minutes, plus practice✓
- 4Keeping state safe: RTC memory, flash and power cutsReading 15–25 minutes, plus practice✓
- 5Diagnosing faults in the fieldReading 15–25 minutes, plus practice✓
🛠️Assignment: JalSetu's reliability
- Make sensor faults handled errors, so every wake completes and sleeps.
- Save the state in RTC memory as
JS1, the JSON and a CRC32, with safe defaults when it's missing or damaged. - Sketch JalSetu as RTOS tasks with queues and a mutex for the I2C bus.
- Design JalSetu's status message for diagnosis.
- Run
pytest tests/test_power.pyand note which tests pass (3 and 6 at least).
Self-check before you finish:
- [ ] A dead sensor doesn't crash the device (test 3).
- [ ] Damaged RTC memory gives fresh defaults (test 6).
- [ ] The status answers "is it alive, is it healthy, what's wrong".
- [ ] No secret appears in any log or status.
✅Module check
Explain in a few sentences, in your own words:
How does firmware keep working for months without anyone touching it?
Show a good answer
A good answer mentions: short interrupt handlers that set flags or queue data, with debouncing; RTOS tasks with priorities, queues and short-held mutexes, avoiding priority inversion and deadlock; a watchdog fed only after real progress, the reset cause recorded and expected errors handled; state saved with a magic marker and CRC, flash appended or written then renamed, and writes batched to limit wear; and health information (version, battery, resets, errors, backlog) in each status, with last-heard times and small event logs.
📚Official references
Official documentation and guidance for this module's topics, chosen on 2 November 2026. Tools, laws and standards change, so check the current version before you rely on a detail. If a link has moved, search the same site.
📝Module quiz
10 questions · 10 marks each · 100 marks in all · pass mark 70% · retry as often as you like ·
