These functions provide the ability to erase, read, and write the SPI flash.
- Warning
- Use of SPI flash 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.
|
API_EXPORT int CALL_CONV | bladerf_erase_flash (struct bladerf *dev, uint32_t erase_block, uint32_t count) |
|
API_EXPORT int CALL_CONV | bladerf_erase_flash_bytes (struct bladerf *dev, uint32_t address, uint32_t length) |
|
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_read_flash_bytes (struct bladerf *dev, uint8_t *buf, uint32_t address, uint32_t bytes) |
|
API_EXPORT int CALL_CONV | bladerf_write_flash (struct bladerf *dev, const uint8_t *buf, uint32_t page, uint32_t count) |
|
API_EXPORT int CALL_CONV | bladerf_write_flash_bytes (struct bladerf *dev, const uint8_t *buf, uint32_t address, uint32_t length) |
|
API_EXPORT int CALL_CONV | bladerf_lock_otp (struct bladerf *dev) |
|
API_EXPORT int CALL_CONV | bladerf_read_otp (struct bladerf *dev, uint8_t *buf) |
|
API_EXPORT int CALL_CONV | bladerf_write_otp (struct bladerf *dev, uint8_t *buf) |
|
◆ bladerf_erase_flash()
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
- Note
- This function operates in units of 64 KiB erase blocks
-
Not recommended for new designs. Consider using the
bladerf_erase_flash_bytes()
function instead. It will perform the necessary conversion from bytes to pages based on the specific flash architecture found on the board.
- Parameters
-
| dev | Device handle |
[in] | erase_block | Erase block from which to start erasing |
[in] | count | Number of blocks to erase |
- Returns
- 0 on success, or BLADERF_ERR_INVAL on an invalid
erase_block
or count
value, or a value from Error codes list on other failures
◆ bladerf_erase_flash_bytes()
API_EXPORT int CALL_CONV bladerf_erase_flash_bytes |
( |
struct bladerf * |
dev, |
|
|
uint32_t |
address, |
|
|
uint32_t |
length |
|
) |
| |
Erase regions of the bladeRF's SPI flash
- Note
- This function operates in units of bytes
- Parameters
-
| dev | Device handle |
[in] | address | Address at which to start erasing |
[in] | length | Number of bytes to erase |
- Returns
- 0 on success, or BLADERF_ERR_INVAL on an invalid
address
or length
value, or a value from Error codes list on other failures
◆ bladerf_lock_otp()
Lock the bladeRF's OTP
- Parameters
-
- Returns
- 0 on success, or BLADERF_ERR_INVAL on an invalid
page
or count
value, or a value from Error codes list on other failures.
◆ bladerf_read_flash()
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
- Note
- This function operates in units of flash pages.
-
Not recommended for new designs. Consider using the
bladerf_read_flash_bytes()
function instead. It will perform the necessary conversion from bytes to pages based on the specific flash architecture found on the board.
- Parameters
-
| dev | Device handle |
[in] | buf | Buffer to read data into. Must be count * flash-page-size bytes or larger. |
[in] | page | Page to begin reading from |
[in] | count | Number of pages to read |
- Returns
- 0 on success, or BLADERF_ERR_INVAL on an invalid
page
or count
value, or a value from Error codes list on other failures.
◆ bladerf_read_flash_bytes()
API_EXPORT int CALL_CONV bladerf_read_flash_bytes |
( |
struct bladerf * |
dev, |
|
|
uint8_t * |
buf, |
|
|
uint32_t |
address, |
|
|
uint32_t |
bytes |
|
) |
| |
Read data from the bladeRF's SPI flash
- Note
- This function operates in units of bytes.
- Parameters
-
| dev | Device handle |
[in] | buf | Buffer to read data into. Must be bytes bytes or larger. |
[in] | address | Address to begin reading from |
[in] | bytes | Number of bytes to read |
- Returns
- 0 on success, or BLADERF_ERR_INVAL on an invalid
address
or bytes
value, or a value from Error codes list on other failures.
◆ bladerf_read_otp()
Read data from the bladeRF's SPI flash OTP
- Note
- This function operates solely on the first 256 byte page of the OTP
- Parameters
-
| dev | Device handle |
[in] | buf | Buffer to read OTP data into |
- Returns
- 0 on success, or BLADERF_ERR_INVAL on an invalid
page
or count
value, or a value from Error codes list on other failures.
◆ bladerf_write_flash()
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
- Note
- This function operates in units of flash pages.
-
Not recommended for new designs. Consider using the
bladerf_write_flash_bytes()
function instead. It will perform the necessary conversion from bytes to pages based on the specific flash architecture found on the board.
- Parameters
-
| dev | Device handle |
[in] | buf | Data to write to flash |
[in] | page | Page to begin writing at |
[in] | count | Number of pages to write |
- Returns
- 0 on success, or BLADERF_ERR_INVAL on an invalid
page
or count
value, or a value from Error codes list on other failures.
◆ bladerf_write_flash_bytes()
API_EXPORT int CALL_CONV bladerf_write_flash_bytes |
( |
struct bladerf * |
dev, |
|
|
const uint8_t * |
buf, |
|
|
uint32_t |
address, |
|
|
uint32_t |
length |
|
) |
| |
Write data to the bladeRF's SPI flash device
- Note
- This function operates in units of bytes.
- Parameters
-
| dev | Device handle |
[in] | buf | Data to write to flash |
[in] | address | Address to begin writing at |
[in] | length | Number of bytes to write |
- Returns
- 0 on success, or BLADERF_ERR_INVAL on an invalid
address
or length
value, or a value from Error codes list on other failures.
◆ bladerf_write_otp()
Write data to the bladeRF's SPI flash OTP device
- Note
- This function operates solely on the first 256 byte page of the OTP
- Parameters
-
| dev | Device handle |
[in] | buf | Data to write to OTP |
- Returns
- 0 on success, or BLADERF_ERR_INVAL on an invalid
page
or count
value, or a value from Error codes list on other failures.