![]() |
libbladeRF
2.5.0
Nuand bladeRF library
|
This section contains a file format and associated routines for storing and loading flash contents with metadata.
These functions are thread-safe.
Modules | |
Flash image format constants | |
Data Structures | |
struct | bladerf_image |
Macros | |
#define | BLADERF_IMAGE_MAGIC_LEN 7 |
#define | BLADERF_IMAGE_CHECKSUM_LEN 32 |
#define | BLADERF_IMAGE_RESERVED_LEN 128 |
Functions | |
API_EXPORT struct bladerf_image *CALL_CONV | bladerf_alloc_image (struct bladerf *dev, bladerf_image_type type, uint32_t address, uint32_t length) |
API_EXPORT struct bladerf_image *CALL_CONV | bladerf_alloc_cal_image (struct bladerf *dev, bladerf_fpga_size fpga_size, uint16_t vctcxo_trim) |
API_EXPORT void CALL_CONV | bladerf_free_image (struct bladerf_image *image) |
API_EXPORT int CALL_CONV | bladerf_image_write (struct bladerf *dev, struct bladerf_image *image, const char *file) |
API_EXPORT int CALL_CONV | bladerf_image_read (struct bladerf_image *image, const char *file) |
enum bladerf_image_type |
Type of data stored in a flash image
Definition at line 3258 of file libbladeRF.h.
#define BLADERF_IMAGE_CHECKSUM_LEN 32 |
Size of bladeRF flash image checksum
Definition at line 3278 of file libbladeRF.h.
#define BLADERF_IMAGE_MAGIC_LEN 7 |
Size of the magic signature at the beginning of bladeRF image files
Definition at line 3275 of file libbladeRF.h.
#define BLADERF_IMAGE_RESERVED_LEN 128 |
Size of reserved region of flash image
Definition at line 3281 of file libbladeRF.h.
API_EXPORT struct bladerf_image* CALL_CONV bladerf_alloc_cal_image | ( | struct bladerf * | dev, |
bladerf_fpga_size | fpga_size, | ||
uint16_t | vctcxo_trim | ||
) |
Create a flash image initialized to contain a calibration data region.
This is intended to be used in conjunction with bladerf_image_write(), or a write of the image's data
field to flash.
[in] | dev | Device handle |
[in] | fpga_size | Target FPGA size |
[in] | vctcxo_trim | VCTCXO oscillator trim value. |
NULL
on memory allocation failure API_EXPORT struct bladerf_image* CALL_CONV bladerf_alloc_image | ( | struct bladerf * | dev, |
bladerf_image_type | type, | ||
uint32_t | address, | ||
uint32_t | length | ||
) |
Allocate and initialize an image structure.
This following bladerf_image fields are populated: magic
, version
, timestamp
, type
, address
, and length
The following bladerf_image fields are zeroed out: checksum
, serial
, and reserved
If the length
parameter is not 0, the bladerf_image data
field will be dynamically allocated. Otherwise, data
will be set to NULL.
length
should be use only with bladerf_image_write(); bladerf_image_read() allocates and sets data
based upon size of the image contents, and does not attempt to free() the data
field before setting it.The address
and length
fields should be set 0 when reading an image from a file.
NULL
on memory allocation failure or invalid address/length. API_EXPORT void CALL_CONV bladerf_free_image | ( | struct bladerf_image * | image | ) |
Free a bladerf_image previously obtained via bladerf_alloc_image.
If the bladerf_image's data
field is non-NULL
, it will be freed.
[in,out] | image | Flash image |
API_EXPORT int CALL_CONV bladerf_image_read | ( | struct bladerf_image * | image, |
const char * | file | ||
) |
Read flash image from a file.
image
parameter has been obtained via a call to bladerf_alloc_image(), with a length
of 0.image
fields will be populated upon success, overwriting any previous values.image
parameter should not be used if this function fails.[out] | image | Flash image structure to populate. |
[in] | file | File to read image from. |
API_EXPORT int CALL_CONV bladerf_image_write | ( | struct bladerf * | dev, |
struct bladerf_image * | image, | ||
const char * | file | ||
) |
Write a flash image to a file.
This function will fill in the checksum field before writing the contents to the specified file. The user-supplied contents of this field are ignored.
image
has been initialized using bladerf_alloc_image() image->checksum
will be populated if this function succeeds[in] | dev | Device handle |
[in] | image | Flash image |
[in] | file | File to write the flash image to |