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 mainAnd then carry on with your usual gdb shenanigans.
Libraries
- Embedded template library (data structures and such): https://www.etlcpp.com/
Specific Boards
ESP32
STM 32
- Integrating CMSIS (optimized signal processing library): Howto
Drivers, Sensors, and Other Stuff
Flash
Testing and Integration Testing
Do this like an onion!
- unit tests to check functions interfacing with hardware (mock out the hardware)
- integration tests: tests integration with components with the hardware mocked out
- HIL (hardware in the loop): automatically flash boards and test them (pytest?)
- emulations: something like renode, not strictly necessary
Implementations below:
- Unit-tests: Ceedling
- Some HIL examples: https://www.bunniestudios.com/blog/2018/exclave-hardware-testing-in-mass-production-made-easier/