mgmt/mcumgr: Standardise MCUmgr Kconfig names

Standardise Kconfig options for MCUmgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2022-11-24 16:28:24 +00:00 committed by Carles Cufí
commit db34adf9c3
70 changed files with 505 additions and 493 deletions

View file

@ -1,5 +1,5 @@
# Copyright Runtime.io 2018. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR
@ -16,21 +16,21 @@ module = MCUMGR
module-str = mcumgr
source "subsys/logging/Kconfig.template.log_config"
config MCUMGR_SMP_WORKQUEUE_STACK_SIZE
int "MCUMGR SMP workqueue stack size"
config MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE
int "MCUmgr transport workqueue stack size"
default 2048
help
Stack size of the MCUMGR SMP work queue.
Stack size of the MCUmgr for transport subsystem work queue.
config MCUMGR_SMP_WORKQUEUE_THREAD_PRIO
int "MCUMGR SMP workqueue thread priority"
config MCUMGR_TRANSPORT_WORKQUEUE_THREAD_PRIO
int "MCUmgr transport workqueue thread priority"
default 3
help
Scheduling priority of the MCUMGR SMP work queue.
Scheduling priority of the MCUmgr transport subsystem work queue.
rsource "mgmt/Kconfig"
config MGMT_MAX_MAIN_MAP_ENTRIES
config MCUMGR_SMP_CBOR_MAX_MAIN_MAP_ENTRIES
int "Number of predicted maximum entries to main response map"
default 15
help
@ -45,42 +45,42 @@ config MGMT_MAX_MAIN_MAP_ENTRIES
encapsulating them, you may want to increase this value
in case when encoding starts to fail.
config MGMT_MIN_DECODING_LEVELS
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS
int
help
Minimal decoding levels, map/list encapsulation, required
to be supported by zcbor decoding of SMP responses
is auto genereated from MGMT_MIN_DECODING_LEVEL_? options.
is auto genereated from MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_? options.
A group or command that adds additional maps/lists above the
base map, which is already taken into account, should
select one of the MGMT_MIN_DECODING_LEVEL_?.
default 5 if MGMT_MIN_DECODING_LEVEL_5
default 4 if MGMT_MIN_DECODING_LEVEL_4
default 3 if MGMT_MIN_DECODING_LEVEL_3
default 2 if MGMT_MIN_DECODING_LEVEL_2
default 1 if MGMT_MIN_DECODING_LEVEL_1
select one of the MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_?.
default 5 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_5
default 4 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_4
default 3 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_3
default 2 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
default 1 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_1
default 0
config MGMT_MIN_DECODING_LEVEL_1
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_1
bool
config MGMT_MIN_DECODING_LEVEL_2
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
bool
config MGMT_MIN_DECODING_LEVEL_3
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_3
bool
config MGMT_MIN_DECODING_LEVEL_4
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_4
bool
config MGMT_MIN_DECODING_LEVEL_5
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_5
bool
config MGMT_MAX_DECODING_LEVELS
config MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS
int "Number of map/list encapsulations allowed by SMP encoding"
range MGMT_MIN_DECODING_LEVELS 15
default MGMT_MIN_DECODING_LEVELS
range MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS 15
default MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS
help
This is a maximum number of levels of maps/lists that will
be expected to be decoded within different command groups.
@ -142,8 +142,8 @@ rsource "transport/Kconfig"
endmenu
module = MCUMGR_SMP
module-str = mcumgr_smp
module = MCUMGR_TRANSPORT
module-str = mcumgr_transport
source "subsys/logging/Kconfig.template.log_config"
endif # MCUMGR

View file

@ -5,9 +5,9 @@
# SPDX-License-Identifier: Apache-2.0
#
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_FS_MGMT fs_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_IMG_MGMT img_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_OS_MGMT os_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_STAT_MGMT stat_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_SHELL_MGMT shell_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_ZEPHYR_BASIC zephyr_basic)
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_FS fs_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_IMG img_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_OS os_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_STAT stat_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_SHELL shell_mgmt)
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_ZBASIC zephyr_basic)

View file

@ -10,11 +10,11 @@
# interface, when File System management is enabled.
zephyr_library(mgmt_mcumgr_grp_fs)
zephyr_library_sources(src/fs_mgmt.c)
zephyr_library_sources_ifdef(CONFIG_FS_MGMT_CHECKSUM_HASH src/fs_mgmt_hash_checksum.c)
zephyr_library_sources_ifdef(CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32 src/fs_mgmt_hash_checksum_crc32.c)
zephyr_library_sources_ifdef(CONFIG_FS_MGMT_HASH_SHA256 src/fs_mgmt_hash_checksum_sha256.c)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH src/fs_mgmt_hash_checksum.c)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32 src/fs_mgmt_hash_checksum_crc32.c)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_GRP_FS_HASH_SHA256 src/fs_mgmt_hash_checksum_sha256.c)
if (CONFIG_FS_MGMT_CHECKSUM_HASH AND CONFIG_FS_MGMT_HASH_SHA256)
if (CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH AND CONFIG_MCUMGR_GRP_FS_HASH_SHA256)
if (NOT CONFIG_TINYCRYPT)
zephyr_library_link_libraries(mbedTLS)
endif()

View file

@ -2,10 +2,10 @@
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_CMD_FS_MGMT
menuconfig MCUMGR_GRP_FS
bool "Mcumgr handlers for file management (insecure)"
depends on FILE_SYSTEM
select MGMT_MIN_DECODING_LEVEL_2
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
help
Enables mcumgr handlers for file management
@ -14,24 +14,24 @@ menuconfig MCUMGR_CMD_FS_MGMT
private keys. Use of this feature in production is strongly
discouraged.
if MCUMGR_CMD_FS_MGMT
if MCUMGR_GRP_FS
choice FS_MGMT_MAX_FILE_SIZE
choice MCUMGR_GRP_FS_MAX_FILE_SIZE
prompt "Maximum file size that could be uploaded/downloaded"
default FS_MGMT_MAX_FILE_SIZE_64KB
default MCUMGR_GRP_FS_MAX_FILE_SIZE_64KB
help
Maximum file size that will be allowed to be downloaded from
device.
This option decides on number of bytes that are reserved in
CBOR frame for storage of offset/size of file downloaded.
config FS_MGMT_MAX_FILE_SIZE_64KB
config MCUMGR_GRP_FS_MAX_FILE_SIZE_64KB
bool "<= 64KB"
help
Files that have size up to 64KB require 1 to 3 bytes to encode
size/offset within CBOR frame with file chunk.
config FS_MGMT_MAX_FILE_SIZE_4GB
config MCUMGR_GRP_FS_MAX_FILE_SIZE_4GB
bool "<= 4GB"
help
Files that have size up to 4GB require 1 to 5 bytes to encode
@ -39,10 +39,10 @@ config FS_MGMT_MAX_FILE_SIZE_4GB
endchoice
config FS_MGMT_MAX_OFFSET_LEN
config MCUMGR_GRP_FS_MAX_OFFSET_LEN
int
default 3 if FS_MGMT_MAX_FILE_SIZE_64KB
default 5 if FS_MGMT_MAX_FILE_SIZE_4GB
default 3 if MCUMGR_GRP_FS_MAX_FILE_SIZE_64KB
default 5 if MCUMGR_GRP_FS_MAX_FILE_SIZE_4GB
help
Maximal byte length of encoded offset/size, within transferred
CBOR frame containing chunk of downloaded file.
@ -50,42 +50,42 @@ config FS_MGMT_MAX_OFFSET_LEN
as it selects sizes of fields within headers.
NOTE: This option is hidden intentionally as it is intended
to be assigned from limited set of allowed values, depending on
the selection made in FS_MGMT_MAX_FILE_SIZE menu.
the selection made in MCUMGR_GRP_FS_MAX_FILE_SIZE menu.
config FS_MGMT_DL_CHUNK_SIZE_LIMIT
config MCUMGR_GRP_FS_DL_CHUNK_SIZE_LIMIT
bool "Setting custom size of download file chunk"
help
By default file chunk, that will be read off storage and fit into
mcumgr frame, is automatically calculated to fit into buffer
of size MCUGMR_BUF_SIZE with all headers.
of size MCUGMR_TRANSPORT_NETBUF_SIZE with all headers.
Enabling this option allows to set MAXIMUM value that will be
allowed for such chunk.
Look inside fs_mgmt_config.h for details.
if FS_MGMT_DL_CHUNK_SIZE_LIMIT
if MCUMGR_GRP_FS_DL_CHUNK_SIZE_LIMIT
config FS_MGMT_DL_CHUNK_SIZE
config MCUMGR_GRP_FS_DL_CHUNK_SIZE
int "Maximum chunk size for file downloads"
range 65 MCUMGR_BUF_SIZE
default MCUMGR_BUF_SIZE
range 65 MCUMGR_TRANSPORT_NETBUF_SIZE
default MCUMGR_TRANSPORT_NETBUF_SIZE
help
Sets the MAXIMUM size of chunk which will be rounded down to
number of bytes that, with all the required headers, will fit
into MCUMGR_BUF_SIZE. This means that actual value might be lower
then selected, in which case compiler warning will be issued.
Look inside fs_mgmt_config.h for details.
Note that header sizes are affected by FS_MGMT_MAX_OFFSET_LEN.
into MCUMGR_TRANSPORT_NETBUF_SIZE. This means that actual value
might be lower then selected, in which case compiler warning will
be issued. Look inside fs_mgmt_config.h for details.
Note that header sizes are affected by MCUMGR_GRP_FS_MAX_OFFSET_LEN.
endif
config FS_MGMT_FILE_STATUS
config MCUMGR_GRP_FS_FILE_STATUS
bool "File status command"
default y
help
This command allows a remote device to retrieve the status of a file,
at present only the size of the file is returned (if it exists).
config FS_MGMT_CHECKSUM_HASH
config MCUMGR_GRP_FS_CHECKSUM_HASH
bool "Checksum/hash mcumgr functions"
help
Enable this to support the hash/checksum mcumgr functionality,
@ -93,9 +93,9 @@ config FS_MGMT_CHECKSUM_HASH
Note that this requires enough stack space to buffer data
from the file being read and generate the output hash/checksum.
if FS_MGMT_CHECKSUM_HASH
if MCUMGR_GRP_FS_CHECKSUM_HASH
config FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE
config MCUMGR_GRP_FS_CHECKSUM_HASH_CHUNK_SIZE
int "Checksum calculation buffer size"
range 32 16384
default 128
@ -103,13 +103,13 @@ config FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE
Chunk size of buffer to use when calculating file checksum or hash
(uses stack).
config FS_MGMT_CHECKSUM_IEEE_CRC32
config MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32
bool "IEEE CRC32 checksum support"
default y
help
Enable IEEE CRC32 checksum support for mcumgr.
config FS_MGMT_HASH_SHA256
config MCUMGR_GRP_FS_HASH_SHA256
bool "SHA256 hash support"
depends on TINYCRYPT_SHA256 || MBEDTLS_MAC_SHA256_ENABLED
help
@ -132,7 +132,7 @@ config MCUMGR_GRP_FS_CHECKSUM_HASH_SUPPORTED_MAX_TYPES
endif
config FS_MGMT_PATH_SIZE
config MCUMGR_GRP_FS_PATH_LEN
int "Maximum file path length"
default 64
help

View file

@ -7,9 +7,9 @@
#ifndef H_FS_MGMT_CONFIG_
#define H_FS_MGMT_CONFIG_
/* File chunk needs to fit into the CONFIG_MCUMGR_BUF_SIZE with all required
* headers and other data fields. The following data reduces space available
* for file chunk in CONFIG_MCUMGR_BUF_SIZE:
/* File chunk needs to fit into the CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE with
* all required headers and other data fields. The following data reduces
* space available for file chunk in CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE:
* MGMT_HDR_SIZE - header that is placed in front of buffer and not
* visible by CBOR encoder (see smp_handle_single_req);
* 9 + 1 -- bytes taken by marker of CBOR undefined length map and map
@ -17,32 +17,32 @@
* 1 + strlen("off") + [1, N] -- CBOR encoded pair of "off" key and
* offset value of the chunk within the file;
* 1 + strlen("data") + [1, N] -- CBOR encoded "data" key and value
* representing that should be <= CONFIG_FS_MGMT_DL_CHUNK_SIZE
* representing that should be <= CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE
* 1 + strlen("rc") + 1 -- status code of operation;
* 1 + strlen("len") + [1, N] -- CBOR encoded "len" marker and complete
* length of a file; this is only sent once when "off" is 0;
*
* FS_MGMT_DL_CHUNK_SIZE is calculated with most pessimistic estimations,
* MCUMGR_GRP_FS_DL_CHUNK_SIZE is calculated with most pessimistic estimations,
* where CBOR encoding of data takes longest form.
*/
#define CBOR_AND_OTHER_HDR \
(MGMT_HDR_SIZE + \
(9 + 1) + \
(1 + 3 + CONFIG_FS_MGMT_MAX_OFFSET_LEN) + \
(1 + 4 + CONFIG_FS_MGMT_MAX_OFFSET_LEN) + \
(1 + 2 + 1) + \
(1 + 3 + CONFIG_FS_MGMT_MAX_OFFSET_LEN))
#define CBOR_AND_OTHER_HDR \
(MGMT_HDR_SIZE + \
(9 + 1) + \
(1 + 3 + CONFIG_MCUMGR_GRP_FS_MAX_OFFSET_LEN) + \
(1 + 4 + CONFIG_MCUMGR_GRP_FS_MAX_OFFSET_LEN) + \
(1 + 2 + 1) + \
(1 + 3 + CONFIG_MCUMGR_GRP_FS_MAX_OFFSET_LEN))
#if defined(CONFIG_FS_MGMT_DL_CHUNK_SIZE_LIMIT)
#if (CONFIG_FS_MGMT_DL_CHUNK_SIZE + CBOR_AND_OTHER_HDR) > CONFIG_MCUMGR_BUF_SIZE
#warning FS_MGMT_DL_CHUNK_SIZE too big, rounding it down.
#if defined(CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE_LIMIT)
#if (CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE + CBOR_AND_OTHER_HDR) > CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE
#warning CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE too big, rounding it down.
#else
#define FS_MGMT_DL_CHUNK_SIZE (CONFIG_FS_MGMT_DL_CHUNK_SIZE)
#define MCUMGR_GRP_FS_DL_CHUNK_SIZE (CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE)
#endif
#endif
#if !defined(FS_MGMT_DL_CHUNK_SIZE)
#define FS_MGMT_DL_CHUNK_SIZE (CONFIG_MCUMGR_BUF_SIZE - CBOR_AND_OTHER_HDR)
#if !defined(MCUMGR_GRP_FS_DL_CHUNK_SIZE)
#define MCUMGR_GRP_FS_DL_CHUNK_SIZE (CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE - CBOR_AND_OTHER_HDR)
#endif
#endif

View file

@ -25,11 +25,11 @@
#include <mgmt/mcumgr/util/zcbor_bulk.h>
#include <mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_config.h>
#if defined(CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32)
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32)
#include <mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_hash_checksum_crc32.h>
#endif
#if defined(CONFIG_FS_MGMT_HASH_SHA256)
#if defined(CONFIG_MCUMGR_GRP_FS_HASH_SHA256)
#include <mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_hash_checksum_sha256.h>
#endif
@ -37,21 +37,21 @@
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
#endif
#ifdef CONFIG_FS_MGMT_CHECKSUM_HASH
#ifdef CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH
/* Define default hash/checksum */
#if defined(CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32)
#define FS_MGMT_CHECKSUM_HASH_DEFAULT "crc32"
#elif defined(CONFIG_FS_MGMT_HASH_SHA256)
#define FS_MGMT_CHECKSUM_HASH_DEFAULT "sha256"
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32)
#define MCUMGR_GRP_FS_CHECKSUM_HASH_DEFAULT "crc32"
#elif defined(CONFIG_MCUMGR_GRP_FS_HASH_SHA256)
#define MCUMGR_GRP_FS_CHECKSUM_HASH_DEFAULT "sha256"
#else
#error "Missing mcumgr fs checksum/hash algorithm selection?"
#endif
/* Define largest hach/checksum output size (bytes) */
#if defined(CONFIG_FS_MGMT_HASH_SHA256)
#define FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE 32
#elif defined(CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32)
#define FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE 4
#if defined(CONFIG_MCUMGR_GRP_FS_HASH_SHA256)
#define MCUMGR_GRP_FS_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE 32
#elif defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32)
#define MCUMGR_GRP_FS_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE 4
#endif
#endif
@ -76,7 +76,7 @@ static struct {
static const struct mgmt_handler fs_mgmt_handlers[];
#if defined(CONFIG_FS_MGMT_CHECKSUM_HASH)
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH)
/* Hash/checksum iterator information passing structure */
struct fs_mgmt_hash_checksum_iterator_info {
zcbor_state_t *zse;
@ -164,8 +164,8 @@ done:
*/
static int fs_mgmt_file_download(struct smp_streamer *ctxt)
{
uint8_t file_data[FS_MGMT_DL_CHUNK_SIZE];
char path[CONFIG_FS_MGMT_PATH_SIZE + 1];
uint8_t file_data[MCUMGR_GRP_FS_DL_CHUNK_SIZE];
char path[CONFIG_MCUMGR_GRP_FS_PATH_LEN + 1];
uint64_t off = ULLONG_MAX;
size_t bytes_read = 0;
size_t file_len;
@ -219,7 +219,7 @@ static int fs_mgmt_file_download(struct smp_streamer *ctxt)
}
/* Read the requested chunk from the file. */
rc = fs_mgmt_read(path, off, FS_MGMT_DL_CHUNK_SIZE, file_data, &bytes_read);
rc = fs_mgmt_read(path, off, MCUMGR_GRP_FS_DL_CHUNK_SIZE, file_data, &bytes_read);
if (rc != 0) {
return rc;
}
@ -302,7 +302,7 @@ done:
*/
static int fs_mgmt_file_upload(struct smp_streamer *ctxt)
{
char file_name[CONFIG_FS_MGMT_PATH_SIZE + 1];
char file_name[CONFIG_MCUMGR_GRP_FS_PATH_LEN + 1];
unsigned long long len = ULLONG_MAX;
unsigned long long off = ULLONG_MAX;
size_t new_off;
@ -394,13 +394,13 @@ static int fs_mgmt_file_upload(struct smp_streamer *ctxt)
MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE;
}
#if defined(CONFIG_FS_MGMT_FILE_STATUS)
#if defined(CONFIG_MCUMGR_GRP_FS_FILE_STATUS)
/**
* Command handler: fs stat (read)
*/
static int fs_mgmt_file_status(struct smp_streamer *ctxt)
{
char path[CONFIG_FS_MGMT_PATH_SIZE + 1];
char path[CONFIG_MCUMGR_GRP_FS_PATH_LEN + 1];
size_t file_len;
int rc;
zcbor_state_t *zse = ctxt->writer->zs;
@ -448,15 +448,15 @@ static int fs_mgmt_file_status(struct smp_streamer *ctxt)
}
#endif
#if defined(CONFIG_FS_MGMT_CHECKSUM_HASH)
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH)
/**
* Command handler: fs hash/checksum (read)
*/
static int fs_mgmt_file_hash_checksum(struct smp_streamer *ctxt)
{
char path[CONFIG_FS_MGMT_PATH_SIZE + 1];
char type_arr[HASH_CHECKSUM_TYPE_SIZE + 1] = FS_MGMT_CHECKSUM_HASH_DEFAULT;
char output[FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE];
char path[CONFIG_MCUMGR_GRP_FS_PATH_LEN + 1];
char type_arr[HASH_CHECKSUM_TYPE_SIZE + 1] = MCUMGR_GRP_FS_CHECKSUM_HASH_DEFAULT;
char output[MCUMGR_GRP_FS_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE];
uint64_t len = ULLONG_MAX;
uint64_t off = 0;
size_t file_len;
@ -563,13 +563,13 @@ static int fs_mgmt_file_hash_checksum(struct smp_streamer *ctxt)
if (group->output_size == sizeof(uint8_t)) {
tmp_val = (uint64_t)(*(uint8_t *)output);
#if FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE > 1
#if MCUMGR_GRP_FS_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE > 1
} else if (group->output_size == sizeof(uint16_t)) {
tmp_val = (uint64_t)(*(uint16_t *)output);
#if FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE > 2
#if MCUMGR_GRP_FS_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE > 2
} else if (group->output_size == sizeof(uint32_t)) {
tmp_val = (uint64_t)(*(uint32_t *)output);
#if FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE > 4
#if MCUMGR_GRP_FS_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE > 4
} else if (group->output_size == sizeof(uint64_t)) {
tmp_val = (*(uint64_t *)output);
#endif
@ -646,13 +646,13 @@ static const struct mgmt_handler fs_mgmt_handlers[] = {
.mh_read = fs_mgmt_file_download,
.mh_write = fs_mgmt_file_upload,
},
#if defined(CONFIG_FS_MGMT_FILE_STATUS)
#if defined(CONFIG_MCUMGR_GRP_FS_FILE_STATUS)
[FS_MGMT_ID_STAT] = {
.mh_read = fs_mgmt_file_status,
.mh_write = NULL,
},
#endif
#if defined(CONFIG_FS_MGMT_CHECKSUM_HASH)
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH)
[FS_MGMT_ID_HASH_CHECKSUM] = {
.mh_read = fs_mgmt_file_hash_checksum,
.mh_write = NULL,
@ -678,13 +678,13 @@ static void fs_mgmt_register_group(void)
{
mgmt_register_group(&fs_mgmt_group);
#if defined(CONFIG_FS_MGMT_CHECKSUM_HASH)
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH)
/* Register any supported hash or checksum functions */
#if defined(CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32)
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32)
fs_mgmt_hash_checksum_register_crc32();
#endif
#if defined(CONFIG_FS_MGMT_HASH_SHA256)
#if defined(CONFIG_MCUMGR_GRP_FS_HASH_SHA256)
fs_mgmt_hash_checksum_register_sha256();
#endif
#endif

View file

@ -20,9 +20,9 @@ static int fs_mgmt_hash_checksum_crc32(struct fs_file_t *file, uint8_t *output,
size_t *out_len, size_t len)
{
/* Calculate IEEE CRC32 checksum of target file */
uint8_t buffer[CONFIG_FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE];
uint8_t buffer[CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_CHUNK_SIZE];
ssize_t bytes_read = 0;
size_t read_size = CONFIG_FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE;
size_t read_size = CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_CHUNK_SIZE;
uint32_t crc32 = 0;
/* Clear length prior to calculation */

View file

@ -30,8 +30,8 @@ static int fs_mgmt_hash_checksum_sha256(struct fs_file_t *file, uint8_t *output,
{
int rc = 0;
ssize_t bytes_read = 0;
size_t read_size = CONFIG_FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE;
uint8_t buffer[CONFIG_FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE];
size_t read_size = CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_CHUNK_SIZE;
uint8_t buffer[CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_CHUNK_SIZE];
struct tc_sha256_state_struct sha;
/* Clear variables prior to calculation */
@ -77,8 +77,8 @@ static int fs_mgmt_hash_checksum_sha256(struct fs_file_t *file, uint8_t *output,
{
int rc = 0;
ssize_t bytes_read = 0;
size_t read_size = CONFIG_FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE;
uint8_t buffer[CONFIG_FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE];
size_t read_size = CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_CHUNK_SIZE;
uint8_t buffer[CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_CHUNK_SIZE];
mbedtls_md_context_t mbed_hash_ctx;
const mbedtls_md_info_t *mbed_hash_info;

View file

@ -2,23 +2,23 @@
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_CMD_IMG_MGMT
menuconfig MCUMGR_GRP_IMG
bool "Mcumgr handlers for image management"
select FLASH
select MPU_ALLOW_FLASH_WRITE if ARM_MPU
select IMG_MANAGER
select MGMT_MIN_DECODING_LEVEL_2
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
help
Enables mcumgr handlers for image management
if MCUMGR_CMD_IMG_MGMT
if MCUMGR_GRP_IMG
if HEAP_MEM_POOL_SIZE > 0
config IMG_MGMT_USE_HEAP_FOR_FLASH_IMG_CONTEXT
config MCUMGR_GRP_IMG_USE_HEAP_FOR_FLASH_IMG_CONTEXT
bool "Use heap mem pool for flash image DFU context"
help
Use heap to allocate flash image upload context, otherwise a static variable will
be used. The context object is used by IMG_MANAGER to buffer image writes
be used. The context object is used by MCUMGR_GRP_IMG_MANAGER to buffer image writes
and has significant size, mainly affected by image write buffer of
the CONFIG_IMG_BLOCK_BUF_SIZE size and additional fields that hold the state information
(struct flash_img_context).
@ -29,32 +29,32 @@ config IMG_MGMT_USE_HEAP_FOR_FLASH_IMG_CONTEXT
operation, an issue that should also be addressed within application.
endif
config IMG_MGMT_UPDATABLE_IMAGE_NUMBER
config MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER
int "Number of supported images"
default UPDATEABLE_IMAGE_NUMBER
range 1 2
help
Sets how many application images are supported (pairs of secondary and primary slots).
Setting this to 2 requires MCUMGR_BUF_SIZE to be at least 512b.
Setting this to 2 requires MCUMGR_TRANSPORT_NETBUF_SIZE to be at least 512b.
NOTE: The UPDATEABLE_IMAGE_NUMBER of MCUBOOT configuration, even for Zephyr build,
needs to be set to the same value; this is due to the fact that the mcumgr uses
boot_util and the UPDATEABLE_IMAGE_NUMBER controls number of images supported
by that library.
config IMG_MGMT_VERBOSE_ERR
config MCUMGR_GRP_IMG_VERBOSE_ERR
bool "Verbose error responses when uploading application image"
select MGMT_VERBOSE_ERR_RESPONSE
select MCUMGR_SMP_VERBOSE_ERR_RESPONSE
help
Add additional "rsn" key to SMP responses, where provided, explaining
non-0 "rc" codes.
config IMG_MGMT_DUMMY_HDR
config MCUMGR_GRP_IMG_DUMMY_HDR
bool "Return dummy image header data for imgr functions"
help
Returns dummy image header data for imgr functions,
useful when there are no images present, Eg: unit tests.
config IMG_MGMT_DIRECT_IMAGE_UPLOAD
config MCUMGR_GRP_IMG_DIRECT_UPLOAD
bool "Allow direct image upload"
help
Enables directly uploading image to selected image partition.
@ -66,7 +66,7 @@ config IMG_MGMT_DIRECT_IMAGE_UPLOAD
behaviour is, when image is not selected, to upload to image that represents secondary
slot in normal operation.
config IMG_MGMT_REJECT_DIRECT_XIP_MISMATCHED_SLOT
config MCUMGR_GRP_IMG_REJECT_DIRECT_XIP_MISMATCHED_SLOT
bool "Reject Direct-XIP applications with mismatched address"
help
When enabled, the mcumgr will compare base address of application,
@ -76,7 +76,7 @@ config IMG_MGMT_REJECT_DIRECT_XIP_MISMATCHED_SLOT
The base address can be set, to an image binary header, with imgtool,
using the --rom-fixed command line option.
config IMG_MGMT_FRUGAL_LIST
config MCUMGR_GRP_IMG_FRUGAL_LIST
bool "Omit zero, empty or false values from status list"
help
The status list send back from the device will only be filled with data that is non-zero,
@ -100,7 +100,7 @@ config MCUMGR_GRP_IMG_STATUS_HOOKS
uploads. Note that these are status checking only, to allow inspecting of a file upload
or prevent it, CONFIG_MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK must be used.
module = MCUMGR_IMG_MGMT
module = MCUMGR_GRP_IMG
module-str = mcumgr_img_mgmt
source "subsys/logging/Kconfig.template.log_config"

View file

@ -35,11 +35,11 @@
#endif
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(mcumgr_img_mgmt, CONFIG_MCUMGR_IMG_MGMT_LOG_LEVEL);
LOG_MODULE_DECLARE(mcumgr_img_mgmt, CONFIG_MCUMGR_GRP_IMG_LOG_LEVEL);
struct img_mgmt_state g_img_mgmt_state;
#ifdef CONFIG_IMG_MGMT_VERBOSE_ERR
#ifdef CONFIG_MCUMGR_GRP_IMG_VERBOSE_ERR
const char *img_mgmt_err_str_app_reject = "app reject";
const char *img_mgmt_err_str_hdr_malformed = "header malformed";
const char *img_mgmt_err_str_magic_mismatch = "magic mismatch";
@ -86,7 +86,7 @@ img_mgmt_read_info(int image_slot, struct image_version *ver, uint8_t *hash,
uint32_t *flags)
{
#ifdef CONFIG_IMG_MGMT_DUMMY_HDR
#ifdef CONFIG_MCUMGR_GRP_IMG_DUMMY_HDR
uint8_t dummy_hash[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x00, 0x11, 0x22,
0x33, 0x44, 0x55, 0x66, 0x77};
@ -217,7 +217,7 @@ img_mgmt_find_by_ver(struct image_version *find, uint8_t *hash)
int i;
struct image_version ver;
for (i = 0; i < 2 * CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER; i++) {
for (i = 0; i < 2 * CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER; i++) {
if (img_mgmt_read_info(i, &ver, hash, NULL) != 0) {
continue;
}
@ -238,7 +238,7 @@ img_mgmt_find_by_hash(uint8_t *find, struct image_version *ver)
int i;
uint8_t hash[IMAGE_HASH_LEN];
for (i = 0; i < 2 * CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER; i++) {
for (i = 0; i < 2 * CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER; i++) {
if (img_mgmt_read_info(i, ver, hash, NULL) != 0) {
continue;
}

View file

@ -37,7 +37,7 @@
*/
#define MAX_IMG_CHARACTERISTICS 15
#ifndef CONFIG_IMG_MGMT_FRUGAL_LIST
#ifndef CONFIG_MCUMGR_GRP_IMG_FRUGAL_LIST
#define ZCBOR_ENCODE_FLAG(zse, label, value) \
(zcbor_tstr_put_lit(zse, label) && zcbor_bool_put(zse, value))
#else
@ -216,9 +216,9 @@ img_mgmt_state_read(struct smp_streamer *ctxt)
struct zcbor_string zhash = { .value = hash, .len = IMAGE_HASH_LEN };
ok = zcbor_tstr_put_lit(zse, "images") &&
zcbor_list_start_encode(zse, 2 * CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER);
zcbor_list_start_encode(zse, 2 * CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER);
for (i = 0; ok && i < 2 * CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER; i++) {
for (i = 0; ok && i < 2 * CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER; i++) {
int rc = img_mgmt_read_info(i, &ver, hash, &flags);
if (rc != 0) {
continue;
@ -227,7 +227,7 @@ img_mgmt_state_read(struct smp_streamer *ctxt)
state_flags = img_mgmt_state_flags(i);
ok = zcbor_map_start_encode(zse, MAX_IMG_CHARACTERISTICS) &&
(CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 1 ||
(CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 1 ||
(zcbor_tstr_put_lit(zse, "image") &&
zcbor_int32_put(zse, i >> 1))) &&
zcbor_tstr_put_lit(zse, "slot") &&
@ -257,9 +257,9 @@ img_mgmt_state_read(struct smp_streamer *ctxt)
zcbor_map_end_encode(zse, MAX_IMG_CHARACTERISTICS);
}
ok = ok && zcbor_list_end_encode(zse, 2 * CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER);
ok = ok && zcbor_list_end_encode(zse, 2 * CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER);
/* splitStatus is always 0 so in frugal list it is not present at all */
if (!IS_ENABLED(CONFIG_IMG_MGMT_FRUGAL_LIST) && ok) {
if (!IS_ENABLED(CONFIG_MCUMGR_GRP_IMG_FRUGAL_LIST) && ok) {
ok = zcbor_tstr_put_lit(zse, "splitStatus") &&
zcbor_int32_put(zse, 0);
}

View file

@ -5,7 +5,7 @@
*/
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(mcumgr_img_mgmt, CONFIG_MCUMGR_IMG_MGMT_LOG_LEVEL);
LOG_MODULE_REGISTER(mcumgr_img_mgmt, CONFIG_MCUMGR_GRP_IMG_LOG_LEVEL);
#include <zephyr/kernel.h>
#include <zephyr/init.h>
@ -28,8 +28,8 @@ LOG_MODULE_REGISTER(mcumgr_img_mgmt, CONFIG_MCUMGR_IMG_MGMT_LOG_LEVEL);
#define SLOT2_PARTITION slot2_partition
#define SLOT3_PARTITION slot3_partition
BUILD_ASSERT(CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 1 ||
(CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 2 &&
BUILD_ASSERT(CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 1 ||
(CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 2 &&
FIXED_PARTITION_EXISTS(SLOT2_PARTITION) &&
FIXED_PARTITION_EXISTS(SLOT3_PARTITION)),
"Missing partitions?");
@ -161,12 +161,12 @@ img_mgmt_flash_area_id(int slot)
return fa_id;
}
#if CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 1
#if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 1
/**
* In normal operation this function will select between first two slot
* (in reality it just checks whether second slot can be used), ignoring the
* slot parameter.
* When CONFIG_IMG_MGMT_DIRECT_IMAGE_UPLOAD is defined it will check if given
* When CONFIG_MCUMGR_GRP_IMG_DIRECT_UPLOAD is defined it will check if given
* slot is available, and allowed, for DFU; providing 0 as a parameter means
* find any unused and non-active available (auto-select); any other positive
* value is direct (slot + 1) to be used; if checks are positive, then area
@ -176,7 +176,7 @@ img_mgmt_flash_area_id(int slot)
static int
img_mgmt_get_unused_slot_area_id(int slot)
{
#if defined(CONFIG_IMG_MGMT_DIRECT_IMAGE_UPLOAD)
#if defined(CONFIG_MCUMGR_GRP_IMG_DIRECT_UPLOAD)
slot--;
if (slot < -1) {
return -1;
@ -197,7 +197,7 @@ img_mgmt_get_unused_slot_area_id(int slot)
}
}
return -1;
#if defined(CONFIG_IMG_MGMT_DIRECT_IMAGE_UPLOAD)
#if defined(CONFIG_MCUMGR_GRP_IMG_DIRECT_UPLOAD)
}
/*
* Direct selection; the first two slots are checked for being available
@ -212,7 +212,7 @@ img_mgmt_get_unused_slot_area_id(int slot)
#endif
}
#elif CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 2
#elif CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 2
static int
img_mgmt_get_unused_slot_area_id(int image)
{
@ -291,7 +291,7 @@ img_mgmt_write_pending(int slot, bool permanent)
{
int rc;
if (slot != 1 && !(CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 2 && slot == 3)) {
if (slot != 1 && !(CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 2 && slot == 3)) {
return MGMT_ERR_EINVAL;
}
@ -342,7 +342,7 @@ img_mgmt_read(int slot, unsigned int offset, void *dst, unsigned int num_bytes)
return 0;
}
#if defined(CONFIG_IMG_MGMT_USE_HEAP_FOR_FLASH_IMG_CONTEXT)
#if defined(CONFIG_MCUMGR_GRP_IMG_USE_HEAP_FOR_FLASH_IMG_CONTEXT)
int
img_mgmt_write_image_data(unsigned int offset, const void *data, unsigned int num_bytes, bool last)
{
@ -586,7 +586,7 @@ img_mgmt_upload_inspect(const struct img_mgmt_upload_req *req,
return MGMT_ERR_ENOENT;
}
#if defined(CONFIG_IMG_MGMT_REJECT_DIRECT_XIP_MISMATCHED_SLOT)
#if defined(CONFIG_MCUMGR_GRP_IMG_REJECT_DIRECT_XIP_MISMATCHED_SLOT)
if (hdr->ih_flags & IMAGE_F_ROM_FIXED_ADDR) {
rc = flash_area_open(action->area_id, &fa);
if (rc) {

View file

@ -2,15 +2,15 @@
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_CMD_OS_MGMT
menuconfig MCUMGR_GRP_OS
bool "Mcumgr handlers for OS management"
select REBOOT
help
Enables mcumgr handlers for OS management
if MCUMGR_CMD_OS_MGMT
if MCUMGR_GRP_OS
config OS_MGMT_RESET_MS
config MCUMGR_GRP_OS_RESET_MS
int "Delay before executing reset command (ms)"
default 250
depends on REBOOT
@ -19,7 +19,7 @@ config OS_MGMT_RESET_MS
before performing the reset. This delay allows time for the mcumgr
response to be delivered.
config MCUMGR_GRP_OS_OS_RESET_HOOK
config MCUMGR_GRP_OS_RESET_HOOK
bool "Reset hook"
depends on REBOOT
depends on MCUMGR_MGMT_NOTIFICATION_HOOKS
@ -32,13 +32,13 @@ config MCUMGR_GRP_OS_OS_RESET_HOOK
and will allow the application to perform any required operations
before accepting or declining the reset request.
config OS_MGMT_TASKSTAT
config MCUMGR_GRP_OS_TASKSTAT
bool "Support for taskstat command"
depends on THREAD_MONITOR
if OS_MGMT_TASKSTAT
if MCUMGR_GRP_OS_TASKSTAT
config OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS
config MCUMGR_GRP_OS_TASKSTAT_ONLY_SUPPORTED_STATS
bool "Send only data gathered by Zephyr"
default y
help
@ -48,27 +48,27 @@ config OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS
map entries for each listed task.
Enabling this option will slightly reduce code size.
choice OS_MGMT_TASKSTAT_THREAD_NAME_CHOICE
choice MCUMGR_GRP_OS_TASKSTAT_THREAD_NAME_CHOICE
prompt "Characteristic used as thread name in taskstat"
default OS_MGMT_TASKSTAT_USE_THREAD_NAME_FOR_NAME if THREAD_NAME
default OS_MGMT_TASKSTAT_USE_THREAD_PRIO_FOR_NAME
default MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_NAME_FOR_NAME if THREAD_NAME
default MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_PRIO_FOR_NAME
help
Select what will serve as thread name in "taskstat" response.
By default taskstat responses use thread priority, when THREAD_NAME is disabled,
config OS_MGMT_TASKSTAT_USE_THREAD_NAME_FOR_NAME
config MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_NAME_FOR_NAME
bool "Thread name"
depends on THREAD_NAME
config OS_MGMT_TASKSTAT_USE_THREAD_IDX_FOR_NAME
config MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_IDX_FOR_NAME
bool "Thread index"
config OS_MGMT_TASKSTAT_USE_THREAD_PRIO_FOR_NAME
config MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_PRIO_FOR_NAME
bool "Thread priority"
endchoice
config OS_MGMT_TASKSTAT_MAX_NUM_THREADS
config MCUMGR_GRP_OS_TASKSTAT_MAX_NUM_THREADS
int "Predicted maximum number of threads to return on taskstat list"
default 50
help
@ -76,7 +76,7 @@ config OS_MGMT_TASKSTAT_MAX_NUM_THREADS
The value does not affect memory allocation, it is used by zcbor
to figure out how to encode map depending on its predicted size.
config OS_MGMT_TASKSTAT_THREAD_NAME_LEN
config MCUMGR_GRP_OS_TASKSTAT_THREAD_NAME_LEN
int "Length of thread name to return in response"
default THREAD_MAX_NAME_LEN if THREAD_NAME
default 5 if !THREAD_NAME
@ -91,7 +91,7 @@ config OS_MGMT_TASKSTAT_THREAD_NAME_LEN
in such case this value should also take into account possible '-'
sign.
config OS_MGMT_TASKSTAT_SIGNED_PRIORITY
config MCUMGR_GRP_OS_TASKSTAT_SIGNED_PRIORITY
bool "Signed priorities"
default y
help
@ -101,7 +101,7 @@ config OS_MGMT_TASKSTAT_SIGNED_PRIORITY
Disable this option if your client software is unable to properly decode and
accept signed integers as priorities.
config OS_MGMT_TASKSTAT_STACK_INFO
config MCUMGR_GRP_OS_TASKSTAT_STACK_INFO
bool "Include stack info in taskstat responses"
depends on THREAD_STACK_INFO
help
@ -115,12 +115,12 @@ config OS_MGMT_TASKSTAT_STACK_INFO
endif
config OS_MGMT_ECHO
config MCUMGR_GRP_OS_ECHO
bool "Support for echo command"
default y
select MGMT_MIN_DECODING_LEVEL_2
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
config OS_MGMT_MCUMGR_PARAMS
config MCUMGR_GRP_OS_MCUMGR_PARAMS
bool "MCUMGR Parameters retrieval command"
config MCUMGR_GRP_OS_INFO

View file

@ -58,7 +58,7 @@ static K_TIMER_DEFINE(os_mgmt_reset_timer, os_mgmt_reset_cb, NULL);
*/
#define TASKSTAT_COLUMNS_MAX 20
#ifdef CONFIG_OS_MGMT_TASKSTAT
#ifdef CONFIG_MCUMGR_GRP_OS_TASKSTAT
/* Thread iterator information passing structure */
struct thread_iterator_info {
zcbor_state_t *zse;
@ -83,7 +83,7 @@ extern uint8_t *MCUMGR_GRP_OS_INFO_BUILD_DATE_TIME;
/**
* Command handler: os echo
*/
#ifdef CONFIG_OS_MGMT_ECHO
#ifdef CONFIG_MCUMGR_GRP_OS_ECHO
static int os_mgmt_echo(struct smp_streamer *ctxt)
{
struct zcbor_string value = { 0 };
@ -120,9 +120,9 @@ static int os_mgmt_echo(struct smp_streamer *ctxt)
}
#endif
#ifdef CONFIG_OS_MGMT_TASKSTAT
#ifdef CONFIG_MCUMGR_GRP_OS_TASKSTAT
#ifdef CONFIG_OS_MGMT_TASKSTAT_USE_THREAD_NAME_FOR_NAME
#ifdef CONFIG_MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_NAME_FOR_NAME
static inline bool
os_mgmt_taskstat_encode_thread_name(zcbor_state_t *zse, int idx,
const struct k_thread *thread)
@ -131,8 +131,8 @@ os_mgmt_taskstat_encode_thread_name(zcbor_state_t *zse, int idx,
ARG_UNUSED(idx);
if (name_len > CONFIG_OS_MGMT_TASKSTAT_THREAD_NAME_LEN) {
name_len = CONFIG_OS_MGMT_TASKSTAT_THREAD_NAME_LEN;
if (name_len > CONFIG_MCUMGR_GRP_OS_TASKSTAT_THREAD_NAME_LEN) {
name_len = CONFIG_MCUMGR_GRP_OS_TASKSTAT_THREAD_NAME_LEN;
}
return zcbor_tstr_encode_ptr(zse, thread->name, name_len);
@ -143,11 +143,11 @@ static inline bool
os_mgmt_taskstat_encode_thread_name(zcbor_state_t *zse, int idx,
const struct k_thread *thread)
{
char thread_name[CONFIG_OS_MGMT_TASKSTAT_THREAD_NAME_LEN + 1];
char thread_name[CONFIG_MCUMGR_GRP_OS_TASKSTAT_THREAD_NAME_LEN + 1];
#if defined(CONFIG_OS_MGMT_TASKSTAT_USE_THREAD_PRIO_FOR_NAME)
#if defined(CONFIG_MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_PRIO_FOR_NAME)
idx = (int)thread->base.prio;
#elif defined(CONFIG_OS_MGMT_TASKSTAT_USE_THREAD_IDX_FOR_NAME)
#elif defined(CONFIG_MCUMGR_GRP_OS_TASKSTAT_USE_THREAD_IDX_FOR_NAME)
ARG_UNUSED(thread);
#else
#error Unsupported option for taskstat thread name
@ -165,7 +165,7 @@ static inline bool
os_mgmt_taskstat_encode_stack_info(zcbor_state_t *zse,
const struct k_thread *thread)
{
#ifdef CONFIG_OS_MGMT_TASKSTAT_STACK_INFO
#ifdef CONFIG_MCUMGR_GRP_OS_TASKSTAT_STACK_INFO
size_t stack_size = 0;
size_t stack_used = 0;
bool ok = true;
@ -189,7 +189,7 @@ os_mgmt_taskstat_encode_stack_info(zcbor_state_t *zse,
return ok;
#else
return true;
#endif /* CONFIG_OS_MGMT_TASKSTAT_STACK_INFO */
#endif /* CONFIG_MCUMGR_GRP_OS_TASKSTAT_STACK_INFO */
}
static inline bool
@ -205,7 +205,7 @@ os_mgmt_taskstat_encode_runtime_info(zcbor_state_t *zse,
ok = zcbor_tstr_put_lit(zse, "runtime") &&
zcbor_uint64_put(zse, thread_stats.execution_cycles);
#elif !defined(CONFIG_OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS)
#elif !defined(CONFIG_MCUMGR_GRP_OS_TASKSTAT_ONLY_SUPPORTED_STATS)
ok = zcbor_tstr_put_lit(zse, "runtime") &&
zcbor_uint32_put(zse, 0);
#endif
@ -217,7 +217,7 @@ static inline bool os_mgmt_taskstat_encode_unsupported(zcbor_state_t *zse)
{
bool ok = true;
if (!IS_ENABLED(CONFIG_OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS)) {
if (!IS_ENABLED(CONFIG_MCUMGR_GRP_OS_TASKSTAT_ONLY_SUPPORTED_STATS)) {
ok = zcbor_tstr_put_lit(zse, "cswcnt") &&
zcbor_uint32_put(zse, 0) &&
zcbor_tstr_put_lit(zse, "last_checkin") &&
@ -235,7 +235,7 @@ static inline bool
os_mgmt_taskstat_encode_priority(zcbor_state_t *zse, const struct k_thread *thread)
{
return (zcbor_tstr_put_lit(zse, "prio") &&
IS_ENABLED(CONFIG_OS_MGMT_TASKSTAT_SIGNED_PRIORITY) ?
IS_ENABLED(CONFIG_MCUMGR_GRP_OS_TASKSTAT_SIGNED_PRIORITY) ?
zcbor_int32_put(zse, (int)thread->base.prio) :
zcbor_uint32_put(zse, (unsigned int)thread->base.prio) & 0xff);
}
@ -283,19 +283,19 @@ static int os_mgmt_taskstat_read(struct smp_streamer *ctxt)
};
zcbor_tstr_put_lit(zse, "tasks");
zcbor_map_start_encode(zse, CONFIG_OS_MGMT_TASKSTAT_MAX_NUM_THREADS);
zcbor_map_start_encode(zse, CONFIG_MCUMGR_GRP_OS_TASKSTAT_MAX_NUM_THREADS);
/* Iterate the list of tasks, encoding each. */
k_thread_foreach(os_mgmt_taskstat_encode_one, (void *)&iterator_ctx);
if (!iterator_ctx.ok ||
!zcbor_map_end_encode(zse, CONFIG_OS_MGMT_TASKSTAT_MAX_NUM_THREADS)) {
!zcbor_map_end_encode(zse, CONFIG_MCUMGR_GRP_OS_TASKSTAT_MAX_NUM_THREADS)) {
return MGMT_ERR_EMSGSIZE;
}
return 0;
}
#endif /* CONFIG_OS_MGMT_TASKSTAT */
#endif /* CONFIG_MCUMGR_GRP_OS_TASKSTAT */
#ifdef CONFIG_REBOOT
/**
@ -314,7 +314,7 @@ static void os_mgmt_reset_cb(struct k_timer *timer)
static int os_mgmt_reset(struct smp_streamer *ctxt)
{
#if defined(CONFIG_MCUMGR_GRP_OS_OS_RESET_HOOK)
#if defined(CONFIG_MCUMGR_GRP_OS_RESET_HOOK)
int rc = mgmt_callback_notify(MGMT_EVT_OP_OS_MGMT_RESET, NULL, 0);
if (rc != MGMT_ERR_EOK) {
@ -322,13 +322,13 @@ static int os_mgmt_reset(struct smp_streamer *ctxt)
}
#endif
k_timer_start(&os_mgmt_reset_timer, K_MSEC(CONFIG_OS_MGMT_RESET_MS),
k_timer_start(&os_mgmt_reset_timer, K_MSEC(CONFIG_MCUMGR_GRP_OS_RESET_MS),
K_NO_WAIT);
return 0;
}
#endif
#ifdef CONFIG_OS_MGMT_MCUMGR_PARAMS
#ifdef CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS
static int
os_mgmt_mcumgr_params(struct smp_streamer *ctxt)
{
@ -336,9 +336,9 @@ os_mgmt_mcumgr_params(struct smp_streamer *ctxt)
bool ok;
ok = zcbor_tstr_put_lit(zse, "buf_size") &&
zcbor_uint32_put(zse, CONFIG_MCUMGR_BUF_SIZE) &&
zcbor_uint32_put(zse, CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE) &&
zcbor_tstr_put_lit(zse, "buf_count") &&
zcbor_uint32_put(zse, CONFIG_MCUMGR_BUF_COUNT);
zcbor_uint32_put(zse, CONFIG_MCUMGR_TRANSPORT_NETBUF_COUNT);
return ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE;
}
@ -641,12 +641,12 @@ fail:
#endif
static const struct mgmt_handler os_mgmt_group_handlers[] = {
#ifdef CONFIG_OS_MGMT_ECHO
#ifdef CONFIG_MCUMGR_GRP_OS_ECHO
[OS_MGMT_ID_ECHO] = {
os_mgmt_echo, os_mgmt_echo
},
#endif
#ifdef CONFIG_OS_MGMT_TASKSTAT
#ifdef CONFIG_MCUMGR_GRP_OS_TASKSTAT
[OS_MGMT_ID_TASKSTAT] = {
os_mgmt_taskstat_read, NULL
},
@ -656,7 +656,7 @@ static const struct mgmt_handler os_mgmt_group_handlers[] = {
NULL, os_mgmt_reset
},
#endif
#ifdef CONFIG_OS_MGMT_MCUMGR_PARAMS
#ifdef CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS
[OS_MGMT_ID_MCUMGR_PARAMS] = {
os_mgmt_mcumgr_params, NULL
},

View file

@ -2,11 +2,11 @@
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_CMD_SHELL_MGMT
menuconfig MCUMGR_GRP_SHELL
bool "Mcumgr handlers for shell management"
depends on SHELL
select SHELL_BACKEND_DUMMY
select MGMT_MIN_DECODING_LEVEL_2
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
help
Enables mcumgr handlers for shell management. The handler will utilize
the dummy backend to execute shell commands and capture the output to
@ -14,23 +14,23 @@ menuconfig MCUMGR_CMD_SHELL_MGMT
physical interfaces outside of the scope of the user.
It is possible to use additional shell backends in coordination
with this handler and they will not interfere.
The SHELL_BACKEND_DUMMY_BUF_SIZE will affect how many characters
The MCUMGR_GRP_SHELL_BACKEND_DUMMY_BUF_SIZE will affect how many characters
will be returned from command output, if your output gets cut, then
increase the value. Remember to set MCUMGR_BUF_SIZE accordingly.
increase the value. Remember to set MCUMGR_TRANSPORT_NETBUF_SIZE accordingly.
Note that maximum length of shell command accepted is regulated by
the CONFIG_SHELL_CMD_BUFF_SIZE, and a buffer for a command is allocated
on a stack, by the mcumgr, so enabling MCUMGR_CMD_SHELL_MGMT and
on a stack, by the mcumgr, so enabling MCUMGR_GRP_SHELL and
changes to the CONFIG_SHELL_CMD_BUFF_SIZE may increase stack size
requirements.
if MCUMGR_CMD_SHELL_MGMT
if MCUMGR_GRP_SHELL
# Show dummy shell buffer size here, will show help text of original prompt so
# nothing extra is needed here, nor a default value.
config SHELL_BACKEND_DUMMY_BUF_SIZE
int "Shell output buffer size (Size of dummy buffer size)"
config MCUMGR_CMD_SHELL_MGMT_LEGACY_RC_RETURN_CODE
config MCUMGR_GRP_SHELL_LEGACY_RC_RETURN_CODE
bool "Legacy behaviour: Use rc field for shell function return code"
help
Enabling this options brings back legacy behaviour where the shell
@ -40,4 +40,4 @@ config MCUMGR_CMD_SHELL_MGMT_LEGACY_RC_RETURN_CODE
shell command exit code, and rc will be used for SMP processing
error codes.
endif # MCUMGR_CMD_SHELL_MGMT
endif # MCUMGR_GRP_SHELL

View file

@ -111,7 +111,7 @@ shell_mgmt_exec(struct smp_streamer *ctxt)
/* Key="ret"; value=<status>, or rc if legacy option enabled */
ok = zcbor_tstr_put_lit(zse, "o") &&
zcbor_tstr_encode(zse, &cmd_out) &&
#ifdef CONFIG_MCUMGR_CMD_SHELL_MGMT_LEGACY_RC_RETURN_CODE
#ifdef CONFIG_MCUMGR_GRP_SHELL_LEGACY_RC_RETURN_CODE
zcbor_tstr_put_lit(zse, "rc") &&
#else
zcbor_tstr_put_lit(zse, "ret") &&

View file

@ -2,17 +2,17 @@
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_CMD_STAT_MGMT
menuconfig MCUMGR_GRP_STAT
bool "Mcumgr handlers for statistics management"
depends on STATS
select MGMT_MIN_DECODING_LEVEL_2
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
help
Enables mcumgr handlers for statistics management.
config STAT_MGMT_MAX_NAME_LEN
config MCUMGR_GRP_STAT_MAX_NAME_LEN
int "Maximum stat group name length"
default 32
depends on MCUMGR_CMD_STAT_MGMT
depends on MCUMGR_GRP_STAT
help
Limits the maximum stat group name length in mcumgr requests, in bytes.
A buffer of this size gets allocated on the stack during handling of all

View file

@ -119,7 +119,7 @@ stat_mgmt_show(struct smp_streamer *ctxt)
struct zcbor_string value = { 0 };
zcbor_state_t *zse = ctxt->writer->zs;
zcbor_state_t *zsd = ctxt->reader->zs;
char stat_name[CONFIG_STAT_MGMT_MAX_NAME_LEN];
char stat_name[CONFIG_MCUMGR_GRP_STAT_MAX_NAME_LEN];
bool ok;
size_t counter = 0;

View file

@ -5,4 +5,4 @@
#
zephyr_library(mgmt_mcumgr_grp_zephyr)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE src/basic_mgmt.c)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE src/basic_mgmt.c)

View file

@ -1,21 +1,21 @@
# Copyright (c) 2022 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_GRP_ZEPHYR_BASIC
menuconfig MCUMGR_GRP_ZBASIC
bool "Zephyr specific basic group of commands"
help
Enables mcumgr to processing of Zephyr specific groups.
if MCUMGR_GRP_ZEPHYR_BASIC
if MCUMGR_GRP_ZBASIC
config MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE
config MCUMGR_GRP_ZBASIC_STORAGE_ERASE
bool "Storage erase command"
help
Enables command that allows to erase storage partition.
module=MCUMGR_ZEPHYR_GRP
module=MCUMGR_GRP_ZBASIC
module-dep=LOG
module-str=mcumgr_zephyr_grp
module-str=mcumgr_grp_zbasic
source "subsys/logging/Kconfig.template.log_config"
endif

View file

@ -2,12 +2,12 @@
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
config MGMT_VERBOSE_ERR_RESPONSE
config MCUMGR_SMP_VERBOSE_ERR_RESPONSE
bool "Support verbose error response"
help
Support for encoding "rc" code explanation in form of "rsn"
text string. This is useful, when returning MGMT_ERR_EUNKNOWN,
to add additional information on the source of an error.
Note that the "rsn" is string additional to "rc" code,
so MCUMGR_BUF_SIZE should be large enough to be able to encode
both.
so MCUMGR_TRANSPORT_NETBUF_SIZE should be large enough to be able
to encode both.

View file

@ -99,7 +99,7 @@ static int smp_build_err_rsp(struct smp_streamer *streamer, const struct smp_hdr
zcbor_tstr_put_lit(zsp, "rc") &&
zcbor_int32_put(zsp, status);
#ifdef CONFIG_MGMT_VERBOSE_ERR_RESPONSE
#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
if (ok && rc_rsn != NULL) {
ok = zcbor_tstr_put_lit(zsp, "rsn") &&
zcbor_tstr_put_term(zsp, rc_rsn);
@ -163,7 +163,8 @@ static int smp_handle_single_payload(struct smp_streamer *cbuf, const struct smp
if (handler_fn) {
*handler_found = true;
zcbor_map_start_encode(cbuf->writer->zs, CONFIG_MGMT_MAX_MAIN_MAP_ENTRIES);
zcbor_map_start_encode(cbuf->writer->zs,
CONFIG_MCUMGR_SMP_CBOR_MAX_MAIN_MAP_ENTRIES);
#if defined(CONFIG_MCUMGR_SMP_COMMAND_STATUS_HOOKS)
cmd_recv.group = req_hdr->nh_group;
@ -177,7 +178,8 @@ static int smp_handle_single_payload(struct smp_streamer *cbuf, const struct smp
rc = handler_fn(cbuf);
/* End response payload. */
if (!zcbor_map_end_encode(cbuf->writer->zs, CONFIG_MGMT_MAX_MAIN_MAP_ENTRIES) &&
if (!zcbor_map_end_encode(cbuf->writer->zs,
CONFIG_MCUMGR_SMP_CBOR_MAX_MAIN_MAP_ENTRIES) &&
rc == 0) {
rc = MGMT_ERR_EMSGSIZE;
}

View file

@ -10,26 +10,26 @@
zephyr_library(mgmt_mcumgr_transport)
zephyr_library_sources(src/smp.c)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_REASSEMBLY
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
src/smp_reassembly.c
)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_BT
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_BT
src/smp_bt.c
)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_SHELL
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_SHELL
src/smp_shell.c
)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_UART
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_UART
src/smp_uart.c
)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_UDP
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_UDP
src/smp_udp.c
)
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_DUMMY
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_DUMMY
src/smp_dummy.c
)
if (CONFIG_MCUMGR_SMP_SHELL OR CONFIG_MCUMGR_SMP_UART)
if (CONFIG_MCUMGR_TRANSPORT_SHELL OR CONFIG_MCUMGR_TRANSPORT_UART)
zephyr_library_sources(src/serial_util.c)
endif()

View file

@ -2,35 +2,35 @@
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
config MCUMGR_SMP_REASSEMBLY
config MCUMGR_TRANSPORT_REASSEMBLY
bool
help
Enable structures and functions needed for packet reassembly by SMP backend.
config MCUMGR_BUF_COUNT
config MCUMGR_TRANSPORT_NETBUF_COUNT
int "Number of mcumgr buffers"
default 2 if MCUMGR_SMP_UDP
default 2 if MCUMGR_TRANSPORT_UDP
default 4
help
The number of net_bufs to allocate for mcumgr. These buffers are
used for both requests and responses.
config MCUMGR_BUF_SIZE
config MCUMGR_TRANSPORT_NETBUF_SIZE
int "Size of each mcumgr buffer"
default 2048 if MCUMGR_SMP_UDP
default 2048 if MCUMGR_TRANSPORT_UDP
default 384
help
The size, in bytes, of each mcumgr buffer. This value must satisfy
the following relation:
MCUMGR_BUF_SIZE >= transport-specific-MTU + transport-overhead
In case when MCUMGR_SMP_SHELL is enabled this value should be set to
at least SHELL_BACKEND_DUMMY_BUF_SIZE + 32.
MCUMGR_TRANSPORT_NETBUF_SIZE >= transport-specific-MTU + transport-overhead
In case when MCUMGR_TRANSPORT_SHELL is enabled this value should be set to
at least MCUMGR_GRP_SHELL_BACKEND_DUMMY_BUF_SIZE + 32.
config MCUMGR_BUF_USER_DATA_SIZE
config MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE
int "Size of mcumgr buffer user data"
default 24 if MCUMGR_SMP_UDP && MCUMGR_SMP_UDP_IPV6
default 8 if MCUMGR_SMP_UDP && MCUMGR_SMP_UDP_IPV4
default 8 if MCUMGR_SMP_BT
default 24 if MCUMGR_TRANSPORT_UDP && MCUMGR_TRANSPORT_UDP_IPV6
default 8 if MCUMGR_TRANSPORT_UDP && MCUMGR_TRANSPORT_UDP_IPV4
default 8 if MCUMGR_TRANSPORT_BT
default 4
help
The size, in bytes, of user data to allocate for each mcumgr buffer.

View file

@ -1,8 +1,8 @@
# Copyright Runtime.io 2018. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_SMP_BT
menuconfig MCUMGR_TRANSPORT_BT
bool "Bluetooth mcumgr SMP transport"
select BT
select BT_PERIPHERAL
@ -10,17 +10,17 @@ menuconfig MCUMGR_SMP_BT
help
Enables handling of SMP commands received over Bluetooth.
if MCUMGR_SMP_BT
if MCUMGR_TRANSPORT_BT
config MCUMGR_SMP_REASSEMBLY_BT
config MCUMGR_TRANSPORT_BT_REASSEMBLY
bool "Reassemble packets in Bluetooth SMP transport"
select MCUMGR_SMP_REASSEMBLY
select MCUMGR_TRANSPORT_REASSEMBLY
help
When enabled, the SMP BT transport will buffer and reassemble received
packet fragments before passing it for further processing.
config MCUMGR_SMP_BT_AUTHEN
config MCUMGR_TRANSPORT_BT_AUTHEN
bool "Authenticated requirement for Bluetooth mcumgr SMP transport"
select BT_SMP
default y
@ -28,7 +28,7 @@ config MCUMGR_SMP_BT_AUTHEN
Enables encrypted and authenticated connection requirement to
Bluetooth SMP transport.
config MCUMGR_SMP_BT_CONN_PARAM_CONTROL
config MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL
bool "Request specific connection parameters for SMP packet exchange"
depends on SYSTEM_WORKQUEUE_PRIORITY < 0
depends on BT_GAP_PERIPHERAL_PREF_PARAMS
@ -38,37 +38,37 @@ config MCUMGR_SMP_BT_CONN_PARAM_CONTROL
exchange process.
Its recommended to enable this if SMP is used for DFU.
if MCUMGR_SMP_BT_CONN_PARAM_CONTROL
if MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL
config MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MIN_INT
config MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MIN_INT
int "Minimum connection interval for SMP packet exchange"
default 6
range 6 3200
help
Minimum connection interval in 1.25ms units used during the exchange of SMP packets.
config MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MAX_INT
config MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MAX_INT
int "Maximum connection interval for SMP packet exchange"
default 9
range MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MIN_INT 3200
range MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MIN_INT 3200
help
Maximum connection interval in 1.25ms units used during the exchange of SMP packets.
config MCUMGR_SMP_BT_CONN_PARAM_CONTROL_LATENCY
config MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_LATENCY
int "Peripheral latency for SMP packet exchange"
default 0
range 0 499
help
Peripheral latency in Connection Intervals used during the exchange of SMP packets.
config MCUMGR_SMP_BT_CONN_PARAM_CONTROL_TIMEOUT
config MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_TIMEOUT
int "Supervision timeout for SMP packet exchange"
default 42
range 10 3200
help
Supervision timeout in 10ms used during the exchange of SMP packets.
config MCUMGR_SMP_BT_CONN_PARAM_CONTROL_RESTORE_TIME
config MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_RESTORE_TIME
int "Connection parameters restore time in milliseconds"
default 5000
range 1000 65535
@ -77,7 +77,7 @@ config MCUMGR_SMP_BT_CONN_PARAM_CONTROL_RESTORE_TIME
connection parameters are restored to peripheral preferred values
(BT_GAP_PERIPHERAL_PREF_PARAMS).
config MCUMGR_SMP_BT_CONN_PARAM_CONTROL_RETRY_TIME
config MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_RETRY_TIME
int "Connection parameters update retry time in milliseconds"
default 1000
range 1 5000
@ -85,7 +85,7 @@ config MCUMGR_SMP_BT_CONN_PARAM_CONTROL_RETRY_TIME
In case connection parameters update fails due to an error, this
option specifies the time of the next update attempt.
endif # MCUMGR_SMP_BT_CONN_PARAM_CONTROL
endif # MCUMGR_TRASNPORT_BT_CONN_PARAM_CONTROL
config MCUMGR_TRANSPORT_BT_AUTOMATIC_INIT
bool "Bluetooth SMP stack enable autostart/setup"
@ -107,4 +107,4 @@ config MCUMGR_TRANSPORT_BT_AUTOMATIC_INIT_WAIT
Bluetooth stack to become ready from the ``bt_enable()`` call,
otherwise will return instantly without waiting.
endif # MCUMGR_SMP_BT
endif # MCUMGR_TRANSPORT_BT

View file

@ -1,16 +1,17 @@
# Copyright Laird Connectivity 2021. All rights reserved.
# Copyright Nordic Semiconductor ASA 2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_SMP_DUMMY
menuconfig MCUMGR_TRANSPORT_DUMMY
bool "Dummy SMP backend"
select BASE64
help
Enables the dummy SMP backend which can be used for unit testing
SMP functionality without needing a real interface or driver.
if MCUMGR_SMP_DUMMY
if MCUMGR_TRANSPORT_DUMMY
config MCUMGR_SMP_DUMMY_RX_BUF_SIZE
config MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE
int "Size of receive buffer for dummy interface mcumgr fragments"
default 128
help
@ -18,4 +19,4 @@ config MCUMGR_SMP_DUMMY_RX_BUF_SIZE
in bytes. This value must be large enough to accommodate any
line sent by an mcumgr client.
endif # MCUMGR_SMP_DUMMY
endif # MCUMGR_TRANSPORT_DUMMY

View file

@ -1,8 +1,8 @@
# Copyright Runtime.io 2018. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_SMP_SHELL
menuconfig MCUMGR_TRANSPORT_SHELL
bool "Shell mcumgr SMP transport"
select SHELL
select SHELL_BACKEND_SERIAL
@ -11,20 +11,20 @@ menuconfig MCUMGR_SMP_SHELL
Enables handling of SMP commands received over shell. This allows
the shell to be use for both mcumgr commands and shell commands.
if MCUMGR_SMP_SHELL
if MCUMGR_TRANSPORT_SHELL
config MCUMGR_SMP_SHELL_MTU
config MCUMGR_TRANSPORT_SHELL_MTU
int "Shell SMP MTU"
default 256
help
Maximum size of SMP frames sent and received over shell. This value
must satisfy the following relation:
MCUMGR_SMP_SHELL_MTU <= MCUMGR_BUF_SIZE + 2
MCUMGR_TRANSPORT_SHELL_MTU <= MCUMGR_TRANSPORT_NETBUF_SIZE + 2
config MCUMGR_SMP_SHELL_RX_BUF_COUNT
config MCUMGR_TRANSPORT_SHELL_RX_BUF_COUNT
int "Shell SMP RX buffer count"
default 2
help
Number of buffers used for receiving SMP fragments over shell.
endif # MCUMGR_SMP_SHELL
endif # MCUMGR_TRANSPORT_SHELL

View file

@ -1,27 +1,27 @@
# Copyright Runtime.io 2018. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_SMP_UART
menuconfig MCUMGR_TRANSPORT_UART
bool "UART mcumgr SMP transport"
select UART_MCUMGR
select BASE64
help
Enables handling of SMP commands received over UART. This is a
lightweight alternative to MCUMGR_SMP_SHELL. It allows mcumgr
lightweight alternative to MCUMGR_TRANSPORT_SHELL. It allows mcumgr
commands to be received over UART without requiring an additional
thread.
if UART_ASYNC_API && MCUMGR_SMP_UART
if UART_ASYNC_API && MCUMGR_TRANSPORT_UART
menuconfig MCUMGR_SMP_UART_ASYNC
menuconfig MCUMGR_TRANSPORT_UART_ASYNC
bool "Use async UART API when available"
help
The option enables use of UART async API when available for selected mcumgr uart port.
if MCUMGR_SMP_UART_ASYNC
if MCUMGR_TRANSPORT_UART_ASYNC
config MCUMGR_SMP_UART_ASYNC_BUFS
config MCUMGR_TRANSPORT_UART_ASYNC_BUFS
int "Number of async RX UART buffers"
range 2 8
default 2
@ -31,21 +31,21 @@ config MCUMGR_SMP_UART_ASYNC_BUFS
receive data without stopping due to running out of buffer space. At least two buffers
area required for smooth RX operation.
config MCUMGR_SMP_UART_ASYNC_BUF_SIZE
config MCUMGR_TRANSPORT_UART_ASYNC_BUF_SIZE
int "Size of single async RX UART buffer"
default 64
help
The size of single buffer for asynchronous RX.
endif # MCUMGR_SMP_UART_ASYNC
endif # MCUMGR_TRANSPORT_UART_ASYNC
endif # UART_ASYNC_API
config MCUMGR_SMP_UART_MTU
config MCUMGR_TRANSPORT_UART_MTU
int "UART SMP MTU"
default 256
depends on MCUMGR_SMP_UART
depends on MCUMGR_TRANSPORT_UART
help
Maximum size of SMP frames sent and received over UART, in bytes.
This value must satisfy the following relation:
MCUMGR_SMP_UART_MTU <= MCUMGR_BUF_SIZE + 2
MCUMGR_TRANSPORT_UART_MTU <= MCUMGR_TRANSPORT_NETBUF_SIZE + 2

View file

@ -1,8 +1,8 @@
# Copyright Runtime.io 2018. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020. All rights reserved.
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUMGR_SMP_UDP
menuconfig MCUMGR_TRANSPORT_UDP
bool "UDP mcumgr SMP transport"
select NETWORKING
select NET_UDP
@ -12,9 +12,9 @@ menuconfig MCUMGR_SMP_UDP
Enables handling of SMP commands received over UDP.
Will start a thread for listening on the configured UDP port.
if MCUMGR_SMP_UDP
if MCUMGR_TRANSPORT_UDP
config MCUMGR_SMP_UDP_IPV4
config MCUMGR_TRANSPORT_UDP_IPV4
bool "UDP SMP using IPv4"
depends on NET_IPV4
default y
@ -22,38 +22,38 @@ config MCUMGR_SMP_UDP_IPV4
Enable SMP UDP using IPv4 addressing.
Can be enabled alongside IPv6 addressing.
config MCUMGR_SMP_UDP_IPV6
config MCUMGR_TRANSPORT_UDP_IPV6
bool "UDP SMP using IPv6"
depends on NET_IPV6
help
Enable SMP UDP using IPv6 addressing.
Can be enabled alongside IPv4 addressing.
config MCUMGR_SMP_UDP_PORT
config MCUMGR_TRANSPORT_UDP_PORT
int "UDP SMP port"
default 1337
help
UDP port that SMP server will listen for SMP commands on.
config MCUMGR_SMP_UDP_STACK_SIZE
config MCUMGR_TRANSPORT_UDP_STACK_SIZE
int "UDP SMP stack size"
default 512
help
Stack size of the SMP UDP listening thread
config MCUMGR_SMP_UDP_THREAD_PRIO
config MCUMGR_TRANSPORT_UDP_THREAD_PRIO
int "UDP SMP thread priority"
default 0
help
Scheduling priority of the SMP UDP listening thread.
config MCUMGR_SMP_UDP_MTU
config MCUMGR_TRANSPORT_UDP_MTU
int "UDP SMP MTU"
default 1500
help
Maximum size of SMP frames sent and received over UDP, in bytes.
This value must satisfy the following relation:
MCUMGR_SMP_UDP_MTU <= MCUMGR_BUF_SIZE + SMP msg overhead - address size
MCUMGR_TRANSPORT_UDP_MTU <= MCUMGR_TRANSPORT_NETBUF_SIZE + SMP msg overhead - address size
where address size is determined by IPv4/IPv6 selection.
config MCUMGR_TRANSPORT_UDP_AUTOMATIC_INIT
@ -65,4 +65,4 @@ config MCUMGR_TRANSPORT_UDP_AUTOMATIC_INIT
UDP SMP service when the network interface is up and disable it when
it goes down (at layer 4).
endif # MCUMGR_SMP_UDP
endif # MCUMGR_TRANSPORT_UDP

View file

@ -42,8 +42,9 @@ void smp_reassembly_init(struct smp_transport *smpt);
*
* @return number of expected bytes left to complete the packet, 0 means buffer is complete
* and no more fragments are expected;
* -ENOSR if a packet length, read from header, is bigger than CONFIG_MCUMGR_BUF_SIZE,
* which means there is no way to fit it in the configured buffer;
* -ENOSR if a packet length, read from header, is bigger than
* CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE, which means there is no way to fit it in
* the configured buffer;
* -EOVERFLOW if attempting to add a fragment that would make complete packet larger
* than expected;
* -ENOMEM if failed to allocate a new buffer for packet assembly;
@ -110,7 +111,7 @@ int smp_reassembly_drop(struct smp_transport *smpt);
* Note: for efficiency there is no NULL check on @p smpt pointer and it is caller's responsibility
* to validate the pointer before passing it to this function.
*
* @return pointer to "user data" of CONFIG_MCUMGR_BUF_USER_DATA_SIZE size;
* @return pointer to "user data" of CONFIG_MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE size;
* NULL if no re-assembly in progress.
*/
void *smp_reassembly_get_ud(const struct smp_transport *smpt);

View file

@ -15,7 +15,7 @@
#include <mgmt/mcumgr/transport/smp_reassembly.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(mcumgr_smp, CONFIG_MCUMGR_SMP_LOG_LEVEL);
LOG_MODULE_REGISTER(mcumgr_smp, CONFIG_MCUMGR_TRANSPORT_LOG_LEVEL);
/* To be able to unit test some callers some functions need to be
* demoted to allow overriding them.
@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(mcumgr_smp, CONFIG_MCUMGR_SMP_LOG_LEVEL);
#define WEAK
#endif
K_THREAD_STACK_DEFINE(smp_work_queue_stack, CONFIG_MCUMGR_SMP_WORKQUEUE_STACK_SIZE);
K_THREAD_STACK_DEFINE(smp_work_queue_stack, CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE);
static struct k_work_q smp_work_queue;
@ -34,8 +34,9 @@ static const struct k_work_queue_config smp_work_queue_config = {
.name = "mcumgr smp"
};
NET_BUF_POOL_DEFINE(pkt_pool, CONFIG_MCUMGR_BUF_COUNT, CONFIG_MCUMGR_BUF_SIZE,
CONFIG_MCUMGR_BUF_USER_DATA_SIZE, NULL);
NET_BUF_POOL_DEFINE(pkt_pool, CONFIG_MCUMGR_TRANSPORT_NETBUF_COUNT,
CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE,
CONFIG_MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE, NULL);
struct net_buf *smp_packet_alloc(void)
{
@ -150,7 +151,7 @@ smp_transport_init(struct smp_transport *smpt,
.query_valid_check = query_valid_check_func,
};
#ifdef CONFIG_MCUMGR_SMP_REASSEMBLY
#ifdef CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
smp_reassembly_init(smpt);
#endif
@ -234,7 +235,7 @@ static int smp_init(const struct device *dev)
k_work_queue_start(&smp_work_queue, smp_work_queue_stack,
K_THREAD_STACK_SIZEOF(smp_work_queue_stack),
CONFIG_MCUMGR_SMP_WORKQUEUE_THREAD_PRIO, &smp_work_queue_config);
CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_THREAD_PRIO, &smp_work_queue_config);
return 0;
}

View file

@ -28,40 +28,40 @@
#endif
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(mcumgr_smp, CONFIG_MCUMGR_SMP_LOG_LEVEL);
LOG_MODULE_DECLARE(mcumgr_smp, CONFIG_MCUMGR_TRANSPORT_LOG_LEVEL);
#define RESTORE_TIME COND_CODE_1(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL, \
(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_RESTORE_TIME), \
(0))
#define RETRY_TIME COND_CODE_1(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL, \
(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_RETRY_TIME), \
(0))
#define RESTORE_TIME COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL, \
(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_RESTORE_TIME), \
(0))
#define RETRY_TIME COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL, \
(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_RETRY_TIME), \
(0))
#define CONN_PARAM_SMP COND_CODE_1(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL, \
BT_LE_CONN_PARAM( \
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MIN_INT, \
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MAX_INT, \
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_LATENCY, \
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_TIMEOUT), \
#define CONN_PARAM_SMP COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL, \
BT_LE_CONN_PARAM( \
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MIN_INT, \
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MAX_INT, \
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_LATENCY, \
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_TIMEOUT), \
(NULL))
#define CONN_PARAM_PREF COND_CODE_1(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL, \
BT_LE_CONN_PARAM( \
CONFIG_BT_PERIPHERAL_PREF_MIN_INT, \
CONFIG_BT_PERIPHERAL_PREF_MAX_INT, \
CONFIG_BT_PERIPHERAL_PREF_LATENCY, \
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT), \
(NULL))
#define CONN_PARAM_PREF COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL, \
BT_LE_CONN_PARAM( \
CONFIG_BT_PERIPHERAL_PREF_MIN_INT, \
CONFIG_BT_PERIPHERAL_PREF_MAX_INT, \
CONFIG_BT_PERIPHERAL_PREF_LATENCY, \
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT), \
(NULL))
/* Minimum number of bytes that must be able to be sent with a notification to a target device
* before giving up
*/
#define SMP_BT_MINIMUM_MTU_SEND_FAILURE 20
#ifdef CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL
#ifdef CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL
/* Verification of SMP Connection Parameters configuration that is not possible in the Kconfig. */
BUILD_ASSERT((CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_TIMEOUT * 4U) >
((1U + CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_LATENCY) *
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MAX_INT));
BUILD_ASSERT((CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_TIMEOUT * 4U) >
((1U + CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_LATENCY) *
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MAX_INT));
#endif
struct smp_bt_user_data {
@ -70,8 +70,9 @@ struct smp_bt_user_data {
};
/* Verification of user data being able to fit */
BUILD_ASSERT(sizeof(struct smp_bt_user_data) <= CONFIG_MCUMGR_BUF_USER_DATA_SIZE,
"CONFIG_MCUMGR_BUF_USER_DATA_SIZE not large enough to fit Bluetooth user data");
BUILD_ASSERT(sizeof(struct smp_bt_user_data) <= CONFIG_MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE,
"CONFIG_MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE not large enough to fit Bluetooth"
" user data");
enum {
CONN_PARAM_SMP_REQUESTED = BIT(0),
@ -230,7 +231,7 @@ static ssize_t smp_bt_chr_write(struct bt_conn *conn,
uint8_t flags)
{
struct conn_param_data *cpd = conn_param_data_get(conn);
#ifdef CONFIG_MCUMGR_SMP_REASSEMBLY_BT
#ifdef CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY
int ret;
bool started;
@ -277,7 +278,7 @@ static ssize_t smp_bt_chr_write(struct bt_conn *conn,
*/
struct smp_bt_user_data *ud = smp_reassembly_get_ud(&smp_bt_transport);
if (IS_ENABLED(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL)) {
if (IS_ENABLED(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL)) {
conn_param_smp_enable(conn);
}
@ -320,7 +321,7 @@ static ssize_t smp_bt_chr_write(struct bt_conn *conn,
ud->conn = conn;
ud->id = cpd->id;
if (IS_ENABLED(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL)) {
if (IS_ENABLED(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL)) {
conn_param_smp_enable(conn);
}
@ -332,7 +333,7 @@ static ssize_t smp_bt_chr_write(struct bt_conn *conn,
static void smp_bt_ccc_changed(const struct bt_gatt_attr *attr, uint16_t value)
{
#ifdef CONFIG_MCUMGR_SMP_REASSEMBLY_BT
#ifdef CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY
if (smp_reassembly_expected(&smp_bt_transport) >= 0 && value == 0) {
struct smp_bt_user_data *ud = smp_reassembly_get_ud(&smp_bt_transport);
@ -351,14 +352,14 @@ static struct bt_gatt_attr smp_bt_attrs[] = {
BT_GATT_CHARACTERISTIC(&smp_bt_chr_uuid.uuid,
BT_GATT_CHRC_WRITE_WITHOUT_RESP |
BT_GATT_CHRC_NOTIFY,
#ifdef CONFIG_MCUMGR_SMP_BT_AUTHEN
#ifdef CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN
BT_GATT_PERM_WRITE_AUTHEN,
#else
BT_GATT_PERM_WRITE,
#endif
NULL, smp_bt_chr_write, NULL),
BT_GATT_CCC(smp_bt_ccc_changed,
#ifdef CONFIG_MCUMGR_SMP_BT_AUTHEN
#ifdef CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN
BT_GATT_PERM_READ_AUTHEN |
BT_GATT_PERM_WRITE_AUTHEN),
#else
@ -592,7 +593,7 @@ static void disconnected(struct bt_conn *conn, uint8_t reason)
cpd->id = 0;
cpd->conn = NULL;
if (IS_ENABLED(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL)) {
if (IS_ENABLED(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL)) {
/* Cancel work if ongoing. */
(void)k_work_cancel_delayable(&cpd->dwork);
(void)k_work_cancel_delayable(&cpd->ework);
@ -663,7 +664,7 @@ void smp_bt_start(void)
bt_conn_cb_register(&conn_callbacks);
if (IS_ENABLED(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL)) {
if (IS_ENABLED(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL)) {
conn_param_control_init();
}

View file

@ -10,8 +10,8 @@
*/
/* Define required for uart_mcumgr.h functionality reuse */
#define CONFIG_UART_MCUMGR_RX_BUF_SIZE CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE
#define MCUMGR_DUMMY_MAX_FRAME CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE
#define CONFIG_UART_MCUMGR_RX_BUF_SIZE CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE
#define MCUMGR_DUMMY_MAX_FRAME CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE
#include <zephyr/kernel.h>
#include <zephyr/init.h>
@ -29,8 +29,8 @@
#include <mgmt/mcumgr/transport/smp_internal.h>
BUILD_ASSERT(CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE != 0,
"CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE must be > 0");
BUILD_ASSERT(CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE != 0,
"CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE must be > 0");
struct device;
static struct mcumgr_serial_rx_ctxt smp_dummy_rx_ctxt;
@ -38,9 +38,9 @@ static struct mcumgr_serial_rx_ctxt smp_dummy_tx_ctxt;
static struct smp_transport smp_dummy_transport;
static bool enable_dummy_smp;
static struct k_sem smp_data_ready_sem;
static uint8_t smp_send_buffer[CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE];
static uint8_t smp_send_buffer[CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE];
static uint16_t smp_send_pos;
static uint8_t smp_receive_buffer[CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE];
static uint8_t smp_receive_buffer[CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE];
static uint16_t smp_receive_pos;
/** Callback to execute when a valid fragment has been received. */
@ -152,7 +152,7 @@ static void smp_dummy_rx_frag(struct uart_mcumgr_rx_buf *rx_buf)
static uint16_t smp_dummy_get_mtu(const struct net_buf *nb)
{
return CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE;
return CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE;
}
int dummy_mcumgr_send_raw(const void *data, int len)

View file

@ -13,6 +13,8 @@
#include <mgmt/mcumgr/transport/smp_internal.h>
#define MCUMGR_TRANSPORT_NETBUF_SIZE CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE
void smp_reassembly_init(struct smp_transport *smpt)
{
smpt->__reassembly.current = NULL;
@ -46,7 +48,8 @@ int smp_reassembly_collect(struct smp_transport *smpt, const void *buf, uint16_t
expected += sizeof(struct smp_hdr);
/* Joining net_bufs not supported yet */
if (len > CONFIG_MCUMGR_BUF_SIZE || expected > CONFIG_MCUMGR_BUF_SIZE) {
if (len > MCUMGR_TRANSPORT_NETBUF_SIZE ||
expected > MCUMGR_TRANSPORT_NETBUF_SIZE) {
return -ENOSR;
}

View file

@ -27,7 +27,8 @@
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(smp_shell);
BUILD_ASSERT(CONFIG_MCUMGR_SMP_SHELL_MTU != 0, "CONFIG_MCUMGR_SMP_SHELL_MTU must be > 0");
BUILD_ASSERT(CONFIG_MCUMGR_TRANSPORT_SHELL_MTU != 0,
"CONFIG_MCUMGR_TRANSPORT_SHELL_MTU must be > 0");
static struct smp_transport smp_shell_transport;
@ -160,7 +161,7 @@ void smp_shell_process(struct smp_shell_data *data)
static uint16_t smp_shell_get_mtu(const struct net_buf *nb)
{
return CONFIG_MCUMGR_SMP_SHELL_MTU;
return CONFIG_MCUMGR_TRANSPORT_SHELL_MTU;
}
static int smp_shell_tx_raw(const void *data, int len)

View file

@ -20,7 +20,7 @@
#include <mgmt/mcumgr/transport/smp_internal.h>
BUILD_ASSERT(CONFIG_MCUMGR_SMP_UART_MTU != 0, "CONFIG_MCUMGR_SMP_UART_MTU must be > 0");
BUILD_ASSERT(CONFIG_MCUMGR_TRANSPORT_UART_MTU != 0, "CONFIG_MCUMGR_TRANSPORT_UART_MTU must be > 0");
struct device;
@ -77,7 +77,7 @@ static void smp_uart_rx_frag(struct uart_mcumgr_rx_buf *rx_buf)
static uint16_t smp_uart_get_mtu(const struct net_buf *nb)
{
return CONFIG_MCUMGR_SMP_UART_MTU;
return CONFIG_MCUMGR_TRANSPORT_UART_MTU;
}
static int smp_uart_tx_pkt(struct net_buf *nb)

View file

@ -37,34 +37,34 @@
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(smp_udp);
BUILD_ASSERT(CONFIG_MCUMGR_SMP_UDP_MTU != 0, "CONFIG_MCUMGR_SMP_UDP_MTU must be > 0");
BUILD_ASSERT(CONFIG_MCUMGR_TRANSPORT_UDP_MTU != 0, "CONFIG_MCUMGR_TRANSPORT_UDP_MTU must be > 0");
struct config {
int sock;
const char *proto;
struct smp_transport smp_transport;
char recv_buffer[CONFIG_MCUMGR_SMP_UDP_MTU];
char recv_buffer[CONFIG_MCUMGR_TRANSPORT_UDP_MTU];
struct k_thread thread;
K_KERNEL_STACK_MEMBER(stack, CONFIG_MCUMGR_SMP_UDP_STACK_SIZE);
K_KERNEL_STACK_MEMBER(stack, CONFIG_MCUMGR_TRANSPORT_UDP_STACK_SIZE);
};
struct configs {
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
struct config ipv4;
#endif
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
struct config ipv6;
#endif
};
static struct configs configs = {
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
.ipv4 = {
.proto = "IPv4",
.sock = -1,
},
#endif
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
.ipv6 = {
.proto = "IPv6",
.sock = -1,
@ -76,7 +76,7 @@ static struct configs configs = {
static struct net_mgmt_event_callback smp_udp_mgmt_cb;
#endif
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
static int smp_udp4_tx(struct net_buf *nb)
{
int ret;
@ -96,7 +96,7 @@ static int smp_udp4_tx(struct net_buf *nb)
}
#endif
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
static int smp_udp6_tx(struct net_buf *nb)
{
int ret;
@ -120,7 +120,7 @@ static uint16_t smp_udp_get_mtu(const struct net_buf *nb)
{
ARG_UNUSED(nb);
return CONFIG_MCUMGR_SMP_UDP_MTU;
return CONFIG_MCUMGR_TRANSPORT_UDP_MTU;
}
static int smp_udp_ud_copy(struct net_buf *dst, const struct net_buf *src)
@ -147,7 +147,7 @@ static void smp_udp_receive_thread(void *p1, void *p2, void *p3)
socklen_t addr_len = sizeof(addr);
int len = recvfrom(conf->sock, conf->recv_buffer,
CONFIG_MCUMGR_SMP_UDP_MTU,
CONFIG_MCUMGR_TRANSPORT_UDP_MTU,
0, &addr, &addr_len);
if (len > 0) {
@ -176,13 +176,13 @@ static int smp_udp_init(const struct device *dev)
{
ARG_UNUSED(dev);
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
smp_transport_init(&configs.ipv4.smp_transport,
smp_udp4_tx, smp_udp_get_mtu,
smp_udp_ud_copy, NULL, NULL);
#endif
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
smp_transport_init(&configs.ipv6.smp_transport,
smp_udp6_tx, smp_udp_get_mtu,
smp_udp_ud_copy, NULL, NULL);
@ -221,7 +221,7 @@ static void create_thread(struct config *conf, const char *name)
k_thread_create(&(conf->thread), conf->stack,
K_KERNEL_STACK_SIZEOF(conf->stack),
smp_udp_receive_thread, conf, NULL, NULL,
CONFIG_MCUMGR_SMP_UDP_THREAD_PRIO, 0, K_FOREVER);
CONFIG_MCUMGR_TRANSPORT_UDP_THREAD_PRIO, 0, K_FOREVER);
k_thread_name_set(&(conf->thread), name);
k_thread_start(&(conf->thread));
@ -233,12 +233,12 @@ int smp_udp_open(void)
{
struct config *conf;
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
struct sockaddr_in addr4;
memset(&addr4, 0, sizeof(addr4));
addr4.sin_family = AF_INET;
addr4.sin_port = htons(CONFIG_MCUMGR_SMP_UDP_PORT);
addr4.sin_port = htons(CONFIG_MCUMGR_TRANSPORT_UDP_PORT);
addr4.sin_addr.s_addr = htonl(INADDR_ANY);
conf = &configs.ipv4;
@ -251,12 +251,12 @@ int smp_udp_open(void)
create_thread(conf, "smp_udp4");
#endif
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
struct sockaddr_in6 addr6;
memset(&addr6, 0, sizeof(addr6));
addr6.sin6_family = AF_INET6;
addr6.sin6_port = htons(CONFIG_MCUMGR_SMP_UDP_PORT);
addr6.sin6_port = htons(CONFIG_MCUMGR_TRANSPORT_UDP_PORT);
addr6.sin6_addr = in6addr_any;
conf = &configs.ipv6;
@ -274,7 +274,7 @@ int smp_udp_open(void)
int smp_udp_close(void)
{
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
if (configs.ipv4.sock >= 0) {
k_thread_abort(&(configs.ipv4.thread));
close(configs.ipv4.sock);
@ -282,7 +282,7 @@ int smp_udp_close(void)
}
#endif
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
if (configs.ipv6.sock >= 0) {
k_thread_abort(&(configs.ipv6.thread));
close(configs.ipv6.sock);

View file

@ -19,10 +19,10 @@ LOG_MODULE_REGISTER(shell_uart);
#define RX_POLL_PERIOD K_NO_WAIT
#endif
#ifdef CONFIG_MCUMGR_SMP_SHELL
NET_BUF_POOL_DEFINE(smp_shell_rx_pool, CONFIG_MCUMGR_SMP_SHELL_RX_BUF_COUNT,
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
NET_BUF_POOL_DEFINE(smp_shell_rx_pool, CONFIG_MCUMGR_TRANSPORT_SHELL_RX_BUF_COUNT,
SMP_SHELL_RX_BUF_SIZE, 0, NULL);
#endif /* CONFIG_MCUMGR_SMP_SHELL */
#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
SHELL_UART_DEFINE(shell_transport_uart,
CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE,
@ -40,7 +40,7 @@ static void uart_rx_handle(const struct device *dev,
uint32_t len;
uint32_t rd_len;
bool new_data = false;
#ifdef CONFIG_MCUMGR_SMP_SHELL
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
struct smp_shell_data *const smp = &sh_uart->ctrl_blk->smp;
#endif
@ -58,7 +58,7 @@ static void uart_rx_handle(const struct device *dev,
if (rd_len > 0) {
new_data = true;
}
#ifdef CONFIG_MCUMGR_SMP_SHELL
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
/* Divert bytes from shell handling if it is
* part of an mcumgr frame.
*/
@ -71,7 +71,7 @@ static void uart_rx_handle(const struct device *dev,
data[j] = data[i + j];
}
}
#endif /* CONFIG_MCUMGR_SMP_SHELL */
#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
int err = ring_buf_put_finish(sh_uart->rx_ringbuf,
rd_len);
(void)err;
@ -83,7 +83,7 @@ static void uart_rx_handle(const struct device *dev,
LOG_WRN("RX ring buffer full.");
rd_len = uart_fifo_read(dev, &dummy, 1);
#ifdef CONFIG_MCUMGR_SMP_SHELL
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
/* If successful in getting byte from the fifo, try
* feeding it to SMP as a part of mcumgr frame.
*/
@ -91,7 +91,7 @@ static void uart_rx_handle(const struct device *dev,
(smp_shell_rx_bytes(smp, &dummy, 1) == 1)) {
new_data = true;
}
#endif /* CONFIG_MCUMGR_SMP_SHELL */
#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
}
} while (rd_len && (rd_len == len));
@ -201,7 +201,7 @@ static int init(const struct shell_transport *transport,
sh_uart->ctrl_blk->handler = evt_handler;
sh_uart->ctrl_blk->context = context;
#ifdef CONFIG_MCUMGR_SMP_SHELL
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
sh_uart->ctrl_blk->smp.buf_pool = &smp_shell_rx_pool;
k_fifo_init(&sh_uart->ctrl_blk->smp.buf_ready);
#endif
@ -293,14 +293,14 @@ static int read(const struct shell_transport *transport,
return 0;
}
#ifdef CONFIG_MCUMGR_SMP_SHELL
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
static void update(const struct shell_transport *transport)
{
struct shell_uart *sh_uart = (struct shell_uart *)transport->ctx;
smp_shell_process(&sh_uart->ctrl_blk->smp);
}
#endif /* CONFIG_MCUMGR_SMP_SHELL */
#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
const struct shell_transport_api shell_uart_transport_api = {
.init = init,
@ -308,9 +308,9 @@ const struct shell_transport_api shell_uart_transport_api = {
.enable = enable,
.write = write,
.read = read,
#ifdef CONFIG_MCUMGR_SMP_SHELL
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
.update = update,
#endif /* CONFIG_MCUMGR_SMP_SHELL */
#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
};
static int enable_shell_uart(const struct device *arg)
@ -328,7 +328,7 @@ static int enable_shell_uart(const struct device *arg)
return -ENODEV;
}
if (IS_ENABLED(CONFIG_MCUMGR_SMP_SHELL)) {
if (IS_ENABLED(CONFIG_MCUMGR_TRANSPORT_SHELL)) {
smp_shell_init();
}