All paths

Software that must not fail

Write firmware for a heater the way safety engineers do: failure modes, defensive input, the real watchdog, asserts that stay, redundancy and reviews, all on an Uno.

Arduino Uno R3Free7 lessons5 h4 chapters4,010 XPCoding · Expert+400 XP

0 of 7 done

What you will build

3 projects, built step by step

7 lessons in 4 chapters, about 5 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 1 project

Defensive code

The heater takes its setpoint over serial and trusts none of it: a line buffer that cannot overflow, strtol with an end pointer, a range check before the cast, and a clear REJECTED for everything else.

Open it in the simulator
Chapter 2 project

Asserts in production

A SAFE_ASSERT macro that never compiles away: on a broken invariant it cuts the heater, records the line number in EEPROM, resets through the watchdog and stays latched until a person presses RESET.

Open it in the simulator
Chapter 3 project

Reviews

A heater controller with three planted bugs, found the way a reviewer finds them: a stray semicolon that trips at room temperature, a 16-bit int that makes the dry-fire cutout impossible, and a wait loop with no way out.

Open it in the simulator
The map

Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

Think in failures

What can break, how bad it is, and code that refuses to believe bad input.

  1. Open400 XP

    Failure modes

    A naive thermostat that trusts every reading, and an FMEA table that ranks what can go wrong by severity, occurrence and detection. Break the sensor wire and watch it heat a tank it thinks is colder than space.

    0 of 7 steps

  2. ProjectLocked860 XP

    Defensive code

    The heater takes its setpoint over serial and trusts none of it: a line buffer that cannot overflow, strtol with an end pointer, a range check before the cast, and a clear REJECTED for everything else.

    0 of 7 steps

4 questions, graded as you go.
Chapter 2

Catch it while it runs

The chip's watchdog for hangs, and asserts that fail safe in the field.

  1. Locked400 XP

    Watchdogs

    The ATmega328P's real watchdog at 250 ms: a hang it catches, a slow job that trips it, the reset cause in MCUSR, and a bad setting that hangs every boot until a counter in EEPROM drops it into safe mode.

    0 of 7 steps

  2. ProjectLocked800 XP

    Asserts in production

    A SAFE_ASSERT macro that never compiles away: on a broken invariant it cuts the heater, records the line number in EEPROM, resets through the watchdog and stays latched until a person presses RESET.

    0 of 7 steps

5 questions, graded as you go.
Chapter 3

Trust nothing once

Two sensors, a setpoint stored twice, and a review that finds three bugs.

  1. Locked400 XP

    Redundancy

    Two DS18B20s watch one tank and must agree within 2 C, the hotter one wins, and the setpoint is stored twice, once inverted, so a flipped bit in RAM is caught before it is used.

    0 of 7 steps

  2. ProjectLocked700 XP

    Reviews

    A heater controller with three planted bugs, found the way a reviewer finds them: a stray semicolon that trips at room temperature, a 16-bit int that makes the dry-fire cutout impossible, and a wait loop with no way out.

    0 of 6 steps

4 questions, graded as you go.
Chapter 4

Boss

One controller with every layer, attacked until it gives.

  1. Locked450 XP

    Boss: a fail-safe heater

    Every layer in one controller: a sensor plausibility check, a latched over-temperature trip only a person can reset, a guarded setpoint, SAFE_ASSERT and the real watchdog. Attack it, then find the one failure mode it still misses.

    0 of 8 steps

3 questions, graded as you go.
Syllabus

Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

Think in failures

  1. Failure modesA naive thermostat that trusts every reading, and an FMEA table that ranks what can go wrong by severity, occurrence and detection. Break the sensor wire and watch it heat a tank it thinks is colder than space.
  2. Defensive codeThe heater takes its setpoint over serial and trusts none of it: a line buffer that cannot overflow, strtol with an end pointer, a range check before the cast, and a clear REJECTED for everything else.
Chapter 2

Catch it while it runs

  1. WatchdogsThe ATmega328P's real watchdog at 250 ms: a hang it catches, a slow job that trips it, the reset cause in MCUSR, and a bad setting that hangs every boot until a counter in EEPROM drops it into safe mode.
  2. Asserts in productionA SAFE_ASSERT macro that never compiles away: on a broken invariant it cuts the heater, records the line number in EEPROM, resets through the watchdog and stays latched until a person presses RESET.
Chapter 3

Trust nothing once

  1. RedundancyTwo DS18B20s watch one tank and must agree within 2 C, the hotter one wins, and the setpoint is stored twice, once inverted, so a flipped bit in RAM is caught before it is used.
  2. ReviewsA heater controller with three planted bugs, found the way a reviewer finds them: a stray semicolon that trips at room temperature, a 16-bit int that makes the dry-fire cutout impossible, and a wait loop with no way out.
Chapter 4

Boss

  1. Boss: a fail-safe heaterEvery layer in one controller: a sensor plausibility check, a latched over-temperature trip only a person can reset, a guarded setpoint, SAFE_ASSERT and the real watchdog. Attack it, then find the one failure mode it still misses.
Kits

Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.

See every kit
Questions

About Software that must not fail

Is Software that must not fail free?

Yes. All 7 lessons of Software that must not fail are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Arduino Uno R3?

No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Software that must not fail take?

About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Defensive code, Asserts in production and Reviews.

Where do I start?

With "Failure modes", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.