From Prototype to Production

Your code works on a dev board. The sensors read correctly, the telemetry streams, the watchdog keeps things alive. Now what? The gap between a working prototype and a reliable product is filled with hardware design, testing discipline, chip selection, and certification. This chapter covers the practical knowledge you need to cross that gap.

Power Design

Every production board needs clean, stable power. Here is the standard power chain:

Battery (7.4V–12.6V)
  │
  ├── Schottky Diode (reverse polarity protection)
  │
  ├── Bulk Capacitor (100µF electrolytic)
  │
  ├── 3.3V LDO Regulator (e.g., AMS1117-3.3)
  │     │
  │     ├── 10µF input cap
  │     ├── 10µF output cap
  │     │
  │     └── 3.3V Rail
  │           │
  │           ├── STM32 (100nF on each VDD pin)
  │           ├── IMU (100nF)
  │           ├── Barometer (100nF)
  │           └── Other ICs (100nF each)
  │
  └── 5V Buck Converter (if needed for servos/motors)

The 100nF rule: Every IC gets a 100nF ceramic decoupling capacitor on every power pin, placed as close to the pin as physically possible — within 5mm. This is not optional. Without decoupling caps, high-frequency current spikes from the digital logic create voltage dips that cause random resets, communication errors, and sensor noise.

ComponentPurposePlacement
Schottky diodeReverse polarity protectionBattery input
100µF electrolyticBulk energy storageAfter diode
10µF ceramicRegulator stabilityRegulator input and output
100nF ceramicHigh-frequency decouplingEvery VDD pin, within 5mm
Ferrite beadIsolate analog/digital powerBetween VDDA and VDD

Fun Fact: The 100nF decoupling capacitor is the single most common component on any digital PCB. A typical STM32H7 board might have 15-20 of them just for the microcontroller alone — one for each VDD, VDDA, VDDLDO, and VREF pin.

PCB Design Tips

PCB layout is where electrical theory meets physical reality. A schematic that works perfectly in simulation can fail on a poorly laid out board.

Ground planes: Use a solid, unbroken ground plane on an inner layer. Do not route signal traces through the ground plane under your MCU. Current returns through the ground plane directly beneath the signal trace — if you cut the ground, the return current has to detour around the cut, creating an antenna.

Signal integrity for SPI: The SPI clock (SCK) is your highest-frequency signal. Keep SPI traces short — under 5cm. Route SCK and MOSI/MISO as a group, keep them away from noisy power traces. Match trace lengths if your SPI clock exceeds 20MHz.

Sensor placement: Put the IMU as far from motors and power electronics as possible. Vibration and electromagnetic interference from motors corrupt accelerometer and gyroscope readings. If you cannot get physical distance, use a separate ground pour under the IMU connected to the main ground at a single point.

Layer stackup for a 4-layer board:

LayerPurpose
TopSignal traces, components
Inner 1Ground plane (unbroken)
Inner 2Power plane (3.3V, 5V)
BottomSignal traces, components

SWD test pads: Always include SWD pads (SWDIO, SWCLK, GND, 3.3V, NRST) on your production board, even if you plan to program via UART bootloader. When something goes wrong in the field, SWD access is invaluable for debugging. Use through-hole pads or tag-connect footprints.

Think About It: A 4-layer PCB costs roughly 30-50% more than a 2-layer board in small quantities. For anything with high-speed SPI, multiple power rails, or noise-sensitive analog inputs, the 4-layer board pays for itself in debugging time you do not spend.

Testing Levels

Professional embedded development uses three testing stages. Skipping any of them is asking for field failures.

Desk Testing

This is what you have been doing throughout this book — the board on your desk, connected to a debugger, exercising each subsystem:

  • Sensor verification: Read WHO_AM_I registers, verify data ranges make sense
  • Communication check: UART telemetry at all supported baud rates, SPI at full speed
  • Watchdog validation: Deliberately trigger a hang (infinite loop), confirm the watchdog resets the system
  • Thermal test: Run the system for 24 hours continuously, monitor for drift or failures
  • Power consumption: Measure idle and active current draw, verify sleep modes work

Integration Testing

Connect the board to the full system — motors, airframe, sensors in their final mounting positions:

  • EMI testing: Do motors cause sensor noise? Does the radio interfere with I2C? Run all subsystems simultaneously at full power
  • Vibration testing: Mount the board as it will be mounted in production. Read IMU data while motors are running. Look for resonance frequencies
  • Failsafe testing: Disconnect each sensor one at a time. Does the system degrade gracefully? Pull the battery briefly — does the watchdog catch the brownout?
  • Temperature range: If your product operates outdoors, test in a freezer and under a heat lamp. STM32 industrial-grade chips are rated for -40C to +105C

Field Testing

The system in its real environment:

  • Tethered first: For a drone, fly tethered to the ground before free flight. For a vehicle, test on a dynamometer before road testing
  • Log everything: Record all sensor data, system states, and error counts. Review logs after each test session
  • Endurance testing: Run the system for 10x the expected mission duration. If your drone flight is 15 minutes, test for 2.5 hours
  • Edge cases: Test at the boundaries — maximum altitude, minimum temperature, maximum speed, lowest battery voltage
#![allow(unused)]
fn main() {
// A simple flight log structure for field testing
#[derive(defmt::Format)]
struct FlightLog {
    timestamp_ms: u64,
    mode: FlightMode,
    battery_v: f32,
    error_count: u32,
    imu_valid: bool,
    baro_valid: bool,
}
}

STM32 Selection for Production

Choosing the right STM32 for a product is different from choosing one for learning. Here are the key factors:

FactorConsideration
LongevityWill ST manufacture this chip for 10+ years?
AvailabilityCan you actually buy 1000 units today?
PackageQFP for hand soldering, BGA for density
Temperature rangeCommercial (0-70C) vs Industrial (-40 to +105C)
Cost at volumePer-unit price at 1K, 10K, 100K quantities
EcosystemHAL maturity, Embassy support, community knowledge

STM32G0 — The go-to for cost-sensitive, low-complexity products. Widely available, extremely affordable, good Embassy support. Perfect for sensor nodes, simple controllers, LED drivers.

STM32F4 — The workhorse. The F411 and F407 have been in production for over a decade, are available from every distributor, and have the largest community. If your product needs an FPU and moderate performance, the F4 is a safe bet.

STM32H5 — ST's newest mainstream high-performance family. Designed as the long-term successor to the F4/F7. Better power efficiency, hardware security, and guaranteed long production life.

STM32U5 — The ultra-low-power choice. If your product runs on a coin cell or needs months of battery life, the U5 family is built for it.

Fun Fact: The STM32F103 — the "Blue Pill" chip — has been in continuous production since 2007. That is nearly two decades. ST commits to a minimum 10-year production lifecycle for most STM32 families, and many go well beyond that.

Cost Tiers (Approximate, 1K Quantity)

TierFamiliesApproximate INRUse Case
BudgetF0, G0, L050-100Simple sensors, LED control
MainstreamF1, F4, G4150-350Motor control, data logging
High PerformanceF7, H7, H5500-1200Signal processing, multi-sensor fusion
Ultra Low PowerL4, U5200-500Battery-powered, wearables

Certification Considerations

If you sell a product, it needs to pass regulatory certification. The requirements depend on your market:

CE marking (Europe) and FCC (USA) — Required for any electronic device. Covers electromagnetic emissions (your board does not interfere with other devices) and immunity (other devices do not break yours). Good PCB design with proper ground planes and decoupling gets you most of the way there.

DO-178C (Aviation) — If your embedded system goes in an aircraft, the software must be developed under this standard. Rust's type safety and memory safety are increasingly recognized as beneficial, but the tooling certification story is still evolving.

IEC 61508 (Industrial Safety) — For safety-instrumented systems in industrial environments. Requires formal hazard analysis and systematic software development practices.

The good news: Rust's compile-time guarantees — no null pointer dereferences, no buffer overflows, no data races — give you a head start on the safety arguments for any of these standards.

Supply Chain

The semiconductor shortage of 2021-2023 taught the industry painful lessons. For production:

  • Second source: If possible, design your board to accept two pin-compatible STM32 variants. The F411CE and F401CE share the same pinout
  • Buy ahead: Once your design is finalized, buy 6-12 months of inventory for critical components
  • Distributor relationships: Work with authorized distributors (Mouser, DigiKey, Farnell). Avoid the gray market for production components
  • Design for availability: Use common packages (LQFP-64, LQFP-48) rather than exotic ones. Common parts are restocked first during shortages

Summary

Going from prototype to production is a discipline, not a single step. Get the power design right, lay out the PCB carefully, test at every level, choose chips with long production commitments, and plan for supply chain disruptions. The firmware patterns from the rest of this book give you reliable software — this chapter gives you the context to put it on reliable hardware.