![]() |
Morse Micro IoT SDK
2.12.3
|
This API provides abstraction from the underlying flash hardware.
Data Structures | |
| struct | mmhal_flash_partition_config |
| Flash partition configuration structure. More... | |
Macros | |
| #define | MMHAL_FLASH_ERASE_VALUE 0xFF |
| This is the value erased flash bytes are set to. More... | |
| #define | MMHAL_FLASH_ADDR_T uint32_t |
| Underlying integer type for mmhal_flash_addr_t. More... | |
| #define | MMHAL_FLASH_PARTITION_CONFIG_DEFAULT { 0, 0, false } |
| Initial values for mmhal_flash_partition_config. More... | |
Typedefs | |
| typedef MMHAL_FLASH_ADDR_T | mmhal_flash_addr_t |
| Address type used by the mmhal flash API. More... | |
Functions | |
| const struct mmhal_flash_partition_config * | mmhal_get_mmconfig_partition (void) |
| Get MMCONFIG flash partition configuration. More... | |
| const struct mmhal_flash_partition_config * | mmhal_get_factory_mmconfig_partition (void) |
| Get optional factory default MMCONFIG flash partition configuration. More... | |
| int | mmhal_flash_erase (mmhal_flash_addr_t block_address) |
| Erases a specified block of flash. More... | |
| uint32_t | mmhal_flash_getblocksize (mmhal_flash_addr_t block_address) |
| Returns the size of the flash block at the specified address. More... | |
| int | mmhal_flash_read (mmhal_flash_addr_t read_address, uint8_t *buf, size_t size) |
| Read a block of data from the specified Flash address into the buffer. More... | |
| int | mmhal_flash_write (mmhal_flash_addr_t write_address, const uint8_t *data, size_t size) |
| Write a block of data to the specified Flash address. More... | |
| const struct lfs_config * | mmhal_get_littlefs_config (void) |
| Get LittleFS configuration. More... | |
| #define MMHAL_FLASH_ADDR_T uint32_t |
Underlying integer type for mmhal_flash_addr_t.
Defaults to uint32_t. May be overridden by the build system (e.g. by defining MMHAL_FLASH_ADDR_T on the compiler command line) if a platform requires a wider integer type to represent a flash address.
Definition at line 44 of file mmhal_flash.h.
| #define MMHAL_FLASH_ERASE_VALUE 0xFF |
This is the value erased flash bytes are set to.
This shall be 0xFF as this is the value that hardware flash erases to.
Definition at line 32 of file mmhal_flash.h.
| #define MMHAL_FLASH_PARTITION_CONFIG_DEFAULT { 0, 0, false } |
Initial values for mmhal_flash_partition_config.
Definition at line 85 of file mmhal_flash.h.
| typedef MMHAL_FLASH_ADDR_T mmhal_flash_addr_t |
Address type used by the mmhal flash API.
Definition at line 48 of file mmhal_flash.h.
| int mmhal_flash_erase | ( | mmhal_flash_addr_t | block_address | ) |
Erases a specified block of flash.
The given block_address may be anywhere within the block to erase – the entire block will be erased. Once erased all bytes in the block shall be MMHAL_FLASH_ERASE_VALUE.
| block_address | The address of the block of flash to erase. Addresses are implementation dependent, but should be within a range defined by a given mmhal_flash_partition_config. |
| uint32_t mmhal_flash_getblocksize | ( | mmhal_flash_addr_t | block_address | ) |
Returns the size of the flash block at the specified address.
| block_address | The address of the flash block. Addresses are implementation dependent, but should be within a range defined by a given mmhal_flash_partition_config. |
| int mmhal_flash_read | ( | mmhal_flash_addr_t | read_address, |
| uint8_t * | buf, | ||
| size_t | size | ||
| ) |
Read a block of data from the specified Flash address into the buffer.
| read_address | The address to read from. Addresses are implementation dependent, but should be within a range defined by a given mmhal_flash_partition_config. |
| buf | The buffer to read into. |
| size | The number of bytes to read. |
| int mmhal_flash_write | ( | mmhal_flash_addr_t | write_address, |
| const uint8_t * | data, | ||
| size_t | size | ||
| ) |
Write a block of data to the specified Flash address.
There is no alignment or minimum size requirement. This function will take care of aligning the data and merging with existing Flash contents. The Flash block is not erased, it is up to the application to determine if the block needs to be erased before programming.
| write_address | The address to write to. Addresses are implementation dependent, but should be within a range defined by a given mmhal_flash_partition_config. |
| data | A pointer to the block of data to write. |
| size | The number of bytes to write. |
| const struct mmhal_flash_partition_config * mmhal_get_factory_mmconfig_partition | ( | void | ) |
Get optional factory default MMCONFIG flash partition configuration.
This partition uses the same on-flash format as a single MMCONFIG image, but is treated as read-only by mmconfig. If present and valid, values in this partition are used as fall-backs when a key is absent from the writable MMCONFIG partition. Platforms that do not provide a factory default partition may omit this function; a weak default implementation returns NULL.
Note that unlike mmhal_get_mmconfig_partition(), the size here is used only for a single partition. Therefore it would be normal to define a factory partition that is half the size (or less) of the normal config partition, and it is not necessary to align it to a flash sector as it is not erased.
| const struct lfs_config * mmhal_get_littlefs_config | ( | void | ) |
Get LittleFS configuration.
LittleFS initialization is done by littlefs_init() in mmosal_shim_fileio.c. which in turn calls this function to fetch the hardware configuration for LittleFS from the HAL layer. The LittleFS configuration will vary from platform to platform. If LittleFS is not supported by the platform then we just return NULL. This function returns a static pointer to struct lfs_config which is defined in lfs.h.
See mmhal_littlefs.c for the full HAL layer implementation for your platform. See mmosal_shim_fileio.c for the libc shims for LittleFS. See README.md in the src/littlefs folder for detailed information on LittleFS.
| const struct mmhal_flash_partition_config * mmhal_get_mmconfig_partition | ( | void | ) |
Get MMCONFIG flash partition configuration.
MMCONFIG initialization is done by mmconfig_init() in mmconfig.c, which in turn calls this function to fetch the partition configuration for config store from the HAL layer. If config store is not supported by the platform then we just return NULL. This function returns a static pointer to struct mmhal_flash_partition_config.
Because primary/secondary partitions are used in the current implementation, the available config storage is half of the provided size.