From 8137bd7e5109e8616d8271379997abc070d563b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Reierstad?= Date: Mon, 13 May 2024 07:33:24 +0200 Subject: [PATCH] [nrf fromtree] bluetooth: mesh: Adapt BLOB IO to RRAM write size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adapts flash writing for BLOB IO to RRAM. The previously used write block alignment is not needed for RRAM. Signed-off-by: Håvard Reierstad (cherry picked from commit 0f416b3576d2b259f1bf4f381d8cae430bb41d2a) Signed-off-by: Håvard Reierstad --- subsys/bluetooth/mesh/blob_io_flash.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/mesh/blob_io_flash.c b/subsys/bluetooth/mesh/blob_io_flash.c index 8090416ab12..b82a7d20f7f 100644 --- a/subsys/bluetooth/mesh/blob_io_flash.c +++ b/subsys/bluetooth/mesh/blob_io_flash.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Noioic Semiconductor ASA + * Copyright (c) 2020 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,7 +12,7 @@ #include "net.h" #include "transport.h" -#define WRITE_BLOCK_SIZE 4 +#define WRITE_BLOCK_SIZE DT_PROP(DT_INST(0, soc_nv_flash), write_block_size) #define FLASH_IO(_io) CONTAINER_OF(_io, struct bt_mesh_blob_io_flash, io) @@ -110,6 +110,13 @@ static int wr_chunk(const struct bt_mesh_blob_io *io, const struct bt_mesh_blob_chunk *chunk) { struct bt_mesh_blob_io_flash *flash = FLASH_IO(io); + + if (IS_ENABLED(CONFIG_SOC_FLASH_NRF_RRAM)) { + return flash_area_write(flash->area, + flash->offset + block->offset + chunk->offset, + chunk->data, chunk->size); + } + uint8_t buf[ROUND_UP(BLOB_CHUNK_SIZE_MAX(BT_MESH_RX_SDU_MAX), WRITE_BLOCK_SIZE)]; off_t area_offset = flash->offset + block->offset + chunk->offset;