Rework the Host Command support. It includes:
-change API to backend
-change a way of defining rx and tx buffers
-fix synchronization between the handler and backend layer
-simplify the HC handler
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Follow naming pattern in the subsystems(logging or shell) and name
the layer between generic handler and peripheral driver "backend".
The name doesn't suit that well to the SHI backend, because there isn't
SHI API itself and the SHI interface is used only for the host
communication. So the backend code includes the peripheral driver itself.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
The Host Commands can be used with different transport layers e.g. SHI
or eSPI. The code that provides the peripheral API and allows sending
and receiving Host Commands via different transport layers is not
actually drivers of a peripheral, so move it to the
subsys/mgmt/ec_host_cmd folder.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Select in Kconfig causes many issues with dependency loops, this
resolves the issue by replacing most select with depends on for
MCUmgr, including updates to the sample smp_svr application and
tests.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Changes one of the callback register/unregister functions to use
2 events OR'd together instead of 2 events registered separately,
this is to help test that grouped events are working.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This replaces the requirement for applications to manually
register MCUmgr handlers by having an iterable section which
then automatically registers the handlers at boot time.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Replaces ZCBOR_MAP_DECODE_KEY_VAL with ZCBOR_MAP_DECODE_KEY_DECODER
in test and adds equivalency test between
ZCBOR_MAP_DECODE_KEY_VAL and ZCBOR_MAP_DECODE_KEY_DECODER.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The zcbor_map_decode_bulk is able to decode embedded CBOR types
like maps in maps, but this has been missing proper tests.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Two simple fixes in zassert messages where one message has
been printing incorrect variable and other has been using
formatting to just print literal 0.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Adds a test which enables all Kconfig options for MCUmgr (that are
not deprecated and can be supported on the nrf52840dk board) to
ensure that if a breaking change is introduced in CI then it can
be caught.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add missing fields in structure containing the arguments used by
the host commands handlers and change the order of parameters
in macro used for defining the handlers.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
This commit increases the stack size for thread handling the host
commands requests. It was required due to the stack being
corrupted using earlier default size. The thread priority is now
configurable using the Kconfig.
It also adds alignment to the tx_buffer since the npcx MCU requires it
to work correctly and removes clearing the buffer before use due to
the hard time requirements. Tests checking if buffers are cleared
are also removed.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
The commit reworks mgmt/mcumgr subsystem source code to remove
lib subdirectory and make it a little bit more flat.
It also moves all API interface files, which are supposed to be
visible by applications using MCUMgr, to interface sub-directories,
and exposes them with full paths; for example to include general
MCUMgr support, group registration and so on, user would now include:
<mgmt/mcumgr/mgmt/mgmt.h>
to additionally have control on File System group management
registration user would need:
<mgmt/mcumgr/mgmt/grp/fs_mgmt.h>
All internal headers have been removed from interface.
CMAkeLists.txt get significant rework and various MCUMgr subsystems
have been divided into separate sub-libraries.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Adds a test which checks that the fs_mgmt supported hash/checksum
functionality is working and returns the expected response.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
SMP reassembly is the only non-protocol code in MCUmgr that
directly accesses SMP header; this tests has been accessing
mgmt_hdr structure and now it is named smp_hdr and visible
via smp_internal.h.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
buf.c have been providing net_buf pool allocator and dealocator
for SMP packets: mcumgr_buf_alloc and mcumgr_buf_free.
The functions have been moved to smp.c and renamed
smp_packet_alloc and smp_packet_free, respectively.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
SMP buffer allocation functions have been moved to smp/smp.h,
and buf.h has been removed.
Definitions of cbor_nb_reader and cbor_nb_writer have also been moved.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Moves a .h file added outside of the zephyr include folder to be
within the zephyr include folder.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds a simple mcumgr test which checks that the os_mgmt echo commmand
works and responds with the correct data.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths
Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
If struct tx_structure is too large than the buffer that
expected_dut_to_host references, leading the compiler to generate a warning
about the possibility of buffer overflow.
Leave out the 'struct ec_response_too_big' so that 'struct tx_structure'
fits within the 256 byte buffer.
This was caught when using GCC 11.3.0 building the test for native_posix.
Signed-off-by: Keith Packard <keithp@keithp.com>
lwm2m: Regenerate lwm2m_senml code from the CDDL description.
Reapply manual changes.
Create a sh script to perform the regeneration.
tests: zcbor_bulk: Adapt to zcbor 0.5.1
zcbor_new_decode_state() now has no return value.
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
The commit adds unit tests for zcbor_bulk utility function,
which has been provided to internally support zcbor in decoding
maps with command parameters.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Move to CMake 3.20.0.
At the Toolchain WG it was decided to move to CMake 3.20.0.
The main reason for increasing CMake version is better toolchain
support.
Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Move ec_host_cmd.h out of the top level include/ dir into
include/mgmt/ec_host_cmd.h and deprecated the old location.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add a generic host command handler framework that allows users to
declare new host command handlers with the HOST_COMMAND_HANDLER macro
at build time. The framework will handle incoming messages from the
host command peripheral device and forwards the incoming data to the
appropriate host command handler, which is looked up by id.
The framework will also send the response from the handler back to the
host command peripheral device. The device handles sending the data on
the physical bus.
This type of host command communication is typically done on an embedded
controller for a notebook or computer. The host would be the main
application processor (aka AP, CPU, SoC).
Signed-off-by: Jett Rink <jettrink@google.com>