pub struct SpiFlash<'a> { /* private fields */ }Expand description
Accessor for the W25Q80BV SPI Flash in the HackRF.
⚠️ WARNING: This allows for directly manipulating the SPI flash, which is a great way to brick your HackRF and require recovering through DFU mode.
The general write procedure is to erase the flash, write all bytes to it starting from address 0, then verify by reading the flash to verify a successful write. As long as you don’t depower it after a flash operation, a failed write attempt can potentially be repeated, as it appears the HackRF only accesses flash during initial boot and configuration.
Implementations§
Source§impl SpiFlash<'_>
impl SpiFlash<'_>
Sourcepub async fn erase(&self) -> Result<(), Error>
pub async fn erase(&self) -> Result<(), Error>
Erase the entire flash memory.
Should be immediately followed by writing a new image, or the HackRF will be soft-bricked (but recoverable by DFU).
Sourcepub async fn write(&self, addr: u32, data: &[u8]) -> Result<(), Error>
pub async fn write(&self, addr: u32, data: &[u8]) -> Result<(), Error>
Write firmware to the flash memory.
Should only be used for firmware image writing, and needs to be preceeded by an erase command before doing a write sequence.
Writes can be up to the max size of the memory; this command will split them into sub-commands if needed.
Sourcepub async fn read(&self, addr: u32, len: usize) -> Result<Vec<u8>, Error>
pub async fn read(&self, addr: u32, len: usize) -> Result<Vec<u8>, Error>
Read from the flash memory.
This should only be used for firmware verification.
Reads can be up to the max size of the memory; this command will split them into sub-commands if needed.
Sourcepub async fn status(&self) -> Result<[u8; 2], Error>
pub async fn status(&self) -> Result<[u8; 2], Error>
Get the status registers of the W25Q80BV flash memory.
Requires API version 0x0103 or higher.
Sourcepub async fn clear_status(&self) -> Result<(), Error>
pub async fn clear_status(&self) -> Result<(), Error>
Clear the status registers of the W25Q80BV flash memory.