Commit graph

808 commits

Author SHA1 Message Date
Daniel DeGrasse
58234d490c samples: subsys: mcumgr: Remove deprecated <power/reboot.h> header
MCUMgr sample was failing to build due to including a deprecated header.
Replace it with the new header file to fix the build.

Fixes #41050

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2021-12-10 10:30:41 +01:00
Dominik Ermel
1ccd9f0060 mgmt/mcumgr/lib: Reduce taskstat to Zephyr supported statistics
The commit adds CONFIG_OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS
Kconfig option that disables code filling in task statistics, for
mcumgr command `taskstat`, that are not collected or supported by
Zephyr.
Setting this option to y will skip following statistics in response:
"runtime", "cswcnt", "last_checkin" and "next_checkin".

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-30 11:48:44 +01:00
Dominik Ermel
0e7e08e186 mgmt/mcumgr: Fix serial packet length not including CRC16
The length field of packet has not been including the length of
CRC16 field.

Fixes #39546

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-30 11:44:26 +01:00
Jordan Yates
8e99db5801 Kconfig: net: deprecate NET_BUF_USER_DATA_LEN
As user data sizes are now set on a per pool basis, this Kconfig option
has no purpose.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-24 16:04:50 +02:00
Jordan Yates
ef440b7e7e mgmt: mcumgr: use user_data_len member
Use the new `user_data_len` member to determine size of data to copy.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-24 16:04:50 +02:00
Siddharth Chandrasekaran
5c175cc8e4 mgmt/osdp: Handle errors in uart_fifo_read()
Since 581c20e242 ("drivers: uart: Cleanup not supported API handling")
uart_fifo_read() returns -ve on errors. Correct the check on its return
value to work with this new API.

CID: 240662
Fixes: #39840
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2021-11-23 10:39:03 -05:00
Dominik Ermel
020d44456d mgmt/mcumgr/lib: Fix multi-image upload not working
The commit fixes the issue where duplicated code in
img_mgmt_impl_upload_inspect caused redirecting all image uploads,
in multi-image configuration, to the first image.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-16 21:24:09 -05:00
Dominik Ermel
1d17a4bc55 mgmt/mcumgr: Add CONFIG_IMG_MGMT_FRUGAL_LIST
The commit adds Kconfig options that enables "frugal status list";
when enabled, the status list will be sent with zero, empty and false
values omitted, slightly reducing number of bytes sent as response
from device.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-16 10:45:57 +01:00
Dominik Ermel
a29ab5106b mgmt/mcumgr/lib: Add Kconfig option MGMT_CBORATTR_FLOAT_SUPPORT
The option enables float numbers processing within CBOR attributes.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-16 10:45:57 +01:00
Dominik Ermel
cf10549e7e mgmt/mcumgr/lib: Replace license block
The commit changes licensing to SPDX tags.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-16 10:45:57 +01:00
Dominik Ermel
56e602b22b mgmt/mcumgr/lib: Fix compliance
Commit fixes compliance issues.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-16 10:45:57 +01:00
Dominik Ermel
0bc87573bf mgmt/mcumgr/lib: Documentation fixes
References to Mynewt have been removed and README for Zephyr has been
merged directly to the README.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-16 10:45:57 +01:00
Dominik Ermel
dfc57ae390 mgmt/mcumgr/lib: Remove non-Zephyr code
The commit removes MYNEWT sepcific code and code that has been
conditionally compiled with "ifndef _ZEPHYR_".

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-16 10:45:57 +01:00
Dominik Ermel
c8381a9d14 mgmt/mcumgr/lib: Remove log management commands
Not implemented.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-16 10:45:57 +01:00
Dominik Ermel
af75feac4f mgmt/mcumgr/lib: Copy mcumgr library under mgmt subsystem
The commit copies code of mcumgr, as a lib, under subsys/mgmt/mcumgr.
Only source files relevant for Zephyr have been copied, and changes
to source files have been limited only to path changes, where
required.
Samples have been left out as the only relevant sample, smp_svr,
is already within Zephyr source tree.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-16 10:45:57 +01:00
Dominik Ermel
4c9b308367 mgmt/mcumgr: Remove duplicated frame fragment marker processing
The mcumgr_serial_parse_op has been called to extract marker and
check if it is valid, just for the caller mcumgr_serial_process_frag
to process the marker again.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-12 14:48:52 +01:00
Dominik Ermel
8384fdd263 mgmt/mcumgr: Fix UART processing of TX frames
The commit fixes problem with UART TX frame processing, which was
caused by incorrect output buffer size evaulation, where input buffer
of certain len would cause entire output frame to be filled with no
place left for CRC causing a transmission to hang.
The commit, additionally, moves input buffer reminder processing out of
the input buffer processing loop.

Fixes #37893

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-09 11:17:29 +01:00
Dominik Ermel
5c9984baf7 mgmt/mcumgr: Simplify mcumgr_serial_tx_pkt
Removed some of variables used within the function, and some of
the redundant arithmetic operations.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-09 11:17:29 +01:00
Dominik Ermel
90ed7557e7 mgmt/mcumgr: Add mising static to zephyr_smp_alloc_rsp
The commit adds missing static to the zephyr_smp_alloc_rsp
function definition; it also reorders some of definitions
and removes no longer needed block of forward declarations
of functions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-11-08 18:17:31 +01:00
Andrew Hedin
e828009757 mgmt: mcumgr: Make SMP service notification function public
Allow SMP messages to be sent from user space.
For example, a user defined command can be sent when a value changes
so the client doesn't have to poll.
Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2021-11-03 16:36:17 -04:00
Dominik Ermel
512dab526c mgmt/mcumgr: Add Kconfig option to select number of supported images
The commit adds IMG_MGMT_UPDATABLE_IMAGE_NUMBER Kconfig option, int,
that allows to select how many images are supported by mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-10-05 19:20:51 -04:00
Yong Cong Sin
54490e8fe3 subsys/mgmt/hawkbit: Check retval of mbedtls_md_update
Check the return value of mbedtls_md_update and break on error.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
5cee596c9b subsys/mgmt/hawkbit: Cleanup connection if error after http_request
All errors that occured after http_request should clean up the
connection.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
22b5a03321 subsys/mgmt/hawkbit: Break and return if error
There's no need to continue if there's an error, so just break and
return.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
dfb55e5353 subsys/mgmt/hawkbit: Warning if image is unconfirmed
Add a warning if the image is unconfirmed. Add a delay before rebooting
so that the user knows what happened.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
8363e805c0 subsys/mgmt/hawkbit: Handle multipacket response properly
The current HAWKBIT_PROBE & HAWKBIT_PROBE_DEPLOYMENT_BASE response
handlers aren't able to handle multipacket response from Hawkbit
server. This commit fixes it by using the implementation from
HAWKBIT_DOWNLOAD.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Signed-off-by: Joep Buruma <burumaj50@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
793c0340d4 subsys/mgmt/hawkbit: Implement DDI API authentication
Implement Hawkbit DDI API authentication for the client.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
8ffb5e2ff2 subsys/mgmt/hawkbit: Use log_strdup for string pointers
Use log_strdup for string pointers.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
6e8b1d7c29 subsys/mgmt/hawkbit: Clean up log and print error codes
Clean up log messages and print error codes wherever possible.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Dominik Ermel
adcf32b45c mgmt/mcumgr: Add Kconfig option for direct image upload
The commit adds CONFIG_IMG_MGMT_DIRECT_IMAGE_UPLOAD that allows
to turn on the direct image upload.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-09-06 09:22:28 -04:00
Gerson Fernando Budke
529d9149d3 mgmt: updatehub: Use coap_packet_get_payload function
The #36758 fixes coap_packet_get_payload function by normalizing
offset value in the library.  That change create a regression on
UpdateHub.  However, the UpdateHub can now use coap_packet_get_payload
function instead manually compute payload start and payload size.
This refactors the current code in favor of coap_packet_get_payload
and fixes the regression.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2021-09-02 16:54:15 +02:00
Yong Cong Sin
d156fa754e subsys/mgmt/hawkbit: Compute & compare image hash
Compute the SHA256 hash of the downloaded image and compare that with
the hash in the deploymentBase to guarantee that only the correctly
downloaded image will be flashed.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
eaa29d9d71 subsys/mgmt/hawkbit: Prevent multiple instances of hawkbit_probe
Use a semaphore to prevent the hawkbit_probe from running more than once
at the same time since it reset the hawkbit context on entry and will
affect other running instance.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
17dd9f4928 subsys/mgmt/hawkbit: Check if the download completed
Remove the unused semaphore and use a boolean variable to check if the
download is complete.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
73668323cf subsys/mgmt/hawkbit: Use dts for "storage" partition
Use devicetree for the "storage" partition.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
7c8de26f45 samples/subsys/mgmt/hawkbit: Remove unused definition
Remove unused NETWORK_TIMEOUT definition.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
1409b90c90 subsys/mgmt/hawkbit: Fix typos
Fix multiple typos and make the sample's log output consistent
with the subsys.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Co-Authored-By: Sylvio Alves <sylviojalves@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
a5f49ac943 subsys/mgmt/hawkbit: Add missing CONFIG_HAWKBIT_LOG_LEVEL
Add missing CONFIG_HAWKBIT_LOG_LEVEL so that its verbosity can be
configured.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Dominik Ermel
f7ac14ddc7 mgmt/mcumgr: Allow using UART async API
The commit provides preliminary support for async UART within
mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-08-17 17:12:34 +02:00
Fabio Baltieri
f88a420d69 toolchain: migrate iterable sections calls to the external API
This migrates all the current iterable section usages to the external
API, dropping the "Z_" prefix:

Z_ITERABLE_SECTION_ROM
Z_ITERABLE_SECTION_ROM_GC_ALLOWED
Z_ITERABLE_SECTION_RAM
Z_ITERABLE_SECTION_RAM_GC_ALLOWED
Z_STRUCT_SECTION_ITERABLE
Z_STRUCT_SECTION_ITERABLE_ALTERNATE
Z_STRUCT_SECTION_FOREACH

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-08-12 17:47:04 -04:00
Dominik Ermel
75e9fa8274 subsys/mgmt/mcumgr: Add missing static to function storage_erase
The local function has been missing static specifier.
The commit also removes unused STORAGE_MGMT_ID_ERASE define.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-30 21:50:45 -04:00
Joep Buruma
6f6e5dfde0 mgmt: hawkbit: fix codestyle and whitespaces
Fix compliance code check

Signed-off-by: Joep Buruma <burumaj50@gmail.com>
2021-07-28 07:32:46 -04:00
Joep Buruma
e45c07cd60 mgmt: hawkbit: Fix case where body_data not set correctly
When downloading large files from the hawkbit server
 the only time rsp->body_start is checked is on the
first call. After this it is never checked again.

This caused the wrong data to be written to flash
and a failed update.

Signed-off-by: Joep Buruma <burumaj50@gmail.com>
2021-07-28 07:32:46 -04:00
Emil Obalski
36cf484640 mcumgr: smp: Fix NULL pointer reference
SMP implementation across bt/udp does not check
if allocation of the buffer was successful.
If the buffer is not granted an error shall be
returned.

This patch fixes BUS FAULT issue when NULL
pointer is referenced.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2021-07-23 16:25:47 -04:00
Dominik Ermel
6617af02c4 subsys/mgmt/mcumgr: Add SMP Zephyr specific storage erase command
The commit adds support for Zephyr basic mgmt group to mcumgr.
The first command added to the group is storage erase command.

Authored-by: Sigvart Hovland <sigvart.hovland@nordicsemi.no>
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-13 11:56:39 +02:00
Joakim Andersson
d97186e1ec mgmt: mcumgr: smp_bt: Use UUID encode macro for 128-bit UUIDs
Use UUID encode macro fro 128-bit UUIDs for readability. This makes
it easier to see which service you are working with as the
bt_uuid_to_str prints the 128-bit UUIDs in this format.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-11 16:13:35 +02:00
Dominik Ermel
f451cd3663 mgmt/mcumgr: Info on SHELL_BACKEND_DUMMY_BUF_SIZE impact on mcumgr
The commit adds information to Kconfig options:
 MCUMGR_CMD_SHELL_MGMT and MCUMGR_BUF_SIZE
on how the SHELL_BACKEND_DUMMY_BUF_SIZE value impacts them.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-05-26 00:05:56 -04:00
Marcin Niestroj
1beb95938e smp: shell: consume all pending buffers in smp_shell_process()
smp_shell_process() is called only once after receiving new bytes over
shell. If multiple MCUMGR frames were received over UART one after the
other, then calling smp_shell_process() resulted in consuming only the
first one. All subsequent frames were not processed unless there was
some more RX traffic.

Process received frames in smp_shell_process() in a loop until there is
no frame left. This will make sure that received packets are not stalled
waiting for more RX traffic to trigger processing again.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-05-06 19:13:20 +02:00
Gerard Marull-Paretas
f163bdb280 power: move reboot functionality to os lib
Reboot functionality has nothing to do with PM, so move it out to the
subsys/os folder.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 20:34:00 -04:00
Peter Bigot
5dced184b8 mgmt: updatehub: Conversion of k_work API
Replace all existing deprecated API with the recommended alternative.

Fixes: #34101

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2021-04-27 16:13:24 -04:00