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:
parent
61b5566e74
commit
db34adf9c3
70 changed files with 505 additions and 493 deletions
|
@ -215,7 +215,7 @@ config UART_MCUMGR_RX_BUF_COUNT
|
||||||
buffers hold received mcumgr fragments prior to reassembly. This
|
buffers hold received mcumgr fragments prior to reassembly. This
|
||||||
setting's value must satisfy the following relation:
|
setting's value must satisfy the following relation:
|
||||||
UART_MCUMGR_RX_BUF_COUNT * UART_MCUMGR_RX_BUF_SIZE >=
|
UART_MCUMGR_RX_BUF_COUNT * UART_MCUMGR_RX_BUF_SIZE >=
|
||||||
MCUMGR_SMP_UART_MTU
|
MCUMGR_TRANSPORT_UART_MTU
|
||||||
|
|
||||||
endif # UART_MCUMGR
|
endif # UART_MCUMGR
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,9 @@ static bool uart_mcumgr_ignoring;
|
||||||
K_MEM_SLAB_DEFINE(uart_mcumgr_slab, sizeof(struct uart_mcumgr_rx_buf),
|
K_MEM_SLAB_DEFINE(uart_mcumgr_slab, sizeof(struct uart_mcumgr_rx_buf),
|
||||||
CONFIG_UART_MCUMGR_RX_BUF_COUNT, 1);
|
CONFIG_UART_MCUMGR_RX_BUF_COUNT, 1);
|
||||||
|
|
||||||
#if defined(CONFIG_MCUMGR_SMP_UART_ASYNC)
|
#if defined(CONFIG_MCUMGR_TRANSPORT_UART_ASYNC)
|
||||||
uint8_t async_buffer[CONFIG_MCUMGR_SMP_UART_ASYNC_BUFS][CONFIG_MCUMGR_SMP_UART_ASYNC_BUF_SIZE];
|
uint8_t async_buffer[CONFIG_MCUMGR_TRANSPORT_UART_ASYNC_BUFS]
|
||||||
|
[CONFIG_MCUMGR_TRANSPORT_UART_ASYNC_BUF_SIZE];
|
||||||
static int async_current;
|
static int async_current;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ void uart_mcumgr_free_rx_buf(struct uart_mcumgr_rx_buf *rx_buf)
|
||||||
k_mem_slab_free(&uart_mcumgr_slab, &block);
|
k_mem_slab_free(&uart_mcumgr_slab, &block);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(CONFIG_MCUMGR_SMP_UART_ASYNC)
|
#if !defined(CONFIG_MCUMGR_TRANSPORT_UART_ASYNC)
|
||||||
/**
|
/**
|
||||||
* Reads a chunk of received data from the UART.
|
* Reads a chunk of received data from the UART.
|
||||||
*/
|
*/
|
||||||
|
@ -119,7 +120,7 @@ static struct uart_mcumgr_rx_buf *uart_mcumgr_rx_byte(uint8_t byte)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_MCUMGR_SMP_UART_ASYNC)
|
#if defined(CONFIG_MCUMGR_TRANSPORT_UART_ASYNC)
|
||||||
static void uart_mcumgr_async(const struct device *dev, struct uart_event *evt, void *user_data)
|
static void uart_mcumgr_async(const struct device *dev, struct uart_event *evt, void *user_data)
|
||||||
{
|
{
|
||||||
struct uart_mcumgr_rx_buf *rx_buf;
|
struct uart_mcumgr_rx_buf *rx_buf;
|
||||||
|
@ -155,7 +156,7 @@ static void uart_mcumgr_async(const struct device *dev, struct uart_event *evt,
|
||||||
* UART_RX_BUF_REQUEST is processed.
|
* UART_RX_BUF_REQUEST is processed.
|
||||||
*/
|
*/
|
||||||
++async_current;
|
++async_current;
|
||||||
async_current %= CONFIG_MCUMGR_SMP_UART_ASYNC_BUFS;
|
async_current %= CONFIG_MCUMGR_TRANSPORT_UART_ASYNC_BUFS;
|
||||||
uart_rx_buf_rsp(dev, async_buffer[async_current],
|
uart_rx_buf_rsp(dev, async_buffer[async_current],
|
||||||
sizeof(async_buffer[async_current]));
|
sizeof(async_buffer[async_current]));
|
||||||
break;
|
break;
|
||||||
|
@ -217,7 +218,7 @@ int uart_mcumgr_send(const uint8_t *data, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(CONFIG_MCUMGR_SMP_UART_ASYNC)
|
#if defined(CONFIG_MCUMGR_TRANSPORT_UART_ASYNC)
|
||||||
static void uart_mcumgr_setup(const struct device *uart)
|
static void uart_mcumgr_setup(const struct device *uart)
|
||||||
{
|
{
|
||||||
uart_callback_set(uart, uart_mcumgr_async, NULL);
|
uart_callback_set(uart, uart_mcumgr_async, NULL);
|
||||||
|
|
|
@ -106,7 +106,7 @@ struct img_mgmt_upload_action {
|
||||||
bool proceed;
|
bool proceed;
|
||||||
/** Whether to erase the destination flash area. */
|
/** Whether to erase the destination flash area. */
|
||||||
bool erase;
|
bool erase;
|
||||||
#ifdef CONFIG_IMG_MGMT_VERBOSE_ERR
|
#ifdef CONFIG_MCUMGR_GRP_IMG_VERBOSE_ERR
|
||||||
/** "rsn" string to be sent as explanation for "rc" code */
|
/** "rsn" string to be sent as explanation for "rc" code */
|
||||||
const char *rc_rsn;
|
const char *rc_rsn;
|
||||||
#endif
|
#endif
|
||||||
|
@ -219,7 +219,7 @@ int img_mgmt_state_confirm(void);
|
||||||
*/
|
*/
|
||||||
int img_mgmt_vercmp(const struct image_version *a, const struct image_version *b);
|
int img_mgmt_vercmp(const struct image_version *a, const struct image_version *b);
|
||||||
|
|
||||||
#ifdef CONFIG_IMG_MGMT_VERBOSE_ERR
|
#ifdef CONFIG_MCUMGR_GRP_IMG_VERBOSE_ERR
|
||||||
#define IMG_MGMT_UPLOAD_ACTION_SET_RC_RSN(action, rsn) ((action)->rc_rsn = (rsn))
|
#define IMG_MGMT_UPLOAD_ACTION_SET_RC_RSN(action, rsn) ((action)->rc_rsn = (rsn))
|
||||||
#define IMG_MGMT_UPLOAD_ACTION_RC_RSN(action) ((action)->rc_rsn)
|
#define IMG_MGMT_UPLOAD_ACTION_RC_RSN(action) ((action)->rc_rsn)
|
||||||
int img_mgmt_error_rsp(struct smp_streamer *ctxt, int rc, const char *rsn);
|
int img_mgmt_error_rsp(struct smp_streamer *ctxt, int rc, const char *rsn);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#ifndef ZEPHYR_INCLUDE_ZEPHYR_MCUMGR_GRP_ZEPHYR_BASIC_H_
|
#ifndef ZEPHYR_INCLUDE_ZEPHYR_MCUMGR_GRP_ZBASIC_H_
|
||||||
#define ZEPHYR_INCLUDE_ZEPHYR_MCUMGR_GRP_ZEPHYR_BASIC_H_
|
#define ZEPHYR_INCLUDE_ZEPHYR_MCUMGR_GRP_ZBASIC_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -19,4 +19,4 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_ZEPHYR_MCUMGR_GRP_ZEPHYR_BASIC_H_ */
|
#endif /* ZEPHYR_INCLUDE_ZEPHYR_MCUMGR_GRP_ZBASIC_H_ */
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
#include <zephyr/sys/slist.h>
|
#include <zephyr/sys/slist.h>
|
||||||
#include <zephyr/mgmt/mcumgr/mgmt/mgmt.h>
|
#include <zephyr/mgmt/mcumgr/mgmt/mgmt.h>
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_CMD_FS_MGMT
|
#ifdef CONFIG_MCUMGR_GRP_FS
|
||||||
#include <zephyr/mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_callbacks.h>
|
#include <zephyr/mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_callbacks.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_CMD_IMG_MGMT
|
#ifdef CONFIG_MCUMGR_GRP_IMG
|
||||||
#include <zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt_callbacks.h>
|
#include <zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt_callbacks.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ typedef void *(*mgmt_alloc_rsp_fn)(const void *src_buf, void *arg);
|
||||||
*/
|
*/
|
||||||
typedef void (*mgmt_reset_buf_fn)(void *buf, void *arg);
|
typedef void (*mgmt_reset_buf_fn)(void *buf, void *arg);
|
||||||
|
|
||||||
#ifdef CONFIG_MGMT_VERBOSE_ERR_RESPONSE
|
#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
|
||||||
#define MGMT_CTXT_SET_RC_RSN(mc, rsn) ((mc->rc_rsn) = (rsn))
|
#define MGMT_CTXT_SET_RC_RSN(mc, rsn) ((mc->rc_rsn) = (rsn))
|
||||||
#define MGMT_CTXT_RC_RSN(mc) ((mc)->rc_rsn)
|
#define MGMT_CTXT_RC_RSN(mc) ((mc)->rc_rsn)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -37,10 +37,10 @@ extern "C" {
|
||||||
|
|
||||||
struct cbor_nb_reader {
|
struct cbor_nb_reader {
|
||||||
struct net_buf *nb;
|
struct net_buf *nb;
|
||||||
/* CONFIG_MGMT_MAX_DECODING_LEVELS + 2 translates to minimal
|
/* CONFIG_MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS + 2 translates to minimal
|
||||||
* zcbor backup states.
|
* zcbor backup states.
|
||||||
*/
|
*/
|
||||||
zcbor_state_t zs[CONFIG_MGMT_MAX_DECODING_LEVELS + 2];
|
zcbor_state_t zs[CONFIG_MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS + 2];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cbor_nb_writer {
|
struct cbor_nb_writer {
|
||||||
|
@ -71,7 +71,7 @@ struct smp_streamer {
|
||||||
struct cbor_nb_reader *reader;
|
struct cbor_nb_reader *reader;
|
||||||
struct cbor_nb_writer *writer;
|
struct cbor_nb_writer *writer;
|
||||||
|
|
||||||
#ifdef CONFIG_MGMT_VERBOSE_ERR_RESPONSE
|
#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
|
||||||
const char *rc_rsn;
|
const char *rc_rsn;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -116,7 +116,7 @@ struct smp_transport {
|
||||||
smp_transport_ud_free_fn ud_free;
|
smp_transport_ud_free_fn ud_free;
|
||||||
smp_transport_query_valid_check_fn query_valid_check;
|
smp_transport_query_valid_check_fn query_valid_check;
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_REASSEMBLY
|
#ifdef CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
|
||||||
/* Packet reassembly internal data, API access only */
|
/* Packet reassembly internal data, API access only */
|
||||||
struct {
|
struct {
|
||||||
struct net_buf *current; /* net_buf used for reassembly */
|
struct net_buf *current; /* net_buf used for reassembly */
|
||||||
|
@ -138,7 +138,7 @@ struct zephyr_smp_transport {
|
||||||
smp_transport_ud_copy_fn zst_ud_copy;
|
smp_transport_ud_copy_fn zst_ud_copy;
|
||||||
smp_transport_ud_free_fn zst_ud_free;
|
smp_transport_ud_free_fn zst_ud_free;
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_REASSEMBLY
|
#ifdef CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
|
||||||
/* Packet reassembly internal data, API access only */
|
/* Packet reassembly internal data, API access only */
|
||||||
struct {
|
struct {
|
||||||
struct net_buf *current; /* net_buf used for reassembly */
|
struct net_buf *current; /* net_buf used for reassembly */
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
/** @file
|
/** @file
|
||||||
* @brief Dummy transport for the mcumgr SMP protocol for unit testing.
|
* @brief Dummy transport for the mcumgr SMP protocol for unit testing.
|
||||||
*/
|
*/
|
||||||
#ifndef ZEPHYR_INCLUDE_MGMT_MCUMGR_SMP_DUMMY_H_
|
#ifndef ZEPHYR_INCLUDE_MGMT_MCUMGR_TRANSPORT_DUMMY_H_
|
||||||
#define ZEPHYR_INCLUDE_MGMT_MCUMGR_SMP_DUMMY_H_
|
#define ZEPHYR_INCLUDE_MGMT_MCUMGR_TRANSPORT_DUMMY_H_
|
||||||
|
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <zephyr/net/buf.h>
|
#include <zephyr/net/buf.h>
|
||||||
|
@ -98,4 +98,4 @@ void smp_dummy_disable(void);
|
||||||
*/
|
*/
|
||||||
bool smp_dummy_get_status(void);
|
bool smp_dummy_get_status(void);
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_MGMT_MCUMGR_SMP_DUMMY_H_ */
|
#endif /* ZEPHYR_INCLUDE_MGMT_MCUMGR_TRANSPORT_DUMMY_H_ */
|
||||||
|
|
|
@ -25,9 +25,9 @@ struct shell_uart_ctrl_blk {
|
||||||
void *context;
|
void *context;
|
||||||
atomic_t tx_busy;
|
atomic_t tx_busy;
|
||||||
bool blocking_tx;
|
bool blocking_tx;
|
||||||
#ifdef CONFIG_MCUMGR_SMP_SHELL
|
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
|
||||||
struct smp_shell_data smp;
|
struct smp_shell_data smp;
|
||||||
#endif /* CONFIG_MCUMGR_SMP_SHELL */
|
#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN
|
#ifdef CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN
|
||||||
|
|
|
@ -13,5 +13,5 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||||
project(smp_svr)
|
project(smp_svr)
|
||||||
|
|
||||||
target_sources(app PRIVATE src/main.c)
|
target_sources(app PRIVATE src/main.c)
|
||||||
target_sources_ifdef(CONFIG_MCUMGR_SMP_BT app PRIVATE src/bluetooth.c)
|
target_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_BT app PRIVATE src/bluetooth.c)
|
||||||
target_sources_ifdef(CONFIG_MCUMGR_SMP_UDP app PRIVATE src/udp.c)
|
target_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_UDP app PRIVATE src/udp.c)
|
||||||
|
|
|
@ -5,31 +5,31 @@ CONFIG_BT_BUF_ACL_TX_SIZE=502
|
||||||
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
|
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
|
||||||
|
|
||||||
# Enable the Bluetooth mcumgr transport (unauthenticated).
|
# Enable the Bluetooth mcumgr transport (unauthenticated).
|
||||||
CONFIG_MCUMGR_SMP_BT=y
|
CONFIG_MCUMGR_TRANSPORT_BT=y
|
||||||
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
|
CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n
|
||||||
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL=y
|
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
|
||||||
|
|
||||||
# Enable the Shell mcumgr transport.
|
# Enable the Shell mcumgr transport.
|
||||||
CONFIG_MCUMGR_SMP_SHELL=y
|
CONFIG_MCUMGR_TRANSPORT_SHELL=y
|
||||||
|
|
||||||
# Enable the mcumgr Packet Reassembly feature over Bluetooth and its configuration dependencies.
|
# Enable the mcumgr Packet Reassembly feature over Bluetooth and its configuration dependencies.
|
||||||
# MCUmgr buffer size is optimized to fit one SMP packet divided into five Bluetooth Write Commands,
|
# MCUmgr buffer size is optimized to fit one SMP packet divided into five Bluetooth Write Commands,
|
||||||
# transmitted with the maximum possible MTU value: 498 bytes.
|
# transmitted with the maximum possible MTU value: 498 bytes.
|
||||||
CONFIG_MCUMGR_SMP_REASSEMBLY_BT=y
|
CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
|
||||||
CONFIG_MCUMGR_BUF_SIZE=2475
|
CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE=2475
|
||||||
CONFIG_OS_MGMT_MCUMGR_PARAMS=y
|
CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y
|
||||||
CONFIG_MCUMGR_SMP_WORKQUEUE_STACK_SIZE=4608
|
CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4608
|
||||||
|
|
||||||
# Enable the LittleFS file system.
|
# Enable the LittleFS file system.
|
||||||
CONFIG_FILE_SYSTEM=y
|
CONFIG_FILE_SYSTEM=y
|
||||||
CONFIG_FILE_SYSTEM_LITTLEFS=y
|
CONFIG_FILE_SYSTEM_LITTLEFS=y
|
||||||
|
|
||||||
# Enable file system commands
|
# Enable file system commands
|
||||||
CONFIG_MCUMGR_CMD_FS_MGMT=y
|
CONFIG_MCUMGR_GRP_FS=y
|
||||||
|
|
||||||
# Enable the storage erase command.
|
# Enable the storage erase command.
|
||||||
CONFIG_MCUMGR_GRP_ZEPHYR_BASIC=y
|
CONFIG_MCUMGR_GRP_ZBASIC=y
|
||||||
CONFIG_MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE=y
|
CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE=y
|
||||||
|
|
||||||
# Disable Bluetooth ping support
|
# Disable Bluetooth ping support
|
||||||
CONFIG_BT_CTLR_LE_PING=n
|
CONFIG_BT_CTLR_LE_PING=n
|
||||||
|
|
|
@ -3,4 +3,4 @@ CONFIG_USB_DEVICE_STACK=y
|
||||||
CONFIG_SERIAL=y
|
CONFIG_SERIAL=y
|
||||||
CONFIG_UART_LINE_CTRL=y
|
CONFIG_UART_LINE_CTRL=y
|
||||||
# USB backend is serial device
|
# USB backend is serial device
|
||||||
CONFIG_MCUMGR_SMP_UART=y
|
CONFIG_MCUMGR_TRANSPORT_UART=y
|
||||||
|
|
|
@ -6,4 +6,4 @@ CONFIG_FILE_SYSTEM_LITTLEFS=y
|
||||||
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
|
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
|
||||||
|
|
||||||
# Enable file system commands
|
# Enable file system commands
|
||||||
CONFIG_MCUMGR_CMD_FS_MGMT=y
|
CONFIG_MCUMGR_GRP_FS=y
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
# Enable the serial mcumgr transport.
|
# Enable the serial mcumgr transport.
|
||||||
CONFIG_MCUMGR_SMP_UART=y
|
CONFIG_MCUMGR_TRANSPORT_UART=y
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Enable shell commands.
|
# Enable shell commands.
|
||||||
CONFIG_SHELL=y
|
CONFIG_SHELL=y
|
||||||
CONFIG_SHELL_BACKEND_SERIAL=n
|
CONFIG_SHELL_BACKEND_SERIAL=n
|
||||||
CONFIG_MCUMGR_CMD_SHELL_MGMT=y
|
CONFIG_MCUMGR_GRP_SHELL=y
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Enable the shell mcumgr transport.
|
# Enable the shell mcumgr transport.
|
||||||
CONFIG_MCUMGR_SMP_SHELL=y
|
CONFIG_MCUMGR_TRANSPORT_SHELL=y
|
||||||
|
|
||||||
# mcumgr-cli application doesn't accepts log in the channel it uses
|
# mcumgr-cli application doesn't accepts log in the channel it uses
|
||||||
CONFIG_SHELL_LOG_BACKEND=n
|
CONFIG_SHELL_LOG_BACKEND=n
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Enable the UDP mcumgr transports.
|
# Enable the UDP mcumgr transports.
|
||||||
CONFIG_MCUMGR_SMP_UDP=y
|
CONFIG_MCUMGR_TRANSPORT_UDP=y
|
||||||
CONFIG_MCUMGR_SMP_UDP_IPV4=y
|
CONFIG_MCUMGR_TRANSPORT_UDP_IPV4=y
|
||||||
CONFIG_MCUMGR_SMP_UDP_IPV6=y
|
CONFIG_MCUMGR_TRANSPORT_UDP_IPV6=y
|
||||||
|
|
||||||
# Network settings
|
# Network settings
|
||||||
CONFIG_NETWORKING=y
|
CONFIG_NETWORKING=y
|
||||||
|
|
|
@ -15,16 +15,16 @@ CONFIG_FLASH=y
|
||||||
CONFIG_THREAD_MONITOR=y
|
CONFIG_THREAD_MONITOR=y
|
||||||
|
|
||||||
# Support for taskstat command
|
# Support for taskstat command
|
||||||
CONFIG_OS_MGMT_TASKSTAT=y
|
CONFIG_MCUMGR_GRP_OS_TASKSTAT=y
|
||||||
|
|
||||||
# Enable statistics and statistic names.
|
# Enable statistics and statistic names.
|
||||||
CONFIG_STATS=y
|
CONFIG_STATS=y
|
||||||
CONFIG_STATS_NAMES=y
|
CONFIG_STATS_NAMES=y
|
||||||
|
|
||||||
# Enable most core commands.
|
# Enable most core commands.
|
||||||
CONFIG_MCUMGR_CMD_IMG_MGMT=y
|
CONFIG_MCUMGR_GRP_IMG=y
|
||||||
CONFIG_MCUMGR_CMD_OS_MGMT=y
|
CONFIG_MCUMGR_GRP_OS=y
|
||||||
CONFIG_MCUMGR_CMD_STAT_MGMT=y
|
CONFIG_MCUMGR_GRP_STAT=y
|
||||||
|
|
||||||
# Enable logging
|
# Enable logging
|
||||||
CONFIG_LOG=y
|
CONFIG_LOG=y
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
#include <zephyr/stats/stats.h>
|
#include <zephyr/stats/stats.h>
|
||||||
#include <zephyr/usb/usb_device.h>
|
#include <zephyr/usb/usb_device.h>
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_CMD_FS_MGMT
|
#ifdef CONFIG_MCUMGR_GRP_FS
|
||||||
#include <zephyr/device.h>
|
#include <zephyr/device.h>
|
||||||
#include <zephyr/fs/fs.h>
|
#include <zephyr/fs/fs.h>
|
||||||
#include <zephyr/fs/littlefs.h>
|
#include <zephyr/fs/littlefs.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_MCUMGR_CMD_STAT_MGMT
|
#ifdef CONFIG_MCUMGR_GRP_STAT
|
||||||
#include <zephyr/mgmt/mcumgr/grp/stat_mgmt/stat_mgmt.h>
|
#include <zephyr/mgmt/mcumgr/grp/stat_mgmt/stat_mgmt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ STATS_NAME_END(smp_svr_stats);
|
||||||
/* Define an instance of the stats group. */
|
/* Define an instance of the stats group. */
|
||||||
STATS_SECT_DECL(smp_svr_stats) smp_svr_stats;
|
STATS_SECT_DECL(smp_svr_stats) smp_svr_stats;
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_CMD_FS_MGMT
|
#ifdef CONFIG_MCUMGR_GRP_FS
|
||||||
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
|
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
|
||||||
static struct fs_mount_t littlefs_mnt = {
|
static struct fs_mount_t littlefs_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
|
@ -60,13 +60,13 @@ void main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register the built-in mcumgr command handlers. */
|
/* Register the built-in mcumgr command handlers. */
|
||||||
#ifdef CONFIG_MCUMGR_CMD_FS_MGMT
|
#ifdef CONFIG_MCUMGR_GRP_FS
|
||||||
rc = fs_mount(&littlefs_mnt);
|
rc = fs_mount(&littlefs_mnt);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
LOG_ERR("Error mounting littlefs [%d]", rc);
|
LOG_ERR("Error mounting littlefs [%d]", rc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_MCUMGR_SMP_BT
|
#ifdef CONFIG_MCUMGR_TRANSPORT_BT
|
||||||
start_smp_bluetooth_adverts();
|
start_smp_bluetooth_adverts();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Copyright Runtime.io 2018. All rights reserved.
|
# 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
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR
|
menuconfig MCUMGR
|
||||||
|
@ -16,21 +16,21 @@ module = MCUMGR
|
||||||
module-str = mcumgr
|
module-str = mcumgr
|
||||||
source "subsys/logging/Kconfig.template.log_config"
|
source "subsys/logging/Kconfig.template.log_config"
|
||||||
|
|
||||||
config MCUMGR_SMP_WORKQUEUE_STACK_SIZE
|
config MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE
|
||||||
int "MCUMGR SMP workqueue stack size"
|
int "MCUmgr transport workqueue stack size"
|
||||||
default 2048
|
default 2048
|
||||||
help
|
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
|
config MCUMGR_TRANSPORT_WORKQUEUE_THREAD_PRIO
|
||||||
int "MCUMGR SMP workqueue thread priority"
|
int "MCUmgr transport workqueue thread priority"
|
||||||
default 3
|
default 3
|
||||||
help
|
help
|
||||||
Scheduling priority of the MCUMGR SMP work queue.
|
Scheduling priority of the MCUmgr transport subsystem work queue.
|
||||||
|
|
||||||
rsource "mgmt/Kconfig"
|
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"
|
int "Number of predicted maximum entries to main response map"
|
||||||
default 15
|
default 15
|
||||||
help
|
help
|
||||||
|
@ -45,42 +45,42 @@ config MGMT_MAX_MAIN_MAP_ENTRIES
|
||||||
encapsulating them, you may want to increase this value
|
encapsulating them, you may want to increase this value
|
||||||
in case when encoding starts to fail.
|
in case when encoding starts to fail.
|
||||||
|
|
||||||
config MGMT_MIN_DECODING_LEVELS
|
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS
|
||||||
int
|
int
|
||||||
help
|
help
|
||||||
Minimal decoding levels, map/list encapsulation, required
|
Minimal decoding levels, map/list encapsulation, required
|
||||||
to be supported by zcbor decoding of SMP responses
|
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
|
A group or command that adds additional maps/lists above the
|
||||||
base map, which is already taken into account, should
|
base map, which is already taken into account, should
|
||||||
select one of the MGMT_MIN_DECODING_LEVEL_?.
|
select one of the MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_?.
|
||||||
default 5 if MGMT_MIN_DECODING_LEVEL_5
|
default 5 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_5
|
||||||
default 4 if MGMT_MIN_DECODING_LEVEL_4
|
default 4 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_4
|
||||||
default 3 if MGMT_MIN_DECODING_LEVEL_3
|
default 3 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_3
|
||||||
default 2 if MGMT_MIN_DECODING_LEVEL_2
|
default 2 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
|
||||||
default 1 if MGMT_MIN_DECODING_LEVEL_1
|
default 1 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_1
|
||||||
default 0
|
default 0
|
||||||
|
|
||||||
|
|
||||||
config MGMT_MIN_DECODING_LEVEL_1
|
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_1
|
||||||
bool
|
bool
|
||||||
|
|
||||||
config MGMT_MIN_DECODING_LEVEL_2
|
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
|
||||||
bool
|
bool
|
||||||
|
|
||||||
config MGMT_MIN_DECODING_LEVEL_3
|
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_3
|
||||||
bool
|
bool
|
||||||
|
|
||||||
config MGMT_MIN_DECODING_LEVEL_4
|
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_4
|
||||||
bool
|
bool
|
||||||
|
|
||||||
config MGMT_MIN_DECODING_LEVEL_5
|
config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_5
|
||||||
bool
|
bool
|
||||||
|
|
||||||
config MGMT_MAX_DECODING_LEVELS
|
config MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS
|
||||||
int "Number of map/list encapsulations allowed by SMP encoding"
|
int "Number of map/list encapsulations allowed by SMP encoding"
|
||||||
range MGMT_MIN_DECODING_LEVELS 15
|
range MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS 15
|
||||||
default MGMT_MIN_DECODING_LEVELS
|
default MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS
|
||||||
help
|
help
|
||||||
This is a maximum number of levels of maps/lists that will
|
This is a maximum number of levels of maps/lists that will
|
||||||
be expected to be decoded within different command groups.
|
be expected to be decoded within different command groups.
|
||||||
|
@ -142,8 +142,8 @@ rsource "transport/Kconfig"
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
module = MCUMGR_SMP
|
module = MCUMGR_TRANSPORT
|
||||||
module-str = mcumgr_smp
|
module-str = mcumgr_transport
|
||||||
source "subsys/logging/Kconfig.template.log_config"
|
source "subsys/logging/Kconfig.template.log_config"
|
||||||
|
|
||||||
endif # MCUMGR
|
endif # MCUMGR
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
|
||||||
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_FS_MGMT fs_mgmt)
|
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_FS fs_mgmt)
|
||||||
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_IMG_MGMT img_mgmt)
|
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_IMG img_mgmt)
|
||||||
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_OS_MGMT os_mgmt)
|
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_OS os_mgmt)
|
||||||
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_STAT_MGMT stat_mgmt)
|
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_STAT stat_mgmt)
|
||||||
add_subdirectory_ifdef(CONFIG_MCUMGR_CMD_SHELL_MGMT shell_mgmt)
|
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_SHELL shell_mgmt)
|
||||||
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_ZEPHYR_BASIC zephyr_basic)
|
add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_ZBASIC zephyr_basic)
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
# interface, when File System management is enabled.
|
# interface, when File System management is enabled.
|
||||||
zephyr_library(mgmt_mcumgr_grp_fs)
|
zephyr_library(mgmt_mcumgr_grp_fs)
|
||||||
zephyr_library_sources(src/fs_mgmt.c)
|
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_MCUMGR_GRP_FS_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_MCUMGR_GRP_FS_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_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)
|
if (NOT CONFIG_TINYCRYPT)
|
||||||
zephyr_library_link_libraries(mbedTLS)
|
zephyr_library_link_libraries(mbedTLS)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_CMD_FS_MGMT
|
menuconfig MCUMGR_GRP_FS
|
||||||
bool "Mcumgr handlers for file management (insecure)"
|
bool "Mcumgr handlers for file management (insecure)"
|
||||||
depends on FILE_SYSTEM
|
depends on FILE_SYSTEM
|
||||||
select MGMT_MIN_DECODING_LEVEL_2
|
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
|
||||||
help
|
help
|
||||||
Enables mcumgr handlers for file management
|
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
|
private keys. Use of this feature in production is strongly
|
||||||
discouraged.
|
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"
|
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
|
help
|
||||||
Maximum file size that will be allowed to be downloaded from
|
Maximum file size that will be allowed to be downloaded from
|
||||||
device.
|
device.
|
||||||
This option decides on number of bytes that are reserved in
|
This option decides on number of bytes that are reserved in
|
||||||
CBOR frame for storage of offset/size of file downloaded.
|
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"
|
bool "<= 64KB"
|
||||||
help
|
help
|
||||||
Files that have size up to 64KB require 1 to 3 bytes to encode
|
Files that have size up to 64KB require 1 to 3 bytes to encode
|
||||||
size/offset within CBOR frame with file chunk.
|
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"
|
bool "<= 4GB"
|
||||||
help
|
help
|
||||||
Files that have size up to 4GB require 1 to 5 bytes to encode
|
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
|
endchoice
|
||||||
|
|
||||||
config FS_MGMT_MAX_OFFSET_LEN
|
config MCUMGR_GRP_FS_MAX_OFFSET_LEN
|
||||||
int
|
int
|
||||||
default 3 if FS_MGMT_MAX_FILE_SIZE_64KB
|
default 3 if MCUMGR_GRP_FS_MAX_FILE_SIZE_64KB
|
||||||
default 5 if FS_MGMT_MAX_FILE_SIZE_4GB
|
default 5 if MCUMGR_GRP_FS_MAX_FILE_SIZE_4GB
|
||||||
help
|
help
|
||||||
Maximal byte length of encoded offset/size, within transferred
|
Maximal byte length of encoded offset/size, within transferred
|
||||||
CBOR frame containing chunk of downloaded file.
|
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.
|
as it selects sizes of fields within headers.
|
||||||
NOTE: This option is hidden intentionally as it is intended
|
NOTE: This option is hidden intentionally as it is intended
|
||||||
to be assigned from limited set of allowed values, depending on
|
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"
|
bool "Setting custom size of download file chunk"
|
||||||
help
|
help
|
||||||
By default file chunk, that will be read off storage and fit into
|
By default file chunk, that will be read off storage and fit into
|
||||||
mcumgr frame, is automatically calculated to fit into buffer
|
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
|
Enabling this option allows to set MAXIMUM value that will be
|
||||||
allowed for such chunk.
|
allowed for such chunk.
|
||||||
Look inside fs_mgmt_config.h for details.
|
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"
|
int "Maximum chunk size for file downloads"
|
||||||
range 65 MCUMGR_BUF_SIZE
|
range 65 MCUMGR_TRANSPORT_NETBUF_SIZE
|
||||||
default MCUMGR_BUF_SIZE
|
default MCUMGR_TRANSPORT_NETBUF_SIZE
|
||||||
help
|
help
|
||||||
Sets the MAXIMUM size of chunk which will be rounded down to
|
Sets the MAXIMUM size of chunk which will be rounded down to
|
||||||
number of bytes that, with all the required headers, will fit
|
number of bytes that, with all the required headers, will fit
|
||||||
into MCUMGR_BUF_SIZE. This means that actual value might be lower
|
into MCUMGR_TRANSPORT_NETBUF_SIZE. This means that actual value
|
||||||
then selected, in which case compiler warning will be issued.
|
might be lower then selected, in which case compiler warning will
|
||||||
Look inside fs_mgmt_config.h for details.
|
be issued. Look inside fs_mgmt_config.h for details.
|
||||||
Note that header sizes are affected by FS_MGMT_MAX_OFFSET_LEN.
|
Note that header sizes are affected by MCUMGR_GRP_FS_MAX_OFFSET_LEN.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config FS_MGMT_FILE_STATUS
|
config MCUMGR_GRP_FS_FILE_STATUS
|
||||||
bool "File status command"
|
bool "File status command"
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
This command allows a remote device to retrieve the status of a file,
|
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).
|
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"
|
bool "Checksum/hash mcumgr functions"
|
||||||
help
|
help
|
||||||
Enable this to support the hash/checksum mcumgr functionality,
|
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
|
Note that this requires enough stack space to buffer data
|
||||||
from the file being read and generate the output hash/checksum.
|
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"
|
int "Checksum calculation buffer size"
|
||||||
range 32 16384
|
range 32 16384
|
||||||
default 128
|
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
|
Chunk size of buffer to use when calculating file checksum or hash
|
||||||
(uses stack).
|
(uses stack).
|
||||||
|
|
||||||
config FS_MGMT_CHECKSUM_IEEE_CRC32
|
config MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32
|
||||||
bool "IEEE CRC32 checksum support"
|
bool "IEEE CRC32 checksum support"
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Enable IEEE CRC32 checksum support for mcumgr.
|
Enable IEEE CRC32 checksum support for mcumgr.
|
||||||
|
|
||||||
config FS_MGMT_HASH_SHA256
|
config MCUMGR_GRP_FS_HASH_SHA256
|
||||||
bool "SHA256 hash support"
|
bool "SHA256 hash support"
|
||||||
depends on TINYCRYPT_SHA256 || MBEDTLS_MAC_SHA256_ENABLED
|
depends on TINYCRYPT_SHA256 || MBEDTLS_MAC_SHA256_ENABLED
|
||||||
help
|
help
|
||||||
|
@ -132,7 +132,7 @@ config MCUMGR_GRP_FS_CHECKSUM_HASH_SUPPORTED_MAX_TYPES
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config FS_MGMT_PATH_SIZE
|
config MCUMGR_GRP_FS_PATH_LEN
|
||||||
int "Maximum file path length"
|
int "Maximum file path length"
|
||||||
default 64
|
default 64
|
||||||
help
|
help
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
#ifndef H_FS_MGMT_CONFIG_
|
#ifndef H_FS_MGMT_CONFIG_
|
||||||
#define H_FS_MGMT_CONFIG_
|
#define H_FS_MGMT_CONFIG_
|
||||||
|
|
||||||
/* File chunk needs to fit into the CONFIG_MCUMGR_BUF_SIZE with all required
|
/* File chunk needs to fit into the CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE with
|
||||||
* headers and other data fields. The following data reduces space available
|
* all required headers and other data fields. The following data reduces
|
||||||
* for file chunk in CONFIG_MCUMGR_BUF_SIZE:
|
* space available for file chunk in CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE:
|
||||||
* MGMT_HDR_SIZE - header that is placed in front of buffer and not
|
* MGMT_HDR_SIZE - header that is placed in front of buffer and not
|
||||||
* visible by CBOR encoder (see smp_handle_single_req);
|
* visible by CBOR encoder (see smp_handle_single_req);
|
||||||
* 9 + 1 -- bytes taken by marker of CBOR undefined length map and map
|
* 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
|
* 1 + strlen("off") + [1, N] -- CBOR encoded pair of "off" key and
|
||||||
* offset value of the chunk within the file;
|
* offset value of the chunk within the file;
|
||||||
* 1 + strlen("data") + [1, N] -- CBOR encoded "data" key and value
|
* 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("rc") + 1 -- status code of operation;
|
||||||
* 1 + strlen("len") + [1, N] -- CBOR encoded "len" marker and complete
|
* 1 + strlen("len") + [1, N] -- CBOR encoded "len" marker and complete
|
||||||
* length of a file; this is only sent once when "off" is 0;
|
* 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.
|
* where CBOR encoding of data takes longest form.
|
||||||
*/
|
*/
|
||||||
#define CBOR_AND_OTHER_HDR \
|
#define CBOR_AND_OTHER_HDR \
|
||||||
(MGMT_HDR_SIZE + \
|
(MGMT_HDR_SIZE + \
|
||||||
(9 + 1) + \
|
(9 + 1) + \
|
||||||
(1 + 3 + CONFIG_FS_MGMT_MAX_OFFSET_LEN) + \
|
(1 + 3 + CONFIG_MCUMGR_GRP_FS_MAX_OFFSET_LEN) + \
|
||||||
(1 + 4 + CONFIG_FS_MGMT_MAX_OFFSET_LEN) + \
|
(1 + 4 + CONFIG_MCUMGR_GRP_FS_MAX_OFFSET_LEN) + \
|
||||||
(1 + 2 + 1) + \
|
(1 + 2 + 1) + \
|
||||||
(1 + 3 + CONFIG_FS_MGMT_MAX_OFFSET_LEN))
|
(1 + 3 + CONFIG_MCUMGR_GRP_FS_MAX_OFFSET_LEN))
|
||||||
|
|
||||||
#if defined(CONFIG_FS_MGMT_DL_CHUNK_SIZE_LIMIT)
|
#if defined(CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE_LIMIT)
|
||||||
#if (CONFIG_FS_MGMT_DL_CHUNK_SIZE + CBOR_AND_OTHER_HDR) > CONFIG_MCUMGR_BUF_SIZE
|
#if (CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE + CBOR_AND_OTHER_HDR) > CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE
|
||||||
#warning FS_MGMT_DL_CHUNK_SIZE too big, rounding it down.
|
#warning CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE too big, rounding it down.
|
||||||
#else
|
#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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(FS_MGMT_DL_CHUNK_SIZE)
|
#if !defined(MCUMGR_GRP_FS_DL_CHUNK_SIZE)
|
||||||
#define FS_MGMT_DL_CHUNK_SIZE (CONFIG_MCUMGR_BUF_SIZE - CBOR_AND_OTHER_HDR)
|
#define MCUMGR_GRP_FS_DL_CHUNK_SIZE (CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE - CBOR_AND_OTHER_HDR)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
#include <mgmt/mcumgr/util/zcbor_bulk.h>
|
#include <mgmt/mcumgr/util/zcbor_bulk.h>
|
||||||
#include <mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_config.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>
|
#include <mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_hash_checksum_crc32.h>
|
||||||
#endif
|
#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>
|
#include <mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_hash_checksum_sha256.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -37,21 +37,21 @@
|
||||||
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
|
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_FS_MGMT_CHECKSUM_HASH
|
#ifdef CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH
|
||||||
/* Define default hash/checksum */
|
/* Define default hash/checksum */
|
||||||
#if defined(CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32)
|
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32)
|
||||||
#define FS_MGMT_CHECKSUM_HASH_DEFAULT "crc32"
|
#define MCUMGR_GRP_FS_CHECKSUM_HASH_DEFAULT "crc32"
|
||||||
#elif defined(CONFIG_FS_MGMT_HASH_SHA256)
|
#elif defined(CONFIG_MCUMGR_GRP_FS_HASH_SHA256)
|
||||||
#define FS_MGMT_CHECKSUM_HASH_DEFAULT "sha256"
|
#define MCUMGR_GRP_FS_CHECKSUM_HASH_DEFAULT "sha256"
|
||||||
#else
|
#else
|
||||||
#error "Missing mcumgr fs checksum/hash algorithm selection?"
|
#error "Missing mcumgr fs checksum/hash algorithm selection?"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define largest hach/checksum output size (bytes) */
|
/* Define largest hach/checksum output size (bytes) */
|
||||||
#if defined(CONFIG_FS_MGMT_HASH_SHA256)
|
#if defined(CONFIG_MCUMGR_GRP_FS_HASH_SHA256)
|
||||||
#define FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE 32
|
#define MCUMGR_GRP_FS_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE 32
|
||||||
#elif defined(CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32)
|
#elif defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32)
|
||||||
#define FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE 4
|
#define MCUMGR_GRP_FS_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE 4
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ static struct {
|
||||||
|
|
||||||
static const struct mgmt_handler fs_mgmt_handlers[];
|
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 */
|
/* Hash/checksum iterator information passing structure */
|
||||||
struct fs_mgmt_hash_checksum_iterator_info {
|
struct fs_mgmt_hash_checksum_iterator_info {
|
||||||
zcbor_state_t *zse;
|
zcbor_state_t *zse;
|
||||||
|
@ -164,8 +164,8 @@ done:
|
||||||
*/
|
*/
|
||||||
static int fs_mgmt_file_download(struct smp_streamer *ctxt)
|
static int fs_mgmt_file_download(struct smp_streamer *ctxt)
|
||||||
{
|
{
|
||||||
uint8_t file_data[FS_MGMT_DL_CHUNK_SIZE];
|
uint8_t file_data[MCUMGR_GRP_FS_DL_CHUNK_SIZE];
|
||||||
char path[CONFIG_FS_MGMT_PATH_SIZE + 1];
|
char path[CONFIG_MCUMGR_GRP_FS_PATH_LEN + 1];
|
||||||
uint64_t off = ULLONG_MAX;
|
uint64_t off = ULLONG_MAX;
|
||||||
size_t bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
size_t file_len;
|
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. */
|
/* 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) {
|
if (rc != 0) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ done:
|
||||||
*/
|
*/
|
||||||
static int fs_mgmt_file_upload(struct smp_streamer *ctxt)
|
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 len = ULLONG_MAX;
|
||||||
unsigned long long off = ULLONG_MAX;
|
unsigned long long off = ULLONG_MAX;
|
||||||
size_t new_off;
|
size_t new_off;
|
||||||
|
@ -394,13 +394,13 @@ static int fs_mgmt_file_upload(struct smp_streamer *ctxt)
|
||||||
MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE;
|
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)
|
* Command handler: fs stat (read)
|
||||||
*/
|
*/
|
||||||
static int fs_mgmt_file_status(struct smp_streamer *ctxt)
|
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;
|
size_t file_len;
|
||||||
int rc;
|
int rc;
|
||||||
zcbor_state_t *zse = ctxt->writer->zs;
|
zcbor_state_t *zse = ctxt->writer->zs;
|
||||||
|
@ -448,15 +448,15 @@ static int fs_mgmt_file_status(struct smp_streamer *ctxt)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_FS_MGMT_CHECKSUM_HASH)
|
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH)
|
||||||
/**
|
/**
|
||||||
* Command handler: fs hash/checksum (read)
|
* Command handler: fs hash/checksum (read)
|
||||||
*/
|
*/
|
||||||
static int fs_mgmt_file_hash_checksum(struct smp_streamer *ctxt)
|
static int fs_mgmt_file_hash_checksum(struct smp_streamer *ctxt)
|
||||||
{
|
{
|
||||||
char path[CONFIG_FS_MGMT_PATH_SIZE + 1];
|
char path[CONFIG_MCUMGR_GRP_FS_PATH_LEN + 1];
|
||||||
char type_arr[HASH_CHECKSUM_TYPE_SIZE + 1] = FS_MGMT_CHECKSUM_HASH_DEFAULT;
|
char type_arr[HASH_CHECKSUM_TYPE_SIZE + 1] = MCUMGR_GRP_FS_CHECKSUM_HASH_DEFAULT;
|
||||||
char output[FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE];
|
char output[MCUMGR_GRP_FS_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE];
|
||||||
uint64_t len = ULLONG_MAX;
|
uint64_t len = ULLONG_MAX;
|
||||||
uint64_t off = 0;
|
uint64_t off = 0;
|
||||||
size_t file_len;
|
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)) {
|
if (group->output_size == sizeof(uint8_t)) {
|
||||||
tmp_val = (uint64_t)(*(uint8_t *)output);
|
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)) {
|
} else if (group->output_size == sizeof(uint16_t)) {
|
||||||
tmp_val = (uint64_t)(*(uint16_t *)output);
|
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)) {
|
} else if (group->output_size == sizeof(uint32_t)) {
|
||||||
tmp_val = (uint64_t)(*(uint32_t *)output);
|
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)) {
|
} else if (group->output_size == sizeof(uint64_t)) {
|
||||||
tmp_val = (*(uint64_t *)output);
|
tmp_val = (*(uint64_t *)output);
|
||||||
#endif
|
#endif
|
||||||
|
@ -646,13 +646,13 @@ static const struct mgmt_handler fs_mgmt_handlers[] = {
|
||||||
.mh_read = fs_mgmt_file_download,
|
.mh_read = fs_mgmt_file_download,
|
||||||
.mh_write = fs_mgmt_file_upload,
|
.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] = {
|
[FS_MGMT_ID_STAT] = {
|
||||||
.mh_read = fs_mgmt_file_status,
|
.mh_read = fs_mgmt_file_status,
|
||||||
.mh_write = NULL,
|
.mh_write = NULL,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_FS_MGMT_CHECKSUM_HASH)
|
#if defined(CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH)
|
||||||
[FS_MGMT_ID_HASH_CHECKSUM] = {
|
[FS_MGMT_ID_HASH_CHECKSUM] = {
|
||||||
.mh_read = fs_mgmt_file_hash_checksum,
|
.mh_read = fs_mgmt_file_hash_checksum,
|
||||||
.mh_write = NULL,
|
.mh_write = NULL,
|
||||||
|
@ -678,13 +678,13 @@ static void fs_mgmt_register_group(void)
|
||||||
{
|
{
|
||||||
mgmt_register_group(&fs_mgmt_group);
|
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 */
|
/* 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();
|
fs_mgmt_hash_checksum_register_crc32();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_FS_MGMT_HASH_SHA256)
|
#if defined(CONFIG_MCUMGR_GRP_FS_HASH_SHA256)
|
||||||
fs_mgmt_hash_checksum_register_sha256();
|
fs_mgmt_hash_checksum_register_sha256();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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)
|
size_t *out_len, size_t len)
|
||||||
{
|
{
|
||||||
/* Calculate IEEE CRC32 checksum of target file */
|
/* 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;
|
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;
|
uint32_t crc32 = 0;
|
||||||
|
|
||||||
/* Clear length prior to calculation */
|
/* Clear length prior to calculation */
|
||||||
|
|
|
@ -30,8 +30,8 @@ static int fs_mgmt_hash_checksum_sha256(struct fs_file_t *file, uint8_t *output,
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
ssize_t bytes_read = 0;
|
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;
|
||||||
uint8_t buffer[CONFIG_FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE];
|
uint8_t buffer[CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_CHUNK_SIZE];
|
||||||
struct tc_sha256_state_struct sha;
|
struct tc_sha256_state_struct sha;
|
||||||
|
|
||||||
/* Clear variables prior to calculation */
|
/* 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;
|
int rc = 0;
|
||||||
ssize_t bytes_read = 0;
|
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;
|
||||||
uint8_t buffer[CONFIG_FS_MGMT_CHECKSUM_HASH_CHUNK_SIZE];
|
uint8_t buffer[CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_CHUNK_SIZE];
|
||||||
mbedtls_md_context_t mbed_hash_ctx;
|
mbedtls_md_context_t mbed_hash_ctx;
|
||||||
const mbedtls_md_info_t *mbed_hash_info;
|
const mbedtls_md_info_t *mbed_hash_info;
|
||||||
|
|
||||||
|
|
|
@ -2,23 +2,23 @@
|
||||||
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_CMD_IMG_MGMT
|
menuconfig MCUMGR_GRP_IMG
|
||||||
bool "Mcumgr handlers for image management"
|
bool "Mcumgr handlers for image management"
|
||||||
select FLASH
|
select FLASH
|
||||||
select MPU_ALLOW_FLASH_WRITE if ARM_MPU
|
select MPU_ALLOW_FLASH_WRITE if ARM_MPU
|
||||||
select IMG_MANAGER
|
select IMG_MANAGER
|
||||||
select MGMT_MIN_DECODING_LEVEL_2
|
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
|
||||||
help
|
help
|
||||||
Enables mcumgr handlers for image management
|
Enables mcumgr handlers for image management
|
||||||
|
|
||||||
if MCUMGR_CMD_IMG_MGMT
|
if MCUMGR_GRP_IMG
|
||||||
|
|
||||||
if HEAP_MEM_POOL_SIZE > 0
|
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"
|
bool "Use heap mem pool for flash image DFU context"
|
||||||
help
|
help
|
||||||
Use heap to allocate flash image upload context, otherwise a static variable will
|
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
|
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
|
the CONFIG_IMG_BLOCK_BUF_SIZE size and additional fields that hold the state information
|
||||||
(struct flash_img_context).
|
(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.
|
operation, an issue that should also be addressed within application.
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config IMG_MGMT_UPDATABLE_IMAGE_NUMBER
|
config MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER
|
||||||
int "Number of supported images"
|
int "Number of supported images"
|
||||||
default UPDATEABLE_IMAGE_NUMBER
|
default UPDATEABLE_IMAGE_NUMBER
|
||||||
range 1 2
|
range 1 2
|
||||||
help
|
help
|
||||||
Sets how many application images are supported (pairs of secondary and primary slots).
|
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,
|
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
|
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
|
boot_util and the UPDATEABLE_IMAGE_NUMBER controls number of images supported
|
||||||
by that library.
|
by that library.
|
||||||
|
|
||||||
config IMG_MGMT_VERBOSE_ERR
|
config MCUMGR_GRP_IMG_VERBOSE_ERR
|
||||||
bool "Verbose error responses when uploading application image"
|
bool "Verbose error responses when uploading application image"
|
||||||
select MGMT_VERBOSE_ERR_RESPONSE
|
select MCUMGR_SMP_VERBOSE_ERR_RESPONSE
|
||||||
help
|
help
|
||||||
Add additional "rsn" key to SMP responses, where provided, explaining
|
Add additional "rsn" key to SMP responses, where provided, explaining
|
||||||
non-0 "rc" codes.
|
non-0 "rc" codes.
|
||||||
|
|
||||||
config IMG_MGMT_DUMMY_HDR
|
config MCUMGR_GRP_IMG_DUMMY_HDR
|
||||||
bool "Return dummy image header data for imgr functions"
|
bool "Return dummy image header data for imgr functions"
|
||||||
help
|
help
|
||||||
Returns dummy image header data for imgr functions,
|
Returns dummy image header data for imgr functions,
|
||||||
useful when there are no images present, Eg: unit tests.
|
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"
|
bool "Allow direct image upload"
|
||||||
help
|
help
|
||||||
Enables directly uploading image to selected image partition.
|
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
|
behaviour is, when image is not selected, to upload to image that represents secondary
|
||||||
slot in normal operation.
|
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"
|
bool "Reject Direct-XIP applications with mismatched address"
|
||||||
help
|
help
|
||||||
When enabled, the mcumgr will compare base address of application,
|
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,
|
The base address can be set, to an image binary header, with imgtool,
|
||||||
using the --rom-fixed command line option.
|
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"
|
bool "Omit zero, empty or false values from status list"
|
||||||
help
|
help
|
||||||
The status list send back from the device will only be filled with data that is non-zero,
|
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
|
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.
|
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
|
module-str = mcumgr_img_mgmt
|
||||||
source "subsys/logging/Kconfig.template.log_config"
|
source "subsys/logging/Kconfig.template.log_config"
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <zephyr/logging/log.h>
|
#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;
|
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_app_reject = "app reject";
|
||||||
const char *img_mgmt_err_str_hdr_malformed = "header malformed";
|
const char *img_mgmt_err_str_hdr_malformed = "header malformed";
|
||||||
const char *img_mgmt_err_str_magic_mismatch = "magic mismatch";
|
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)
|
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,
|
uint8_t dummy_hash[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x00, 0x11, 0x22,
|
||||||
0x33, 0x44, 0x55, 0x66, 0x77};
|
0x33, 0x44, 0x55, 0x66, 0x77};
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ img_mgmt_find_by_ver(struct image_version *find, uint8_t *hash)
|
||||||
int i;
|
int i;
|
||||||
struct image_version ver;
|
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) {
|
if (img_mgmt_read_info(i, &ver, hash, NULL) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ img_mgmt_find_by_hash(uint8_t *find, struct image_version *ver)
|
||||||
int i;
|
int i;
|
||||||
uint8_t hash[IMAGE_HASH_LEN];
|
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) {
|
if (img_mgmt_read_info(i, ver, hash, NULL) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
#define MAX_IMG_CHARACTERISTICS 15
|
#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) \
|
#define ZCBOR_ENCODE_FLAG(zse, label, value) \
|
||||||
(zcbor_tstr_put_lit(zse, label) && zcbor_bool_put(zse, value))
|
(zcbor_tstr_put_lit(zse, label) && zcbor_bool_put(zse, value))
|
||||||
#else
|
#else
|
||||||
|
@ -216,9 +216,9 @@ img_mgmt_state_read(struct smp_streamer *ctxt)
|
||||||
struct zcbor_string zhash = { .value = hash, .len = IMAGE_HASH_LEN };
|
struct zcbor_string zhash = { .value = hash, .len = IMAGE_HASH_LEN };
|
||||||
|
|
||||||
ok = zcbor_tstr_put_lit(zse, "images") &&
|
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);
|
int rc = img_mgmt_read_info(i, &ver, hash, &flags);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -227,7 +227,7 @@ img_mgmt_state_read(struct smp_streamer *ctxt)
|
||||||
state_flags = img_mgmt_state_flags(i);
|
state_flags = img_mgmt_state_flags(i);
|
||||||
|
|
||||||
ok = zcbor_map_start_encode(zse, MAX_IMG_CHARACTERISTICS) &&
|
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_tstr_put_lit(zse, "image") &&
|
||||||
zcbor_int32_put(zse, i >> 1))) &&
|
zcbor_int32_put(zse, i >> 1))) &&
|
||||||
zcbor_tstr_put_lit(zse, "slot") &&
|
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);
|
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 */
|
/* 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") &&
|
ok = zcbor_tstr_put_lit(zse, "splitStatus") &&
|
||||||
zcbor_int32_put(zse, 0);
|
zcbor_int32_put(zse, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zephyr/logging/log.h>
|
#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/kernel.h>
|
||||||
#include <zephyr/init.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 SLOT2_PARTITION slot2_partition
|
||||||
#define SLOT3_PARTITION slot3_partition
|
#define SLOT3_PARTITION slot3_partition
|
||||||
|
|
||||||
BUILD_ASSERT(CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 1 ||
|
BUILD_ASSERT(CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 1 ||
|
||||||
(CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 2 &&
|
(CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 2 &&
|
||||||
FIXED_PARTITION_EXISTS(SLOT2_PARTITION) &&
|
FIXED_PARTITION_EXISTS(SLOT2_PARTITION) &&
|
||||||
FIXED_PARTITION_EXISTS(SLOT3_PARTITION)),
|
FIXED_PARTITION_EXISTS(SLOT3_PARTITION)),
|
||||||
"Missing partitions?");
|
"Missing partitions?");
|
||||||
|
@ -161,12 +161,12 @@ img_mgmt_flash_area_id(int slot)
|
||||||
return fa_id;
|
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 normal operation this function will select between first two slot
|
||||||
* (in reality it just checks whether second slot can be used), ignoring the
|
* (in reality it just checks whether second slot can be used), ignoring the
|
||||||
* slot parameter.
|
* 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
|
* 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
|
* 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
|
* 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
|
static int
|
||||||
img_mgmt_get_unused_slot_area_id(int slot)
|
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--;
|
slot--;
|
||||||
if (slot < -1) {
|
if (slot < -1) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -197,7 +197,7 @@ img_mgmt_get_unused_slot_area_id(int slot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
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
|
* 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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 2
|
#elif CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 2
|
||||||
static int
|
static int
|
||||||
img_mgmt_get_unused_slot_area_id(int image)
|
img_mgmt_get_unused_slot_area_id(int image)
|
||||||
{
|
{
|
||||||
|
@ -291,7 +291,7 @@ img_mgmt_write_pending(int slot, bool permanent)
|
||||||
{
|
{
|
||||||
int rc;
|
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;
|
return MGMT_ERR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ img_mgmt_read(int slot, unsigned int offset, void *dst, unsigned int num_bytes)
|
||||||
return 0;
|
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
|
int
|
||||||
img_mgmt_write_image_data(unsigned int offset, const void *data, unsigned int num_bytes, bool last)
|
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;
|
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) {
|
if (hdr->ih_flags & IMAGE_F_ROM_FIXED_ADDR) {
|
||||||
rc = flash_area_open(action->area_id, &fa);
|
rc = flash_area_open(action->area_id, &fa);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_CMD_OS_MGMT
|
menuconfig MCUMGR_GRP_OS
|
||||||
bool "Mcumgr handlers for OS management"
|
bool "Mcumgr handlers for OS management"
|
||||||
select REBOOT
|
select REBOOT
|
||||||
help
|
help
|
||||||
Enables mcumgr handlers for OS management
|
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)"
|
int "Delay before executing reset command (ms)"
|
||||||
default 250
|
default 250
|
||||||
depends on REBOOT
|
depends on REBOOT
|
||||||
|
@ -19,7 +19,7 @@ config OS_MGMT_RESET_MS
|
||||||
before performing the reset. This delay allows time for the mcumgr
|
before performing the reset. This delay allows time for the mcumgr
|
||||||
response to be delivered.
|
response to be delivered.
|
||||||
|
|
||||||
config MCUMGR_GRP_OS_OS_RESET_HOOK
|
config MCUMGR_GRP_OS_RESET_HOOK
|
||||||
bool "Reset hook"
|
bool "Reset hook"
|
||||||
depends on REBOOT
|
depends on REBOOT
|
||||||
depends on MCUMGR_MGMT_NOTIFICATION_HOOKS
|
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
|
and will allow the application to perform any required operations
|
||||||
before accepting or declining the reset request.
|
before accepting or declining the reset request.
|
||||||
|
|
||||||
config OS_MGMT_TASKSTAT
|
config MCUMGR_GRP_OS_TASKSTAT
|
||||||
bool "Support for taskstat command"
|
bool "Support for taskstat command"
|
||||||
depends on THREAD_MONITOR
|
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"
|
bool "Send only data gathered by Zephyr"
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
|
@ -48,27 +48,27 @@ config OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS
|
||||||
map entries for each listed task.
|
map entries for each listed task.
|
||||||
Enabling this option will slightly reduce code size.
|
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"
|
prompt "Characteristic used as thread name in taskstat"
|
||||||
default OS_MGMT_TASKSTAT_USE_THREAD_NAME_FOR_NAME if THREAD_NAME
|
default MCUMGR_GRP_OS_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_PRIO_FOR_NAME
|
||||||
help
|
help
|
||||||
Select what will serve as thread name in "taskstat" response.
|
Select what will serve as thread name in "taskstat" response.
|
||||||
By default taskstat responses use thread priority, when THREAD_NAME is disabled,
|
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"
|
bool "Thread name"
|
||||||
depends on 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"
|
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"
|
bool "Thread priority"
|
||||||
|
|
||||||
endchoice
|
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"
|
int "Predicted maximum number of threads to return on taskstat list"
|
||||||
default 50
|
default 50
|
||||||
help
|
help
|
||||||
|
@ -76,7 +76,7 @@ config OS_MGMT_TASKSTAT_MAX_NUM_THREADS
|
||||||
The value does not affect memory allocation, it is used by zcbor
|
The value does not affect memory allocation, it is used by zcbor
|
||||||
to figure out how to encode map depending on its predicted size.
|
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"
|
int "Length of thread name to return in response"
|
||||||
default THREAD_MAX_NAME_LEN if THREAD_NAME
|
default THREAD_MAX_NAME_LEN if THREAD_NAME
|
||||||
default 5 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 '-'
|
in such case this value should also take into account possible '-'
|
||||||
sign.
|
sign.
|
||||||
|
|
||||||
config OS_MGMT_TASKSTAT_SIGNED_PRIORITY
|
config MCUMGR_GRP_OS_TASKSTAT_SIGNED_PRIORITY
|
||||||
bool "Signed priorities"
|
bool "Signed priorities"
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
|
@ -101,7 +101,7 @@ config OS_MGMT_TASKSTAT_SIGNED_PRIORITY
|
||||||
Disable this option if your client software is unable to properly decode and
|
Disable this option if your client software is unable to properly decode and
|
||||||
accept signed integers as priorities.
|
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"
|
bool "Include stack info in taskstat responses"
|
||||||
depends on THREAD_STACK_INFO
|
depends on THREAD_STACK_INFO
|
||||||
help
|
help
|
||||||
|
@ -115,12 +115,12 @@ config OS_MGMT_TASKSTAT_STACK_INFO
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config OS_MGMT_ECHO
|
config MCUMGR_GRP_OS_ECHO
|
||||||
bool "Support for echo command"
|
bool "Support for echo command"
|
||||||
default y
|
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"
|
bool "MCUMGR Parameters retrieval command"
|
||||||
|
|
||||||
config MCUMGR_GRP_OS_INFO
|
config MCUMGR_GRP_OS_INFO
|
||||||
|
|
|
@ -58,7 +58,7 @@ static K_TIMER_DEFINE(os_mgmt_reset_timer, os_mgmt_reset_cb, NULL);
|
||||||
*/
|
*/
|
||||||
#define TASKSTAT_COLUMNS_MAX 20
|
#define TASKSTAT_COLUMNS_MAX 20
|
||||||
|
|
||||||
#ifdef CONFIG_OS_MGMT_TASKSTAT
|
#ifdef CONFIG_MCUMGR_GRP_OS_TASKSTAT
|
||||||
/* Thread iterator information passing structure */
|
/* Thread iterator information passing structure */
|
||||||
struct thread_iterator_info {
|
struct thread_iterator_info {
|
||||||
zcbor_state_t *zse;
|
zcbor_state_t *zse;
|
||||||
|
@ -83,7 +83,7 @@ extern uint8_t *MCUMGR_GRP_OS_INFO_BUILD_DATE_TIME;
|
||||||
/**
|
/**
|
||||||
* Command handler: os echo
|
* Command handler: os echo
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_OS_MGMT_ECHO
|
#ifdef CONFIG_MCUMGR_GRP_OS_ECHO
|
||||||
static int os_mgmt_echo(struct smp_streamer *ctxt)
|
static int os_mgmt_echo(struct smp_streamer *ctxt)
|
||||||
{
|
{
|
||||||
struct zcbor_string value = { 0 };
|
struct zcbor_string value = { 0 };
|
||||||
|
@ -120,9 +120,9 @@ static int os_mgmt_echo(struct smp_streamer *ctxt)
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
static inline bool
|
||||||
os_mgmt_taskstat_encode_thread_name(zcbor_state_t *zse, int idx,
|
os_mgmt_taskstat_encode_thread_name(zcbor_state_t *zse, int idx,
|
||||||
const struct k_thread *thread)
|
const struct k_thread *thread)
|
||||||
|
@ -131,8 +131,8 @@ os_mgmt_taskstat_encode_thread_name(zcbor_state_t *zse, int idx,
|
||||||
|
|
||||||
ARG_UNUSED(idx);
|
ARG_UNUSED(idx);
|
||||||
|
|
||||||
if (name_len > CONFIG_OS_MGMT_TASKSTAT_THREAD_NAME_LEN) {
|
if (name_len > CONFIG_MCUMGR_GRP_OS_TASKSTAT_THREAD_NAME_LEN) {
|
||||||
name_len = CONFIG_OS_MGMT_TASKSTAT_THREAD_NAME_LEN;
|
name_len = CONFIG_MCUMGR_GRP_OS_TASKSTAT_THREAD_NAME_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return zcbor_tstr_encode_ptr(zse, thread->name, 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,
|
os_mgmt_taskstat_encode_thread_name(zcbor_state_t *zse, int idx,
|
||||||
const struct k_thread *thread)
|
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;
|
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);
|
ARG_UNUSED(thread);
|
||||||
#else
|
#else
|
||||||
#error Unsupported option for taskstat thread name
|
#error Unsupported option for taskstat thread name
|
||||||
|
@ -165,7 +165,7 @@ static inline bool
|
||||||
os_mgmt_taskstat_encode_stack_info(zcbor_state_t *zse,
|
os_mgmt_taskstat_encode_stack_info(zcbor_state_t *zse,
|
||||||
const struct k_thread *thread)
|
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_size = 0;
|
||||||
size_t stack_used = 0;
|
size_t stack_used = 0;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
@ -189,7 +189,7 @@ os_mgmt_taskstat_encode_stack_info(zcbor_state_t *zse,
|
||||||
return ok;
|
return ok;
|
||||||
#else
|
#else
|
||||||
return true;
|
return true;
|
||||||
#endif /* CONFIG_OS_MGMT_TASKSTAT_STACK_INFO */
|
#endif /* CONFIG_MCUMGR_GRP_OS_TASKSTAT_STACK_INFO */
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
@ -205,7 +205,7 @@ os_mgmt_taskstat_encode_runtime_info(zcbor_state_t *zse,
|
||||||
|
|
||||||
ok = zcbor_tstr_put_lit(zse, "runtime") &&
|
ok = zcbor_tstr_put_lit(zse, "runtime") &&
|
||||||
zcbor_uint64_put(zse, thread_stats.execution_cycles);
|
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") &&
|
ok = zcbor_tstr_put_lit(zse, "runtime") &&
|
||||||
zcbor_uint32_put(zse, 0);
|
zcbor_uint32_put(zse, 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -217,7 +217,7 @@ static inline bool os_mgmt_taskstat_encode_unsupported(zcbor_state_t *zse)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
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") &&
|
ok = zcbor_tstr_put_lit(zse, "cswcnt") &&
|
||||||
zcbor_uint32_put(zse, 0) &&
|
zcbor_uint32_put(zse, 0) &&
|
||||||
zcbor_tstr_put_lit(zse, "last_checkin") &&
|
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)
|
os_mgmt_taskstat_encode_priority(zcbor_state_t *zse, const struct k_thread *thread)
|
||||||
{
|
{
|
||||||
return (zcbor_tstr_put_lit(zse, "prio") &&
|
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_int32_put(zse, (int)thread->base.prio) :
|
||||||
zcbor_uint32_put(zse, (unsigned int)thread->base.prio) & 0xff);
|
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_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. */
|
/* Iterate the list of tasks, encoding each. */
|
||||||
k_thread_foreach(os_mgmt_taskstat_encode_one, (void *)&iterator_ctx);
|
k_thread_foreach(os_mgmt_taskstat_encode_one, (void *)&iterator_ctx);
|
||||||
|
|
||||||
if (!iterator_ctx.ok ||
|
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 MGMT_ERR_EMSGSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_OS_MGMT_TASKSTAT */
|
#endif /* CONFIG_MCUMGR_GRP_OS_TASKSTAT */
|
||||||
|
|
||||||
#ifdef CONFIG_REBOOT
|
#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)
|
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);
|
int rc = mgmt_callback_notify(MGMT_EVT_OP_OS_MGMT_RESET, NULL, 0);
|
||||||
|
|
||||||
if (rc != MGMT_ERR_EOK) {
|
if (rc != MGMT_ERR_EOK) {
|
||||||
|
@ -322,13 +322,13 @@ static int os_mgmt_reset(struct smp_streamer *ctxt)
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
K_NO_WAIT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_OS_MGMT_MCUMGR_PARAMS
|
#ifdef CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS
|
||||||
static int
|
static int
|
||||||
os_mgmt_mcumgr_params(struct smp_streamer *ctxt)
|
os_mgmt_mcumgr_params(struct smp_streamer *ctxt)
|
||||||
{
|
{
|
||||||
|
@ -336,9 +336,9 @@ os_mgmt_mcumgr_params(struct smp_streamer *ctxt)
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
ok = zcbor_tstr_put_lit(zse, "buf_size") &&
|
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_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;
|
return ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE;
|
||||||
}
|
}
|
||||||
|
@ -641,12 +641,12 @@ fail:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct mgmt_handler os_mgmt_group_handlers[] = {
|
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_ID_ECHO] = {
|
||||||
os_mgmt_echo, os_mgmt_echo
|
os_mgmt_echo, os_mgmt_echo
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_OS_MGMT_TASKSTAT
|
#ifdef CONFIG_MCUMGR_GRP_OS_TASKSTAT
|
||||||
[OS_MGMT_ID_TASKSTAT] = {
|
[OS_MGMT_ID_TASKSTAT] = {
|
||||||
os_mgmt_taskstat_read, NULL
|
os_mgmt_taskstat_read, NULL
|
||||||
},
|
},
|
||||||
|
@ -656,7 +656,7 @@ static const struct mgmt_handler os_mgmt_group_handlers[] = {
|
||||||
NULL, os_mgmt_reset
|
NULL, os_mgmt_reset
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_OS_MGMT_MCUMGR_PARAMS
|
#ifdef CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS
|
||||||
[OS_MGMT_ID_MCUMGR_PARAMS] = {
|
[OS_MGMT_ID_MCUMGR_PARAMS] = {
|
||||||
os_mgmt_mcumgr_params, NULL
|
os_mgmt_mcumgr_params, NULL
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_CMD_SHELL_MGMT
|
menuconfig MCUMGR_GRP_SHELL
|
||||||
bool "Mcumgr handlers for shell management"
|
bool "Mcumgr handlers for shell management"
|
||||||
depends on SHELL
|
depends on SHELL
|
||||||
select SHELL_BACKEND_DUMMY
|
select SHELL_BACKEND_DUMMY
|
||||||
select MGMT_MIN_DECODING_LEVEL_2
|
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
|
||||||
help
|
help
|
||||||
Enables mcumgr handlers for shell management. The handler will utilize
|
Enables mcumgr handlers for shell management. The handler will utilize
|
||||||
the dummy backend to execute shell commands and capture the output to
|
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.
|
physical interfaces outside of the scope of the user.
|
||||||
It is possible to use additional shell backends in coordination
|
It is possible to use additional shell backends in coordination
|
||||||
with this handler and they will not interfere.
|
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
|
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
|
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
|
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
|
changes to the CONFIG_SHELL_CMD_BUFF_SIZE may increase stack size
|
||||||
requirements.
|
requirements.
|
||||||
|
|
||||||
if MCUMGR_CMD_SHELL_MGMT
|
if MCUMGR_GRP_SHELL
|
||||||
|
|
||||||
# Show dummy shell buffer size here, will show help text of original prompt so
|
# Show dummy shell buffer size here, will show help text of original prompt so
|
||||||
# nothing extra is needed here, nor a default value.
|
# nothing extra is needed here, nor a default value.
|
||||||
config SHELL_BACKEND_DUMMY_BUF_SIZE
|
config SHELL_BACKEND_DUMMY_BUF_SIZE
|
||||||
int "Shell output buffer size (Size of dummy buffer 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"
|
bool "Legacy behaviour: Use rc field for shell function return code"
|
||||||
help
|
help
|
||||||
Enabling this options brings back legacy behaviour where the shell
|
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
|
shell command exit code, and rc will be used for SMP processing
|
||||||
error codes.
|
error codes.
|
||||||
|
|
||||||
endif # MCUMGR_CMD_SHELL_MGMT
|
endif # MCUMGR_GRP_SHELL
|
||||||
|
|
|
@ -111,7 +111,7 @@ shell_mgmt_exec(struct smp_streamer *ctxt)
|
||||||
/* Key="ret"; value=<status>, or rc if legacy option enabled */
|
/* Key="ret"; value=<status>, or rc if legacy option enabled */
|
||||||
ok = zcbor_tstr_put_lit(zse, "o") &&
|
ok = zcbor_tstr_put_lit(zse, "o") &&
|
||||||
zcbor_tstr_encode(zse, &cmd_out) &&
|
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") &&
|
zcbor_tstr_put_lit(zse, "rc") &&
|
||||||
#else
|
#else
|
||||||
zcbor_tstr_put_lit(zse, "ret") &&
|
zcbor_tstr_put_lit(zse, "ret") &&
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_CMD_STAT_MGMT
|
menuconfig MCUMGR_GRP_STAT
|
||||||
bool "Mcumgr handlers for statistics management"
|
bool "Mcumgr handlers for statistics management"
|
||||||
depends on STATS
|
depends on STATS
|
||||||
select MGMT_MIN_DECODING_LEVEL_2
|
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
|
||||||
help
|
help
|
||||||
Enables mcumgr handlers for statistics management.
|
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"
|
int "Maximum stat group name length"
|
||||||
default 32
|
default 32
|
||||||
depends on MCUMGR_CMD_STAT_MGMT
|
depends on MCUMGR_GRP_STAT
|
||||||
help
|
help
|
||||||
Limits the maximum stat group name length in mcumgr requests, in bytes.
|
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
|
A buffer of this size gets allocated on the stack during handling of all
|
||||||
|
|
|
@ -119,7 +119,7 @@ stat_mgmt_show(struct smp_streamer *ctxt)
|
||||||
struct zcbor_string value = { 0 };
|
struct zcbor_string value = { 0 };
|
||||||
zcbor_state_t *zse = ctxt->writer->zs;
|
zcbor_state_t *zse = ctxt->writer->zs;
|
||||||
zcbor_state_t *zsd = ctxt->reader->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;
|
bool ok;
|
||||||
size_t counter = 0;
|
size_t counter = 0;
|
||||||
|
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
zephyr_library(mgmt_mcumgr_grp_zephyr)
|
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)
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
# Copyright (c) 2022 Nordic Semiconductor ASA
|
# Copyright (c) 2022 Nordic Semiconductor ASA
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_GRP_ZEPHYR_BASIC
|
menuconfig MCUMGR_GRP_ZBASIC
|
||||||
bool "Zephyr specific basic group of commands"
|
bool "Zephyr specific basic group of commands"
|
||||||
help
|
help
|
||||||
Enables mcumgr to processing of Zephyr specific groups.
|
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"
|
bool "Storage erase command"
|
||||||
help
|
help
|
||||||
Enables command that allows to erase storage partition.
|
Enables command that allows to erase storage partition.
|
||||||
|
|
||||||
module=MCUMGR_ZEPHYR_GRP
|
module=MCUMGR_GRP_ZBASIC
|
||||||
module-dep=LOG
|
module-dep=LOG
|
||||||
module-str=mcumgr_zephyr_grp
|
module-str=mcumgr_grp_zbasic
|
||||||
source "subsys/logging/Kconfig.template.log_config"
|
source "subsys/logging/Kconfig.template.log_config"
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
config MGMT_VERBOSE_ERR_RESPONSE
|
config MCUMGR_SMP_VERBOSE_ERR_RESPONSE
|
||||||
bool "Support verbose error response"
|
bool "Support verbose error response"
|
||||||
help
|
help
|
||||||
Support for encoding "rc" code explanation in form of "rsn"
|
Support for encoding "rc" code explanation in form of "rsn"
|
||||||
text string. This is useful, when returning MGMT_ERR_EUNKNOWN,
|
text string. This is useful, when returning MGMT_ERR_EUNKNOWN,
|
||||||
to add additional information on the source of an error.
|
to add additional information on the source of an error.
|
||||||
Note that the "rsn" is string additional to "rc" code,
|
Note that the "rsn" is string additional to "rc" code,
|
||||||
so MCUMGR_BUF_SIZE should be large enough to be able to encode
|
so MCUMGR_TRANSPORT_NETBUF_SIZE should be large enough to be able
|
||||||
both.
|
to encode both.
|
||||||
|
|
|
@ -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_tstr_put_lit(zsp, "rc") &&
|
||||||
zcbor_int32_put(zsp, status);
|
zcbor_int32_put(zsp, status);
|
||||||
|
|
||||||
#ifdef CONFIG_MGMT_VERBOSE_ERR_RESPONSE
|
#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
|
||||||
if (ok && rc_rsn != NULL) {
|
if (ok && rc_rsn != NULL) {
|
||||||
ok = zcbor_tstr_put_lit(zsp, "rsn") &&
|
ok = zcbor_tstr_put_lit(zsp, "rsn") &&
|
||||||
zcbor_tstr_put_term(zsp, rc_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) {
|
if (handler_fn) {
|
||||||
*handler_found = true;
|
*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)
|
#if defined(CONFIG_MCUMGR_SMP_COMMAND_STATUS_HOOKS)
|
||||||
cmd_recv.group = req_hdr->nh_group;
|
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);
|
rc = handler_fn(cbuf);
|
||||||
|
|
||||||
/* End response payload. */
|
/* 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 == 0) {
|
||||||
rc = MGMT_ERR_EMSGSIZE;
|
rc = MGMT_ERR_EMSGSIZE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,26 +10,26 @@
|
||||||
zephyr_library(mgmt_mcumgr_transport)
|
zephyr_library(mgmt_mcumgr_transport)
|
||||||
zephyr_library_sources(src/smp.c)
|
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
|
src/smp_reassembly.c
|
||||||
)
|
)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_BT
|
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_BT
|
||||||
src/smp_bt.c
|
src/smp_bt.c
|
||||||
)
|
)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_SHELL
|
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_SHELL
|
||||||
src/smp_shell.c
|
src/smp_shell.c
|
||||||
)
|
)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_UART
|
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_UART
|
||||||
src/smp_uart.c
|
src/smp_uart.c
|
||||||
)
|
)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_UDP
|
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_UDP
|
||||||
src/smp_udp.c
|
src/smp_udp.c
|
||||||
)
|
)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MCUMGR_SMP_DUMMY
|
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_DUMMY
|
||||||
src/smp_dummy.c
|
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)
|
zephyr_library_sources(src/serial_util.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -2,35 +2,35 @@
|
||||||
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
config MCUMGR_SMP_REASSEMBLY
|
config MCUMGR_TRANSPORT_REASSEMBLY
|
||||||
bool
|
bool
|
||||||
help
|
help
|
||||||
Enable structures and functions needed for packet reassembly by SMP backend.
|
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"
|
int "Number of mcumgr buffers"
|
||||||
default 2 if MCUMGR_SMP_UDP
|
default 2 if MCUMGR_TRANSPORT_UDP
|
||||||
default 4
|
default 4
|
||||||
help
|
help
|
||||||
The number of net_bufs to allocate for mcumgr. These buffers are
|
The number of net_bufs to allocate for mcumgr. These buffers are
|
||||||
used for both requests and responses.
|
used for both requests and responses.
|
||||||
|
|
||||||
config MCUMGR_BUF_SIZE
|
config MCUMGR_TRANSPORT_NETBUF_SIZE
|
||||||
int "Size of each mcumgr buffer"
|
int "Size of each mcumgr buffer"
|
||||||
default 2048 if MCUMGR_SMP_UDP
|
default 2048 if MCUMGR_TRANSPORT_UDP
|
||||||
default 384
|
default 384
|
||||||
help
|
help
|
||||||
The size, in bytes, of each mcumgr buffer. This value must satisfy
|
The size, in bytes, of each mcumgr buffer. This value must satisfy
|
||||||
the following relation:
|
the following relation:
|
||||||
MCUMGR_BUF_SIZE >= transport-specific-MTU + transport-overhead
|
MCUMGR_TRANSPORT_NETBUF_SIZE >= transport-specific-MTU + transport-overhead
|
||||||
In case when MCUMGR_SMP_SHELL is enabled this value should be set to
|
In case when MCUMGR_TRANSPORT_SHELL is enabled this value should be set to
|
||||||
at least SHELL_BACKEND_DUMMY_BUF_SIZE + 32.
|
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"
|
int "Size of mcumgr buffer user data"
|
||||||
default 24 if MCUMGR_SMP_UDP && MCUMGR_SMP_UDP_IPV6
|
default 24 if MCUMGR_TRANSPORT_UDP && MCUMGR_TRANSPORT_UDP_IPV6
|
||||||
default 8 if MCUMGR_SMP_UDP && MCUMGR_SMP_UDP_IPV4
|
default 8 if MCUMGR_TRANSPORT_UDP && MCUMGR_TRANSPORT_UDP_IPV4
|
||||||
default 8 if MCUMGR_SMP_BT
|
default 8 if MCUMGR_TRANSPORT_BT
|
||||||
default 4
|
default 4
|
||||||
help
|
help
|
||||||
The size, in bytes, of user data to allocate for each mcumgr buffer.
|
The size, in bytes, of user data to allocate for each mcumgr buffer.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Copyright Runtime.io 2018. All rights reserved.
|
# 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
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_SMP_BT
|
menuconfig MCUMGR_TRANSPORT_BT
|
||||||
bool "Bluetooth mcumgr SMP transport"
|
bool "Bluetooth mcumgr SMP transport"
|
||||||
select BT
|
select BT
|
||||||
select BT_PERIPHERAL
|
select BT_PERIPHERAL
|
||||||
|
@ -10,17 +10,17 @@ menuconfig MCUMGR_SMP_BT
|
||||||
help
|
help
|
||||||
Enables handling of SMP commands received over Bluetooth.
|
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"
|
bool "Reassemble packets in Bluetooth SMP transport"
|
||||||
select MCUMGR_SMP_REASSEMBLY
|
select MCUMGR_TRANSPORT_REASSEMBLY
|
||||||
help
|
help
|
||||||
When enabled, the SMP BT transport will buffer and reassemble received
|
When enabled, the SMP BT transport will buffer and reassemble received
|
||||||
packet fragments before passing it for further processing.
|
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"
|
bool "Authenticated requirement for Bluetooth mcumgr SMP transport"
|
||||||
select BT_SMP
|
select BT_SMP
|
||||||
default y
|
default y
|
||||||
|
@ -28,7 +28,7 @@ config MCUMGR_SMP_BT_AUTHEN
|
||||||
Enables encrypted and authenticated connection requirement to
|
Enables encrypted and authenticated connection requirement to
|
||||||
Bluetooth SMP transport.
|
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"
|
bool "Request specific connection parameters for SMP packet exchange"
|
||||||
depends on SYSTEM_WORKQUEUE_PRIORITY < 0
|
depends on SYSTEM_WORKQUEUE_PRIORITY < 0
|
||||||
depends on BT_GAP_PERIPHERAL_PREF_PARAMS
|
depends on BT_GAP_PERIPHERAL_PREF_PARAMS
|
||||||
|
@ -38,37 +38,37 @@ config MCUMGR_SMP_BT_CONN_PARAM_CONTROL
|
||||||
exchange process.
|
exchange process.
|
||||||
Its recommended to enable this if SMP is used for DFU.
|
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"
|
int "Minimum connection interval for SMP packet exchange"
|
||||||
default 6
|
default 6
|
||||||
range 6 3200
|
range 6 3200
|
||||||
help
|
help
|
||||||
Minimum connection interval in 1.25ms units used during the exchange of SMP packets.
|
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"
|
int "Maximum connection interval for SMP packet exchange"
|
||||||
default 9
|
default 9
|
||||||
range MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MIN_INT 3200
|
range MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MIN_INT 3200
|
||||||
help
|
help
|
||||||
Maximum connection interval in 1.25ms units used during the exchange of SMP packets.
|
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"
|
int "Peripheral latency for SMP packet exchange"
|
||||||
default 0
|
default 0
|
||||||
range 0 499
|
range 0 499
|
||||||
help
|
help
|
||||||
Peripheral latency in Connection Intervals used during the exchange of SMP packets.
|
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"
|
int "Supervision timeout for SMP packet exchange"
|
||||||
default 42
|
default 42
|
||||||
range 10 3200
|
range 10 3200
|
||||||
help
|
help
|
||||||
Supervision timeout in 10ms used during the exchange of SMP packets.
|
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"
|
int "Connection parameters restore time in milliseconds"
|
||||||
default 5000
|
default 5000
|
||||||
range 1000 65535
|
range 1000 65535
|
||||||
|
@ -77,7 +77,7 @@ config MCUMGR_SMP_BT_CONN_PARAM_CONTROL_RESTORE_TIME
|
||||||
connection parameters are restored to peripheral preferred values
|
connection parameters are restored to peripheral preferred values
|
||||||
(BT_GAP_PERIPHERAL_PREF_PARAMS).
|
(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"
|
int "Connection parameters update retry time in milliseconds"
|
||||||
default 1000
|
default 1000
|
||||||
range 1 5000
|
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
|
In case connection parameters update fails due to an error, this
|
||||||
option specifies the time of the next update attempt.
|
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
|
config MCUMGR_TRANSPORT_BT_AUTOMATIC_INIT
|
||||||
bool "Bluetooth SMP stack enable autostart/setup"
|
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,
|
Bluetooth stack to become ready from the ``bt_enable()`` call,
|
||||||
otherwise will return instantly without waiting.
|
otherwise will return instantly without waiting.
|
||||||
|
|
||||||
endif # MCUMGR_SMP_BT
|
endif # MCUMGR_TRANSPORT_BT
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
# Copyright Laird Connectivity 2021. All rights reserved.
|
# Copyright Laird Connectivity 2021. All rights reserved.
|
||||||
|
# Copyright Nordic Semiconductor ASA 2022. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_SMP_DUMMY
|
menuconfig MCUMGR_TRANSPORT_DUMMY
|
||||||
bool "Dummy SMP backend"
|
bool "Dummy SMP backend"
|
||||||
select BASE64
|
select BASE64
|
||||||
help
|
help
|
||||||
Enables the dummy SMP backend which can be used for unit testing
|
Enables the dummy SMP backend which can be used for unit testing
|
||||||
SMP functionality without needing a real interface or driver.
|
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"
|
int "Size of receive buffer for dummy interface mcumgr fragments"
|
||||||
default 128
|
default 128
|
||||||
help
|
help
|
||||||
|
@ -18,4 +19,4 @@ config MCUMGR_SMP_DUMMY_RX_BUF_SIZE
|
||||||
in bytes. This value must be large enough to accommodate any
|
in bytes. This value must be large enough to accommodate any
|
||||||
line sent by an mcumgr client.
|
line sent by an mcumgr client.
|
||||||
|
|
||||||
endif # MCUMGR_SMP_DUMMY
|
endif # MCUMGR_TRANSPORT_DUMMY
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Copyright Runtime.io 2018. All rights reserved.
|
# 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
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_SMP_SHELL
|
menuconfig MCUMGR_TRANSPORT_SHELL
|
||||||
bool "Shell mcumgr SMP transport"
|
bool "Shell mcumgr SMP transport"
|
||||||
select SHELL
|
select SHELL
|
||||||
select SHELL_BACKEND_SERIAL
|
select SHELL_BACKEND_SERIAL
|
||||||
|
@ -11,20 +11,20 @@ menuconfig MCUMGR_SMP_SHELL
|
||||||
Enables handling of SMP commands received over shell. This allows
|
Enables handling of SMP commands received over shell. This allows
|
||||||
the shell to be use for both mcumgr commands and shell commands.
|
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"
|
int "Shell SMP MTU"
|
||||||
default 256
|
default 256
|
||||||
help
|
help
|
||||||
Maximum size of SMP frames sent and received over shell. This value
|
Maximum size of SMP frames sent and received over shell. This value
|
||||||
must satisfy the following relation:
|
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"
|
int "Shell SMP RX buffer count"
|
||||||
default 2
|
default 2
|
||||||
help
|
help
|
||||||
Number of buffers used for receiving SMP fragments over shell.
|
Number of buffers used for receiving SMP fragments over shell.
|
||||||
|
|
||||||
endif # MCUMGR_SMP_SHELL
|
endif # MCUMGR_TRANSPORT_SHELL
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
# Copyright Runtime.io 2018. All rights reserved.
|
# 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
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_SMP_UART
|
menuconfig MCUMGR_TRANSPORT_UART
|
||||||
bool "UART mcumgr SMP transport"
|
bool "UART mcumgr SMP transport"
|
||||||
select UART_MCUMGR
|
select UART_MCUMGR
|
||||||
select BASE64
|
select BASE64
|
||||||
help
|
help
|
||||||
Enables handling of SMP commands received over UART. This is a
|
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
|
commands to be received over UART without requiring an additional
|
||||||
thread.
|
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"
|
bool "Use async UART API when available"
|
||||||
help
|
help
|
||||||
The option enables use of UART async API when available for selected mcumgr uart port.
|
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"
|
int "Number of async RX UART buffers"
|
||||||
range 2 8
|
range 2 8
|
||||||
default 2
|
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
|
receive data without stopping due to running out of buffer space. At least two buffers
|
||||||
area required for smooth RX operation.
|
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"
|
int "Size of single async RX UART buffer"
|
||||||
default 64
|
default 64
|
||||||
help
|
help
|
||||||
The size of single buffer for asynchronous RX.
|
The size of single buffer for asynchronous RX.
|
||||||
|
|
||||||
endif # MCUMGR_SMP_UART_ASYNC
|
endif # MCUMGR_TRANSPORT_UART_ASYNC
|
||||||
|
|
||||||
endif # UART_ASYNC_API
|
endif # UART_ASYNC_API
|
||||||
|
|
||||||
config MCUMGR_SMP_UART_MTU
|
config MCUMGR_TRANSPORT_UART_MTU
|
||||||
int "UART SMP MTU"
|
int "UART SMP MTU"
|
||||||
default 256
|
default 256
|
||||||
depends on MCUMGR_SMP_UART
|
depends on MCUMGR_TRANSPORT_UART
|
||||||
help
|
help
|
||||||
Maximum size of SMP frames sent and received over UART, in bytes.
|
Maximum size of SMP frames sent and received over UART, in bytes.
|
||||||
This value must satisfy the following relation:
|
This value must satisfy the following relation:
|
||||||
MCUMGR_SMP_UART_MTU <= MCUMGR_BUF_SIZE + 2
|
MCUMGR_TRANSPORT_UART_MTU <= MCUMGR_TRANSPORT_NETBUF_SIZE + 2
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Copyright Runtime.io 2018. All rights reserved.
|
# 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
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig MCUMGR_SMP_UDP
|
menuconfig MCUMGR_TRANSPORT_UDP
|
||||||
bool "UDP mcumgr SMP transport"
|
bool "UDP mcumgr SMP transport"
|
||||||
select NETWORKING
|
select NETWORKING
|
||||||
select NET_UDP
|
select NET_UDP
|
||||||
|
@ -12,9 +12,9 @@ menuconfig MCUMGR_SMP_UDP
|
||||||
Enables handling of SMP commands received over UDP.
|
Enables handling of SMP commands received over UDP.
|
||||||
Will start a thread for listening on the configured UDP port.
|
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"
|
bool "UDP SMP using IPv4"
|
||||||
depends on NET_IPV4
|
depends on NET_IPV4
|
||||||
default y
|
default y
|
||||||
|
@ -22,38 +22,38 @@ config MCUMGR_SMP_UDP_IPV4
|
||||||
Enable SMP UDP using IPv4 addressing.
|
Enable SMP UDP using IPv4 addressing.
|
||||||
Can be enabled alongside IPv6 addressing.
|
Can be enabled alongside IPv6 addressing.
|
||||||
|
|
||||||
config MCUMGR_SMP_UDP_IPV6
|
config MCUMGR_TRANSPORT_UDP_IPV6
|
||||||
bool "UDP SMP using IPv6"
|
bool "UDP SMP using IPv6"
|
||||||
depends on NET_IPV6
|
depends on NET_IPV6
|
||||||
help
|
help
|
||||||
Enable SMP UDP using IPv6 addressing.
|
Enable SMP UDP using IPv6 addressing.
|
||||||
Can be enabled alongside IPv4 addressing.
|
Can be enabled alongside IPv4 addressing.
|
||||||
|
|
||||||
config MCUMGR_SMP_UDP_PORT
|
config MCUMGR_TRANSPORT_UDP_PORT
|
||||||
int "UDP SMP port"
|
int "UDP SMP port"
|
||||||
default 1337
|
default 1337
|
||||||
help
|
help
|
||||||
UDP port that SMP server will listen for SMP commands on.
|
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"
|
int "UDP SMP stack size"
|
||||||
default 512
|
default 512
|
||||||
help
|
help
|
||||||
Stack size of the SMP UDP listening thread
|
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"
|
int "UDP SMP thread priority"
|
||||||
default 0
|
default 0
|
||||||
help
|
help
|
||||||
Scheduling priority of the SMP UDP listening thread.
|
Scheduling priority of the SMP UDP listening thread.
|
||||||
|
|
||||||
config MCUMGR_SMP_UDP_MTU
|
config MCUMGR_TRANSPORT_UDP_MTU
|
||||||
int "UDP SMP MTU"
|
int "UDP SMP MTU"
|
||||||
default 1500
|
default 1500
|
||||||
help
|
help
|
||||||
Maximum size of SMP frames sent and received over UDP, in bytes.
|
Maximum size of SMP frames sent and received over UDP, in bytes.
|
||||||
This value must satisfy the following relation:
|
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.
|
where address size is determined by IPv4/IPv6 selection.
|
||||||
|
|
||||||
config MCUMGR_TRANSPORT_UDP_AUTOMATIC_INIT
|
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
|
UDP SMP service when the network interface is up and disable it when
|
||||||
it goes down (at layer 4).
|
it goes down (at layer 4).
|
||||||
|
|
||||||
endif # MCUMGR_SMP_UDP
|
endif # MCUMGR_TRANSPORT_UDP
|
||||||
|
|
|
@ -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
|
* @return number of expected bytes left to complete the packet, 0 means buffer is complete
|
||||||
* and no more fragments are expected;
|
* and no more fragments are expected;
|
||||||
* -ENOSR if a packet length, read from header, is bigger than CONFIG_MCUMGR_BUF_SIZE,
|
* -ENOSR if a packet length, read from header, is bigger than
|
||||||
* which means there is no way to fit it in the configured buffer;
|
* 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
|
* -EOVERFLOW if attempting to add a fragment that would make complete packet larger
|
||||||
* than expected;
|
* than expected;
|
||||||
* -ENOMEM if failed to allocate a new buffer for packet assembly;
|
* -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
|
* 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.
|
* 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.
|
* NULL if no re-assembly in progress.
|
||||||
*/
|
*/
|
||||||
void *smp_reassembly_get_ud(const struct smp_transport *smpt);
|
void *smp_reassembly_get_ud(const struct smp_transport *smpt);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <mgmt/mcumgr/transport/smp_reassembly.h>
|
#include <mgmt/mcumgr/transport/smp_reassembly.h>
|
||||||
|
|
||||||
#include <zephyr/logging/log.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
|
/* To be able to unit test some callers some functions need to be
|
||||||
* demoted to allow overriding them.
|
* demoted to allow overriding them.
|
||||||
|
@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(mcumgr_smp, CONFIG_MCUMGR_SMP_LOG_LEVEL);
|
||||||
#define WEAK
|
#define WEAK
|
||||||
#endif
|
#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;
|
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"
|
.name = "mcumgr smp"
|
||||||
};
|
};
|
||||||
|
|
||||||
NET_BUF_POOL_DEFINE(pkt_pool, CONFIG_MCUMGR_BUF_COUNT, CONFIG_MCUMGR_BUF_SIZE,
|
NET_BUF_POOL_DEFINE(pkt_pool, CONFIG_MCUMGR_TRANSPORT_NETBUF_COUNT,
|
||||||
CONFIG_MCUMGR_BUF_USER_DATA_SIZE, NULL);
|
CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE,
|
||||||
|
CONFIG_MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE, NULL);
|
||||||
|
|
||||||
struct net_buf *smp_packet_alloc(void)
|
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,
|
.query_valid_check = query_valid_check_func,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_REASSEMBLY
|
#ifdef CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
|
||||||
smp_reassembly_init(smpt);
|
smp_reassembly_init(smpt);
|
||||||
#endif
|
#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_work_queue_start(&smp_work_queue, smp_work_queue_stack,
|
||||||
K_THREAD_STACK_SIZEOF(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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,40 +28,40 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <zephyr/logging/log.h>
|
#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, \
|
#define RESTORE_TIME COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL, \
|
||||||
(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_RESTORE_TIME), \
|
(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_RESTORE_TIME), \
|
||||||
(0))
|
(0))
|
||||||
#define RETRY_TIME COND_CODE_1(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL, \
|
#define RETRY_TIME COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL, \
|
||||||
(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_RETRY_TIME), \
|
(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_RETRY_TIME), \
|
||||||
(0))
|
(0))
|
||||||
|
|
||||||
#define CONN_PARAM_SMP COND_CODE_1(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL, \
|
#define CONN_PARAM_SMP COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL, \
|
||||||
BT_LE_CONN_PARAM( \
|
BT_LE_CONN_PARAM( \
|
||||||
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MIN_INT, \
|
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MIN_INT, \
|
||||||
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MAX_INT, \
|
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MAX_INT, \
|
||||||
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_LATENCY, \
|
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_LATENCY, \
|
||||||
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_TIMEOUT), \
|
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_TIMEOUT), \
|
||||||
(NULL))
|
(NULL))
|
||||||
#define CONN_PARAM_PREF COND_CODE_1(CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL, \
|
#define CONN_PARAM_PREF COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL, \
|
||||||
BT_LE_CONN_PARAM( \
|
BT_LE_CONN_PARAM( \
|
||||||
CONFIG_BT_PERIPHERAL_PREF_MIN_INT, \
|
CONFIG_BT_PERIPHERAL_PREF_MIN_INT, \
|
||||||
CONFIG_BT_PERIPHERAL_PREF_MAX_INT, \
|
CONFIG_BT_PERIPHERAL_PREF_MAX_INT, \
|
||||||
CONFIG_BT_PERIPHERAL_PREF_LATENCY, \
|
CONFIG_BT_PERIPHERAL_PREF_LATENCY, \
|
||||||
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT), \
|
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT), \
|
||||||
(NULL))
|
(NULL))
|
||||||
|
|
||||||
/* Minimum number of bytes that must be able to be sent with a notification to a target device
|
/* Minimum number of bytes that must be able to be sent with a notification to a target device
|
||||||
* before giving up
|
* before giving up
|
||||||
*/
|
*/
|
||||||
#define SMP_BT_MINIMUM_MTU_SEND_FAILURE 20
|
#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. */
|
/* Verification of SMP Connection Parameters configuration that is not possible in the Kconfig. */
|
||||||
BUILD_ASSERT((CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_TIMEOUT * 4U) >
|
BUILD_ASSERT((CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_TIMEOUT * 4U) >
|
||||||
((1U + CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_LATENCY) *
|
((1U + CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_LATENCY) *
|
||||||
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MAX_INT));
|
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MAX_INT));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct smp_bt_user_data {
|
struct smp_bt_user_data {
|
||||||
|
@ -70,8 +70,9 @@ struct smp_bt_user_data {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Verification of user data being able to fit */
|
/* Verification of user data being able to fit */
|
||||||
BUILD_ASSERT(sizeof(struct smp_bt_user_data) <= CONFIG_MCUMGR_BUF_USER_DATA_SIZE,
|
BUILD_ASSERT(sizeof(struct smp_bt_user_data) <= CONFIG_MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE,
|
||||||
"CONFIG_MCUMGR_BUF_USER_DATA_SIZE not large enough to fit Bluetooth user data");
|
"CONFIG_MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE not large enough to fit Bluetooth"
|
||||||
|
" user data");
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CONN_PARAM_SMP_REQUESTED = BIT(0),
|
CONN_PARAM_SMP_REQUESTED = BIT(0),
|
||||||
|
@ -230,7 +231,7 @@ static ssize_t smp_bt_chr_write(struct bt_conn *conn,
|
||||||
uint8_t flags)
|
uint8_t flags)
|
||||||
{
|
{
|
||||||
struct conn_param_data *cpd = conn_param_data_get(conn);
|
struct conn_param_data *cpd = conn_param_data_get(conn);
|
||||||
#ifdef CONFIG_MCUMGR_SMP_REASSEMBLY_BT
|
#ifdef CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY
|
||||||
int ret;
|
int ret;
|
||||||
bool started;
|
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);
|
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);
|
conn_param_smp_enable(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +321,7 @@ static ssize_t smp_bt_chr_write(struct bt_conn *conn,
|
||||||
ud->conn = conn;
|
ud->conn = conn;
|
||||||
ud->id = cpd->id;
|
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);
|
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)
|
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) {
|
if (smp_reassembly_expected(&smp_bt_transport) >= 0 && value == 0) {
|
||||||
struct smp_bt_user_data *ud = smp_reassembly_get_ud(&smp_bt_transport);
|
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_CHARACTERISTIC(&smp_bt_chr_uuid.uuid,
|
||||||
BT_GATT_CHRC_WRITE_WITHOUT_RESP |
|
BT_GATT_CHRC_WRITE_WITHOUT_RESP |
|
||||||
BT_GATT_CHRC_NOTIFY,
|
BT_GATT_CHRC_NOTIFY,
|
||||||
#ifdef CONFIG_MCUMGR_SMP_BT_AUTHEN
|
#ifdef CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN
|
||||||
BT_GATT_PERM_WRITE_AUTHEN,
|
BT_GATT_PERM_WRITE_AUTHEN,
|
||||||
#else
|
#else
|
||||||
BT_GATT_PERM_WRITE,
|
BT_GATT_PERM_WRITE,
|
||||||
#endif
|
#endif
|
||||||
NULL, smp_bt_chr_write, NULL),
|
NULL, smp_bt_chr_write, NULL),
|
||||||
BT_GATT_CCC(smp_bt_ccc_changed,
|
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_READ_AUTHEN |
|
||||||
BT_GATT_PERM_WRITE_AUTHEN),
|
BT_GATT_PERM_WRITE_AUTHEN),
|
||||||
#else
|
#else
|
||||||
|
@ -592,7 +593,7 @@ static void disconnected(struct bt_conn *conn, uint8_t reason)
|
||||||
cpd->id = 0;
|
cpd->id = 0;
|
||||||
cpd->conn = NULL;
|
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. */
|
/* Cancel work if ongoing. */
|
||||||
(void)k_work_cancel_delayable(&cpd->dwork);
|
(void)k_work_cancel_delayable(&cpd->dwork);
|
||||||
(void)k_work_cancel_delayable(&cpd->ework);
|
(void)k_work_cancel_delayable(&cpd->ework);
|
||||||
|
@ -663,7 +664,7 @@ void smp_bt_start(void)
|
||||||
|
|
||||||
bt_conn_cb_register(&conn_callbacks);
|
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();
|
conn_param_control_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Define required for uart_mcumgr.h functionality reuse */
|
/* Define required for uart_mcumgr.h functionality reuse */
|
||||||
#define CONFIG_UART_MCUMGR_RX_BUF_SIZE 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_SMP_DUMMY_RX_BUF_SIZE
|
#define MCUMGR_DUMMY_MAX_FRAME CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE
|
||||||
|
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <zephyr/init.h>
|
#include <zephyr/init.h>
|
||||||
|
@ -29,8 +29,8 @@
|
||||||
|
|
||||||
#include <mgmt/mcumgr/transport/smp_internal.h>
|
#include <mgmt/mcumgr/transport/smp_internal.h>
|
||||||
|
|
||||||
BUILD_ASSERT(CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE != 0,
|
BUILD_ASSERT(CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE != 0,
|
||||||
"CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE must be > 0");
|
"CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE must be > 0");
|
||||||
|
|
||||||
struct device;
|
struct device;
|
||||||
static struct mcumgr_serial_rx_ctxt smp_dummy_rx_ctxt;
|
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 struct smp_transport smp_dummy_transport;
|
||||||
static bool enable_dummy_smp;
|
static bool enable_dummy_smp;
|
||||||
static struct k_sem smp_data_ready_sem;
|
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 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;
|
static uint16_t smp_receive_pos;
|
||||||
|
|
||||||
/** Callback to execute when a valid fragment has been received. */
|
/** 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)
|
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)
|
int dummy_mcumgr_send_raw(const void *data, int len)
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#include <mgmt/mcumgr/transport/smp_internal.h>
|
#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)
|
void smp_reassembly_init(struct smp_transport *smpt)
|
||||||
{
|
{
|
||||||
smpt->__reassembly.current = NULL;
|
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);
|
expected += sizeof(struct smp_hdr);
|
||||||
|
|
||||||
/* Joining net_bufs not supported yet */
|
/* 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;
|
return -ENOSR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
LOG_MODULE_REGISTER(smp_shell);
|
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;
|
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)
|
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)
|
static int smp_shell_tx_raw(const void *data, int len)
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include <mgmt/mcumgr/transport/smp_internal.h>
|
#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;
|
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)
|
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)
|
static int smp_uart_tx_pkt(struct net_buf *nb)
|
||||||
|
|
|
@ -37,34 +37,34 @@
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
LOG_MODULE_REGISTER(smp_udp);
|
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 {
|
struct config {
|
||||||
int sock;
|
int sock;
|
||||||
const char *proto;
|
const char *proto;
|
||||||
struct smp_transport smp_transport;
|
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;
|
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 {
|
struct configs {
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
|
||||||
struct config ipv4;
|
struct config ipv4;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
|
||||||
struct config ipv6;
|
struct config ipv6;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct configs configs = {
|
static struct configs configs = {
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
|
||||||
.ipv4 = {
|
.ipv4 = {
|
||||||
.proto = "IPv4",
|
.proto = "IPv4",
|
||||||
.sock = -1,
|
.sock = -1,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
|
||||||
.ipv6 = {
|
.ipv6 = {
|
||||||
.proto = "IPv6",
|
.proto = "IPv6",
|
||||||
.sock = -1,
|
.sock = -1,
|
||||||
|
@ -76,7 +76,7 @@ static struct configs configs = {
|
||||||
static struct net_mgmt_event_callback smp_udp_mgmt_cb;
|
static struct net_mgmt_event_callback smp_udp_mgmt_cb;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
|
||||||
static int smp_udp4_tx(struct net_buf *nb)
|
static int smp_udp4_tx(struct net_buf *nb)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -96,7 +96,7 @@ static int smp_udp4_tx(struct net_buf *nb)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
|
||||||
static int smp_udp6_tx(struct net_buf *nb)
|
static int smp_udp6_tx(struct net_buf *nb)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -120,7 +120,7 @@ static uint16_t smp_udp_get_mtu(const struct net_buf *nb)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(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)
|
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);
|
socklen_t addr_len = sizeof(addr);
|
||||||
|
|
||||||
int len = recvfrom(conf->sock, conf->recv_buffer,
|
int len = recvfrom(conf->sock, conf->recv_buffer,
|
||||||
CONFIG_MCUMGR_SMP_UDP_MTU,
|
CONFIG_MCUMGR_TRANSPORT_UDP_MTU,
|
||||||
0, &addr, &addr_len);
|
0, &addr, &addr_len);
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
|
@ -176,13 +176,13 @@ static int smp_udp_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(dev);
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
|
||||||
smp_transport_init(&configs.ipv4.smp_transport,
|
smp_transport_init(&configs.ipv4.smp_transport,
|
||||||
smp_udp4_tx, smp_udp_get_mtu,
|
smp_udp4_tx, smp_udp_get_mtu,
|
||||||
smp_udp_ud_copy, NULL, NULL);
|
smp_udp_ud_copy, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
|
||||||
smp_transport_init(&configs.ipv6.smp_transport,
|
smp_transport_init(&configs.ipv6.smp_transport,
|
||||||
smp_udp6_tx, smp_udp_get_mtu,
|
smp_udp6_tx, smp_udp_get_mtu,
|
||||||
smp_udp_ud_copy, NULL, NULL);
|
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_thread_create(&(conf->thread), conf->stack,
|
||||||
K_KERNEL_STACK_SIZEOF(conf->stack),
|
K_KERNEL_STACK_SIZEOF(conf->stack),
|
||||||
smp_udp_receive_thread, conf, NULL, NULL,
|
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_name_set(&(conf->thread), name);
|
||||||
k_thread_start(&(conf->thread));
|
k_thread_start(&(conf->thread));
|
||||||
|
@ -233,12 +233,12 @@ int smp_udp_open(void)
|
||||||
{
|
{
|
||||||
struct config *conf;
|
struct config *conf;
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
|
||||||
struct sockaddr_in addr4;
|
struct sockaddr_in addr4;
|
||||||
|
|
||||||
memset(&addr4, 0, sizeof(addr4));
|
memset(&addr4, 0, sizeof(addr4));
|
||||||
addr4.sin_family = AF_INET;
|
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);
|
addr4.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
|
||||||
conf = &configs.ipv4;
|
conf = &configs.ipv4;
|
||||||
|
@ -251,12 +251,12 @@ int smp_udp_open(void)
|
||||||
create_thread(conf, "smp_udp4");
|
create_thread(conf, "smp_udp4");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
|
||||||
struct sockaddr_in6 addr6;
|
struct sockaddr_in6 addr6;
|
||||||
|
|
||||||
memset(&addr6, 0, sizeof(addr6));
|
memset(&addr6, 0, sizeof(addr6));
|
||||||
addr6.sin6_family = AF_INET6;
|
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;
|
addr6.sin6_addr = in6addr_any;
|
||||||
|
|
||||||
conf = &configs.ipv6;
|
conf = &configs.ipv6;
|
||||||
|
@ -274,7 +274,7 @@ int smp_udp_open(void)
|
||||||
|
|
||||||
int smp_udp_close(void)
|
int smp_udp_close(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV4
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
|
||||||
if (configs.ipv4.sock >= 0) {
|
if (configs.ipv4.sock >= 0) {
|
||||||
k_thread_abort(&(configs.ipv4.thread));
|
k_thread_abort(&(configs.ipv4.thread));
|
||||||
close(configs.ipv4.sock);
|
close(configs.ipv4.sock);
|
||||||
|
@ -282,7 +282,7 @@ int smp_udp_close(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_UDP_IPV6
|
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
|
||||||
if (configs.ipv6.sock >= 0) {
|
if (configs.ipv6.sock >= 0) {
|
||||||
k_thread_abort(&(configs.ipv6.thread));
|
k_thread_abort(&(configs.ipv6.thread));
|
||||||
close(configs.ipv6.sock);
|
close(configs.ipv6.sock);
|
||||||
|
|
|
@ -19,10 +19,10 @@ LOG_MODULE_REGISTER(shell_uart);
|
||||||
#define RX_POLL_PERIOD K_NO_WAIT
|
#define RX_POLL_PERIOD K_NO_WAIT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_SHELL
|
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
|
||||||
NET_BUF_POOL_DEFINE(smp_shell_rx_pool, CONFIG_MCUMGR_SMP_SHELL_RX_BUF_COUNT,
|
NET_BUF_POOL_DEFINE(smp_shell_rx_pool, CONFIG_MCUMGR_TRANSPORT_SHELL_RX_BUF_COUNT,
|
||||||
SMP_SHELL_RX_BUF_SIZE, 0, NULL);
|
SMP_SHELL_RX_BUF_SIZE, 0, NULL);
|
||||||
#endif /* CONFIG_MCUMGR_SMP_SHELL */
|
#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
|
||||||
|
|
||||||
SHELL_UART_DEFINE(shell_transport_uart,
|
SHELL_UART_DEFINE(shell_transport_uart,
|
||||||
CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE,
|
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 len;
|
||||||
uint32_t rd_len;
|
uint32_t rd_len;
|
||||||
bool new_data = false;
|
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;
|
struct smp_shell_data *const smp = &sh_uart->ctrl_blk->smp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ static void uart_rx_handle(const struct device *dev,
|
||||||
if (rd_len > 0) {
|
if (rd_len > 0) {
|
||||||
new_data = true;
|
new_data = true;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_MCUMGR_SMP_SHELL
|
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
|
||||||
/* Divert bytes from shell handling if it is
|
/* Divert bytes from shell handling if it is
|
||||||
* part of an mcumgr frame.
|
* part of an mcumgr frame.
|
||||||
*/
|
*/
|
||||||
|
@ -71,7 +71,7 @@ static void uart_rx_handle(const struct device *dev,
|
||||||
data[j] = data[i + j];
|
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,
|
int err = ring_buf_put_finish(sh_uart->rx_ringbuf,
|
||||||
rd_len);
|
rd_len);
|
||||||
(void)err;
|
(void)err;
|
||||||
|
@ -83,7 +83,7 @@ static void uart_rx_handle(const struct device *dev,
|
||||||
LOG_WRN("RX ring buffer full.");
|
LOG_WRN("RX ring buffer full.");
|
||||||
|
|
||||||
rd_len = uart_fifo_read(dev, &dummy, 1);
|
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
|
/* If successful in getting byte from the fifo, try
|
||||||
* feeding it to SMP as a part of mcumgr frame.
|
* 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)) {
|
(smp_shell_rx_bytes(smp, &dummy, 1) == 1)) {
|
||||||
new_data = true;
|
new_data = true;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_MCUMGR_SMP_SHELL */
|
#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
|
||||||
}
|
}
|
||||||
} while (rd_len && (rd_len == len));
|
} 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->handler = evt_handler;
|
||||||
sh_uart->ctrl_blk->context = context;
|
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;
|
sh_uart->ctrl_blk->smp.buf_pool = &smp_shell_rx_pool;
|
||||||
k_fifo_init(&sh_uart->ctrl_blk->smp.buf_ready);
|
k_fifo_init(&sh_uart->ctrl_blk->smp.buf_ready);
|
||||||
#endif
|
#endif
|
||||||
|
@ -293,14 +293,14 @@ static int read(const struct shell_transport *transport,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MCUMGR_SMP_SHELL
|
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
|
||||||
static void update(const struct shell_transport *transport)
|
static void update(const struct shell_transport *transport)
|
||||||
{
|
{
|
||||||
struct shell_uart *sh_uart = (struct shell_uart *)transport->ctx;
|
struct shell_uart *sh_uart = (struct shell_uart *)transport->ctx;
|
||||||
|
|
||||||
smp_shell_process(&sh_uart->ctrl_blk->smp);
|
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 = {
|
const struct shell_transport_api shell_uart_transport_api = {
|
||||||
.init = init,
|
.init = init,
|
||||||
|
@ -308,9 +308,9 @@ const struct shell_transport_api shell_uart_transport_api = {
|
||||||
.enable = enable,
|
.enable = enable,
|
||||||
.write = write,
|
.write = write,
|
||||||
.read = read,
|
.read = read,
|
||||||
#ifdef CONFIG_MCUMGR_SMP_SHELL
|
#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
|
||||||
.update = update,
|
.update = update,
|
||||||
#endif /* CONFIG_MCUMGR_SMP_SHELL */
|
#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int enable_shell_uart(const struct device *arg)
|
static int enable_shell_uart(const struct device *arg)
|
||||||
|
@ -328,7 +328,7 @@ static int enable_shell_uart(const struct device *arg)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_MCUMGR_SMP_SHELL)) {
|
if (IS_ENABLED(CONFIG_MCUMGR_TRANSPORT_SHELL)) {
|
||||||
smp_shell_init();
|
smp_shell_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,40 +8,40 @@ CONFIG_ZTEST_NEW_API=y
|
||||||
CONFIG_TINYCRYPT_SHA256=y
|
CONFIG_TINYCRYPT_SHA256=y
|
||||||
CONFIG_FILE_SYSTEM=y
|
CONFIG_FILE_SYSTEM=y
|
||||||
CONFIG_MCUMGR=y
|
CONFIG_MCUMGR=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY=y
|
CONFIG_MCUMGR_TRANSPORT_DUMMY=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE=512
|
CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE=512
|
||||||
CONFIG_MCUMGR_CMD_FS_MGMT=y
|
CONFIG_MCUMGR_GRP_FS=y
|
||||||
CONFIG_FS_MGMT_FILE_STATUS=n
|
CONFIG_MCUMGR_GRP_FS_FILE_STATUS=n
|
||||||
CONFIG_FS_MGMT_CHECKSUM_HASH=y
|
CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH=y
|
||||||
CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_SUPPORTED_CMD=y
|
CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_SUPPORTED_CMD=y
|
||||||
CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS=y
|
CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS=y
|
||||||
CONFIG_MCUMGR_SMP_COMMAND_STATUS_HOOKS=y
|
CONFIG_MCUMGR_SMP_COMMAND_STATUS_HOOKS=y
|
||||||
CONFIG_MCUMGR_CMD_FS_MGMT=y
|
CONFIG_MCUMGR_GRP_FS=y
|
||||||
CONFIG_FS_MGMT_DL_CHUNK_SIZE_LIMIT=y
|
CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE_LIMIT=y
|
||||||
CONFIG_FS_MGMT_DL_CHUNK_SIZE=128
|
CONFIG_MCUMGR_GRP_FS_DL_CHUNK_SIZE=128
|
||||||
CONFIG_MCUMGR_GRP_FS_FILE_ACCESS_HOOK=y
|
CONFIG_MCUMGR_GRP_FS_FILE_ACCESS_HOOK=y
|
||||||
CONFIG_MCUMGR_CMD_IMG_MGMT=y
|
CONFIG_MCUMGR_GRP_IMG=y
|
||||||
CONFIG_IMG_MGMT_VERBOSE_ERR=y
|
CONFIG_MCUMGR_GRP_IMG_VERBOSE_ERR=y
|
||||||
CONFIG_IMG_MGMT_FRUGAL_LIST=y
|
CONFIG_MCUMGR_GRP_IMG_FRUGAL_LIST=y
|
||||||
CONFIG_MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK=y
|
CONFIG_MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK=y
|
||||||
CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS=y
|
CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS=y
|
||||||
CONFIG_MCUMGR_CMD_OS_MGMT=y
|
CONFIG_MCUMGR_GRP_OS=y
|
||||||
CONFIG_MCUMGR_GRP_OS_OS_RESET_HOOK=y
|
CONFIG_MCUMGR_GRP_OS_RESET_HOOK=y
|
||||||
CONFIG_OS_MGMT_MCUMGR_PARAMS=y
|
CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y
|
||||||
CONFIG_MCUMGR_CMD_SHELL_MGMT=y
|
CONFIG_MCUMGR_GRP_SHELL=y
|
||||||
CONFIG_MCUMGR_CMD_STAT_MGMT=y
|
CONFIG_MCUMGR_GRP_STAT=y
|
||||||
CONFIG_MCUMGR_GRP_ZEPHYR_BASIC=y
|
CONFIG_MCUMGR_GRP_ZBASIC=y
|
||||||
CONFIG_MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE=y
|
CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY=y
|
CONFIG_MCUMGR_TRANSPORT_DUMMY=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE=512
|
CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE=512
|
||||||
CONFIG_SHELL=y
|
CONFIG_SHELL=y
|
||||||
CONFIG_STATS=y
|
CONFIG_STATS=y
|
||||||
CONFIG_MCUMGR_SMP_BT=y
|
CONFIG_MCUMGR_TRANSPORT_BT=y
|
||||||
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
|
CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n
|
||||||
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL=y
|
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
|
||||||
CONFIG_MCUMGR_SMP_REASSEMBLY_BT=y
|
CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
|
||||||
CONFIG_MCUMGR_SMP_SHELL=y
|
CONFIG_MCUMGR_TRANSPORT_SHELL=y
|
||||||
CONFIG_MCUMGR_SMP_BT_AUTHEN=y
|
CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=y
|
||||||
CONFIG_FS_MGMT_FILE_STATUS=y
|
CONFIG_MCUMGR_GRP_FS_FILE_STATUS=y
|
||||||
CONFIG_FS_MGMT_HASH_SHA256=y
|
CONFIG_MCUMGR_GRP_FS_HASH_SHA256=y
|
||||||
CONFIG_OS_MGMT_TASKSTAT=y
|
CONFIG_MCUMGR_GRP_OS_TASKSTAT=y
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
#
|
#
|
||||||
CONFIG_TINYCRYPT=y
|
CONFIG_TINYCRYPT=y
|
||||||
CONFIG_TINYCRYPT_SHA256=y
|
CONFIG_TINYCRYPT_SHA256=y
|
||||||
CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32=y
|
CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32=y
|
||||||
CONFIG_FS_MGMT_HASH_SHA256=y
|
CONFIG_MCUMGR_GRP_FS_HASH_SHA256=y
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32=y
|
CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32=y
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||
#
|
#
|
||||||
CONFIG_TINYCRYPT=y
|
CONFIG_TINYCRYPT=y
|
||||||
CONFIG_TINYCRYPT_SHA256=y
|
CONFIG_TINYCRYPT_SHA256=y
|
||||||
CONFIG_FS_MGMT_HASH_SHA256=y
|
CONFIG_MCUMGR_GRP_FS_HASH_SHA256=y
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
CONFIG_ZTEST=y
|
CONFIG_ZTEST=y
|
||||||
CONFIG_FILE_SYSTEM=y
|
CONFIG_FILE_SYSTEM=y
|
||||||
CONFIG_MCUMGR=y
|
CONFIG_MCUMGR=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY=y
|
CONFIG_MCUMGR_TRANSPORT_DUMMY=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE=512
|
CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE=512
|
||||||
CONFIG_MCUMGR_CMD_FS_MGMT=y
|
CONFIG_MCUMGR_GRP_FS=y
|
||||||
CONFIG_FS_MGMT_FILE_STATUS=n
|
CONFIG_MCUMGR_GRP_FS_FILE_STATUS=n
|
||||||
CONFIG_FS_MGMT_CHECKSUM_HASH=y
|
CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH=y
|
||||||
CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_SUPPORTED_CMD=y
|
CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_SUPPORTED_CMD=y
|
||||||
CONFIG_ZTEST_NEW_API=y
|
CONFIG_ZTEST_NEW_API=y
|
||||||
|
|
|
@ -35,7 +35,7 @@ ZTEST(fs_mgmt_hash_supported, test_supported)
|
||||||
{
|
{
|
||||||
struct net_buf *nb;
|
struct net_buf *nb;
|
||||||
struct hash_checksum_type expected_types[] = {
|
struct hash_checksum_type expected_types[] = {
|
||||||
#ifdef CONFIG_FS_MGMT_HASH_SHA256
|
#ifdef CONFIG_MCUMGR_GRP_FS_HASH_SHA256
|
||||||
|
|
||||||
{
|
{
|
||||||
.name = "sha256",
|
.name = "sha256",
|
||||||
|
@ -45,7 +45,7 @@ ZTEST(fs_mgmt_hash_supported, test_supported)
|
||||||
.entries_matched = false,
|
.entries_matched = false,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_FS_MGMT_CHECKSUM_IEEE_CRC32
|
#ifdef CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32
|
||||||
{
|
{
|
||||||
.name = "crc32",
|
.name = "crc32",
|
||||||
.format = 0,
|
.format = 0,
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#
|
#
|
||||||
CONFIG_ZTEST=y
|
CONFIG_ZTEST=y
|
||||||
CONFIG_MCUMGR=y
|
CONFIG_MCUMGR=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY=y
|
CONFIG_MCUMGR_TRANSPORT_DUMMY=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE=256
|
CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE=256
|
||||||
CONFIG_MCUMGR_CMD_OS_MGMT=y
|
CONFIG_MCUMGR_GRP_OS=y
|
||||||
CONFIG_OS_MGMT_ECHO=y
|
CONFIG_MCUMGR_GRP_OS_ECHO=y
|
||||||
CONFIG_ZTEST_NEW_API=y
|
CONFIG_ZTEST_NEW_API=y
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
#
|
#
|
||||||
CONFIG_ZTEST=y
|
CONFIG_ZTEST=y
|
||||||
CONFIG_MCUMGR=y
|
CONFIG_MCUMGR=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY=y
|
CONFIG_MCUMGR_TRANSPORT_DUMMY=y
|
||||||
CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE=256
|
CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE=256
|
||||||
CONFIG_MCUMGR_CMD_OS_MGMT=y
|
CONFIG_MCUMGR_GRP_OS=y
|
||||||
CONFIG_MCUMGR_GRP_OS_INFO=y
|
CONFIG_MCUMGR_GRP_OS_INFO=y
|
||||||
CONFIG_MCUMGR_GRP_OS_INFO_CUSTOM_HOOKS=y
|
CONFIG_MCUMGR_GRP_OS_INFO_CUSTOM_HOOKS=y
|
||||||
CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS=y
|
CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS=y
|
||||||
|
|
|
@ -53,5 +53,5 @@ tests:
|
||||||
tags: os_mgmt_info
|
tags: os_mgmt_info
|
||||||
extra_configs:
|
extra_configs:
|
||||||
- CONFIG_LIMITED_TEST=y
|
- CONFIG_LIMITED_TEST=y
|
||||||
- CONFIG_MCUMGR_SMP_DUMMY_RX_BUF_SIZE=64
|
- CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE=64
|
||||||
- CONFIG_MCUMGR_GRP_OS_INFO_MAX_RESPONSE_SIZE=32
|
- CONFIG_MCUMGR_GRP_OS_INFO_MAX_RESPONSE_SIZE=32
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
#
|
#
|
||||||
mainmenu "SMP Reassembly unit test"
|
mainmenu "SMP Reassembly unit test"
|
||||||
|
|
||||||
config MCUMGR_SMP_REASSEMBLY_UNIT_TESTS
|
config MCUMGR_TRANSPORT_REASSEMBLY_UNIT_TESTS
|
||||||
def_bool y
|
def_bool y
|
||||||
select MCUMGR_SMP_REASSEMBLY
|
select MCUMGR_TRANSPORT_REASSEMBLY
|
||||||
help
|
help
|
||||||
Enable SMP Reassembly unit tests.
|
Enable SMP Reassembly unit tests.
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
#
|
#
|
||||||
CONFIG_ZTEST=y
|
CONFIG_ZTEST=y
|
||||||
CONFIG_MCUMGR=y
|
CONFIG_MCUMGR=y
|
||||||
CONFIG_MCUMGR_BUF_COUNT=1
|
CONFIG_MCUMGR_TRANSPORT_NETBUF_COUNT=1
|
||||||
CONFIG_ZTEST_NEW_API=y
|
CONFIG_ZTEST_NEW_API=y
|
||||||
|
|
|
@ -13,8 +13,9 @@
|
||||||
#include "mgmt/mcumgr/transport/smp_reassembly.h"
|
#include "mgmt/mcumgr/transport/smp_reassembly.h"
|
||||||
#include "mgmt/mcumgr/transport/smp_internal.h"
|
#include "mgmt/mcumgr/transport/smp_internal.h"
|
||||||
|
|
||||||
|
#define TRANSPORT_NETBUF_SIZE CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE
|
||||||
static struct smp_transport smpt;
|
static struct smp_transport smpt;
|
||||||
static uint8_t buff[CONFIG_MCUMGR_BUF_SIZE];
|
static uint8_t buff[TRANSPORT_NETBUF_SIZE];
|
||||||
#define TEST_FRAME_SIZE 256
|
#define TEST_FRAME_SIZE 256
|
||||||
|
|
||||||
static struct net_buf *backup;
|
static struct net_buf *backup;
|
||||||
|
@ -39,14 +40,14 @@ ZTEST(smp_reassembly, test_first)
|
||||||
|
|
||||||
/** First fragment errors **/
|
/** First fragment errors **/
|
||||||
/* Len longer than netbuf error */
|
/* Len longer than netbuf error */
|
||||||
zassert_equal(-ENOSR, smp_reassembly_collect(&smpt, buff, CONFIG_MCUMGR_BUF_SIZE + 1),
|
zassert_equal(-ENOSR, smp_reassembly_collect(&smpt, buff, TRANSPORT_NETBUF_SIZE + 1),
|
||||||
"Expected -ENOSR error");
|
"Expected -ENOSR error");
|
||||||
/* Len not enough to read expected size from header */
|
/* Len not enough to read expected size from header */
|
||||||
zassert_equal(-ENODATA,
|
zassert_equal(-ENODATA,
|
||||||
smp_reassembly_collect(&smpt, buff, sizeof(struct smp_hdr) - 1),
|
smp_reassembly_collect(&smpt, buff, sizeof(struct smp_hdr) - 1),
|
||||||
"Expected -ENODATA error");
|
"Expected -ENODATA error");
|
||||||
/* Length extracted from header, plus size of header, is bigger than buffer */
|
/* Length extracted from header, plus size of header, is bigger than buffer */
|
||||||
mh->nh_len = sys_cpu_to_be16(CONFIG_MCUMGR_BUF_SIZE - sizeof(struct smp_hdr) + 1);
|
mh->nh_len = sys_cpu_to_be16(TRANSPORT_NETBUF_SIZE - sizeof(struct smp_hdr) + 1);
|
||||||
zassert_equal(-ENOSR,
|
zassert_equal(-ENOSR,
|
||||||
smp_reassembly_collect(&smpt, buff, sizeof(struct smp_hdr) + 1),
|
smp_reassembly_collect(&smpt, buff, sizeof(struct smp_hdr) + 1),
|
||||||
"Expected -ENOSR error");
|
"Expected -ENOSR error");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue