Commit graph

808 commits

Author SHA1 Message Date
Navin Sankar Velliangiri
62149516c4 mgmt: hawkbit: Conversion of k_work API
Implement new workqueue API changes.

Signed-off-by: Navin Sankar Velliangiri <navin@linumiz.com>
2021-04-27 13:29:39 -04:00
Kumar Gala
043891e1ea include: Move ec_host_cmd.h to mgmt/ec_host_cmd.h
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>
2021-04-22 12:51:16 -04:00
Dominik Ermel
f47334aa15 mgmt/mcumgr: Fixing use of k_fifo function on net buf
Fixing problem where k_fifo functions have been used to get/put
data from/info net buf, where documentation has been strictly
forbidding so.

Found, reported and solution suggested by jrhees-cae.

Fixes: #32579

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-03-29 16:13:38 -05:00
Flavio Ceolin
11ea2766bc mgmt: hawkbit: Fix variable type
hwinfo_get_define_id returns and ssize_t with the size og the copied
id in case of success or negative value otherwise.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-26 07:13:13 -04:00
Flavio Ceolin
d665b06adf mgmt: updatehub: Fix variable type
hwinfo_get_define_id returns and ssize_t. Positive value with the
size of the copied id in success or a negative value in case
of error.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-26 07:13:13 -04:00
Siddharth Chandrasekaran
28c823b16e mgmt/osdp: Fix coverity identified logical dead-code
A previous check and return for (maxlen <= 0) makes manlen at least 1 so
checks for (maxlen < 1) would never evaluate to true. Remove these
checks and merge those cases into one.

CID: 215392
Fixes: #33092
Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2021-03-10 10:15:48 -05:00
Siddharth Chandrasekaran
a871f00726 mgmt/osdp: Fix coverity identified off-by-one
Fix a coverity identified, off-by-one, out-of-bound array access at
pd->cap[].

CID: 215379
Fixes: #33095
Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2021-03-10 10:15:48 -05:00
Hubert Miś
77c68aa070 net: coap: clean up token usage in samples and tests
This patch replaces magic numbers with COAP_TOKEN_MAX_LEN value and
removes unnecessary castings of token buffer type.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-02 14:03:01 -05:00
Hubert Miś
22687c34e3 net: coap: define default CoAP version
RFC 7252 (CoAP) specifies value of the Version (Ver) field in the
protocol header to value 1. This patch defines value of the Version
field to make packet initialization easier. All samples and tests
are updated to use the new COAP_VERSION_1 field when initializing
a CoAP packet.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-02 14:03:01 -05:00
Hubert Miś
13aa4b2f9e net: coap: define Content-Format option values
CoAP protocol defines registry of Content-Format option values.
This patch adds this enumeration to coap header file to make it
available to all applications using CoAP protocol. It modifies
code using CoAP service to use new enumeration.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-01-19 16:07:20 -05:00
Dominik Ermel
6c60414059 mgmt: mcumgr: Add support for enabling Direct-XIP app address check
The commit adds Kconfig option:
  CONFIG_IMG_MGMT_REJECT_DIRECT_XIP_MISMATCHED_SLOT
that enables verification of base address Direct-XIP binary, upon
upload, and rejects binaries that would not be able to start from
available address.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-01-18 16:59:29 -05:00
Gerson Fernando Budke
450330420e mgmt: updatehub: Kconfig: Drop NET_CONFIG_SETTINGS option
Remove NET_CONFIG_SETTINGS Kconfig option. The net settings should
be enabled from now at project config or at any overlay. This is
necessary to allow better control when application should start.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-12-14 11:21:06 +01:00
Gerson Fernando Budke
58fa3c039a mgmt: updatehub: Add debug logs
Current logs only prints default logs level. Add LOG_LEVEL at updatehub
to switch to another variation based on CONFIG_UPDATEHUB_LOG_LEVEL.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-12-14 11:21:06 +01:00
Gerson Fernando Budke
2a394372d2 mgmt: updatehub: Clean SHA-256 macros
Clean SHA-256 macros that were left behind when added flash SHA-256
verification.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-12-14 11:21:06 +01:00
Anas Nashif
276ef71890 hawkbit: improve Kconfig dependencies
Put everything inside an if, we should not see anything related to
hawkbit in generated .config if it is not enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-11 16:49:41 -05:00
Anas Nashif
818e8deb3b updatehub: improve Kconfig dependencies
Put everything inside an if, we should not see anything related to
updatehub in generated .config if it is not enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-11 16:49:41 -05:00
Dominik Ermel
c8ccf4fbc8 mgmt: mcumgr: Remove log management support from Kconfig
The commit removes a leftover configuration of the log management that
has never worked and has been removed with the commit
0bb466c34e4fe863733a929baa8f51981263ce3d to apache/mynewt-mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-12-07 12:56:40 +01:00
Brian Bradley
313f1713ac mgmt: mcumgr: add configuration option to enable shell management
This configuration is be required to enable the shell management
command handler supported by the core mcumgr library

Signed-off-by: Brian Bradley <brian.bradley.p@gmail.com>
2020-11-11 13:17:02 +01:00
Kumar Gala
4ff6061b09 mgmt/osdp: Fix build issue
When building the osdsp control_panel sample we get the following
compile error:

subsys/mgmt/osdp/src/osdp_cp.c:993:10: error: implicit declaration of
function 'osdp_cp_send_command_keyset'

Fix by adding ifdef protection around the call to
osdp_cp_send_command_keyset

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-11-03 13:00:11 -06:00
Siddharth Chandrasekaran
4640bafca6 mgmt/osdp: Fix early check of no-data that holds PD online
When waiting for data from CP, the data timeout check must happen before
no-data check. If not, a partial packet may endlessly hold PD in
"wait-for-data" state, while the PD keeps reporting status as online
till another packet is received.

Fix this my moving no-data check below the timeout check.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
8d012aace9 mgmt/osdp: CP: Reset channel before sending a command
Flush channel of any existing partial packets before sending a new
command.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
23c0c77049 mgmt/osdp: Skip all incoming bytes till start of new packet
All OSDP packets must start with a mark byte (0xFF) followed by a Start
of Message byte (0x53). Skip all bytes received until such a sequence is
seen to to avoid waking up the refresh thread needlessly.

Also, refactor osdp_uart_isr() to reduce number of local variables.

Fixes: #28168 Coverity-ID: 214218

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
d6437c1aa1 mgmt/osdp: CP: Unify osdp_cp_send_cmd_*() as osdp_cp_send_command()
Minimize number of exported methods by unifying all osdp_cp_send_cmd_*()
as osdp_cp_send_command().

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Siddharth Chandrasekaran
f0b43a4dfa mgmt/osdp: CP: Add COMSET command
Add osdp_COMSET command to set PD communication parameters.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-21 17:36:16 +02:00
Lauren Murphy
b82efb343e ec_host_cmd: Fix unused return value from k_sem_take call
Fixes Coverity issue 214881.

Fixes #29018

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2020-10-21 06:28:09 -05:00
Flavio Ceolin
619dcef498 mgmt: osdp: Fix a warning about an unused variable
tmp variable is only used when osdp sc is enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-10-13 10:58:02 +02:00
Flavio Ceolin
aa23af14b6 mgmt: osdp: Fix build when osdp sc is not enabled
osdp was unconditionally referencing symbols that are defined only if
osdp sc is enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-10-13 10:58:02 +02:00
Flavio Ceolin
6f7f9dfe7b mgmt: osdp: Make osdp sc requires on CSPRING_ENABLED
OSDP secure channel require a truly random number generator
source. Make this dependency explicit.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-10-13 10:58:02 +02:00
Siddharth Chandrasekaran
7f4d2c741b mgmt/osdp: Add support for Secure Channel
This patch adds Secure Channel capabilities to osdp Control Panel and
Peripheral Device modes.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-10-09 11:45:58 +02:00
Marcin Niestroj
7c5ab5873a mgmt: smp: shell: log warning when buf allocation fails
Log when allocation fails, so user gets warned about communication
problems.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-07 14:51:06 +02:00
Marcin Niestroj
7451a32e98 mgmt: smp: shell: allow to configure multiple RX buffers via Kconfig
With only single RX buffer there is a high chance that such buffer will
not be processed before new bytes come in over UART. This is why it is
good to have at least two buffers, one which can be processed by SMP
layer, while another is being filled with new incoming bytes.

Add Kconfig option which allows to configure multiple buffers filled
with received UART SMP fragments. Use default value of 2, so we can
safely process already received frame in thread, while new fragment
comes in concurrently.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-07 14:51:06 +02:00
Marcin Niestroj
79fa92229a mgmt: smp: shell: use net_buf API for storing UART SMP fragments
So far there was a simple char array used as buffer, with additional
variable representing number of bytes already written into it. After
full frame was written, a boolean flag was simply set to notify thread
about being ready to be processed. There was however no mechanism
implemented to prevent new incoming bytes from overwriting such buffer
before (or during) being processed.

Use net_buf to store temporary frame. Define dedicated net_buf_pool,
from which such buffer will be allocated and freed after being
processed. This will prevent from reusing the same buffer before having
it fully processed (and returning once again to available buffer pool)
in shell thread.

Define also fifo that will store buffers that are ready to be
processed. This will be the mechanism for notifying thread about new
UART SMP fragments.

net_buf pool and k_fifo are used on purpose, keeping in mind their
additional overhead (mostly in RAM/ROM usage). This makes the code ready
for increasing number of buffers if needed. In this commit however we
stick with only 1 buffer, to keep minimal changes in processing flow.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-07 14:51:06 +02:00
Xavier Chapron
824f423e54 misc: Replace assert include and calls by sys/__assert.h equivalent
Replace all calls to the assert macro that comes from libc by calls to
__ASSERT_NO_MSG(). This is usefull as the former might be different
depending on the libc used and the later can be customized to reduce
flash footprint.

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2020-10-02 11:42:40 +02:00
Siddharth Chandrasekaran
2b4ca51c85 mgmt/osdp: Fix osdp_build_ctx(); Add NULL check on ctx
osdp_build_ctx() was returning fixed NULL and the subsequent code did
not check if ctx was NULL due to osdp_build_ctx() failures. Fix both
these issues.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-18 17:36:02 +02:00
NavinSankar Velliangiri
dd8f135e2c mgmt: hawkbit: Fix NULL pointer dereferences
Coverity spots that null pointer is passing to flash_img_buffered_write.
This patch fixes the problem.

Signed-off-by: NavinSankar Velliangiri <navin@linumiz.com>
2020-09-16 13:51:55 -05:00
Flavio Ceolin
e28d3404eb mgmt: hawkbit: Fix resources leakage
Coverity spots that memory allocated for addr was leaking, but the
code was also leaking the socket file descriptor in the error path.
This patch fixes both problems.

Fixes #28172

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-09-16 12:05:21 +02:00
Siddharth Chandrasekaran
a3d07cda9b mgmt/osdp: Make CP/PD mode selection as first entry in Kconfig
CP/PD mode selection is the most frequently looked-for/changed key in
Kconfig. Making that as the first entry for ease of use.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-14 16:00:45 -05:00
Siddharth Chandrasekaran
e6789a82ca mgmt/osdp: Change select SERIAL to imply SERIAL_SUPPORT_INTERRUPT
OSDP subsys was doing a `select SERIAL` in its Kconfig. But this has
other unintended side effects. Change this to
`imply SERIAL_SUPPORT_INTERRUPT`.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-14 16:00:45 -05:00
Jett Rink
1972f0b7f4 ec_host_cmd: add ec host command handler framework
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>
2020-09-04 14:50:45 -04:00
Gerson Fernando Budke
d18f12de23 mgmt: updatehub: Enable flash sha verification
Currently updatehub trust on MCUboot to test a new image. The process
is executed on next boot after a validate the downloaded image.  To
have a more reliable system, is recommended run the SHA-256 algorithm
to attest that firmware was properly stored on the flash memory.  This
implements the use of flash_img_check to achieve that, and as a
consequence, add a new level of trust that avoids an useless reboot
on the system.

Updatehub uses two SHA-256 verification.  One is used to check the
data stream at download.  The second one, realise the verification
reading from flash.  Users have the possibility to chose only one
option or keep both verifications.  However, it is adviced keep
always both verifications enabled to get consistent reports on
back end.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-09-04 17:32:29 +02:00
Gerson Fernando Budke
d0c3dfe093 mgmt: updatehub: Add hash var on context
Currently SHA-256 uses a temporary hash digest to calc final sha sum.
This moves temporary variable from local scope to updatehub context.
The motivation is to use the hash digest on future flash validation.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-09-04 17:32:29 +02:00
Dominik Ermel
1d0fb46165 mgmt: smp: Fix compilation problem
Fix problem with compilation due to incompatible type assignments.

Fixes #28031

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-09-04 16:35:37 +02:00
Siddharth Chandrasekaran
ee99c34fb6 mgmt/osdp: Refactor struct osdp_cmd members for readability
Some of the names used in `struct osdp_cmd` where directly as in the
specification. Initially it appealed to keep them like that but with
time, a little more consistent naming of members helps if you haven't
read the specification document very recently.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-04 10:58:13 +02:00
Siddharth Chandrasekaran
4c9b0ae928 samples: mgmt/osdp: Add CP Sample
Add a OSDP CP mode sample that sends out a periocic command to a
connected PD. It also demosnstrates key press and card read callback
registration.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-04 10:58:13 +02:00
Siddharth Chandrasekaran
ea03c9c304 mgmt/osdp: Add support for CP mode of operation
Following the PD mode implementation (9a91b4ad), this patch adds support
for CP mode of operation in OSDP.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-04 10:58:13 +02:00
Siddharth Chandrasekaran
31d2b991e0 mgmt/osdp: Refactor PD for upcomming CP changes
Some PD init sequence and other methods are useful in CP mode as well.
This patch refactors those methods to osdp_*(), moves them to common
source files and and exposes them from osdp_common.h.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-04 10:58:13 +02:00
NavinSankar Velliangiri
ddd6a650e2 mgmt: hawkbit: Add Hawkbit FOTA Support
Add Hawkbit FOTA support

Signed-off-by: NavinSankar Velliangiri <navin@linumiz.com>
2020-09-03 22:13:52 +02:00
Dominik Ermel
1b617a368f mgmt: smp: Change smp_shell_rx_byte to process data in bulk
The smp_shell_rx_byte has been renamed to smp_shell_rx_bytes and now
accepts data buffer pointer and its size as parameters. Return value
has been changed to size_t and represents number of bytes processed from
the given buffer.

The change has been done to more efficiently serve most common scenario
when the function is called in loop to process buffer, byte by byte.
Previously such operation required passing each byte separately,
with the change the function will work directly on source buffer
reducing number of calls and byte copy operations.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-09-03 21:53:00 +02:00
Flavio Ceolin
86d8475850 osdp: Remove invald serial option
SERIAL_HAS_DRIVER and UART_INTERRUPT_DRIVEN should be selected by the
driver. If something needs is should dependson these options.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-09-02 13:45:26 -04:00
Flavio Ceolin
2fde557e14 osdp: Do not select ENTROPY_GENERATOR
Entropy generator is not used in this subsystem so there is no need to
select it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-09-02 13:45:26 -04:00