Commit graph

21541 commits

Author SHA1 Message Date
Ehud Naim
cea6fb7753 logging: fix cmd_log_self_disable argc checker
according to the comment "all if no modules specified"
to support "all" state, set to 1 number of parameters.

Signed-off-by: Ehud Naim <ehudn@marvell.com>
2020-11-06 13:16:39 -05:00
Dominik Ermel
e8fa66f951 tests/fs/fatfs: Add tests for FS_MOUNT_FLAG_*
Adds various tests for mounting ELM FAT FS with FS_MOUNT_FLAG_NO_FORMAT
and FS_MOUNT_FLAG_READ_ONLY, and operations on read-only mounted
file system.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-06 13:10:13 -05:00
Dominik Ermel
5c2a004c0b tests/fs/littlefs: Add tests for FS_MOUNT_FLAG_*
Adds various tests for mounting LittleFS with FS_MOUNT_FLAG_NO_FORMAT
and FS_MOUNT_FLAG_READ_ONLY, and operations on read-only mounted
file system.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-06 13:10:13 -05:00
Dominik Ermel
aa0fd027fc fs: Add support for mount flags
The flags field has been added to fs_mount_t structure, accompanied
with two new flags:
  FS_MOUNT_FLAG_READ_ONLY -- mount fs as read only
  FS_MOUNT_FLAG_NO_FORMAT -- do not format volume when system not found

Code supporting the flags has been added to FS layer and drivers for
LittleFS and FAT FS.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-06 13:10:13 -05:00
Dominik Ermel
e43ec70d4f subsys/fs: Make FAT FS write support optional
The commit adds FS_FATFS_READ_ONLY Kconfig option; the option, when
selected, excludes write supporting code within ELM FAT driver.

When write support to FAT FS volumes is not desired, this option may be
selected to slightly reduce code size.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-06 13:10:13 -05:00
Dominik Ermel
c31d659f70 subsys/fs: Make FAT FS formatting code optional
The commit adds FS_FAFTFS_MKFS Kconfig option; the option, y by default,
allows to include mkfs supporting code, within fs_mount callback,
for ELM FAT file system driver.

When formatting of FAT FS volumes is not desired, this option may be
deselected to slightly reduce code size.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-06 13:10:13 -05:00
Jukka Rissanen
db6dac3bcf net: tcp2: Fix sending to 6lo based networks
Do not send the original pkt in 6lo based networks as in those
the IPv6 header is mangled and we would not be able to do any
resends of the original pkt. So for 6lo networks, clone the
pkt and send it to peer. The original pkt is kept in sent list
in case we need to resend to peer.

Fixes #29771

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-11-06 18:58:17 +02:00
Jukka Rissanen
f08285fd6f net: shell: Fix TCP statistics printing
Fix TCP statistics printing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-11-06 09:50:02 -06:00
Jukka Rissanen
ab8fd8270a net: stats: Separate dropped TCP data segments and TCP packets
Track the number of dropped TCP data segments and number of dropped
TCP packets in network statistics. It is useful to see these
numbers separately.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-11-06 09:50:02 -06:00
Jukka Rissanen
d4320eedf2 net: tcp2: Update statistics
The amount of sent bytes and transmit errors should update
network statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-11-06 09:50:02 -06:00
Robert Lubos
7127f0a742 net: lwm2m: Notify the application on network error
Add a simple backoff mechanism between consecutive registration attempts
in case of registration failures. Finally, notify the application in
case the registration failed several times.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-11-06 12:58:14 +01:00
Robert Lubos
571b65830b net: lwm2m: Move bootstrap registration send into a separate function
Refactor the boostrap regstration procedure, by splitting the message
creation and sending into a separate function, in similar manner as
it's done with regular registration.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-11-06 12:58:14 +01:00
Robert Lubos
397b2a71fa net: lwm2m: Add a callback to notify socket errors to engine users
Currently, when socket errors occur during receive, the LwM2M engine
restarts the state machine and registers again to the server. While this
works in simple use case (only RD client socket open), it's not a valid
approach when more sockets are open (FW update socket).

Fix this by introducing socket fault callback, which is registered by
the LwM2M engine users. This way, a proper socket owner is notified on
error and can pertake appropriate action.

For RD socket errors the behaviour remains the same - the state machine
is reset and the client registers again to the server. For FW update
socket, handle the error by reopening the socket and retransmitting the
last request. This allows to resume the download from the point the
error occured, w/o a need to start from scratch.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-11-06 12:57:32 +01:00
Trond Einar Snekvik
b20a44ded8 Bluetooth: controller: Silence unused variable warning with non-AE
Places definition of lll under the ADV_EXT #ifdef in lll_adv.c:isr_tx,
to silence build warnings for non-AE builds.

Follow-up from #29753.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-05 11:10:22 -06:00
Marcin Niestroj
fbc487cce3 net: tls: use Maximum Fragment Length (MFL) extension by default
Call mbedtls_ssl_conf_max_frag_len() on created TLS context
configuration, so that Maximum Fragment Length (MFL) will be sent to
peer using RFC 6066 max_fragment_length extension. MFL value is
automatically chosen based on MBEDTLS_SSL_OUT_CONTENT_LEN and
MBEDTLS_SSL_IN_CONTENT_LEN mbed TLS macros.

This extension is mostly useful for TLS client side to tell TLS server
what is the maximum supported receive record length.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-11-05 14:47:24 +02:00
Andrzej Kaczmarek
dd5e9c4da1 Bluetooth: controller: Add common def for max AD size on legacy
This def can be used instead of hardcoding "31" everywhere.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-05 12:17:16 +01:00
Andrzej Kaczmarek
5166426940 Bluetooth: controller: Fix timings for non-1M PHY on advertising
We need to use actual phy wherever required to make sure radio delays
are calculated properly. This is especially important for LE Coded
since delays for that phy are significantly higher than on 1M and 2M.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-05 12:17:16 +01:00
Andrzej Kaczmarek
1df5897679 Bluetooth: controller: Verify AD length for legacy adv
We should not allow setting more than 31 bytes of AD on legacy
instances.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-05 12:17:16 +01:00
Andrzej Kaczmarek
5aab391f4b Bluetooth: controller: Update HCI supported cmds with ext adv
Return proper bitmask of supported commands when extended advertising
enabled.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-05 12:17:16 +01:00
Andrzej Kaczmarek
f2de6931de Bluetooth: controller: Remove redundant check
ull_adv_data_set() is only used for legacy advertising data (either via
legacy HCI command or as fallback for extended advertising set which
uses legacy PDUs) so there is no need to check for extended advertising.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-05 12:17:16 +01:00
Andrzej Kaczmarek
aec809e75e Bluetooth: controller: Remove redundant check
We handle secondary channel only for extended advertising sets, that
means we always have ADV_EXT_IND on primary channel so there is no need
to support non-ext PDUs here.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-05 12:17:16 +01:00
Trond Einar Snekvik
86c793af3f sys: util: Replace MIN(MAX(a, b), c) with CLAMP
Replaces all existing variants of value clamping with the MIN and MAX
macros with the CLAMP macro.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-05 12:12:17 +01:00
Eduardo Montoya
dc56ace3da net: openthread: fix maximum number of children range
This commit corrects the maximum allowed amount of children to
match Thread specification.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-11-04 18:08:48 +02:00
Eduardo Montoya
8399a6067d net: openthread: allow to configure platform info
This commit adds the option to configure the platform information
string of OpenThread.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-11-04 18:08:48 +02:00
Peter Bigot
96bd6f79b9 shell: fix declarations for external device arrays
The objects should be const-qualified for consistency with other uses,
including declarations in headers.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-04 12:14:45 +01:00
Jukka Rissanen
c31148b04c net: tcp2: Update seq when peer closes connection
If the peer ACKs data when it closes the connection, update
our sequence number accordinly. The connection would eventually
be terminated but this will avoid extra resends by the peer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-11-04 11:17:47 +02:00
Jukka Rissanen
f50c9e11f0 net: tcp2: Avoid deadlock when closing the connection
When a connection is being closed, it is possible that the application
will have a lock to net_context and TCP2 connection lock. If we then
receive a final TCP2 ACK and close the connection, the locking order
get switched and TCP2 will first try to get its own lock and then the
net_context lock. This will lead to deadlock as the locking ordering
is now mixed.

The solution is to unref the TCP connection after releasing the
connection lock. The TCP connection unref function will anyway get the
lock so no need to do double locking.

Fixes #29444

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-11-04 11:16:53 +02: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
Marcin Niestroj
761f1c4bed net: tls: fix tls_context leak in ztls_socket() error path
If there are enough tls_context objects in the system (configured by
CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS), but there are not enough file
descriptors (configured by CONFIG_POSIX_MAX_FDS) to create underneath
TCP/UDP socket, then TLS socket creation fails with leaked tls_context.

Call tls_release() in ztls_socket() error path whenever underneath
TCP/UDP socket creation fails.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-11-03 19:25:48 +02:00
Mohamed ElShahawi
a6d32a7a09 net: ping: add warning if ping is not supported
Warn the user that "ping" is not supported in case of offloaded
driver is being used.

Signed-off-by: Mohamed ElShahawi <ExtremeGTX@hotmail.com>
2020-11-03 19:18:57 +02:00
Maureen Helm
10d33e2d28 disk: Fix nxp usdhc driver optional gpio properties
The power and chip detect gpios are optional device tree properties for
the nxp usdhc driver. Fixes a build error on the mm_swiftio board, which
does not set the power gpio property.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-11-03 10:35:49 -06:00
Robert Lubos
4625820354 net: lwm2m: Send Registration Update on lifetime change
According to LwM2M specfication v1.0.2, par. 5.3.2, the LwM2M client
MUST send an “Update” operation to the LwM2M Server whenever the
lifetime parameter of the Server object changes the server). The same
applies for the object instances created/deleted. The changes in objects
seem to already be handled, but the lifetime was not.

Additionally, the "Update" message shall only contain these parameters
which changed since the last update (including objects). As it's
straightforward to determine if the liftime  changed but it's not easy
to tell if there were updates in the object instances, add an
additional parameter to the engine_trigger_update() function, indicating
that new object information shall be sent in the "Update" message.

Eventually add a proper error checking in `sm_send_registration` as the
function is reworked anyway.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-11-03 16:25:13 +01:00
Robert Lubos
f747022d9e net: lwm2m: Fix PULL FW update in case of URI parse errors
The memset on firmware_ctx during PULL FW update initialization will
set the socket descriptor to a valid value of 0. This leads to an error
if parsing of the URI provided by the server fails, and the firware_ctx
is closed - the socket with a descriptor 0 will be accidently closed.
Fix this by invalidating the socket FD after the memset on
initialization.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-11-03 16:24:34 +01:00
Robert Lubos
d8912fe895 net: lwm2m: Remove handle_separate_response flag
It shouldn't be optional to handle separate response, as it's a
mandatory requirement according to the RFC7252:

"The protocol leaves the decision whether to
 piggyback a response or not (i.e., send a separate response) to
 the server.  The client MUST be prepared to receive either."

Therefore, remove the flag as separate responses are handled now
properly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-11-03 16:23:59 +01:00
Robert Lubos
37681a7bef net: lwm2m: Fix separate response handling
Separate response handling implemented in the engine was faulty. The
separate response was not acknowledged by the client, resulting in
spurious retransmissions from the server side.

Also, the pending CON message was retransmitted by the client even after
it was acknowledged by an empty ACK, but the respnse haven't arrived
yet. Fix this by adding a new `acknowledged` flag to the `lwm2m_message`
structure. Once acknowledged, the flag is set and the confirmable
message is no longer retransmitted. We keep the message on the pending
list in order to timeout properly in case separate response does not
arrive in time.

Finally, prevent the reply callback from being called twice in case
the response is transmitted separately from ACk. The callback should
only be called on the actual reply, not the empty ACK.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-11-03 16:23:59 +01:00
Robert Lubos
94d62ca151 net: lwm2m: Add lwm2m_send_empty_ack() function to internal API
So far this function existed as a static function in LwM2M PULL FOTA
module. Since such functionality will be needed in other places, make it
an internal API function.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-11-03 16:23:59 +01:00
Trond Einar Snekvik
2fb56ba74d Bluetooth: Mesh: Account for ASZMIC in encrypt
The decision to set aszmic = 1 in the net_tx structure was made after
the variable was passed to the crypto context, creating a discrepancy
between the two when aszmic is 1.

Extracts transport encryption to a separate function.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-03 16:04:30 +02:00
Dominik Ermel
045900eedf fs: Make fs API callback runt-time check optional
The commit changes run-time checks of file system driver's callbacks
pointers, against null, optional by replacing `if` with `CHECKIF` macro,
which means that they can be removed from compilation with Kconfig
option CONFIG_NO_RUNTIME_CHECKS.
Additionally the commit allows the same checks to fail hard, with
assertion, when CONFIG_ASSERT_ON_ERRORS option is selected.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-03 11:08:25 +01:00
Emil Gydesen
b0a99051f5 Bluetooth: shell: Avoid registering PA sync callbacks more than once
The PA sync callbacks would have been registered for each new
PA sync, which would cause the callbacks to be called multiple times
if multiple PA syncs were created.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-11-03 11:04:07 +01:00
Emil Gydesen
12ceb6c195 Bluetooth: host: Handle PA sync cancel event
The sync established event caused by a cancel by the host
was not properly handled. When cancelling the sync established
event is created, and the sync object should not be deleted
before that event is received.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-11-03 11:04:07 +01:00
Ehud Naim
89928c3c8b net: dhcpv4: check dhcpv4 msg len is correct
check if dhcpv4 msg len is correct and drop it otherwise

Signed-off-by: Ehud Naim <ehudn@marvell.com>
2020-11-02 12:56:16 +02:00
Lingao Meng
5efe6ff887 Bluetooth: Mesh: Fix set friend_cred flag incorrectly
Only set friend_cred to true when friendship established and
use friend cred security material decryption successfully.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-11-02 12:47:36 +02:00
Trond Einar Snekvik
a878b36af0 Bluetooth: Mesh: Permit model walk from any model
Fixes bug where applications that disable model extensions end up in an
infinite loop, and adds support for walking model subtrees, as opposed
to forcing root to be unextended.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-02 12:46:45 +02:00
Andrzej Puzdrowski
19e43e2e04 usb/class/usb_dfu: signal dfuMANIFEST_SYNCH after flashing is done
End of DFU operation was signaled after the last usb dfu request was
received. Therefeore wait_for_usb_dfu() terminated so fast that
dfu_work_handler() was not called by k_work_queue befor.

wait_for_usb_dfu() should terminate after DFU operation was completed.

For fix that k_poll_signal_raise() was moved after the flash write
operation.

fixes #29611

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-10-30 15:58:01 +01:00
Vinayak Kariappa Chettimada
84096455ad Bluetooth: controller: Adv set terminated event on Directed Adv timeout
Add generation of Advertising Set Terminated event on High
Duty Cycle Directed Advertising Timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-30 15:55:57 +01:00
Vinayak Kariappa Chettimada
ad348337a5 Bluetooth: controller: Reduce use of ARG_UNUSED on auto variables
Reduce the use of ARG_UNUSED on auto variables and try to
use conditional compilation where appropriate.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-10-30 15:54:56 +01:00
Dominik Ermel
e7886c6634 fs: fs_unmount will return -ENOTSUP if not implemented by driver
The commit changes error handling by fs_unmount; the function will
return -EINVAL if mount point, described by mp, is not mounted or
-ENNOTSUP when unmounting is not supported by the driver; in the second
case it will also log error.

Additionally to the above changes, checks for correct mnt_path and
mnt_path, within fs_unmount, have been removed as they are not needed;
only the fs_mount_t->fs pointer is needed to decide whether system is
mounted or not.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-10-30 15:54:04 +01:00
Dominik Ermel
5faf3750bc fs: fs_mount parameter verification before mutex locked block
The commit moves fs_mount parameter verification above mutex lock.
The list of mount points is now checked before attempting to obtain
file system API pointer.
All modifications to mount point data structure, given as a parameter
to the fs_mount, are only applied after every other operation needed
have completed successfully, immediately before adding the mount point
to the list of mount points.
The fs_mount will a warning when mounted file system does not support
unmount.
When a file system does not provide mount function, the -ENOTSUP error
will be returned instead of -EINVAL.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-10-30 15:54:04 +01:00
Andrzej Puzdrowski
053857e09a storage/flash_map: Added function for get erased byte value
Added flash_area_erased_val() function for get value of erased
byte of memory which is under flash area.
This function already exist in MCUBoot and zephyr dfu subsystem
which makes simultaneous usage of both impossible.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-10-30 15:53:38 +01:00
Michał Narajowski
3908638bab Bluetooth: Mesh: Fix model tree walk procedure
`bt_mesh_model_tree_walk()` was too simplistic and did not track visited
nodes which caused it to fall into infinite loop. Moreover the double
next jump could skip a level causing depth value to be invalid.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-10-30 16:27:20 +02:00