![]() |
libbladeRF
1.7.2
Nuand bladeRF library
|
These routines provide the ability to manipulate the device's SPI flash. Most users will find no reason to use these, as higher-level functions perform flash accesses under the hood.
These routines are not recommended for use other than testing, development, and significant customization of the bladeRF platform (which would require firmware and libbladeRF changes).
Use of these functions requires an understanding of the underlying SPI flash device, and the bladeRF's flash memory map. Be sure to review the following page and the associated flash datasheet before using these functions: https://github.com/nuand/bladeRF/wiki/FX3-Firmware#spi-flash-layout
These functions are thread-safe.
Functions | |
API_EXPORT int CALL_CONV | bladerf_erase_flash (struct bladerf *dev, uint32_t erase_block, uint32_t count) |
API_EXPORT int CALL_CONV | bladerf_read_flash (struct bladerf *dev, uint8_t *buf, uint32_t page, uint32_t count) |
API_EXPORT int CALL_CONV | bladerf_write_flash (struct bladerf *dev, const uint8_t *buf, uint32_t page, uint32_t count) |
#define BLADERF_FLASH_ADDR_CAL 0x00030000 |
Byte address of calibration data region
Definition at line 4262 of file libbladeRF.h.
#define BLADERF_FLASH_ADDR_FIRMWARE 0x00000000 |
Byte address of FX3 firmware
Definition at line 4239 of file libbladeRF.h.
#define BLADERF_FLASH_ADDR_FPGA 0x00040000 |
Byte address of of the autoloaded FPGA and associated metadata. The first page is allocated for metadata, and the FPGA bitstream resides in the following pages.
Definition at line 4290 of file libbladeRF.h.
#define BLADERF_FLASH_BYTE_LEN_CAL 0x100 |
Length of calibration data, in bytes
Definition at line 4271 of file libbladeRF.h.
#define BLADERF_FLASH_BYTE_LEN_FIRMWARE 0x00030000 |
Length of firmware region of flash, in bytes
Definition at line 4250 of file libbladeRF.h.
#define BLADERF_FLASH_BYTE_LEN_FPGA 0x00370000 |
Length of entire FPGA region, including both metadata and bitstream.
Definition at line 4301 of file libbladeRF.h.
#define BLADERF_FLASH_EB_CAL (BLADERF_FLASH_TO_EB(BLADERF_FLASH_ADDR_CAL)) |
Flash erase block where calibration data starts
Definition at line 4268 of file libbladeRF.h.
#define BLADERF_FLASH_EB_FIRMWARE (BLADERF_FLASH_TO_EB(BLADERF_FLASH_ADDR_FIRMWARE)) |
Flash erase block where FX3 firmware starts
Definition at line 4246 of file libbladeRF.h.
#define BLADERF_FLASH_EB_FPGA (BLADERF_FLASH_TO_EB(BLADERF_FLASH_ADDR_FPGA)) |
Flash erase block where FPGA metadata and bitstream start
Definition at line 4297 of file libbladeRF.h.
#define BLADERF_FLASH_EB_LEN_CAL 1 |
Length of calibration data, in erase blocks. This is a special case, as the entire remainder of the erase block is reserved for future calibration data use. When updating calibration data, the whole block will be erased, even though the current firmware only uses one page of it.
Definition at line 4282 of file libbladeRF.h.
#define BLADERF_FLASH_EB_LEN_FIRMWARE (BLADERF_FLASH_TO_EB(BLADERF_FLASH_BYTE_LEN_FIRMWARE)) |
Length of firmware region of flash, in erase blocks
Definition at line 4257 of file libbladeRF.h.
#define BLADERF_FLASH_EB_LEN_FPGA (BLADERF_FLASH_TO_EB(BLADERF_FLASH_BYTE_LEN_FPGA)) |
Length of entire FPGA region, in units of erase blocks
Definition at line 4304 of file libbladeRF.h.
#define BLADERF_FLASH_EB_SIZE (64 * 1024) |
SPI flash 64KiB erase block size, in bytes
Definition at line 4218 of file libbladeRF.h.
#define BLADERF_FLASH_NUM_EBS (BLADERF_FLASH_TOTAL_SIZE / BLADERF_FLASH_EB_SIZE) |
Size of the SPI flash, in 64KiB erase blocks
Definition at line 4225 of file libbladeRF.h.
#define BLADERF_FLASH_NUM_PAGES (BLADERF_FLASH_TOTAL_SIZE / BLADERF_FLASH_PAGE_SIZE) |
Size of the SPI flash, in pages
Definition at line 4221 of file libbladeRF.h.
#define BLADERF_FLASH_PAGE_CAL (BLADERF_FLASH_TO_PAGES(BLADERF_FLASH_ADDR_CAL)) |
Flash page where calibration data starts
Definition at line 4265 of file libbladeRF.h.
#define BLADERF_FLASH_PAGE_FIRMWARE (BLADERF_FLASH_TO_PAGES(BLADERF_FLASH_ADDR_FIRMWARE)) |
Flash page where FX3 firmware starts
Definition at line 4242 of file libbladeRF.h.
#define BLADERF_FLASH_PAGE_FPGA (BLADERF_FLASH_TO_PAGES(BLADERF_FLASH_ADDR_FPGA)) |
Flash page where FPGA metadata and bitstream start
Definition at line 4293 of file libbladeRF.h.
#define BLADERF_FLASH_PAGE_LEN_CAL (BLADERF_FLASH_TO_PAGES(FLASH_BYTE_LEN_CAL)) |
Length of calibration data, in pages
Definition at line 4274 of file libbladeRF.h.
#define BLADERF_FLASH_PAGE_LEN_FIRMWARE (BLADERF_FLASH_TO_PAGES(BLADERF_FLASH_BYTE_LEN_FIRMWARE)) |
Length of firmware region of flash, in pages
Definition at line 4253 of file libbladeRF.h.
#define BLADERF_FLASH_PAGE_SIZE 256 |
SPI flash page size, in bytes
Definition at line 4215 of file libbladeRF.h.
#define BLADERF_FLASH_TO_EB | ( | bytes | ) | ((bytes) / BLADERF_FLASH_EB_SIZE) |
Convert byte addresses to units of flash erase blocks
Definition at line 4234 of file libbladeRF.h.
#define BLADERF_FLASH_TO_PAGES | ( | bytes | ) | ((bytes) / BLADERF_FLASH_PAGE_SIZE) |
Convert byte addresses to units of flash pages
Definition at line 4231 of file libbladeRF.h.
#define BLADERF_FLASH_TOTAL_SIZE (4 * 1024 * 1024) |
Total size of bladeRF SPI flash, in bytes
Definition at line 4212 of file libbladeRF.h.
API_EXPORT int CALL_CONV bladerf_erase_flash | ( | struct bladerf * | dev, |
uint32_t | erase_block, | ||
uint32_t | count | ||
) |
Erase regions of the bladeRF's SPI flash
This function operates in units of 64KiB erase blocks
dev | Device handle |
erase_block | Erase block to start erasing at |
count | Number of blocks to erase. |
erase_block
or count
value, or a value from Error codes list on other failures API_EXPORT int CALL_CONV bladerf_read_flash | ( | struct bladerf * | dev, |
uint8_t * | buf, | ||
uint32_t | page, | ||
uint32_t | count | ||
) |
Read data from the bladeRF's SPI flash
This function operates in units of 256-byte pages.
dev | Device handle |
buf | Buffer to read data into. Must be count * BLADERF_FLASH_PAGE_SIZE bytes or larger. |
page | Page to begin reading from |
count | Number of pages to read |
page
or count
value, or a value from Error codes list on other failures. API_EXPORT int CALL_CONV bladerf_write_flash | ( | struct bladerf * | dev, |
const uint8_t * | buf, | ||
uint32_t | page, | ||
uint32_t | count | ||
) |
Write data to the bladeRF's SPI flash device
dev | Device handle |
buf | Data to write to flash |
page | Page to begin writing at |
count | Number of pages to write |
page
or count
value, or a value from Error codes list on other failures.