https://github.com/bang-olufsen/dfusepp
A C++11 header-only library for validating DfuSe files on embedded devices
https://github.com/bang-olufsen/dfusepp
cpp cpp11 dfu dfuse embedded header-only
Last synced: about 2 months ago
JSON representation
A C++11 header-only library for validating DfuSe files on embedded devices
- Host: GitHub
- URL: https://github.com/bang-olufsen/dfusepp
- Owner: bang-olufsen
- License: mit
- Created: 2021-03-09T16:44:34.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-25T09:19:49.000Z (over 3 years ago)
- Last Synced: 2025-01-27T22:58:30.347Z (4 months ago)
- Topics: cpp, cpp11, dfu, dfuse, embedded, header-only
- Language: C++
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dfusepp
[](https://github.com/bang-olufsen/dfusepp/actions/workflows/build.yml)
[](https://coveralls.io/github/bang-olufsen/dfusepp?branch=main)
[](https://lgtm.com/projects/g/bang-olufsen/dfusepp/alerts/)
[](https://www.codefactor.io/repository/github/bang-olufsen/dfusepp)
[](LICENSE)A C++11 header-only library for validating [DfuSe](http://rc.fdr.hu/UM0391.pdf) 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](https://github.com/bang-olufsen/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](https://github.com/bang-olufsen/dfuse-tool) also only works with a single DFU image with multiple image elements.
## Usage
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](https://github.com/bang-olufsen/dfusepp/blob/main/test/src/TestDfusepp.cpp).
```cpp
#include
#include
#includeint main()
{
Dfusepp::Dfusepp dfusepp;
std::array dfuImage { ... };dfusepp.addData(dfuImage.data(), 0, dfuImage.size());
if (dfusepp.valid()) {
std::vector images = dfusepp.images();
...
}
}
```## Limitations
* Only support a single image with multiple image elements
* Only support little endian targets due to current unions used