Commit graph

846 commits

Author SHA1 Message Date
Tomasz Chyrowicz
1b50f08ee9 mgmt: Handle slot version equality
If slots have equal version, but a secondary slot is the active one, the
next boot will switch to the primary slot.
Expose this through SMP commands by marking the primary slot as pending.

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
2025-10-31 22:41:16 +02:00
Jamie McCrae
20be667f16 mgmt: mcumgr: grp: settings_mgmt: Part revert settings save change
Partially reverts commit 7d2fb6c013,
it was originally thought that this commit added a method of saving
one specific key using the value that the device already has set,
but has been found to actually save the value that the user has
provided, bypassing the current value that the device has, which is
not compliant with the settings mgmt protocol, therefore remove
this change and it will need to be reworked in future to function
properly by saving one specific value from the device's current
configuration, not a user-specified value

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-10-29 20:18:20 +02:00
Anas Nashif
303af992e5 style: fix 'if (' usage in cmake files
Replace with 'if(' and 'else(' per the cmake style guidelines.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-29 11:44:13 +02:00
Fin Maaß
c821bf3493 mgmt: hawkbit: exclude DIRECT_XIP
DIRECT_XIP requires different images based on
the slot where there it is saved, in hawkbit we
currently have no way of telling the server that or
chosing a image to download based on it, so
make sure it is not used.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-10-22 18:32:16 +03:00
Valerio Setti
f779adf8e0 mgmt: mcumgr: remove usage of legacy Mbed TLS crypto for hash
The long-term goal of Zephyr is to rely exclusively on PSA Crypto API for
crypto support. At the same time Mbed TLS is going to remove legacy crypto
support starting from the next relase (v4.0).

Therefore this commit removes usage of legacy Mbed TLS crypto in favor
of PSA Crypto API. Mbed TLS will still be used in case of a build where
TF-M is not enabled.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-10-22 15:58:51 +03:00
Matheus Marques
816489e321 mgmt: hawkbit: Add options to not confirm or erase at init
Current implementation forces confirmation of current boot image and
second slot erase at hawkbit_init() and it is impossible to communicate
with hawkBit server without running it. This makes impossible to notify
update failures to server (#71750)

Add option HAWKBIT_CONFIRM_IMG_ON_INIT to allow disabling the auto image
confirmation and HAWKBIT_ERASE_SECOND_SLOT_ON_CONFIRM to select if the
second partition slot shall be erased or not.

Disable those to handle of these behaviors on application code.

Signed-off-by: Matheus Marques <code@matheusmbar.com>
2025-10-21 17:23:45 +03:00
Valerio Setti
db7bafbcdb mgmt: updatehub: simplify code
Following the removal of legacy crypto support the code could be further
simplified so this commit accomplish to this part.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-10-20 11:26:13 -04:00
Valerio Setti
b2dd3b4ba9 mgmt: updatehub: remove legacy Mbed TLS crypto support
The long-term Zephyr's goal is rely only on PSA Crypto API for crypto
support in Zephyr and at the same time Mbed TLS will remove this support
from the next release.

Therefore this commit removes usage of legacy crypto hash support from
updatehub.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-10-20 11:26:13 -04:00
Jamie McCrae
a44efd9a95 mgmt: mcumgr: transport: udp: Add support for DTLS
Adds support for using DTLS for the transport

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-10-17 18:28:08 +09:00
Jamie McCrae
1c756cbef5 mgmt: mcumgr: transport: udp: Increase default stack size to 1KiB
Fixes an issue in a board using ethernet that faults with the
default 512 byte size by doubling the default to 1KiB. The actual
size of the thread depends upon the device and application
configuration so needs to be fine tined for each application
anyhow

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-10-15 15:36:53 +03:00
Rami Saad
7d2fb6c013 mgmt: mcumgr: grp: settings_mgmt: Add capability to save setting by key
Extend the save command to allow passing name/val pair to save a
subtree or individual setting to persistent storage.
Resolves zephyrproject-rtos#90407

Co-authored-by: Jamie <40387179+nordicjm@users.noreply.github.com>
Signed-off-by: Rami Saad <rami.saad@morgansolar.com>
2025-10-13 09:35:23 -04:00
Tomasz Chyrowicz
32615695ad dfu: Allow to use imgtool-based headers
It is possible to add MCUboot header through --pad-header option.
In such cases, the FLASH_LOAD_OFFSET does not point to the beginning of
the slot, but to the beginning of the executable area, thus the check
for the active slot should use ranges instead of exact values.

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
2025-10-10 12:57:45 -04:00
Dawid Niedzwiecki
58a7119d28 mgmt: ec_host_cmd: usb: fix double free
Fix double free of a net buffer after request error.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2025-10-07 17:43:59 +03:00
Jamie McCrae
b2884ffb20 mgmt: mcumgr: grp: os_mgmt: Use board target for hardware platform
Uses the full hwmv2 board target for the hardware platform output,
seemingly this was missed in the hwmv2 migration and it was using
the board name only. Adds a deprecated Kconfig to restore to the
previous behaviour

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-10-07 14:06:06 +02:00
Tomasz Chyrowicz
cbcf81e3a4 mcumgr: Enable permanent updates in overwrite mode
It is essential for the overwrite mode to allow confirming the secondary
slot to provide the permanent update.
This types of updates is the only mode in which the application may be
upgraded.

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
2025-09-30 15:29:33 +03:00
Tomasz Chyrowicz
2e0d9ed2cf mgmt: Add missing CONFIG_ prefixes
Fix the incorrect usage of Kconfig symbols and revert back the default
behavior to allow for non-active slot confirmation.

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
2025-09-30 15:29:33 +03:00
Tomasz Chyrowicz
c1baf2f763 mgmt: Allow to block confirming non-acive slots
In Direct XIP with revert, it should be possible to block confirmation
of the non-active slot, so only a bootable binaries are marked as valid.

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
2025-09-22 13:27:27 -04:00
Jeppe Odgaard
6e7268d21b mgmt/mcumgr: add missing designator to ZCBOR_MAP_DECODE_KEY_DECODER
Add missing `.key` designator.

This also fixes a compile error:
> error: either all initializer clauses should be designated or none of
them should be

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2025-09-19 08:37:19 -04:00
Andrea Ronco
4b451307dc doc: mgmt: mcumgr: fix typo in fs_mgmt Kconfig
Fixing a typo in FS managment Kconfig docstring

Signed-off-by: Andrea Ronco <aronco@ethz.ch>
2025-09-11 18:08:20 +01:00
Dawid Niedzwiecki
6fddc44d59 mgmt: ec_host_cmd: add USB backend
Add a new ec_host_cmd backend based on USB. The backend uses the new USB
device stack.

The backend implements a vendor-specific (Google) USB interface. It uses
three endpoints:
- bulk OUT to transfer a host command request
- bulk IN to transfer a host command response
- interrupt IN to signal an event and readiness of the response

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2025-09-09 12:18:52 +01:00
Dawid Niedzwiecki
da61ccc4e3 mgmt: ec_host_cmd: add buffer alignment config
Add a new config to specify an alignment for the buffers defined by the
ec_host_cmd handler.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2025-09-09 12:18:52 +01:00
Fin Maaß
d1b6795d34 mgmt: hawkbit: move variable declaration out of if
move variable declaration out of if,
because it will be optimized away, when
optimisation is enabled and leads to
undefined and unwanted behavior.

In my case `send_buf`  of `http_client_req`
was put at the same address and the
http request was malformed.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-09-09 11:45:16 +02:00
Mandus Börjesson
8409c87e36 mgmt: hawkbit: Add option to not reboot system after update
Some applications might require cleanup prior to performing a system
reboot. Add an option that disables hawkbits automatic reboots so that
it can be postponed until the application is ready.

Signed-off-by: Mandus Börjesson <borjessonmandus@gmail.com>
2025-09-08 16:01:18 +02:00
Appana Durga Kedareswara rao
7542107048 arm64: Add new CPU_CORTEX_A78 configuration for Cortex-A78 support
Introduce a new Kconfig option CPU_CORTEX_A78 to enable support for the
Arm Cortex-A78 CPU architecture within Zephyr. This configuration can be
selected by boards or SoCs that utilize the Cortex-A78 core, enabling
architecture-specific features and optimizations as needed.

Signed-off-by: Appana Durga Kedareswara rao <appana.durga.kedareswara.rao@amd.com>
2025-09-05 16:48:38 -04:00
Jamie McCrae
d12c6888e3 mgmt: mcumgr: grp: img_mgmt: Add support for SHA512 in images
Adds support for images signed with SHA512.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-09-04 14:43:26 +02:00
Jun Lin
e9d470b2f4 ec_host_cmd: shi: npcx: not reset when receiving bad data
When the SHI driver receives data from the host and finds it is invalid
(due to a checksum error or an unsupported protocol version),
it currently resets the state machine, initializes the output buffer,
and waits for CS de-assertion. Upon CS de-assertion, the driver resets
the state machine and initializes the output buffer again. This commit
removes the first redundant reset and re-initialization in the function
`shi_npcx_bad_received_data()`, improving the driver’s efficiency.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2025-09-03 06:09:25 +02:00
Jun Lin
b30d2ac07c ec_host_cmd: shi: npcx: change log level for some error messages
It was observed in a project that when an error transaction occurs,
printing the error message can delay resetting the SHI state machine and
initializing the output buffer, which may cause the subsequent
transaction to fail, especially during stress tests involving heavy host
command communication.
This commit changes some error log level from ERR to DBG to prevent the
condition above from happening.
Also change the default debug level for the SHI driver to LOG_LEVEL_ERR.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2025-08-22 12:37:17 +02:00
Robert Lubos
faa507ef6c net: Fix misc Kconfig style issues in networking area
Fix misc Kconfig style issues in networking area.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-08-21 20:12:48 +02:00
Jamie McCrae
c58ae17389 mgmt: mcumgr: grp: img_mgmt: Show firmware loader slot info
Allows returning image information for the firmware loader image
slot, showing version of the application and flags

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-08-11 13:18:20 -05:00
Jisheng Zhang
13bdae0ad0 arch: arm: Add initial support for Cortex-M52 Core
Add initial support for the Cortex-M52 Core which is an implementation
of the Armv8.1-M mainline architecture.

The support is based on the Cortex-M55 support that already exists in
Zephyr.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
2025-08-06 12:15:23 +03:00
Daniel DeGrasse
188d78b109 mgmt: update img_mgmt_slot_in_use for ramload with revert mode
We should not block erasing pending images when using ramload with
revert mode, because uploading multiple confirmed images with the same
version would brick the device (preventing future FW updates). Update
the dependencies of img_mgmt_slot_in_use to account for this.

Signed-off-by: Daniel DeGrasse <ddegrasse@tenstorrent.com>
2025-08-05 11:53:58 +01:00
Robert Lubos
62a5260e01 net: Fix alignment error with net_ipaddr_copy()
As struct sockaddr have now alignment of 4 bytes, net_ipaddr_copy()
gives the following error if used for sockaddr:

  error: alignment 1 of ‘struct <anonymous>’ is less than 4
  [-Werror=packed-not-aligned]

Just use memcpy() instead, net_ipaddr_copy() was intended to use with IP
addresses, not socket related structs.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Jun Lin
aa3db8e5bb mgmt: ec_host_cmd: backend: shi_npcx: fix log message
This commit fixes the content of the log messages that appear when an
error occurs while applying the pinctrl.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2025-07-02 17:58:20 -05:00
Pisit Sawangvonganan
0ec49fa570 kconfig: fix typo in (soc, subsys)
Utilize a code spell-checking tool to scan for and correct spelling errors
in `Kconfig` files within the `soc` and `subsys` directory.
Additionally, incorporates a fix recommended by the reviewer.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-07-01 10:58:54 -10:00
Adrien Maillard
c37a206673 updatehub: use the new API method in autohandler
Call updatehub_report_error() when detecting an unconfirmed image in
autohandler to ensure the server is notified of the failure before
triggering a rollback.

Signed-off-by: Adrien Maillard <adrien.maillard@edu.hefr.ch>
2025-06-26 22:07:51 -05:00
Adrien Maillard
4d73cd3980 updatehub: report error before rollback on unconfirmed image
Report the error state to the UpdateHub server before triggering a rollback
in autohandler mode. This prevents the server from redeploying the same
(failed) update after rollback, avoiding update loops. Also exposes a new
public syscall: updatehub_report_error(), allowing manual mode users to
report an error explicitly.

Signed-off-by: Adrien Maillard <adrien.maillard@edu.hefr.ch>
2025-06-26 22:07:51 -05:00
Keith Packard
cecde08586 subsys/mgmt: Declare PROCESSOR_NAME for RX targets
Map the current set of RX CPU variants into descriptive names

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-06-26 14:07:03 +02:00
Paul He
f7979f6deb mgmt: mcumgr: remove redundant arguments for zephyr_library
No argument is needed for zephyr_library and a directory-inferred name will
be generated by default.

Signed-off-by: Paul He <pawpawhe@gmail.com>
2025-06-24 20:11:27 -10:00
Jamie McCrae
0adcf2e66d mgmt: mcumgr: grp: os_mgmt: Add optional boot mode for reset
Adds an optional boot mode field which can be used to boot into a
specific image or mode using MCUmgr's OS mgmt reset command

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-06-18 17:48:44 -04:00
Jukka Rissanen
5a9a39caf3 net: mgmt: Convert the mgmt API to use 64-bit masks
Instead of using 32 bit enum values for event numbers, convert
the code to use 64 bit long bit fields. This means that the
user API is changed to use 64 bit event values instead of 32
bit event values.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-18 10:54:44 +02:00
Glenn Andrews
94084e5aba Lib: SMF: Add return code to signal event propagation
See Discussion https://github.com/zephyrproject-rtos/zephyr/discussions/83659
for information about the purpose of this change.

Modifies run actions of hierarchical state machines
to return a value indicating if the event was handled
by the run action or should be propagated up to the
parent run action. Flat state machines are not affected,
and their run action returns void.

smf_set_handled() has been removed and replaced by
this return value. smf_set_state() will not propagate
events regardless of the return value as the transition
is considered to have occurred.

Documentation, tests, samples, has been updated.
USB-C and hawkBit use SMF and have been updated to use
the new return codes.

Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
2025-06-17 16:04:04 +02:00
Glenn Andrews
1bee2920f9 Lib: hawkBit: apply clang-format
Apply clang-format in preparation for code changes.

Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
2025-06-17 16:04:04 +02:00
Fin Maaß
bf111b44ad mgmt: hawkbit: add shell autohandler timeout Kconfig
Add shell autohandler timeout configuration option.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-06-02 22:10:13 +02:00
Neal Jackson
d07f8eed55 mgmt: hawkbit: do not prepend custom controllerId
This commit changes how the controllerId is generated based on device
id, and disentangles the two. The controllerId is what hawkbit uses to
uniquely identify a device, and is not necessarily the same as the
device id, and should be fully customizeable by the user if needed.
Previously, all custom device ids were being prepended with
`CONFIG_BOARD`. When a user selects `CONFIG_HAWKBIT_CUSTOM_DEVICE_ID`,
they should be able to specify the full controllerId used with hawkbit,
without a forced prepend.

Signed-off-by: Neal Jackson <neal@blueirislabs.com>
2025-05-28 11:09:10 +02:00
Neal Jackson
2ef1ddea73 mgmt: hawkbit: interface support for ip addresses and domain name
Previously, hawkbit interface only supported a url/hostname and a port,
and internally it resolves to an IP address. This does not work for
network layers that rely on NAT64, like OpenThread.  Zephyr's
implementation of `getaddrinfo` is not aware of NAT64.  DNS will resolve
an IPV4 address that needs to be converted to IPV6 with the NAT64
prefix.

This commit alters the Hawkbit interface to allow providing an explicit
domain name as a string via `server_domain`, and an already resolved IP
address as `server_addr`.

This commit changes the usage of `hawkbit_runtime_config.server_addr` to
point to either an IP address or domain name. It adds a new Kconfig
(`HAWKBIT_USE_DOMAIN_NAME`) to specify an explicit domain name and adds
a new variable `hawkbit_runtime_config.server_domain`. If
`HAWKBIT_USE_DOMAIN_NAME` is enabled and a user provides an IP address
to `server_addr`, the user must provide a domain name to
`server_domain`.

Signed-off-by: Neal Jackson <neal@blueirislabs.com>
2025-05-28 11:08:53 +02:00
Fin Maaß
4d7e35be1c mgmt: hawkbit: reset action ID after successful update report
reset action ID after successful update report.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-05-27 16:45:21 +02:00
Neal Jackson
f9701a1a21 mgmt: hawkbit: remove DNS_RESOLVER requirement for server_addr
This commit removes the requirement for DNS_RESOLVER. If DNS_RESOLVER is
enabled, hawkbit uses `CONFIG_DNS_RESOLVER_MAX_QUERY_LEN` for the
server_addr buffer, if disabled it uses `CONFIG_INET6_ADDRSTRLEN`.
This adheres to #89533 which removes the requirement for DNS_RESOLVER.

Signed-off-by: Neal Jackson <neal@blueirislabs.com>
2025-05-27 11:50:52 +02:00
Neal Jackson
64de800aa9 mgmt: hawkbit: use sizeof in server_addr length checks
Simplify length checks by using sizeof for the server_addr array.

Signed-off-by: Neal Jackson <neal@blueirislabs.com>
2025-05-27 11:50:52 +02:00
Neal Jackson
d9be126eca mgmt: hawkbit: add check for valid domain name length
This commit adds a `strnlen` length check for `server_addr` to ensure that
it will not be truncated and result in a silent failure. Instead, the
call to `hawkbit_set_config` will return -EINVAL if the supplied
`server_addr` is too long for the internal buffer.

Signed-off-by: Neal Jackson <neal@blueirislabs.com>
2025-05-27 11:50:52 +02:00
Neal Jackson
f75a11d22a mgmt: hawkbit: replace DNS_MAX_NAME_SIZE with DNS_RESOLVER_MAX_QUERY_LEN
The hawkbit subsystem was erroneously using DNS_MAX_NAME_SIZE as the
maximum query length. This limited query strings to only 20 bytes,
truncating many domain names.

Signed-off-by: Neal Jackson <neal@blueirislabs.com>
2025-05-27 11:50:52 +02:00