Commit graph

808 commits

Author SHA1 Message Date
Dominik Ermel
aa0249ddd1 mgmt/mcumgr/lib: STAT mgmt: Remove stat_mgmt_get_group function
The function has been reimplemented within stat_mgmt_list directly,
reducing execution time and code size.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:32 +01:00
Dominik Ermel
6314a9c6d8 mgmt/mcumgr/lib: Unify STAT group code
The commit merges Zephyr specific code from zephyr_stat_mgmt.c
to stat_mgmt.c, removes *_impl_* prototypes of functions that are
used for system specific implementations.
zephyr_ prefixes have been removed from identifiers as they are
no longer needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:32 +01:00
Dominik Ermel
a3ec5b258c mgmt/mcumgr/lib: Start response container after request validation
The commit reorganizes smp_handle_single_payload function to only
open map container, in response, after request have been validated
to be processable.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:03 +01:00
Dominik Ermel
2a33947842 mgmt/mcumgr/lib: Remove unused arg param from mgmt_init_writer_fn
The commit removes arg parameter from mgmt_init_writer_fn
function typedef and implementation in zephyr_smp_init_writer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:37:45 +01:00
Dominik Ermel
10f41622d2 mgmt/mcumgr/lib: Remove unused arg para from mgmt_init_reader_fn
The commit removes arg parameter from mgmt_init_reader_fn
function typedef and implementation in zephyr_smp_init_reader.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:37:45 +01:00
Dominik Ermel
88e2b4c768 mgmt/mcumgr/lib: Replace smp_init_rsp_hdr with smp_make_rsp_hdr
The smp_make_rsp_hdr prepares new response header from request
header, sets proper frame length to it and converts it to
network format.
Because a respose buffer has now pre-allocated space for header
it is no longer required to call the smp_make_rsp_hdr,
formerly smp_init_rsp_hdr, to reserve such space before adding
data that should follow it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:37:45 +01:00
Dominik Ermel
d643a9c4ea mgmt/mcumgr: Reserve SMP header size on buffer initialization
The commit changes cbor_nb_writer_init function to reserve
SMP header size on init. The change makes call to
mgmt_streamer_reset_buf within smp_write_hdr no longer needed.
The mgmt_streamer_write_at function, that has been exclusively
used to write headers, have been replaced with mgmt_streamer_write_hdr
and zephyr_smp_write_hdr, formerly zephyr_smp_write_at, has been
reduced as it no longer needs to check and update net_buf metadata
to write header as the cbor_nb_writer_init does it now.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:37:45 +01:00
Gerard Marull-Paretas
c966a95718 mgmt: mcumgr: fix Kconfig option prompt
Boolean options must not start with "Enable...". Adjusted the prompt to
comply with the guidelines.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-21 18:54:08 +01:00
Dominik Ermel
92103b835b mgmt/mcumgr: Add optional packet re-assembly to BT transport
New CONFIG_MCUMGR_SMP_BT_PKASM has been added that enabled
SMP packet re-assembly, at transport level, to the BT.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 18:03:18 +01:00
Dominik Ermel
a99118d140 tests/mgmt/mcumgr/smp_reassembly: Unit tests for re-assembly
The commit adds unit tests for SMP packet re-assembly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 18:03:18 +01:00
Dominik Ermel
d0499d112a mgmt/mcumgr: Add packet re-assembly support
The commit adds packet re-asembly to SMP that can be used to
collect packet from fragments at SMP transport level.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 18:03:18 +01:00
Dominik Ermel
fa71c9c9e8 mgmt/mcumgr/lib: Prepare mcumgr smp for logging
Commit adds configuration for logging from mcumgr SMP protocol
source, and registers logging module.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 18:03:18 +01:00
Dominik Ermel
9a0174df40 mgmt/mcumgr: Storeage erase may bus fault when no device
The commit fixes erase storage command so that it would return with
error code instead of bus faulting when no device is attached
to flash storage.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 10:14:41 +01:00
Dominik Ermel
c842bb1ac1 mgmg/mcumgr/lib: Fix image commandis bus faults when no device
It is possible for flash partition to have no device attached
which may cause image commands to bus fault device.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-21 10:14:41 +01:00
Nazar Kazakov
f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Yong Cong Sin
d2f7d696aa subsys/mgmt/hawkbit: update http response handling
Following the merge of #42026, the http body handling can be
simplified.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-16 10:25:38 +01:00
Yong Cong Sin
49c2d8a635 net: http: Rename body_start to body_frag_start
Following #42026, the body_start pointer now points to the
start of the body fragment in the recv_buffer as long as there
is body in it, either entirely or partially.

Rename the body_start to body_frag_start to better reflect
what it represents.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-15 10:05:21 +01:00
Dominik Ermel
412ff6edce mgmt/mcumgr/lib: Fix os_mgmt_echo returning Cbor error
The os_mgmt_echo is supposed to return MGMT type error not
Cbor; there was missing translation.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-11 10:58:55 +01:00
Dominik Ermel
f184f9d341 mgmt/mcumgr/lib: Fix cbor_internal_read_object error overwrite
The cbor_value_advance at the end of attribute parsing loop could
overwrite err with 0; this could cause loop to fail to break
on error and make cbor_internal_read_object return success, even
if parsing of input buffer failed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-11 10:58:55 +01:00
Dominik Ermel
7946713bcb mgmt/mcumgr/lib: Fix formatting in cborattr
Fixes tabs.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-11 10:57:34 +01:00
Gerard Marull-Paretas
95fb0ded6b kconfig: remove Enable from boolean prompts
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:

sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 15:35:54 +01:00
Dominik Ermel
264877cf50 mgmt/mcumgr/lib: Fix taskstat thread name processing
The commit:
 - removes usage of strnlen to make taskstat code C99 compliant;
 - corrects thread name len, following update description of
   CONFIG_OS_MGMT_TASKSTAT_THREAD_NAME_LEN;
 - reduces duplicated code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-07 10:53:20 +01:00
Dominik Ermel
cd97b19749 mgmg/mcumgr/lib: Remove strnlen from OS echo command
The commit removes usage of strnlen from echo command to make
code C99 compliant, and allow it to compile with newlib.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-07 10:53:20 +01:00
Dominik Ermel
8284d486c4 mgmt/mcumgr: Kconfig: Correct OS_MGMT_TASKSTAT_THREAD_NAME_LEN info
The help for the OS_MGMT_TASKSTAT_THREAD_NAME_LEN stated that
the config includes terminating zero, but this is not true:
when thread name is encoded with CBOR it is encoded with actual
string length and is not zero terminated.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-07 10:53:20 +01:00
Gerard Marull-Paretas
260deccb6e doc: use :kconfig:option: domain role
Kconfig options now belong to the Kconfig domain, therefore, the
:kconfig:option: role needs to be used.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-02 09:28:37 +01:00
Flavio Ceolin
df3d1f83f7 drivers: crypto: Rename cipher file
This file defines the crypto driver API, cipher is supposed to be just
one type of capability (other can be hash) of these drivers, just
change the file name to be consistent with it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-03-01 16:32:43 -05:00
Dominik Ermel
b30fda2639 mgmt/mcumgr/lib: Allow echo buffer size configuration
Commit adds CONFIG_OS_MGMT_ECHO_LENGTH Kconfig option that allows
to configure size of echo buffer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-01 13:21:57 +01:00
Gerard Marull-Paretas
252053f4fe mgmt: hawkbit: nvs: use nvs_mount
Replace deprecated nvs_init() with nvs_mount().

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-01 12:46:34 +01:00
Kamil Piszczek
8e327161bb mcumgr: bluetooth: use dedicated config of connection params during dfu
Extended the connection parameters negotiation procedure used in the
SMP BT module. From now on, it is possible to configure a preferable
set of all connection parameters to be used during the image transfer.
The default values are optimized for transfer throughput.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2022-02-28 11:10:03 +01:00
Dominik Ermel
a30698a148 mgmt/mcumgr: Remove redundant memcpy from buf processing
The commit removes redundant memcpy operations and switches from
using TinyCBOR provided byte order converters to sys_be, native
to Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-22 10:24:44 +01:00
Dominik Ermel
dc8308506e mgmt/mcumgr/lib: Remove unneeded return code check
The smp_process_request_packet has been checking return code from
mgmt_streamer_init_writer where Zephyr implementation of the
callback always returns 0.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-21 20:50:06 -05:00
Carles Cufi
07c78e515c mgmt: mcumgr: Replace use of crc16 with crc16_itu_t
Since this CRC uses the 0x1021 poly with no reflection, a faster
implementation is available in the crc16_itu_t() function, which is
O(n).

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-04 12:33:22 -05:00
Berend Ozceri
9edb8e2afb mgmt: smp: Fix NULL pointer dereferences in UDP transport.
Guard call to k_thread_abort() to ensure it's not called with an
uninitialized thread and fix improper use of inet_pton() with
INADDR_ANY passed in place of a dotted-decimal string. Both of these
would otherwise lead to NULL pointer dereferences.

Signed-off-by: Berend Ozceri <berend@recogni.com>
2022-02-04 11:23:16 +01:00
Dominik Ermel
0905e8e32f mgmt/mcumgr/lib: Fix message_size not updated
The commit fixes smp_process_request_packet failing to decrement
message_size, of read stream, by number of bytes it trims from
an input buffer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-04 11:14:08 +01:00
Dominik Ermel
7728587f47 mgmt/mcumgr/lib: Fix no check on message
The commit fixes smp_process_request_packet not checking header
stated message length against actual message length.
This could lead to an erratic behavior of an application when it tries
to parse CBOR data beyond actual size of message or potential
Zephyr crash.
When application has asserts enabled the error leads to inevitable
Zephyr crash, caused by net_buf checks.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-01 16:20:35 -05:00
Dominik Ermel
8a4c58618b mgmt/mcumgr/lib: Return error on bad SMP header
The changes smp_process_request_packet to return MGMT_ERR_ECORRUPT
in case when failed to read header.
This helps to recognize that there will not be any response sent
from mcumgr to the buffer given to smp_process_request_packet as
it has not been recognized as valid request.
It also removes redundant check on mgmt_streamer_init_reader which
always returns 0 (no failure) in Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-31 17:22:03 +01:00
Dominik Ermel
e83b074128 mgmg/mcumgr/lib: Image upload size no longer needs flash alignment
The mcumgr image upload uses buffed flash writes with use of stream
flash, which makes flash alignment check unneded.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-31 16:22:55 +01:00
Dominik Ermel
643e4d65c6 mgmt/mcumgr/lib: Fix bug in file download chunk size config
The commit fixes bug in compile time calculation of file download
chunk, FS_MGMT_DL_CHUNK_SIZE, that is permitted within selected
mcumgr buffer size, where the mcumgr header length has not been
taken into account.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-21 13:17:59 -05:00
Dominik Ermel
2f7c2333c8 mgmt/mcumg/lib: Use Kconfig options directly in img mgmt
The commit removes internal names given to Kconfig options,
in img_mgmt_config.h, and modifies code to use the Kconfig options
directly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-21 11:34:38 -05:00
Dominik Ermel
6bbc261402 mgmt/mcumg/lib: Use Kconfig options directly in fs mgmt
The commit removes internal names given to Kconfig options,
in fs_mgmt_config.h, and modifies code to use the Kconfig options
directly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-21 11:32:56 -05:00
Dominik Ermel
bd10559364 mgmt/mcumgr/lib: Shorten error path in taskstat processing
The tasktat code filling reposes with use of CBOR has been modified,
utilizing lazy evaluation of C '||' operator, to terminate CBOR
encoding as soon as first error appears.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-11 11:48:08 +01:00
Dominik Ermel
78f01b5900 mgmt/mcumgr/lib: Add OS_MGMT_TASKSTAT_STACK_INFO to mcumgr
The commit adds OS_MGMT_TASKSTAT_STACK_INFO Kconfig option
that allows to skip, when disabled,  "stksz" and "stkuse" reports,
in "taskstat" command responses.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-11 11:48:08 +01:00
Dominik Ermel
a566c92c1c mgmt/mcumgr/lib: Thread name selection for taskstat report
The commit adds Kconfig options and supporting code that allows
to select characteristic that will be used for thread name
in taskstat from:
 - thread name, when THREAD_NAME is enabled;
 - thread ID/index;
 - thread priority.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-11 11:48:08 +01:00
Dominik Ermel
49a3624cc8 mgmt/mcumgr/lib: Allow signed priorities in taskstat
By default the mcumgr taskstat responses send task priorities
as unsigned integers, while Zephyr uses int8_t as priority type.
This commit adds OS_MGMT_TASKSTAT_SIGNED_PRIORITY Kconfig option
that allows to switch to use signed priorities in responses.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-11 11:48:08 +01:00
Dominik Ermel
e293be6ab0 mgmt/mcumgr/lib: Make thread name in taskstat response configurable
The change adds OS_MGMT_THREAD_NAME_LEN that allows to set length of
thread name that is returned in taskstat response.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-11 11:48:08 +01:00
Dominik Ermel
845010287a mgmt/mcumgr/lib: Optimize taskstat for Zephyr
The commit changes taskstat code to directly process thread information
from Zephyr structures, instead of translating them to system agnostic
layer, before formatting response.
It also moves the takstat code to os_mgmt.c.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-11 11:48:08 +01:00
Dominik Ermel
e6437a7ef3 mgmt/mcumgr/lib: Remove os_mgmt_config.h
The commit removes os_mgmt_config.h that has been translating Kconfig
options to mgmt internal definitions for constants, and replaces
usage of these constants with direct use of Kconfig options.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-11 11:48:08 +01:00
Sebastian Bøe
22365b4dea mcumgr: kconfig: Have OS_MGMT_TASKSTAT default to n
OS_MGMT_TASKSTAT depends on THREAD_MONITOR, so when it defaults to y
and THREAD_MONITOR is disabled we get a build error.

Add a depends on to enforce a correct configuration.

Remove default y, as features should be default n.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2022-01-04 11:54:28 +01:00
Sebastian Bøe
8e47651e3f mcumgr: kconfig: Have task funcs ifdef on CONFIG_OS_MGMT_TASKSTAT
zephyr_os_mgmt_task_at and friends are ifdef'ing on a feature they
depend on instead of their own Kconfig option.

Which is not correct.

ifdef on CONFIG_OS_MGMT_TASKSTAT instead.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2022-01-04 11:54:28 +01:00
Emil Obalski
b037054f21 mcumgr: Add latency control functionality
This change adds a posibility to enable low latency connection
parameters for BT when SMP commands are handled.

Support for this functionality is disabled by the default and
can be enabled by CONFIG_MCUMGR_SMP_BT_LATENCY_CONTROL=y option.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2021-12-20 18:46:43 +01:00