Commit graph

808 commits

Author SHA1 Message Date
Yong Cong Sin
dd9d6bbb44 subsys/mgmt/hawkbit: Set ai_socktype if IPV4/IPV6
Follows the implementation of updatehub and set the
`ai_socktype` only if IPV4/IPV6

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-08-18 11:33:38 +00:00
Yong Cong Sin
2ed88e998a subsys/mgmt/hawkbit: Init the hints struct to a known value
Initialize the `hints` struct to a known value so that it won't
cause undetermined behavior when used in `getaddrinfo()`.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-08-18 11:33:38 +00:00
Dominik Ermel
dd79b9c11a subsys/mgmt/hawkbit: Clean up flash map usage
The commit cleans up how flash map labels and definitions are
used.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-08-08 15:03:34 +02:00
Kumar Gala
f2bcc794cd mgmt: osdp: Move to DTS for uart device
Move from using Kconfig OSDP_UART_DEV_NAME to a devicetree
chosen property ("zephyr,osdp-uart").  This is similar to a number
of other functions like "zephyr,shell-uart" or "zephyr,bt-uart".

Changed the integration platform for the osdp samples to
stm32_min_dev_black as it already has zephyr,osdp-uart set.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-23 09:25:23 -05:00
Yudong Zhang
73c4d70614 mgmt: hawkbit: fix call to bin2hex
Fixes: f2affbd973 ("os: lib: bin2hex: fix memory overwrite")
Signed-off-by: Yudong Zhang <mtwget@gmail.com>
2022-07-11 10:30:05 +02:00
Yudong Zhang
0c4d614824 mgmt: updatehub: fix call to bin2hex
We noticed that in the master branch, updatehub fails to start.
That is because of the behaviour change in bin2hex caused by
commit f2affbd ("os: lib: bin2hex: fix memory overwrite").

Fixes: f2affbd973 ("os: lib: bin2hex: fix memory overwrite")
Signed-off-by: Yudong Zhang <mtwget@gmail.com>
2022-07-11 10:30:05 +02:00
Kumar Gala
a204d16bfb ec_host_cmd: Convert to DEVICE_DT_GET
We are working on phasing out use of the devicetree 'label'
property.  We can use DEVICE_DT_GET and drop use of DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-06 11:12:32 +02:00
Berend Ozceri
394d5f7656 mgmt: smp: Allow building with POSIX API in UDP transport
If the POSIX API is selected via the POSIX_API option, don't also select
the conflicting NET_SOCKETS_POSIX_NAMES and use the POSIX headers instead.

Signed-off-by: Berend Ozceri <berend@recogni.com>
2022-07-04 14:22:13 +00:00
Krzysztof Chruscinski
041f0e5379 all: logging: Remove log_strdup function
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 13:42:23 +02:00
Dominik Ermel
f9d69c34c9 mgmt/mcumgr/lib: Remove dead code from img_mgmt_upload
The img_mgmt_impl_erase_if_needed was only called when
CONFIG_IMG_ERASE_PROGRESSIVELY is y, and it does nothing anyway;
because the function always returns 0, and does nothing,
neither the function no result processing, from a call to the
function, is needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 13:42:24 +02:00
Dominik Ermel
0a5525358c mgmt/mcumgr/lib: Add BUSY error code
The commit reserves adds MGMT_ERR_EBUSY (10) error code and adds
documentaiton for it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:55:19 +02:00
Dominik Ermel
185630e387 mgmt/mcumgr/lib: Correct comment alignment
Some of comments have not been aligned to tabs.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:55:19 +02:00
Dominik Ermel
d261c3b891 mgmt/mcumgr/lib: Remove flash_area_open_ex
The function is no longer needed with fix provided by commit
aa5d20aaef (storage/flash_map: Return -ENODEV from flash_area_open).

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:48:23 +02:00
Dominik Ermel
4aea359f27 mgmt/mcumgr/lib: Remove unused state variables from image management
Image management state, struct img_mgmt_state, has been defining
sector_id and sector_end variables, supposed to be used by
progressive erase feature, that have no use in code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:48:04 +02:00
Dominik Ermel
8b7b81d0f2 mgmt/mcumgr/lib: Fix overriding returned error code
The img_mgmt_upload has been overriding return codes of several
utility function calls with MGMT_ERR_EUNKNOWN, even though
these utility functions would be returning MGMT_ERR_* type codes
already, overshadowing real reason of failure.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:47:43 +02:00
Dominik Ermel
1243bf6d15 mgmt/mcumgr/lib: Change image, size and offset types
The commit changes types of image, size and offset elements of
img_mgmt_upload_req structure from unsigned long long to size_t.

This commit also fixes comments and conditional statements, where
these identifiers have been compared against -1, although they have
been clearly defined as unsigned.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:47:10 +02:00
Gerard Marull-Paretas
e207b39404 mgmt: osdp: remove redundant <zephyr/zephyr.h> includes
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:13:11 +02:00
Dominik Ermel
f52085dc54 mgmt/mcumgr/lib: Fix loop when image write fails
The img_mgmt_upload was getting into loop with requesting
offset 0 from mcumgr, when requested to re-try upload after
write fails.
Because it is not really possible to recover from write fail,
at least currently, the commit changes code to reset upload
state in a case of write error and return an error code.
Now, when write fails, an error will be returned and upload
process will be stopped and reset; upload re-try will behave
as a new upload has been requested.

Fixes #44219

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-10 09:48:31 +02:00
Dominik Ermel
3d8960ffe3 mgmt/mcumgr/lib: Remove redundant offset check
The offset is checked, for correctness, before the function
img_mgmt_impl_write_image_data is called, so it is redundant to
do the same check within it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-10 09:48:31 +02:00
Dominik Ermel
0c290864d7 mgmt/mcumgr/lib: Remove no longer needed mgmt_streamer_trim_front
Special function for supporting various types of buffers,
via provided callbacks, is no longer needed when net_buf is the
only type of transport buffer used by mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-07 18:54:11 +02:00
Dominik Ermel
3528c1ee30 mgmt/mcumgr: Replace zephyr_smp_trim_front with net_buf_pull
The additional logic of zephyr_smp_trim_front is no longer needed
and net_buf_pul can be directly used to trim front of net_buf
response when fragmenting.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-07 18:54:11 +02:00
Yong Cong Sin
ae587f8e50 subsys/mgmt/hawkbit: format for readability
Formatted the code so that it is easier to read.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-07 11:52:10 +02:00
Dominik Ermel
37dd4fb775 mgmt/mcumgr/lib: Fix parasitic use of heap by image management
The commit fixes issue where image management would switch to using
heap, whether developer wanted or not, when CONFIG_HEAP_MEM_POOL
gets value greater than zero.
Now when heap is enabled the user can select whether image management
will keep on using static variable, taking static RAM, or will use
heap to allocate the flash image context only when needed.
For this purpose CONFIG_IMG_MGMT_USE_HEAP_FOR_FLASH_IMG_CONTEXT
has been added, which is available when CONFIG_HEAP_MEM_POOL is enabled.

Fixes #44214

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-06 12:05:29 +02:00
Dominik Ermel
e15523d198 mgmt/mcumgr/lib: Use flash_img_bytes_written to check context
The commit replaces direct access to flash_img_context, for the
purpose of checking how much data has been written, with call
to the flash_img_bytes_written.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-05 14:47:35 +02:00
Keith Packard
b7313f85fe subsys/img_mgmt: Add zephyr/toolchain.h for STRINGIFY [v2]
Somehow two files in subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src ended up
using STRINGIFY but nothing in their include path ended up pulling in
zephyr/toolchain/common.h. Include that via zephyr/toolchain.h.

v2:
	Use non-internal zephyr/toolchain.h header

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-27 15:34:34 -07:00
Dominik Ermel
38e554846a mgmt/mcumgr/lib: Improve CONFIG_IMG_MGMT_VERBOSE_ERR description
The description suggested logging information while it never
was the case: it was about adding additional "rsn":value pair
to an SMP response.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-27 15:21:24 -07:00
Fabio Baltieri
e24314f10f include: add more missing zephyr/ prefixes
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07:00
Dominik Ermel
19259ab7db mgmt/mcumgr/lib: Fix image list command crashing when no device
It is possible, in case of two application images, to have no access
to one of devices of the secondary image.
When asserts are enabled, such situation causes crash even though the
image list command can handle it with no problem.
The commit removes the assert and adds additional swap type:
IMG_MGMT_SWAP_TYPE_UNKNOWN to indicate situations where it was
not possible to obtain swap type from boot_util.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-26 13:08:35 -07:00
Dominik Ermel
1bd5665b89 mgmt/mcumgr/lib: Fix usage of MGMT_ERR_ENOMEM
The commit replaces MGMT_ERR_ENOMEM with MGMT_ERR_EMSGSIZE where it
was used to indicate that SMP response does not fit in response
buffer.

Fixes #44535

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-25 13:56:03 -07:00
Dominik Ermel
550f1b096d mgmt/mcumgr/lib: Fix OS taskstat passing incorrect value
The commit fixes incorrect value being passed as used stack
information and also prevents compilation error when
CONFIG_INIT_STACKS is n.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-25 16:09:12 +02:00
Damian Krolik
7e02e8c9f4 mcumgr: fix invalid condition for calling img_mgmt_dfu_stopped
In other places, img_mgmt_dfu_stopped() is called when
a failure occurs and the DFU cannot be continued. In this
place, however, the function is called on success which
does not seem to be correct.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-05-25 14:21:19 +02:00
Matthias Wauer
ba14fc4745 mgmt: img_mgmt: fix typo in variable name
The correct variable name is 'action'

Signed-off-by: Matthias Wauer <matthiaswauer@gmail.com>
2022-05-16 16:56:18 +02:00
Dominik Ermel
578cb132ff mgmt/mcumgr/lib: Make version string work with CONFIG_NEWLIB_LIBC
By default the newlib does not compile with %hhu processing,
to avoid turning on additional options for newlib compilation
this commit changes formatting string to use %hu instead.
The commit fixes problem with malformed version string being
returned, by smp_svr, when CONFIG_NEWLIB_LIBC=y is set together
with CONFIG_NEWLIB_LIBC_NANO=y.

Fixes #45261

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-15 21:33:05 +02:00
Dominik Ermel
0c051d0dd6 mgmt/mcumgr/lib: Fix astray dot in image version
Removed the dot.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-15 21:33:05 +02:00
Jamie McCrae
9e6b5cdca8 mgmt: mcumgr: lib: img: Add image header to callback
This allows an application to inspect a mcumgr img upload command to
provide additional information for acceptance or rejection of it, and
makes the previous private version compare function public so that
application code can call it.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-05-11 20:32:52 +02:00
Jamie McCrae
6a85b1b0d3 mgmt: mcumgr: lib: fs: Add file read/write access callback
This allows an application to inspect a mcumgr file access command and
either allow it or deny it with a result code.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-05-11 17:10:55 +02:00
Gerard Marull-Paretas
5113c1418d subsystems: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:07:35 +02:00
Dominik Ermel
ef199e92df mgmt/mcumgr/lib: doc: Minor fixes to zcbor_bulk documentation
Little polishing here and there.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:35:16 +02:00
Dominik Ermel
fb4afe2112 mgmt/mcumgr/lib: Remove mcumgr_util
With replacement of (u)ll_to_s with snprintf the util is no longer
needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:34:40 +02:00
Dominik Ermel
3445c29979 mgmt/mcumgr/lib: Use snprintf instead of ll_to_s in OS group
The commit replaces usage of ll_to_s with snprintf.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:34:40 +02:00
Dominik Ermel
4a12570ef8 mgmt/mcumgr/lib: Allow image management list broken version str
The commit adds change to image management list where "<???>"
will be returned as version string in case when version to string
conversion fails.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:34:40 +02:00
Dominik Ermel
692a4a7e63 mgmt/mcumgr/lib: Replace ull_to_s with snprintf in img_mgmt_ver_str
The ull_to_s, which is used to covert ints to string, has been
replaced with snprintf.
Above also fixes a bug where ull_to_s has been given INT_MAX as allowed
output string, while it should be given maiximum allowed buffer size.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:34:40 +02:00
Dominik Ermel
ca60b75613 mgmt/mcumgr/lib: Remove mgmt_streamer_reset_buf
Commit removes mgmt_streamer_reset_buf from mcumgr lib,
and supporting Zephyr function zephyr_smp_reset_buf.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-19 11:32:56 +02:00
Jamie McCrae
d67a364ace mgmt: mcumgr: lib: os: Add reset callback
This allows an application to inspect a mcumgr os reset command and
either allow it or deny it with a result code.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-04-13 14:05:57 -07:00
Dominik Ermel
4e03e34138 mgmt/mcumgr/lib: Add missing inclusion of toolchain.h
The zcbor_bulk_priv.h uses STRINGIFY for some of definitions
and, due to lack of inclusion of the toolchain.h, that was causing
compilation errors when NEWLIB would be selected.

Fixes #44811.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-13 13:28:16 -07:00
Jamie McCrae
756a8f7a9b mgmt: mcumgr: fs: Add hash/checksum (with CRC32/SHA256) handler
This adds a hash/checksum mcumgr handler to the file management commands
which can be used to get a hask or checksum of a file, and includes
handler implementations for IEEE CRC32 and SHA256.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-04-12 12:05:30 +02:00
Jamie McCrae
105f8b65e9 mgmt: mcumgr: fs: Add file status handler
This adds a command handler to the file management mcumgr system to get
the status of a file without needing to return file data (currently
reporting the file size).

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-04-12 12:05:30 +02:00
Dominik Ermel
1b92fba8e7 mgmt/mcumgr/lib: endian.h is no longer needed.
Removed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-12 11:42:28 +02:00
Dominik Ermel
e7205683bd mgmt/mcumgr/lib: Replace htons/ntohs with Zephyr functions
The commit replaces htons and ntohs calls, with sys_be16_to_cpu
and sys_to_cpu_be16.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-12 11:42:28 +02:00
Dominik Ermel
8aa7791c53 mgmt/mcumgr/lib: Improve smp_process_request_packet documentation
The commit clarifies smp_process_request_packet behaviour.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-04-11 12:13:33 +02:00