Commit graph

808 commits

Author SHA1 Message Date
Jamie McCrae
ecfbabd213 mgmt: mcumgr: Make SMP version 2 to legacy error lookup extensible
Replaces the manual lookup function with a lookup function which
is provided when registering MCUmgr handlers which can be used to
find the function to translate error codes, allowing out of tree
MCUmgr handlers to provide error translation handlers.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-20 10:35:14 +00:00
Dominik Ermel
ebaa145818 mgmt/MCUmgr/img: Fix build issue with slot0_ns_partition
The commit fixes build issue when building for two application
images in board that does not have slot0_ns_partition.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-07-14 17:49:02 +02:00
Dominik Ermel
cb4aa46faf mgmt/MCUmgr/img: Fix img_mgmt_get_other_slot
Fix conditional compilation within img_mgmt_get_other_slot,
where CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER has been
incorrectly checked and #endif incorrectly placed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-07-14 17:48:40 +02:00
Dawid Niedzwiecki
c590c5c1ee mgmt: ec_host_cmd: add suppressing commands
Add a feature to suppress commands. The suppressed commands are not
logged on the command reception.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-14 09:38:20 +02:00
Dawid Niedzwiecki
cf3b0381ae mgmt: ec_host_cmd: fix init of npxc shi backend
Make sure not to access not assigned pointer at the begining of the
initialization.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-13 09:21:08 +02:00
Dawid Niedzwiecki
b04692b747 mgmt: ec_host_cmd: add user callback for a new command
Add a user possibility to set a callback for receiving a new function.
It allows instant performing some actions, that need to be done before
context switch.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-12 09:26:42 +02:00
Dawid Niedzwiecki
b6a3254d8b mgmt: ec_host_cmd: verify a command before passing it to handler
Verify validity of a received command before passing it to the general
handler.

It allows performing some actions, right after receiving the command.
The context switch is not needed. Such feature may be needed for
overloaded system, where instant reboot is required.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-12 09:26:42 +02:00
Dawid Niedzwiecki
1b6d6fb135 mgmt: ec_host_cmd: add function to signal a new command
Add a function to signal a new host command by a backend.

Use a function instead of giving semaphore, because it allows more
actions on rx event, common for all backends.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-12 09:26:42 +02:00
Dawid Niedzwiecki
7a479eec0d mgmt: ec_host_cmd: save result of IN_PROGRESS command
Add a config to save the final result of a last host command that has
sent EC_HOST_CMD_IN_PROGRESS response. To get the final result use the
ec_host_cmd_send_in_progress_status function.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-12 09:26:42 +02:00
Mykola Kvach
d0472aae7a soc: arm64: add Renesas Rcar Gen3 SoC support
Add files for supporting arm64 Renesas r8a77951 SoC.
Add config option CPU_CORTEX_A57.

Enable build of clock_control_r8a7795_cpg_mssr.c for
a new ARM64 SoC R8A77951.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-07-11 11:17:41 +02:00
Jamie McCrae
c9a4764c10 mgmt: mcumgt: smp: Fix not checking returned status
Fixes not checking if a zcbor operation was successful.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-10 12:04:40 +02:00
Jamie McCrae
fbacedaef8 mgmt: mcumgr: grp: shell_mgmt: Fix issue with unset variable
Fixes an issue where a variable was used without being correctly
set by other parts of the code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-10 09:26:19 +02:00
Dawid Niedzwiecki
40924edec2 mgmt: ec_host_cmd: fix checking command version
The sizeof is used in a wrong way which causes incorrect checking a
version of a command. Use NUM_BITS instead.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-07 09:22:13 +02:00
Dawid Niedzwiecki
521f0ba4f8 mgmt: ec_host_cmd: clear response buffer every command
The response buffer has to be cleared every command not to pass
unintended content e.g. response from a previous command, or stack
content.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-07 09:22:13 +02:00
Dawid Niedzwiecki
f2d6e0f660 mgmt: ec_host_cmd: set max response every command
Update the response buffer size, passed to a command handler, every
command, since a backend could change it in runtime.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-07-07 09:22:13 +02:00
Matthias Breithaupt
04ce5b9e58 mgmt: hawkbit: remove NET_SOCKETS_POSIX_NAMES dependency
Currently, it is not possible to use hawkbit with code that requires
POSIX_API to be set due to the dependency on NET_SOCKETS_POSIX_NAMES.
Since a lot of other code has already been moved to `zsock_`, this
commit does the same for hawkbit.

Co-authored-by: rojedag <r.ojeda@vogl-electronic.com>
Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
2023-06-28 06:32:45 +00:00
Dawid Niedzwiecki
c8c149dce8 mgmt: ec_host_cmd: add logging system
Add a native way to log Host Command communication.

Use Zephyr logging system to do it. Use debug and normal levels.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-06-26 16:13:42 +02:00
Dawid Niedzwiecki
159f56d57e mgmt: ec_host_cmd: use one command to send response
Use one common function to send Host Command response. It allows
handling all response types within one function.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-06-26 16:13:42 +02:00
Marek Pieta
6bbd6d3794 mcumgr: img_mgmt: Fix unused "status" variable warning
Changes aligns ifdefs to fix compilation warnings related to unused
"status" variable.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-06-26 12:31:05 +00:00
Jamie McCrae
6877ad413f mgmt: mcumgr: smp: Allow preventing command execution via hook
Adds status checking to the command status hook which allows an
application to inspect a request and, optionally, reject it.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-21 13:24:12 +02:00
Jamie McCrae
0b6077443d mgmt: mcumgr: grp: img_mgmt: Add optional mutex lock support
Adds an optional Kconfig that adds mutex locks to image management
group functions, this prevents collision between multiple threads
and/or transports.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-21 13:24:01 +02:00
Jamie McCrae
3e71797ba2 mgmt: mcumgr: grp: img_mgmt: Fix missing define
Fixes a missing define which causes a build failure.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-20 15:14:19 +02:00
Daniel Leung
cacefd4c33 mgmt: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Jamie McCrae
1edc8cc762 mgmt: mcumgr: grp: img_mgmt: Fix using signed values
Fixes wrongly using signed values for slot and image number when
listing images.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-14 13:47:08 -04:00
Jamie McCrae
5f9737f482 mgmt: mcumgr: fs_mgmt: Fix duplicate bool ok variables
Fixes wrongly declaring duplicate local variables that already
exist and hiding the previous variables definitions.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-13 07:10:43 -04:00
Jamie McCrae
942fc8517f mgmt: mcumgr: grp: fs_mgmt: Fix unchecked return value
Fixes a coverity issue whereby a return value was not checked.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-05 07:06:37 -04:00
Dawid Niedzwiecki
53525bb9c5 mgmt: ec_host_cmd: add support for IN_PROGRESS status
The IN_PROGRESS status is a specital status that can be sent during
handling a host command. Synchronous backends don't support it, so
an additional check is required.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-26 13:51:30 -04:00
Dawid Niedzwiecki
66d8e27c34 mgmt: ec_host_cmd: add a function to send response
A function to send Host Command response is needed for commands that
that sends IN_PROGRESS status or doesn't return e.g. perform reboot.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-26 13:51:30 -04:00
Dawid Niedzwiecki
a2b9c56ee5 mgmt: ec_host_cmd: fix checking usage of handler buffer
The usage of RX handler buffer was checked incorrectly.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-26 13:51:30 -04:00
Jamie McCrae
d2eed56f4f mgmt: mcumgr: grp: os_mgmt: Fix issue and add xtensa
Fixes an issue with a missing else as part of a condition and adds
xtensa.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
c052a9f4eb mgmt: mcumgr: Disable legacy Kconfigs if legacy mode is disabled
It does not make sense to control configuration of legacy
options if legacy mode is diabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
7225ba0788 mgmt: mcumgr: grp: os_mgmt: Change select to imply for reboot
OS management's reset is optional, therefore only imply reset
instead of selecting it, so it can optionally disabled if not
needed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
aff663dd2f mgmt: mcumgr: smp: Expand ver to version and limit version
Expands a bitfield name from nh_ver to nh_version so it is more
obvious what it is. Also changes the version that goes into the
response to indicate what the maximum supported version of the
protocol is for a device

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 15:05:29 +02:00
Jamie McCrae
7e23e73bc1 mgmt: mcumgr: transport: udp: Rework transport
This reworks the UDP transport to resolve some issues with object
interactions and streamlines the code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 10:22:42 +02:00
Dominik Ermel
9cc6a7f060 mgmt/MCUmgr/grp/img: Fix possible missing failure check
No reason to continue zcbor encoding of slot information for image
list when already failed at encoding version.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-26 10:21:53 +02:00
Dominik Ermel
2f53e7af43 mgmt/MCUmgr/grp/img: DirectXIP flag pending slot as permanent
Image list should also flag pending slot as permanent.
This follows the image list for swap configuration where slot
confirmed for next boot is marked as permanent.
The difference is that in DirectXIP mode it is still possible
to erase slot marked as pending and permanent, before restart
happens.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-26 10:21:28 +02:00
Dominik Ermel
1847540663 mgmt/MCUmgr/grp/img: Remove leftover header img_mgmt_impl.h
The header has been replaced with img_mgmt_priv.h.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-26 10:21:05 +02:00
Jamie McCrae
0cce365c4f mgmt: mcumgr: fs_mgmt: Add other access hooks and minor fixes
Adds callback checks to other fs_mgmt group file access functions
which allows for file access control, and moves where the callback
is triggered for uploads and downloads to prevent getting the
callback multiple times for the same file. The callback struct has
been modified so applications using the previous signature will
need to be updated.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 10:20:39 +02:00
Jamie McCrae
56f66334b0 mgmt: mcumgr: grp: fs_mgmt: Fix cmake selection
Fixes an issue whereby mbedtls will not be included if tinycrypt
is included in the build.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 18:00:53 +02:00
Jamie McCrae
2e4c3f1da9 mgmt: mcumgr: grp: fs_mgmt: Change insecure warning
Changes the warning from being text in Kconfig for filesystem
management as a whole to being a cmake warning which is displayed
if the user has not enabled file access hooks with a link to the
documentation on how to set them up.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 16:36:38 +02:00
Jamie McCrae
1d6ee8da5f mgmt: mcumgr: Change from mcumgr to MCUmgr
Fixes the name of the system.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 16:36:38 +02:00
Dawid Niedzwiecki
aa0c0727b4 mgmt: ec_host_cmd: add config to create a dedicated thread
Add a config to decide if a new dedicated thread for Host Command is
created during initialization.

If not, the ec_host_cmd_task has to be called by another thread to
handle host commands.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-23 16:19:53 +02:00
Jamie McCrae
ea6d326ab4 mgmt: mcumgr: grp: img_mgmt: Remove unused file
Removes a file that provided unimplemented and unused functions.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-22 12:25:05 +02:00
Jamie McCrae
fbd5415ca2 mgmt: mcumgr: grp: fs_mgmt: Fix not checking offset
Fixes an issue whereby the user supplied offset was not checked if
it was provided or not.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-22 12:24:48 +02:00
Jamie McCrae
c95b8ff831 mgmt: mcumgr: grp: img_mgmt: Remove useless hash variable
Removes a hash variable that was set then never used.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-22 12:21:41 +02:00
Gerard Marull-Paretas
dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00
Jamie McCrae
a476eeb8ec mgmt: mcumgr: grp: os_mgmt: Use new error for invalid format
Uses the new error system to report an error if the user provides
an invalid format for the OS info command.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-18 13:31:19 +02:00
Dawid Niedzwiecki
7efc8938eb mgmt: ec_host_cmd: update checking the handler buffer
The general handler may provide buffers for a backend. Use ranges to
check if the provided buffer is used, because the backend may shift the
beginning of the buffer to make space for preamble.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Dawid Niedzwiecki
0a17aa8605 mgmt: ec_host_cmd: add autoinit config
Add a separate config to enable autoinitialization of the host command
subsystem, called by the chosen backend.

It allows setting the chosen backend without autoinit.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Dawid Niedzwiecki
4064a41ce2 mgmt: ec_host_cmd: follow clang format
Edit some source files to follow the clang format.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00