pub struct PartTab {
pub rma_w_state: u8,
pub rma_ov_state: u8,
pub eFWV: u8,
pub fw1_idx: u8,
pub fw2_idx: u8,
pub ota_trap: TrapConfig,
pub mp_trap: TrapConfig,
pub key_exp_op: KeyExportOp,
/* private fields */
}
Expand description
§===================================================================================== Partition Table (PartTab)
The PartTab
struct represents a partition table for the flash, containing various
metadata and configuration related to the partitioning, as well as firmware-specific
data such as the state of firmware updates, trap configurations, and key export
operations.
§Layout:
+-----------------+------------------+---+----------+---------+-------------+-------------+---+---+---+-------+-------+-------+------+----+----------------+
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
+========+=================+==================+===+==========+=========+=============+=============+===+===+===+=======+=======+=======+======+====+================+
| 0x00 | rma_w_state: u8 | rma_ov_state: u8 | | eFWV: u8 | num: u8 | fw1_idx: u8 | fw2_idx: u8 | | ota_trap: u16 | mp_trap: u16 | | key_exp_op: u8 |
+--------+-----------------+------------------+---+----------+---------+-------------+-------------+-----------+---------------+--------------+----+----------------+
| 0x10 | user_len: u32 | user_ext: bytes[12] |
+--------+---------------------------------------------------+------------------------------------------------------------------------------------------------------+
| 0x20 | records: Record * num |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x30 | |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x40 | |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x50 | |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x60 | user_bin: bytes[user_len] |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
Fields§
§rma_w_state: u8
§rma_ov_state: u8
§eFWV: u8
§fw1_idx: u8
§fw2_idx: u8
§ota_trap: TrapConfig
§mp_trap: TrapConfig
§key_exp_op: KeyExportOp
Implementations§
Source§impl PartTab
impl PartTab
Sourcepub fn get_records(&self) -> &[Record]
pub fn get_records(&self) -> &[Record]
Sourcepub fn get_user_bin(&self) -> &[u8] ⓘ
pub fn get_user_bin(&self) -> &[u8] ⓘ
Returns the user binary data.
This method provides access to the raw user binary data in the partition table.
§Returns:
- A slice of bytes representing the user binary data.
Sourcepub fn get_user_ext(&self) -> &[u8] ⓘ
pub fn get_user_ext(&self) -> &[u8] ⓘ
Returns the user extension data (12 bytes).
This method provides access to the 12-byte user extension field, which can be used for storing additional metadata related to the partition table.
§Returns:
- A reference to the 12-byte array representing the user extension data.
Sourcepub fn set_user_bin(&mut self, user_bin: &[u8])
pub fn set_user_bin(&mut self, user_bin: &[u8])
Sets the user binary data in the partition table.
§Arguments:
user_bin
: A slice of bytes representing the new user binary data to store.
Sourcepub fn set_user_ext(&mut self, user_ext: &[u8])
pub fn set_user_ext(&mut self, user_ext: &[u8])
Sets the user extension data in the partition table.
§Arguments:
user_ext
: A slice of bytes representing the new user extension data (12 bytes).
Sourcepub fn add_record(&mut self, record: Record)
pub fn add_record(&mut self, record: Record)
Adds a new partition record to the partition table.
§Arguments:
record
: TheRecord
struct that defines the new partition entry to add.
Sourcepub fn new_record(&mut self, part_type: PartitionType) -> &mut Record
pub fn new_record(&mut self, part_type: PartitionType) -> &mut Record
Sourcepub fn get_record(&self, part_type: PartitionType) -> Option<&Record>
pub fn get_record(&self, part_type: PartitionType) -> Option<&Record>
Sourcepub fn get_record_mut(
&mut self,
part_type: PartitionType,
) -> Option<&mut Record>
pub fn get_record_mut( &mut self, part_type: PartitionType, ) -> Option<&mut Record>
Sourcepub fn rem_record(&mut self, part_type: PartitionType)
pub fn rem_record(&mut self, part_type: PartitionType)
Removes a partition record from the partition table.
§Arguments:
part_type
: ThePartitionType
enum value representing the partition type to remove.
Sourcepub fn has_record(&self, part_type: PartitionType) -> bool
pub fn has_record(&self, part_type: PartitionType) -> bool
Trait Implementations§
Source§impl FromStream for PartTab
impl FromStream for PartTab
Source§impl TryInto<PartTab> for PartitionTableCfg
impl TryInto<PartTab> for PartitionTableCfg
Source§fn try_into(self) -> Result<PartTab, Self::Error>
fn try_into(self) -> Result<PartTab, Self::Error>
Converts a PartitionTableCfg
instance into a PartTab
instance.
§Returns:
Ok(PartTab)
: APartTab
instance with the appropriate values set.Err(Error)
: An error if something goes wrong, such as if the user extension file does not exist or cannot be read.