Zephyr API Documentation 4.5.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
blob_io_flash.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_IO_FLASH_H__
14#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_IO_FLASH_H__
15
16#include <stdint.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
27
36
37
38 /* Internal flash area pointer. */
39 const struct flash_area *area;
40 /* BLOB stream. */
42
43#if defined(CONFIG_BT_MESH_BLOB_IO_FLASH_BLOCK_CACHE)
44 /* Block cache used when CONFIG_BT_MESH_BLOB_IO_FLASH_BLOCK_CACHE is set.
45 * Received chunks are accumulated here by block-relative offset, and the
46 * whole block is programmed write-block-aligned, exactly once, by the
47 * wr() call that completes the block. This prevents re-programming a
48 * write block that is shared by two adjacent chunks, which would corrupt
49 * the ECC syndrome on flash that allows only one program per erase.
50 */
51 /* Staging buffer for the current block. */
52 uint8_t block_buf[CONFIG_BT_MESH_BLOB_BLOCK_SIZE_MAX];
53 /* Number of valid bytes received into block_buf for the current block;
54 * reaches the block size when the block is complete and gets flushed.
55 */
56 size_t received;
57 /* Sticky error: set when a block flush fails, so that no later wr() can
58 * re-program a write block. Cleared only in io_open (NOT block_start,
59 * which does not always erase); a failed flush latches for the rest of
60 * the stream and the whole transfer fails.
61 */
62 bool block_err;
63#endif /* CONFIG_BT_MESH_BLOB_IO_FLASH_BLOCK_CACHE */
64};
65
75 uint8_t area_id, off_t offset);
76
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_IO_FLASH_H__ */
int bt_mesh_blob_io_flash_init(struct bt_mesh_blob_io_flash *flash, uint8_t area_id, off_t offset)
Initialize a flash stream.
bt_mesh_blob_io_mode
BLOB stream interaction mode.
Definition blob.h:143
__INTPTR_TYPE__ off_t
Definition types.h:36
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
BLOB flash stream.
Definition blob_io_flash.h:29
struct bt_mesh_blob_io io
Definition blob_io_flash.h:41
uint8_t area_id
Flash area ID to write the BLOB to.
Definition blob_io_flash.h:31
enum bt_mesh_blob_io_mode mode
Active stream mode.
Definition blob_io_flash.h:33
const struct flash_area * area
Definition blob_io_flash.h:39
off_t offset
Offset into the flash area to place the BLOB at (in bytes).
Definition blob_io_flash.h:35
BLOB stream.
Definition blob.h:151
Flash partition.
Definition flash_map.h:57