Skip to content

Commit 3b7bbaf

Browse files
committed
mcumgr: img_mgmt rework
img_mgmt and RRAM handling rework. Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
1 parent df276b5 commit 3b7bbaf

9 files changed

Lines changed: 120 additions & 1958 deletions

File tree

applications/firmware_loader/ble_mcumgr/prj.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ CONFIG_NRF_SECURITY=y
4141
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
4242
CONFIG_PSA_WANT_GENERATE_RANDOM=y
4343
CONFIG_BLE_MCUMGR=y
44+
CONFIG_BM_STORAGE=y
45+
CONFIG_BM_STORAGE_BACKEND_SD=y
46+
CONFIG_BM_STORAGE_BACKEND_SD_QUEUE_SIZE=4
47+
CONFIG_RING_BUFFER=y
48+
CONFIG_RING_BUFFER_LARGE=y
4449

4550
CONFIG_LOG=y
4651
CONFIG_LOG_MODE_MINIMAL=y

drivers/flash/soc_flash_nrf_rram.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,6 @@ static int nrf_rram_write(const struct device *dev, off_t addr, const void *data
121121
return -EIO;
122122
}
123123

124-
while (1) {
125-
int taskid;
126-
127-
/* Wait for an event. */
128-
__WFE();
129-
130-
/* Clear Event Register */
131-
__SEV();
132-
__WFE();
133-
134-
ret = sd_evt_get(&taskid);
135-
136-
if (!ret && (taskid == NRF_EVT_FLASH_OPERATION_SUCCESS ||
137-
taskid == NRF_EVT_FLASH_OPERATION_ERROR)) {
138-
if (taskid != NRF_EVT_FLASH_OPERATION_SUCCESS) {
139-
ret = -EIO;
140-
}
141-
142-
break;
143-
}
144-
}
145124

146125
barrier_dmem_fence_full(); /* Barrier following our last write. */
147126

subsys/mgmt/mcumgr/grp/img_mgmt/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
# when Image Management is enabled.
1010
zephyr_library_named(mgmt_mcumgr_grp_img)
1111
zephyr_library_sources(
12-
${ZEPHYR_BASE}/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c
12+
src/zephyr_img_mgmt.c
1313
${ZEPHYR_BASE}/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_util.c
1414
src/img_mgmt_state.c
15-
${ZEPHYR_BASE}/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c
15+
src/img_mgmt.c
1616
)
1717

18-
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/mgmt/mcumgr/grp/img_mgmt/include)
18+
zephyr_library_include_directories(include)
1919

2020
if(CONFIG_MCUBOOT_IMG_MANAGER)
2121
zephyr_library_link_libraries(MCUBOOT_BOOTUTIL)

subsys/mgmt/mcumgr/grp/img_mgmt/include/img_mgmt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ enum img_mgmt_err_code_t {
179179

180180
/** Current active slot for image cannot be determined */
181181
IMG_MGMT_ERR_ACTIVE_SLOT_NOT_KNOWN,
182+
183+
IMG_MGMT_ERR_BUSY,
182184
};
183185

184186
/**
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2018-2021 mcumgr authors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef H_IMG_MGMT_CONFIG_
8+
#define H_IMG_MGMT_CONFIG_
9+
10+
#define IMG_MGMT_BOOT_CURR_SLOT 0
11+
12+
#endif

subsys/mgmt/mcumgr/grp/img_mgmt/include/mgmt/mcumgr/grp/img_mgmt/img_mgmt_priv.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,13 @@ int img_mgmt_write_confirmed(void);
5959
/**
6060
* @brief Reads the specified chunk of data from an image slot.
6161
*
62-
* @param slot The index of the slot to read from.
6362
* @param offset The offset within the slot to read from.
6463
* @param dst On success, the read data gets written here.
6564
* @param num_bytes The number of bytes to read.
6665
*
6766
* @return 0 on success, MGMT_ERR_[...] code on failure.
6867
*/
69-
int img_mgmt_read(int slot, unsigned int offset, void *dst, unsigned int num_bytes);
68+
int img_mgmt_read(unsigned int offset, void *dst, unsigned int num_bytes);
7069

7170
/**
7271
* @brief Writes the specified chunk of image data to slot 1.

0 commit comments

Comments
 (0)