libbladeRF  2.5.0
Nuand bladeRF library
Functions

Description

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.

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_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)
 

Function Documentation

◆ 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
devDevice handle
[in]erase_blockErase block from which to start erasing
[in]countNumber 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
devDevice handle
[in]addressAddress at which to start erasing
[in]lengthNumber 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()

API_EXPORT int CALL_CONV bladerf_lock_otp ( struct bladerf *  dev)

Lock the bladeRF's OTP

Parameters
devDevice handle
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
devDevice handle
[in]bufBuffer to read data into. Must be count * flash-page-size bytes or larger.
[in]pagePage to begin reading from
[in]countNumber 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
devDevice handle
[in]bufBuffer to read data into. Must be bytes bytes or larger.
[in]addressAddress to begin reading from
[in]bytesNumber 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()

API_EXPORT int CALL_CONV bladerf_read_otp ( struct bladerf *  dev,
uint8_t *  buf 
)

Read data from the bladeRF's SPI flash OTP

Note
This function operates solely on the first 256 byte page of the OTP
Parameters
devDevice handle
[in]bufBuffer 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
devDevice handle
[in]bufData to write to flash
[in]pagePage to begin writing at
[in]countNumber 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
devDevice handle
[in]bufData to write to flash
[in]addressAddress to begin writing at
[in]lengthNumber 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()

API_EXPORT int CALL_CONV bladerf_write_otp ( struct bladerf *  dev,
uint8_t *  buf 
)

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
devDevice handle
[in]bufData 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.