Represents a flash partition. More...
#include <Partition.h>
Classes | |
| struct | FullType |
| Express both partition type and subtype together. More... | |
| struct | Info |
| Partition information. More... | |
| struct | SubType |
Public Types | |
| enum | Type : uint8_t { Type::app = 0x00, Type::data = 0x01, Type::storage = 0x02, Type::userMin = 0x40, Type::userMax = 0xFE, Type::invalid = 0xff, Type::any = 0xff } |
| enum | Flag { Flag::encrypted = 0, Flag::readOnly = 31 } |
| using | Name = char[nameSize] |
| using | Flags = BitSet< uint32_t, Flag > |
Public Member Functions | |
| Partition () | |
| Partition (const Partition &other) | |
| Partition (Device &device, const Info &info) | |
| operator bool () const | |
| bool | read (storage_size_t offset, void *dst, size_t size) |
| Read data from the partition. More... | |
| template<typename T > | |
| std::enable_if< std::is_pod< T >::value, bool >::type | read (storage_size_t offset, T &value) |
| bool | write (storage_size_t offset, const void *src, size_t size) |
| Write data to the partition. More... | |
| bool | erase_range (storage_size_t offset, storage_size_t size) |
| Erase part of the partition. More... | |
| Partition::Type | type () const |
| Obtain partition type. More... | |
| uint8_t | subType () const |
| Obtain partition sub-type. More... | |
| FullType | fullType () const |
| Obtain both type and subtype. More... | |
| storage_size_t | address () const |
| Obtain partition starting address. More... | |
| storage_size_t | lastAddress () const |
| Obtain address of last byte in this this partition. More... | |
| storage_size_t | size () const |
| Obtain partition size. More... | |
| String | name () const |
| Get partition name. More... | |
| Flags | flags () const |
| Get partition flags. More... | |
| bool | isEncrypted () const |
Check state of partition encrypted flag. More... | |
| bool | isReadOnly () const |
Check state of partition readOnly flag. More... | |
| bool | getDeviceAddress (storage_size_t &address, storage_size_t size) const |
| Get corresponding storage device address for a given partition offset. More... | |
| String | getDeviceName () const |
| Get name of storage device for this partition. More... | |
| bool | contains (storage_size_t addr) const |
| Determine if given address contained within this partition. More... | |
| bool | operator== (const Partition &other) const |
| bool | operator== (const char *name) const |
| bool | operator== (const String &name) const |
| template<typename T > | |
| bool | operator!= (const T &other) const |
| size_t | getBlockSize () const |
| Obtain smallest allocation unit for erase operations. More... | |
| uint16_t | getSectorSize () const |
| Get sector size for block-addressable devices. More... | |
| storage_size_t | getSectorCount () const |
| Obtain total number of sectors in this partition. More... | |
| bool | sync () |
| Flush any pending writes to the physical media. More... | |
| const Disk::DiskPart * | diskpart () const |
| If this is a disk partition, return pointer to the additional information. More... | |
| size_t | printTo (Print &p) const |
Confirm partition is of the expected type | |
| bool | verify (Type type, uint8_t subtype) const |
| Strong C++ type value. More... | |
| bool | verify (uint8_t type, uint8_t subtype) const |
| Weak 'type' value. More... | |
| template<typename T > | |
| bool | verify (T subType) const |
| Derive type from subtype, expressed as strong C++ enum. More... | |
Get partition type expressed as a string | |
| String | typeString () const |
| String | longTypeString () const |
Static Public Member Functions | |
| static SubType::App | apptypeOta (uint8_t i) |
| Convenience function to get SubType value for the i-th OTA partition. More... | |
Static Public Attributes | |
| static constexpr size_t | nameSize {16} |
Protected Attributes | |
| Device * | mDevice {nullptr} |
| const Info * | mPart {nullptr} |
Detailed Description
Represents a flash partition.
Member Typedef Documentation
◆ Flags
| using Storage::Partition::Flags = BitSet<uint32_t, Flag> |
◆ Name
| using Storage::Partition::Name = char[nameSize] |
Member Enumeration Documentation
◆ Flag
|
strong |
◆ Type
|
strong |
Constructor & Destructor Documentation
◆ Partition() [1/3]
|
inline |
◆ Partition() [2/3]
|
inline |
◆ Partition() [3/3]
Member Function Documentation
◆ address()
|
inline |
Obtain partition starting address.
- Return values
-
storage_size_t Device address
◆ apptypeOta()
|
inlinestatic |
Convenience function to get SubType value for the i-th OTA partition.
◆ contains()
|
inline |
Determine if given address contained within this partition.
◆ diskpart()
|
inline |
If this is a disk partition, return pointer to the additional information.
◆ erase_range()
| bool Storage::Partition::erase_range | ( | storage_size_t | offset, |
| storage_size_t | size | ||
| ) |
Erase part of the partition.
- Parameters
-
offset Where to start erasing, relative to start of partition size Size of region to erase, in bytes
- Return values
-
bool true on success, false on error
- Note
- Both offset and size must be aligned to flash sector size (4Kbytes)
◆ flags()
|
inline |
Get partition flags.
◆ fullType()
|
inline |
Obtain both type and subtype.
◆ getBlockSize()
| size_t Storage::Partition::getBlockSize | ( | ) | const |
Obtain smallest allocation unit for erase operations.
◆ getDeviceAddress()
| bool Storage::Partition::getDeviceAddress | ( | storage_size_t & | address, |
| storage_size_t | size | ||
| ) | const |
Get corresponding storage device address for a given partition offset.
- Parameters
-
address IN: Zero-based offset within partition, OUT: Device address size Size of data to be accessed
- Return values
-
bool true on success, false on failure Fails if the given offset/size combination is out of range, or the partition is undefined.
◆ getDeviceName()
| String Storage::Partition::getDeviceName | ( | ) | const |
Get name of storage device for this partition.
- Return values
-
String
◆ getSectorCount()
|
inline |
Obtain total number of sectors in this partition.
◆ getSectorSize()
| uint16_t Storage::Partition::getSectorSize | ( | ) | const |
Get sector size for block-addressable devices.
- See also
- See
Storage::Device::getSectorSize
◆ isEncrypted()
|
inline |
Check state of partition encrypted flag.
◆ isReadOnly()
|
inline |
Check state of partition readOnly flag.
◆ lastAddress()
|
inline |
Obtain address of last byte in this this partition.
- Return values
-
storage_size_t Device address
◆ longTypeString()
| String Storage::Partition::longTypeString | ( | ) | const |
◆ name()
|
inline |
Get partition name.
◆ operator bool()
|
inlineexplicit |
◆ operator!=()
|
inline |
◆ operator==() [1/3]
|
inline |
◆ operator==() [2/3]
◆ operator==() [3/3]
◆ printTo()
◆ read() [1/2]
|
inline |
◆ read() [2/2]
| bool Storage::Partition::read | ( | storage_size_t | offset, |
| void * | dst, | ||
| size_t | size | ||
| ) |
Read data from the partition.
- Parameters
-
offset Where to start reading, relative to start of partition dst Buffer to store data size Size of data to be read, in bytes.
- Return values
-
bool true on success, false on error
◆ size()
|
inline |
Obtain partition size.
- Return values
-
storage_size_t Size in bytes
◆ subType()
|
inline |
Obtain partition sub-type.
◆ sync()
| bool Storage::Partition::sync | ( | ) |
Flush any pending writes to the physical media.
- See also
- See
Storage::Device::sync
◆ type()
|
inline |
Obtain partition type.
◆ typeString()
| String Storage::Partition::typeString | ( | ) | const |
◆ verify() [1/3]
|
inline |
Derive type from subtype, expressed as strong C++ enum.
◆ verify() [2/3]
Strong C++ type value.
- Parameters
-
type Expected partition type subtype Expected partition sub-type
- Return values
-
bool true if type is OK, false if not. Logs debug messages on failure.
◆ verify() [3/3]
◆ write()
| bool Storage::Partition::write | ( | storage_size_t | offset, |
| const void * | src, | ||
| size_t | size | ||
| ) |
Write data to the partition.
- Parameters
-
offset Where to start writing, relative to start of partition src Data to write size Size of data to be written, in bytes.
- Return values
-
bool true on success, false on error
- Note
- Flash region must be erased first
Member Data Documentation
◆ mDevice
|
protected |
◆ mPart
|
protected |
◆ nameSize
|
staticconstexpr |
The documentation for this class was generated from the following file:
1.8.17