pico-binary-info
Portable Pi Pico binary_info parser
Loading...
Searching...
No Matches
pico-binary-info

Portable C library to extract data from the "binary info" fields of a Pi Pico binary.

This is intended to be used on host systems which may wish to verify/validate binary images, for example before a custom DFU process. Data is parsed in an endianness-independent manner.

Currently supports string and integer field type, and provides wrappers for common field types such as program version, app name, and board name.

Usage

First, initialize a binary info struct from a memory buffer or file descriptor:

// From an in-memory buffer (or memory mapped file)
struct pico_binary_info info;
pico_binary_info_init(&info, image, size);
// From a file descriptor (posix and newlib friendly)
struct pico_binary_info info;
pico_binary_info_init_fd(&info, fd, size);
int pico_binary_info_init(struct pico_binary_info *info, const uint8_t *image, size_t len)
Initialize a pico_binary_info struct using a pointer to a pico binary image which is in memory,...
Definition pico_binary_info.c:163
int pico_binary_info_init_fd(struct pico_binary_info *info, int fd, size_t len)
Initialize a pico_binary_info struct using a file handle.
Definition pico_binary_info.c:175
Struct representing a parsed pico binary info header.
Definition pico_binary_info.h:44

Then, use the pico_binary_info_*() functions to extract data from the binary info struct, for example:

char buf[256];
if (pico_binary_info_get_program_version(&info, buf, sizeof(buf)) == 0)
printf("Version: %s\n", buf);
int pico_binary_info_get_program_version(struct pico_binary_info *info, char *out, size_t out_len)
Fetch the program version string.
Definition pico_binary_info.c:246

See the API Reference for full documentation.

Examples

See examples/ for example usage.

Running Tests

cmake -Bbuild && cmake --build build
ctest --test-dir build --output-on-failure

License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

Vendored code in include/pico/binary_info/ is copyright Raspberry Pi (Trading) Ltd., and is licensed under the BSD-3-Clause license.