Table of Contents

Embedded

  2026-03-21

  Edited: 2026-05-31

Flashing Using OpenOCD

Sometimes each company have their own way of flashing things. OpenOCD basically centralizes ways to flash and debug chips. I find this much easier than hunting down how each company does it, and most of the time the company just uses a fork of OpenOCD.

You are going to need a openocd.cfg. Well you don't but I think it makes things easier

# Sample OpenOCD example for STM using stmlink

# Use stlink, the interface is how you are going to flash it
source [find interface/stlink.cfg]
# Board type, kind of obvious
source [find target/stm32f4x.cfg]

Now you run openocd in a terminal and it should print out a bunch of stuff. Next you are going to run gdb blah.elf where blah.elf is the ELF file of your compiled binary. After gdb opens, type the following commands in (or make a opeoncd.gdb file)

# Connect to OpenOCD
target remote :3333
# Flash the code
load
# Add break point
break main

And then carry on with your usual gdb shenanigans.

Libraries

Specific Boards

ESP32

STM 32

Drivers, Sensors, and Other Stuff

Flash

Testing and Integration Testing

Do this like an onion!

  1. unit tests to check functions interfacing with hardware (mock out the hardware)
  2. integration tests: tests integration with components with the hardware mocked out
  3. HIL (hardware in the loop): automatically flash boards and test them (pytest?)
  4. emulations: something like renode, not strictly necessary

Implementations below: