A C++11 header-only library for validating DfuSe files on embedded devices.
This library is made for validating DfuSe files without having to save the complete image in RAM. Instead only the offsets to the images are saved for easier extract and copy to e.g. Flash. DfuSe images can be generated using dfuse-tool.
By defining DFUSEPP_IMAGE_ELEMENT_VERSION
it is possible to attach a 4 byte version header (1 byte major, 1 byte minor and 2 bytes patch version) to the image elements. This can be useful if several images are to be included and you want to be able to readout the version and save the additional overhead of the 274 bytes Target Prefix per image. The dfuse-tool also only works with a single DFU image with multiple image elements.
Data is added to Dfusepp using the addData
function. This function can be called multiple times e.g. when reading a file to limit the amount of RAM required. For more usage examples please see the unit tests.
#include <array>
#include <vector>
#include <Dfusepp.h>
int main()
{
Dfusepp::Dfusepp dfusepp;
std::array<uint8_t, 1024> dfuImage { ... };
dfusepp.addData(dfuImage.data(), 0, dfuImage.size());
if (dfusepp.valid()) {
std::vector<Dfusepp::ImageElement> images = dfusepp.images();
...
}
}
- Only support a single image with multiple image elements
- Only support little endian targets due to current unions used