Represents a flash partition. More...
#include <Partition.h>
Classes | |
| 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 (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 (size_t offset, T &value) | ||||||
| bool | write (size_t offset, const void *src, size_t size) | ||||||
| Write data to the partition. More... | |||||||
| bool | erase_range (size_t offset, 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... | |||||||
| uint32_t | address () const | ||||||
| Obtain partition starting address. More... | |||||||
| uint32_t | lastAddress () const | ||||||
| Obtain address of last byte in this this partition. More... | |||||||
| uint32_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 (uint32_t &address, 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... | |||||||
| Device * | getDevice () const | ||||||
| Get storage device containing this partition. More... | |||||||
| bool | contains (uint32_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 | ||||||
| size_t | getBlockSize () const | ||||||
| Obtain smallest allocation unit for erase operations. More... | |||||||
Confirm partition is of the expected type | |||||||
| |||||||
| bool | verify (Type type, uint8_t subtype) const | ||||||
| bool | verify (uint8_t type, uint8_t subtype) const | ||||||
| template<typename T > | |||||||
| bool | verify (T subType) const | ||||||
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.
- Parameters
-
uint32_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.
◆ erase_range()
| bool Storage::Partition::erase_range | ( | size_t | offset, |
| 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.
◆ getBlockSize()
| size_t Storage::Partition::getBlockSize | ( | ) | const |
Obtain smallest allocation unit for erase operations.
◆ getDevice()
|
inline |
Get storage device containing this partition.
- Return values
-
Device* null if device isn't registered
◆ getDeviceAddress()
| bool Storage::Partition::getDeviceAddress | ( | uint32_t & | address, |
| 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
◆ 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.
- Parameters
-
uint32_t Device address
◆ longTypeString()
| String Storage::Partition::longTypeString | ( | ) | const |
◆ name()
|
inline |
Get partition name.
◆ operator bool()
|
inlineexplicit |
◆ operator==() [1/3]
◆ operator==() [2/3]
|
inline |
◆ operator==() [3/3]
◆ read() [1/2]
| bool Storage::Partition::read | ( | 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
◆ read() [2/2]
|
inline |
◆ size()
|
inline |
Obtain partition size.
- Return values
-
uint32_t Size in bytes
◆ subType()
|
inline |
Obtain partition sub-type.
◆ type()
|
inline |
Obtain partition type.
◆ typeString()
| String Storage::Partition::typeString | ( | ) | const |
◆ verify() [1/3]
◆ verify() [2/3]
|
inline |
◆ verify() [3/3]
|
inline |
◆ write()
| bool Storage::Partition::write | ( | 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
|
static |
The documentation for this class was generated from the following file:
1.8.13