A lightweight, header-only C++20 library for parsing Intel HEX firmware files.
- Fully header-only (just copy
include/IntelHex.hpp) - C++20 design with no external dependencies
- Parses standard Data, EOF, Extended Segment, and Extended Linear Address records
- Automatically verifies line checksums
#include <IntelHex.hpp>
#include <fstream>
#include <iostream>
int main() {
std::ifstream file("firmware.hex");
if (!file) {
std::cerr << "Failed to open file\\n";
return 1;
}
intelhex::Parser parser;
try {
parser.parse(file);
// Get the flattened binary blob
std::vector<uint8_t> firmware = parser.get_firmware_data();
std::cout << "Firmware size: " << firmware.size() << " bytes\\n";
} catch (const std::exception& e) {
std::cerr << "Failed to parse: " << e.what() << "\\n";
}
return 0;
}To build tests:
cmake -S . -B build -DINTELHEX_BUILD_TESTS=ON
cmake --build build
ctest --test-dir build