Commit graph

808 commits

Author SHA1 Message Date
Dominik Ermel
aff57a0a42 mgmt/mcumgr/lib: Cleanup of img_mgmt_priv.h
Fixed define and removed unneded definitions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:12:03 +02:00
Dominik Ermel
bc276b1a68 mgmt/mcumgr/lib: Correct zephyr_grp log module name
The zephyr_grp log module name was incorrectly named
MGMT_SETTINGS and module registration has been using module name
mgmt_zephyr_basic, which is also incorrect.
Both have been changed to mcumgr_zephyr_grp.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:11:27 +02:00
Dominik Ermel
f79698a37c mgmt/mcumgr/lib: Separate Kconfig for zephyr specific commands
Kconfig options for Zephyr specific group have been moved
to zpehyr_grp/Kconfig.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:11:27 +02:00
Dominik Ermel
a1449521aa mgmt/mcumgr: Kconfig: Gather transport options under own menus
The commit adds transport dedicated menu and gathers all transport
options under that menu; each transport gets its own menu, witch
gathers options specific for that transport

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:10:39 +02:00
Dominik Ermel
b6db591a17 mgmt/mcumgr/lib: Add MCUMGR Parameters command to OS group
Adds new command that allows to retrieve MCUMGR parameters.
Currently the command returns MCUMGR buffer size and count.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:10:20 +02:00
Dominik Ermel
33c0995e03 mgmt/mcumgr/lib: Fix zcbor_map_decode bulk
Fixed problem with uninitialized conditional variable.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 17:43:50 +02:00
Jamie McCrae
0ea3600e5c mgmt: mcumgr: lib: Fix non-visible struct build warnings
Fixes build warnings relating to visibility of 2 structs in mcumgr

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-04-08 15:49:36 +02:00
Dominik Ermel
f36b6d8552 mgmt/mcumgr/lib: Deprecate CONFIG_IMG_MGMT_UL_CHUNK_SIZE
The IMG_MGMT_UL_CHUNK_SIZE is no longer used to control size of
intermediate buffer used for application image chunk processing,
instead directly request trasport buffer is used.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
756c34659b mgmt/mcumgr/lib: Deprecate CONFIG_OS_MGMT_ECHO_LENGTH
The echo sentence is now directly copied from request transport
buffer to response buffer, without use of intermediate buffer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
057f7a2ffd mgmt/mcumgr/lib: Deprecate FS_MGMT_UL_CHUNK_SIZE
Now the chunk of uploaded file is directly read from the transport
buffer, net_buf, and is no longer copied into intermediate buffer
so the real size of chunk is actually how much the sender could
fit into MCUMGR_BUF_SIZE, less the other fields.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
7d27f8dd58 mgmt/mcumgr: Remove dependency on TinyCBOR
Mcumgr now wholy uses zcbor for decoding/encoding SMP
requests/responses.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
05b4142637 mgmt/mcumgr/lib: Remove cborattr from mcumgr
No longer used by mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
265382931f mgmt/mcumgr/lib: Remove mgmt_err_from_cbor function
No longer needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
a3793cbfa7 mgmt/mcumgr: Move Zephyr specific group to zcbor
Replacing TinyCBOR with zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
18f0db5bd0 mgmt/mcumgr/lib: Move FS command group request processing to zcbor
The commit moves processing of SMP requests from TinyCBOR to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
9f1a8cbbb4 mgmt/mcumgr/lib: Move IMG mgmt group request processing to zcbor
The TinyCBOR, in processing SMP requests, have been replaced
with zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
40462946a9 mgmt/mcumgr/lib: Add utility zcbor_map_decode_bulk
The commit adds private, for internal mcumgr use only, utility
function for bulk processing of CBOR map entries.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
ebc62e9bf9 mgmt/mcumgr/lib: Move SHELL mgmt request processing to zcbor
The commit replaces TinyCBOR for request processing within
SHELL command group.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
784d929761 mgmt/mcumgr/lib: Move STAT group request processing to zcbor
The STAT command group request processing has been moved from
TinyCBOR to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
df028e7ee6 mgmt/mcumgr/lib: Switch OS group request processing to zcbor
The commit switches OS group commands to use zcbor instead
of TinyCBOR for processing SMP requests.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
4f9f694398 mgmt/mcumgr/lib: Remove TinyCBOR state objects from mgmt_ctxt
Removes no longer needed elements of struct mgmt_ctxt.
Removes mgmt_ctxt_init, mgmt_streamer_init_reader and init_reader
from struct mgmt_streamer_cfg as they are no longer needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
9675d94119 mgmt/mcumgr/lib: Switch smp_process_request_packet to net_buf
Drops usage of mgmt_streamer.reader in favour of direct access
to net_buf.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
6bddb0305a mgmt/mcumgr: Switch cbor_nb_reader to zcbor
The commit removes cbor_decoder_reader from cbo_nb_reader and
adds zcbor state variable to the structure.
All the code that has been supporting the cbor_decder_reader
has been removed and/or replaced with zcbor/net_buf specific.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
d0445aa4a9 mgmt/mcumgr/lib: Replace cbor_decoder_reader with cbor_nb_reader
Replaces TinyCBOR cbor_decoder_reader with cbor_nb_reader in
SMP processing code.
The SMP source code has been relying on internal elements of the
cbor_decoder_reader and had to be rewritten to use net_buf
structures, that are part of cbor_nb_reader, instead.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
1c9395f3b9 mgmt/mcumgr/lib: Replace calls to mgmt_streamer_init_writer
The calls have been replaced with direct invocations of
cbor_nb_writer_init.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
bff015feff mgmt/mcumgr/lib: Remove cbor_encoder_writer from usage
With transition to zcbor, the cbor_encoder_writer structure of
TinyCBOR is no longer used.
This commit replaces the structure with cbor_nb_writer, which
gathers zcbor processing structure with netbuf into one object.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
7cac9ef413 mgmt/mcumgr/lib: Use zcbor in OS command group responses
The commit switches processing of OS command group responses
to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
f9a7ba38b1 mgmt/mcumgr/lib: Encode IMAGE command group responses with zcbor
The commit moves encoding of IMAGE command group responses to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
2c66849401 mgmt/mcumgr/lib: Encode FS command group responses with zcbor
The commit moves encoding of FS command group responses to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
8cb52b26c1 mgmt/mcumgr/lib: Encode SHELL command group responses with zcbor
The commit moves SHELL command group responses encoding to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
e9b2c6ade2 mgmt/mcumgr/lib: Encode STAT command group responses with zcbor
The commit moves STAT command group responses encoding to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
a8e0b249fe mgmt/mcumgr/lib: Move common code for responses to zcbor
Common SMP response processing code gets switched to zcbor.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Dominik Ermel
c883c45752 mgmt/mcumgr: Add zcbor support for sending responses
The commit modifies cbor_nb_writer to handle zcbor.
Proper initialization code has been added to cbor_nb_writer_init.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-08 13:49:55 +02:00
Yong Cong Sin
9d10127b87 subsys/mgmt/hawkbit: Kconfig: Add HAWKBIT_DDI_SECURITY to choice
Add a name for the choice of authentication modes so that it
can be default to a certain type in project's Kconfig.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-04-06 04:51:07 -04:00
Dominik Ermel
f44a222275 mgmt/mcumgr: Split Kconfig into smaller Kconfigs
The commit splits the main mcumgr Kconfigs into primary Kconfig
that collect general mcumgr options for Zephyr (Zephyr specific
commands, transports, and so on), into lib/Kconfig
that collects library options and command groups' Kconfigs.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-31 14:36:38 -05:00
Yong Cong Sin
313c49ec21 subsys/mgmt/hawkbit: Check the hash of stored firmware
Previously, the hash of the firmware is checked while we are
downloading the firmware. This isn't ideal as the validity of
the firmware written into the flash is not verified and can be
corrupted. Furthermore, checking while downloading will have an
negative impact to the download speed as the CPU need to do
more work during the data transfer.

This PR removes the previous verify-hash-while-download
implementation and use the flash_img_check API instead.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-31 10:28:22 +02:00
Yong Cong Sin
77d829e31e subsys/mgmt/hawkbit: Improve hawkbit_probe readability
After the firmware is downloaded in hawkbit_probe, a series of
operations are done by using the fact that the conditions of
an if-else statement will be ran until a match.

This patches separate these condition into individual
if-condition for better readability

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-31 10:28:22 +02:00
Dominik Ermel
30fcf494be mgmt/mcumgr: Fix possible buffer overflow in BT tranport
The commit add checks whether frame received from BT transport
will really fit into allocated net_buf form mcumgr.

Fixes: #44271

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-29 10:19:09 +02:00
Dominik Ermel
e20f72f7cb kconfig: Remove unneeded ${ZEPHYR_BASE} from template import
The commit removes, from various Kconfigs, ${ZEPHYR_BASE} in
sourcing of logging template.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-24 18:07:28 -04:00
Dominik Ermel
e1d57d19f2 mgmt/mcumgr/lib: Add missing mcumgr_img_mgmt log Kconfig options
Due to lack of proper Kconfig options for the logging module,
default were always applied.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-23 18:40:53 +01:00
Dominik Ermel
7de1061f5c mgmt/mcumgr/lib: Fix LOG_MODULE_NAME for image group
Was mcumgr_flash_mgmt, replaced with mcumgr_img_mgmt.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-23 18:40:53 +01:00
Dominik Ermel
14877fd6a6 mgmt/mcumgr/lib: Use stack allocated shell buffer
The commit moves shell command buffer to stack and changes
initialization to just just put null at the beginning, before calling
a function that will fill in the buffer, and at the end, after the call.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-23 14:04:31 +01:00
Dominik Ermel
7dea9134a9 mgmt/mcumgr/lib: Unify source code for SHELL mgmt group
Moves Zephyr specific code to common source file and removes
no longer needed interface headers.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-23 14:04:31 +01:00
Dominik Ermel
a47fff2d02 mgmt/mcumgr/lib: Fix unneeded stats gathering when container failed
The commit makes stats collection conditional so in case when
CBOR container encoding fails the stats collecting function
will not be called.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 14:49:35 +01:00
Jamie McCrae
6d7d414204 mgmt: mcumgr: lib: smp: Fix checking variable before set
Fixes a twister test issue whereby handler_found and valid_hdr variables
are checked prior to being set.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-03-22 08:32:03 -04:00
Dominik Ermel
5a4f5abc4d mgmt/mcumgr/lib: Fix CONFIG_IMG_MGMT_VERBOSE_ERR
The IMG_MGMT_VERBOSE_ERR Kconfig option has not been really working
since the SMP response that it would setup was reset in case of
error, so in any instance that it would actually be used.

Fixes #32545

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:40:19 +01:00
Dominik Ermel
41cc3f04a0 mgmt/mcumgr/lib: Add support for "rsn" in error SMP responses
The commit adds support for passing "rsn" explanation strings,
for "rc" code, in error SMP responses.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:40:19 +01:00
Dominik Ermel
cbd48e1294 mgmt/mcumgr/lib: FS mgmt replace zephyr_fs_mgmt_truncate
The zephyr_fs_mgmt_truncate has been replaced with fs_unlink
since there is no point to specially check for file existence
before just removing it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:53 +01:00
Dominik Ermel
a0d379a646 mgmt/mcumgr/lib: Fix return paths code style
Functions fs_mgmt_impl_read and fs_mgmt_impl_write have been missing
proper returns.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:53 +01:00
Dominik Ermel
02f355c541 mgmt/mcumgr/lib: FS management reduce duplicated "rc" setting code
The fs_mgmt_file_upload_rsp has been renamed fs_mgmt_file_rsp
and is used everywhere where "rc" code and "off" is placed into
response, instead of duplicating code that does the task.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-22 11:38:53 +01:00