Commit graph

828 commits

Author SHA1 Message Date
Nick Brook
d0d3dd476b mgmt/mcumgr: Add error logs for all error cases
Errors were logged for some cases in zephyr_img_mgmt.c, but not all.
This commit adds error logs for all error cases.

Signed-off-by: Nick Brook <nrbrook@gmail.com>
2025-02-19 14:49:37 +00:00
Jamie McCrae
13ac8fe1f5 mgmt: mcumgr: smp: Fix custom payload size
Fixes an issue when using custom payloads where the size was still
using the zcbor buffer instead of the size of the network buffer

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-02-13 16:44:06 +01:00
Jamie McCrae
0e8cc3e52d dfu: Add support for new MCUboot swap using offset mode
Allows using this newly introduced MCUboot algorithm

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-02-10 19:05:25 +01:00
Jamie McCrae
6d35cc5e85 kconfig: Add new Kconfig for MCUboot swap using move
Adds a new Kconfig for selecting swap using move in MCUboot which
aligns with the proper MCUboot symbol and allows for adding
additional mode Kconfigs

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-02-10 19:05:25 +01:00
Jamie McCrae
f3e2e7dc06 mgmt: mcumgr: grp: img_mgmt: Add image number to confirmed callback
Adds the image number to the confirmed callback

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-02-04 11:56:31 +01:00
Marcin Niestroj
a984187c96 mgmt: mcumgr: rework create_socket() to use single sockaddr storage
Allocate only one 'struct sockaddr_storage', instead of two separate
'struct sockaddr_in' and 'struct sockaddr_in6'. This saves some space in
case both IPv4 and IPv6 are used. Additionally it reduced preprocessor
ifdef statements, resulting in more readable code.

This also solves '-Warray-bounds=' GCC warning (reproducible with
'native_sim' and GCC version 14.2.1 on Arch Linux):

  In function ‘create_socket’,
      inlined from ‘smp_udp_receive_thread’ at \
          subsys/mgmt/mcumgr/transport/src/smp_udp.c:242:7:
  subsys/mgmt/mcumgr/transport/src/smp_udp.c:205:37: warning: \
      array subscript ‘struct sockaddr[0]’ is partly outside array \
      bounds of ‘struct sockaddr_in[1]’ [-Warray-bounds=]
    205 |         tmp_sock = zsock_socket(addr->sa_family, SOCK_DGRAM, \
        |                                 ~~~~^~~~~~~~~~~
                                                        IPPROTO_UDP);
  subsys/mgmt/mcumgr/transport/src/smp_udp.c: In function \
      ‘smp_udp_receive_thread’:
  subsys/mgmt/mcumgr/transport/src/smp_udp.c:170:28: note: \
      object ‘addr4’ of size 8
    170 |         struct sockaddr_in addr4;
        |                            ^~~~~

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2025-02-03 19:53:13 +01:00
Jamie McCrae
98d5aa3792 mgmt: mcumgr: grp: img_mgmt: Fix calling confirm
Fixes calling the registered callbacks for image being confirmed
if the confirmation was not successful

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-02-03 11:18:25 +01:00
Jamie McCrae
c562cbc284 mgmt: mcumgr: grp: img_mgmt: Fix unused label warning
Fixes an issue with a warning when compiling for direct xip mode
without revert

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-01-21 11:11:51 +01:00
Andrzej Głąbek
6d9513ef35 mgmt: mcumgr: grp: os_mgmt: Fix compilation warning
This is a follow up to commit 770482a45a.

Add initialization of the `ok` variable to prevent the "may be
uninitialized" warning when `CONFIG_BOOTLOADER_MCUBOOT` is not
defined.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-01-20 20:56:52 +01:00
Dawid Niedzwiecki
6f6f8bc931 mgmt: ec_host_cmd: uart: improve error handling
Add an array with the states names and use it while logging an error
messages.

Additionally unify the error message format. Do not add
"UART HOST CMD ERROR", because the LOG_ERR macro already informs that
it is an error message.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2025-01-20 11:27:06 +01:00
Fin Maaß
ca43888f54 mgmt: hawkbit: use flash_img_get_upload_slot()
don't assume, that the slot to upload is the second.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-01-17 09:07:45 +01:00
Dawid Niedzwiecki
4f772ebee9 mgmt: ec_host_cmd: uart: add timeout config
Use a config, instead of hardcode, to set timeout value.

It says how much time UART backend should wait for entire message sent
in chunks.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2025-01-16 22:41:09 +01:00
Fin Maaß
3c88970cec mgmt: hawkbit: add CONFIG_HAWKBIT_SAVE_PROGRESS_INTERVAL
add CONFIG_HAWKBIT_SAVE_PROGRESS_INTERVAL, to
be able to set a interval, how often the progress is saved.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-01-09 14:13:42 +01:00
Fin Maaß
4cd44e7da2 mgmt: hawkbit: resume firmware downloads
save download progress, to resume failed
firmware downloads.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-01-09 14:13:42 +01:00
Jamie McCrae
5871037426 mgmt: mcumgr: grp: os_mgmt: Add error code for invalid responses
Adds a new error code that can be used to signify that a query was
valid but the response was not valid

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-01-03 10:02:23 +01:00
Fin Maaß
b500f4c557 mgmt: hawkbit: use settings_save_subtree()
use settings_save_subtree() instead of settings_save() to
only save the hawkbit settings

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-12-25 03:37:14 +01:00
Fin Maaß
6dce233265 mgmt: hawkbit: use flash_area from flash_ctx
don't assume, that the slot to upload is the second.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-12-23 09:17:14 +01:00
Fin Maaß
49f5bc9698 mgmt: hawkbit: add callbacks for events
add callbacks for events.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-12-23 09:17:14 +01:00
Fin Maaß
a3acb67f62 mgmt: hawkbit: rename close to cancel
rename close to cancel, as it is more fitting.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-12-23 09:17:14 +01:00
Fin Maaß
fb573f5d64 mgmt: hawkbit: allow different tenants
allow the use of other tenants.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-12-23 09:17:14 +01:00
Fin Maaß
41f7ae9488 mgmt: hawkbit: use SMF
use smf for hawkbit.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-12-23 09:17:14 +01:00
Valerio Setti
39068cc70e mbedtls: select ENTROPY_GENERATOR when a driver is available
This is based on the introduction of a helper Kconfig symbol in
"subsys/random/Kconfig" which is named CSPRNG_AVAILABLE. When this is
enabled it means that there is a "zephyr,entropy" property defined in the
device-tree, therefore Mbed TLS can select ENTROPY_GENERATOR to allow
the platform specific driver to be included into the build.

This commit also changes other locations where CSPRNG_ENABLED was used
moving it to CSPRNG_AVAILABLE in order to solve dependency loop
build failures.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-12-19 17:53:37 +01:00
Hongquan Li
bda1e7677e Subsys: mgmt: mcumgr: Fix mcumgr assertion error
In the case of IPV6 not enabled, when NET_SOCKETS_PACKET is enabled,
the sizeof(struct sockarr) will change to 20, the value of
MCUMGR_TRANSPORT_NETBUF_MIN_USER_DATA_SIZE is 8, which is not able
to pass the compilation, so I change its default value to 20.

Fixes #82757

Signed-off-by: Hongquan Li <hongquan.prog@gmail.com>
2024-12-16 13:09:28 +01:00
Bas van Loon
44d855391b mgmt: mcumgr: transport: smp: Fix smp_transport_clients list init.
Make sure smp_transport_clients list is only initialized once and
before any transports will try to register and add entries to this
list.

The smp_init() routine was called after smp_init_uart(), causing
the list to be emptied again after registration of the uart client
transport.

Signed-off-by: Bas van Loon <bas@arch-embedded.com>
2024-12-07 11:02:38 +01:00
Jamie McCrae
d68b54752c mgmt: mcumgr: transport: smp_udp: Use k_thread_join
Replaces code that peeked directly into the thread by instead
calling k_thread_join() to check the state of threads

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-12-06 22:22:32 +01:00
Seppo Takalo
9fa82f0d8d mgmt: smp: Fix race condition by using same work queue
Fix possible race condition where SMP client might
release the network buffer before system worker queue
has processed it.

In smp_client uses shared resources like worker queue
linked list and network buffers without maintaining any
thread safety.

For unknown reasons, retry timeout handling is pushed
into system worker queue while the actual transmission
is handled from SMP work queue.

Fix the issue by using the same SMP work queue
for both delayable timeout handling as well as
transmission handling.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-12-06 18:20:10 +01:00
Dawid Niedzwiecki
e9163992cf mgmt: ec_host_cmd: add support for nocache buffers
Some backends use DMA. Usually, DMA doesn't work correctly, when memory
to transfer is cached. Add a config to place the common buffers in the
nocache section.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-12-04 16:11:54 +01:00
Dawid Niedzwiecki
d7df7cdba6 mgmt: ec_host_cmd: stm32_spi: fix rx reload for STM32H7 chips
Disable and enable SPI module before every transaction for STM32H7
chips. It is a recommended way in the STM32 RM. In another case, a first
byte of a transaction is always 0x00.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-12-04 16:11:54 +01:00
Dawid Niedzwiecki
6294c389ca mgmt: ec_host_cmd: stm32_spi: handle underrun for stm32h7 chips
STM32H7 chips have additional configuration regarding underrun event.
Configure the underrun behaviour correctly to use the underrun pattern
and clear the underrun bit before sending new data.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-12-04 16:11:54 +01:00
Dawid Niedzwiecki
21c12786ec mgmt: ec_host_cmd: stm32_spi: fix cs interrupt configuration
Move enabling CS interrupt at the end of the backend configuration,
when everything is ready.

It prevents handling the interrupt, when something is not prepared e.g.
DMA is not configured.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-12-04 16:11:54 +01:00
Dawid Niedzwiecki
c7bebc669f mgmt: ec_host_cmd: stm32_spi: fix clock domain support
Fix support for clock domains. Create define that identify if
clock domain was selected in any of the st_stm32_spi_host_cmd nodes.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-12-04 16:11:54 +01:00
Dawid Niedzwiecki
5d5c4c1d2f mgmt: ec_host_cmd: add support for all dma versions
Update macro used to get fifo threshold from DTS, to support all
STM32 DMA versions.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-12-04 16:11:54 +01:00
Dawid Niedzwiecki
7e5b0d7c3f mgmt: ec_host_cmd: stm32_spi: fix clang-format
Use clang-format for the ec_host_cmd_backend_spi_stm32.c file.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-12-04 16:11:54 +01:00
Jamie McCrae
5437ded36c mgmt: mcumgr: grp: img_mgmt: Fix misplaced #endif
Fixes a misplaced endif which wrongly excluded functions

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2024-11-28 09:38:49 +01:00
Andy Ross
7cdf40541b kernel/sched: Eliminate PRESTART thread state
Traditionally threads have been initialized with a PRESTART flag set,
which gets cleared when the thread runs for the first time via either
its timeout or the k_thread_start() API.

But if you think about it, this is no different, semantically, than
SUSPENDED: the thread is prevented from running until the flag is
cleared.

So unify the two.  Start threads in the SUSPENDED state, point
everyone looking at the PRESTART bit to the SUSPENDED flag, and make
k_thread_start() be a synonym for k_thread_resume().

There is some mild code size savings from the eliminated duplication,
but the real win here is that we make space in the thread flags byte,
which had run out.

Signed-off-by: Andy Ross <andyross@google.com>
2024-11-27 10:38:05 -05:00
Dino Li
40c95e34b8 it8xxx2/shi: wrap pm policy state get/put
When CONFIG_ASSERT is enabled, assertion for unbalanced state lock
get/put is triggered. This commit leverages shi drivers from other
SoCs to resolve the assertion.

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
2024-11-25 10:07:20 +01:00
Fin Maaß
ef9cc18fcf mgmt: hawkbit: don't require HWINFO
don't require HWINFO, when HAWKBIT_CUSTOM_DEVICE_ID.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-11-22 13:02:29 -06:00
Jamie McCrae
a6cca606db mgmt: mcumgr: transport: smp_lorawan: Update downlink function
Updates the function to account for a change in the arguments

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2024-11-17 17:15:10 -05:00
Zak Portnoy
32b1140066 mgmt: smp: shell: Respond on uart shell device when changed at runtime
Responses are currently set to the shell device that was configured
in the device tree.

The shell_uart driver allows for changing it's device during runtime
which leads to a situation where we recieve packets on one device
and respond on another.

This patch causes smp_shell_tx_raw to use the shell_uart device

Signed-off-by: Zak Portnoy <zakportnoy@gmail.com>
2024-11-08 13:57:09 -06:00
Jun Lin
69e85b25fe board: npcx: remove CONFIG_PINCTRL from defconfig of npcx boards
The CONFIG_PINCTRL is removed from the board's defconfig files.
Drivers which use pin control function should add "select PINCTRL"
in their Kconfig files.

Fixes #78619

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-11-07 08:59:14 -08:00
Gerson Fernando Budke
b46e176704 mgmt: mcumgr: stat: Fix stat_mgmt_list behavior
The MCUmgr statistics only work correctly when selecting
MCUMGR_SMP_LEGACY_RC_BEHAVIOUR option. Checks the option
flag on the stat_mgmt_list and fix the behavior.

Fixes: 80476

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2024-10-30 08:55:23 -05:00
Jamie McCrae
973ba91487 mgmt: mcumgr: transport: Add LoRaWAN MCUmgr SMP transport
Adds a transport that uses LoRaWAN for receiving and responding
to messages

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2024-10-25 14:00:48 +02:00
Jamie McCrae
7609a17dc3 mgmt: mcumgr: grp: zephyr_basic: Add missing FLASH_MAP dependency
Adds a missing dependency, this command requires it to erase the
storage area

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2024-10-24 05:43:42 +01:00
Tim Lin
7fa962589f ITE: it8xxx2: Remove CONFIG_PINCTRL from soc defconfig file
The driver Kconfig determines whether pinctrl is enabled
instead of soc defconfig.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-10-15 13:52:55 +02:00
Jamie McCrae
646f116cca mcuboot: Add support for RAM load mode
Adds supporting code that allows the RAM load mode of MCUboot to
be used and for applications to build successfully with it.
Sysbuild can be used to build images for this mode

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-10-11 13:19:39 -04:00
Fin Maaß
d28c0cf08c mgmt: hawkbit: move HAWKBIT_JSON_URL
move HAWKBIT_JSON_URL out of the header.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-10-09 18:10:30 +01:00
Fin Maaß
94bad9d9ac mgmt: hawkbit: seperate header files
seperate the hawkbit header files, to make
it clearer.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-10-09 18:10:30 +01:00
Fin Maaß
dce3d2de66 mgmt: hawkbit: seperate autohandler
seperate the autohandler from the main
hawkbit source. This way the autohandler can
be disabled if it is not needed.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-10-09 18:10:30 +01:00
Fin Maaß
621cf5baec mgmt: hawkbit: get poll interval
Add function to get the poll interval.
This is needed to seperate the autohandler
from the main hawkbit code.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-10-09 18:10:30 +01:00
Fin Maaß
421ab502e4 mgmt: hawkbit: delay autohandler
Be able to delay the next run of
the hawkbit autohandler.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-10-09 18:10:30 +01:00